In my game I have 2 types of "guards," one is a TURRET, the other is a SPIDER. Both of which share the same LOS script. If they "see" you then they will alter their behaviour.
If the TURRET see's you it will alter NPC picture to (51) followed by (50) to represent that it shot you. Also a textbox will be displayed.
If the SPIDER see's you it will alter NPC palette and it will also be set to chase the hero.
The problem: Occasionally when the hero is seen by a TURRET it will cause one of the SPIDER'S to be altered to NPC picture (50).
Here's a snippet of the LOS so you can see what's going on:
Code: Select all
xNPC := NPC X (guardNumber)
yNPC := NPC Y (guardNumber)
xMe := hero x (find hero (0))
yMe := hero y (find hero (0))
# Checks to see if sight is blocked or hero is found
if ((read zone (21, xNPC, yNPC+1) == true) || ((NPC at spot (xNPC, yNPC+1) <> 0))) then(continue)
else if ((xMe == xNPC) && (yMe == yNPC+1)) then(
# Change the guard to chase-mode or make turret shoot
if((guardNumber == 7)||(guardNumber == 8)||(guardNumber == 9)) then(
if(current text box == -1) then(
Alter NPC (guardNumber,NPCstat:picture,51)
suspend NPCs
show text box (6)
wait for textbox
Alter NPC (guardNumber,NPCstat:picture,50)
)
) else (
Alter NPC (guardNumber, NPCstat:move type, NPCmovetype:chaseyoupathfinding)
Alter NPC (guardNumber, NPCstat:activation, NPCactivation:touch)
Alter NPC (guardNumber,NPCstat:palette,1)
)
break
)
I'm wondering if maybe I'm applying the LOS script to too many NPC's and somehow the script is being overloaded somehow causing this strange result. What makes me suspect this is because it is only happening to NPC #14 (the last NPC to be cycled to) and none of the other NPC's.