...
function witch_event() // ORIGINAL - WORKS - DO NOT TOUCH OR ALTER
{
if ((event_type == EVENT_CLICK) && (my.STATE == 2))
{
PANEL* my_panel_0 = pan_create(NULL,0);
PANEL* my_panel_1 = pan_create(NULL,0);
PANEL* my_panel_2 = pan_create(NULL,0);
PANEL* my_panel_3 = pan_create(NULL,0);
FONT* my_font1 = font_create("Times#35i");
FONT* my_font2 = font_create("Times#30i");
pan_setstring(my_panel_0,0,300,400,my_font1,str_create("Hello, my sweetie!"));
pan_setstring(my_panel_1,0,300,450,my_font2,str_create(" Hello. How are you?"));
pan_setstring(my_panel_2,0,300,500,my_font2,str_create(" Get away from me, witch!"));
pan_setstring(my_panel_3,0,300,550,my_font2,str_create(" (Ignore)"));
wait(13);
set(my_panel_0,SHOW);
wait(120);
set(my_panel_1,SHOW);
set(my_panel_2,SHOW);
set(my_panel_3,SHOW);
if(mouse_left && my_panel_1)
{
beep(); // Debugger
pan_setstring(my_panel_0,0,300,400,my_font1,str_create("I am very well. Would you like to buy a potion?"));
pan_setstring(my_panel_1,0,300,450,my_font2,str_create(" Yes, I would."));
pan_setstring(my_panel_2,0,300,500,my_font2,str_create(" No thank you."));
pan_setstring(my_panel_3,0,300,550,my_font2,str_create(" (Ignore)"));
wait(13);
set(my_panel_0,SHOW);
wait(120);
set(my_panel_1,SHOW);
set(my_panel_2,SHOW);
set(my_panel_3,SHOW);
}
}
}
...
action player()
{
...
set(my,FLAG2);
...
}
action castle_witch() // COMMUNICATION SYSTEM STARTEE
{
my.emask |= ENABLE_CLICK;
my.event = witch_event;
...
my.STATE = 1;
while (1)
{
// state 1: wait until player comes close enough //////
if(my.STATE == 1)
{
my.ANIMATION += 1*time_step;
ent_animate(me,"idle",my.ANIMATION,ANM_CYCLE);
c_scan(my.x,my.pan,vector(360,0,150),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);
// detect all FLAG2 entities within 750 quants
if (you)
{
my.STATE = 2;
}
else
{
mouse_map = cursor_pcx;
}
}
if(my.STATE == 2) // Witch senses player, turns toward player
{
my.ANIMATION += 1*time_step;
ent_animate(me,"idle",my.ANIMATION,ANM_CYCLE);
mouse_map = cursor_green_pcx;
enemy = your.CREATOR;
// get the angle to the enemy
VECTOR vDirection;
ANGLE vTargetAngle;
var speed = 1;
vec_diff(vDirection,enemy.x,my.x);
vec_to_angle(vTargetAngle,vDirection);
// vAngle is now the angle to the enemy.
// Turn right or left depending on the difference
// between the current and the target pan angle
my.pan += (time_step * sign(ang(vTargetAngle.pan - my.pan)) * speed);
}
wait(1);
}
}
...