I need help with states and cases

Jim C Hi again:

Here's what I'm trying to do:
When ego walks into the street, I want the program to take control and walk him to a specific x,y. Then I want to hide ego and show an animation in his place, in which he is shown getting run over. Then I want to run the death script.

Here's the relevant code I have so far:

(if(== oops 0)
(if(send gEgo:inRect(0 177 319 189))
= oops 1
Print("You wander aimlessly into the street.")
ProgramControl()
(send gEgo:setCycle(Walk)
setMotion(MoveTo 160 179 RoomScript())
)
)
)
)
(method (changeState newState)
(var dyingScript)
= newState 0
= state newState
(switch(state)
(case 0
(send gEgo:hide())
)
(case 1
(runOver:show()setCycle(End))
= dyingScript ScriptID(DYING_SCRIPT)
(send dyingScript:
caller(5)
register("You're dead!")
)
(send gGame:setScript(dyingScript)
)
)
)
)

Now, when I don't have case 1 in there, he walks to the specified location and disappears, like he's supposed to. But when I add in case 1 to run the animation, he walks to the location but doesn't disappear. The animation plays over him.

Any ideas as to how I could do this better? Thanks!
Eigen First the .... 179 RoomScript()) should be simply RoomScript)
Try placing the (runOver:.... and the death sequence after the (send gEgo: hide()) in case 0


-Eigen
Jim C Thanks, Eigen.

Ok, I did that, but now the dying script runs before anything else in case 0, even before ego even gets to the area of street that was supposed to trigger the event. Any ideas? Thanks!

Here's the relevant code:

(if(== oops 0)
(if(send gEgo:inRect(0 177 319 189))
= oops 1
Print("You wander aimlessly into the street.")
ProgramControl()
(send gEgo:setCycle(Walk)
setMotion(MoveTo 160 179 RoomScript)
)
)
)
)
(method (changeState newState)
(var dyingScript)
= newState 0
= state newState
(switch(state)
(case 0
(send gEgo:hide())
(runOver:show()setCycle(End))
= dyingScript ScriptID(DYING_SCRIPT)
(send dyingScript:
caller(5)
register("You're dead!")
)
(send gGame:setScript(dyingScript)
)
)
)
)
Eigen Then try putting (RoomScript: changeState(1)) after hiding ego and put other stuff under case 1


-Eigen
Jim C Eigen:

When I put that changeState(1) line in, it kept making the game crash. So I completely reworked the code. Now, instead of an animation including both ego and the car, I have the car as a prop, and have Ego change to a different loop. But I couldn't get the car to drive down the street until I defined it as an Act instead of a Prop. Now it works fine, but I'm not sure how to make it move faster. Right now it only creeps along. Any suggestions? Here is the relevant code:

(if(== oops 0)
(if(send gEgo:inRect(0 177 319 189))
= oops 1
Print("You wander aimlessly into the street.")
ProgramControl()
(send gEgo:setLoop(4)
setCel(0)
setCycle(End)
)
(blueCar:show()
setMotion(MoveTo 0 180 RoomScript)
)
)
)
Eigen It probably crahsed becuase you were trying to move a prop not act. Just change your game speed so that the car and all the other stuff will move faster. Since you will be dead after this, there's no need to restore the speed afterwards.

(send gGame:setSpeed(1))

-Eigen
Jim C Great. Thank you so much.