Game Development Reference
In-Depth Information
Implementing the Distraction Behavior for the Skeleton Object
1.
Reopen obj_skeleton_land and add a new Collision event with obj_parrot . Include an
Execute Code action and enter the following code:
1: {
2: if( state != ESTATE_ATTACK )
3:
{
4:
with( obj_skeleton )
5: {
6:
target_obj = obj_flynn
;
pursuing = false;
8: }
9:
10: target_obj = obj_parrot;
11: state = ESTATE_ATTACK;
12: pursuing = true;
13: alarm[1] = 300;
14: alarm[0] = -1;
15: sound_play( snd_wings );
16: }
17: }
7:
Line 2 makes sure that this skeleton is not already in the attacking state and lines 4-8
stop any other skeletons from pursing Archie. We only want Archie to be able to
distract one skeleton at a time. Lines 10-13 make Archie the target of the skeleton's
pursuit for a period of 10 seconds until Alarm1 calls off the pursuit. Line 14 turns off
Alarm 0 so that it doesn't trigger mid-way through an attack, and cause the skeleton to
wander off.
Now, add an Other, Animation End event to obj_skeleton_land and include an
Execute Code action containing the following code:
1: {
2: if( state == ESTATE_ATTACK )
3: {
4: state = ESTATE_WAIT;
5: alarm[0] = 30;
6: }
7: }
2.
This stops the attacking animation at the end of the cycle, putting the skeleton back
into the wait state and resetting the Alarm 0 timer to awaken him again after 1 second.
 
Search WWH ::




Custom Search