After looking closer at the order of the changeState displayed in real-time (see videos) I've noticed that when the RoomScript changeState calls the IvanaScript with (aIvanaScript changeState: 12) the IvanaScript still runs for a brief second.
(7
(self changeState: 0) ;Returns to the start. Only interrupted if talked to.
)
Before handing over to the IvanaScript at state 12. I think this could be the reason why the actor is not following the MoveTo path correctly and other random things don't work correctly. Which script has priority? Could this be the issue?
(script# 33)
(include sci.sh)
(include game.sh)
(use AutoDoor)
(use Controls)
(use Cycle)
(use Door)
(use Feature)
(use Game)
(use Gauge)
(use Inv)
(use Main)
(use MenuBar)
(use Obj)
(use Rev)
(use DPath)
(use rm797) ;showState debugging changestates script
(public
rm033 0
)
(local
seenMsg
msgVar
)
(procedure (PrintA) ; Ivana's(actors) response. Tbis adds a nice title to the dialogue.
(Print &rest #at -1 20 #title {Ivana Chercemov:} #width 222 #mode 1)
)
(define vRoom 033
)
(define lLotto 0)
(define lDoor 1)
(define lSoda 2)
(instance rm033 of Rm
(properties
picture 033
north 0
east 029
south 0
west 34
)
(method (init)
(super init:)
(gAddToPics ;This adds views to the background in a much more elegant way :)
;add: aLotto
add: aCard
doit:
)
(self setScript: RoomScript)
(switch gPreviousRoomNumber
)
(cond
((== gPreviousRoomNumber 032) (gEgo posn: 292 171 loop: 1)
)
(else
(gEgo posn: 292 171 loop: 0)
)
)
(SetUpEgo)
(gEgo init:)
(aDoor init:)
(aLotto init: stopUpd:)
(aSoda init:)
(aIvana init:)
)
)
(instance RoomScript of Script
(properties)
(method (doit)
(super doit:)
; code executed each game cycle
)
(method (handleEvent pEvent)
(super handleEvent: pEvent)
; handle Said's, etc...
(if (Said 'press/button')
(self changeState: 1)
)
)
(method (changeState newState)
(ShowState self newState 1 2) ; Displays changeState info on screen when debug is enabled.
(= state newState)
(switch state
(0
)
(1 ; Ego goes to soda Machine
(ProgramControl)
(gEgo
illegalBits: 0
ignoreActors:
setMotion: MoveTo 163 177 self
)
)
(2 ; Ego presses soda machine button
(gEgo
cycleSpeed: 1
view: 707
setLoop: 2
setCycle: End self
)
)
(3 ; Done pressing button
(gEgo setCycle: Beg self)
)
(4 ;Soda machine turns on
(gEgo view: 000 setCycle: Walk loop: 3)
(ProgramControl)
(aSoda setCycle: Fwd)
(self changeState: 5)
)
(5
(PlayerControl)
(SetUpEgo) ;this sets ego back to normal
(= cycles 20)
(PrintA {Hey, don't touch that!})
)
(6
(= cycles 10)
(aIvanaScript changeState: 12) ; Ssets up Ivana script to move out behind counter and move to the sosa machine.
)
)
)
)
(instance aDoor of AutoDoor
(properties
view vRoom
loop lDoor
cel 0
x 300
y 172
cycleSpeed 1
entranceTo 032
doorCtrl ctlBLUE
roomCtrl ctlGREEN
)
(method (init)
(super init:)
(self
;setCycle: End
setPri: 10
)
)
)
(instance aLotto of Prop
(properties
view vRoom
loop lLotto
x 31
y 133
cycleSpeed 3
)
(method (init)
(super init:)
(self
setCycle: Fwd
setPri: 9
startUpd:
)
)
)
(instance aSoda of Prop
(properties
view vRoom
loop lSoda
x 144
y 176
cycleSpeed 3
)
(method (init)
(super init:)
(self
;setCycle: Fwd
setPri: 13
startUpd:
)
)
)
;;;(instance aLotto of View
;;; (properties
;;; view vRoom
;;; loop lLotto
;;; x 31
;;; y 131
;;; priority 9
;;; signal ignAct
;;; )
;;;)
(instance aCard of View
(properties
view 213
loop 1
x 44
y 130
priority 10
signal ignAct
)
)
(instance aIvana of Act
(properties
view 526
x 50
y 139
loop 0
cel 0
)
(method (init)
(super init:)
(self
setPri: 8
setScript: aIvanaScript
)
)
)
(instance aIvanaScript of Script
(properties)
(method (handleEvent event)
(if (or (!= (event type:) evSAID) (event claimed:))
(return)
)
(cond
(
(or
(Said 'talk/girl, woman, chick, babe, bitch')
(Said 'talk/girl, woman, chick, babe, bitch')
)
(Print 33 0) ; "Hey babe. What's your sign?"
(aIvanaScript changeState: 8 register: 102)
)
((Said 'talk/soda') ; testing soda machine
(aIvanaScript changeState: 12)
)
((Said 'talk')
(cond
((& (gEgo onControl:) ctlCYAN)
(Print 33 1) ; The giant lotto machine seems to drown out your voice.
)
((& (gEgo onControl:) ctlFUCHSIA)
(Print 33 2) ; "You attempt to catch the clerk's attention, "Excuse me.""
(aIvanaScript changeState: 8)
)
(else
(Print 33 12) ; "She can't hear you from way back here."
)
)
)
(
(and
(not (Said 'look>'))
(or
(Said '/key,penthouse,area')
(Said 'enroll')
(Said '//key,penthouse,area')
)
)
(Print 33 3) ; ""Excuse me, clerk. Whats with the soda machine?"
(aIvanaScript changeState: 8 register: 101)
)
((Said 'look/woman,bitch,slut')
(Print 33 4) ; "The Quiki Mart clerk eagerly awaits your every request."
(Print 33 5 #at -1 144) ; "(If you are a registered guest!)" ; this addes the text to the bottom of the screen. (under the breath type meaning)
)
)
)
(method (changeState newState &tmp IvanaLoop)
(ShowState self newState 1 2) ; Displays changeState info on screen when debug is enabled.
(switch (= state newState)
(0
(= seconds 1)
;(= seconds (Random 4 8))
)
(1
(aIvana
illegalBits: 0
setPri: 8
cycleSpeed: 0
setLoop: -1
setCycle: Walk
setMotion: MoveTo 72 124 self ;Ivanna walks up
)
)
(2
(= seconds (Random 4 8))
)
(3
(aIvana setMotion: MoveTo 53 138 self) ;Ivanna walk down
)
(4
(= seconds (Random 4 8))
)
(5
(aIvana setMotion: MoveTo 53 134 self) ;Ivanna walk down part 2
)
(6
(= seconds (Random 3 9)) ; Ivana does some random poses
(switch (= IvanaLoop (Random 0 5))
(0
(aIvana loop: 6 cycleSpeed: 4 setCycle: End self)
)
(1
(aIvana loop: 7 cycleSpeed: 4 setCycle: End self)
)
;;; (else
;;; (= state -1)
;;; )
)
)
(7
(self changeState: 0) ;Returns to the start. Only interupted if talked to.
)
(8
(aIvana setMotion: MoveTo 63 128 self) ; Let's try and talk. Ivanna stops and goes to central point.
)
(9
(aIvana setLoop: 5 cycleSpeed: 4 setCycle: Beg) ;Talk a little
(= seconds 3)
)
(10
(aIvana setCel: 0 setLoop: 0)
(= cycles 10)
)
(11
(cond
(register
(switch register
(101
(PrintA 33 7) ; "test 2"
)
(102
(PrintA 33 6) ; "test 3"
)
)
)
(else
(switch msgVar
(0
(PrintA 33 8) ; "test 1"
)
(1
(PrintA 33 9) ; "Yes? May I help you?"
)
(2
(PrintA 33 10) ; "Would you like me to call security?"
)
(3
(PrintA 33 11) ; "How may I help you?"
)
)
(if (> (++ msgVar) 3)
(= msgVar 0)
)
)
)
(self changeState: 0) ;Start all over again.
)
(12
(aIvana
illegalBits: 0
cycleSpeed: 0
;setLoop: -1
setCycle: Walk
setMotion: MoveTo 78 120 self ;Ivana walks out behind desk
)
)
(13 ;Ivana walks path to soda machine
(aIvana setPri: -1 setMotion: MoveTo 111 119 self)
)
(14 ;Ivana walks path to soda machine
(aIvana setMotion: MoveTo 87 179 self)
)
(15 ;Ivana walks path to soda machine
(aIvana setMotion: MoveTo 143 179 self)
)
(16 ;Ivana faces soda machine and scratches head and waits.
(aIvana loop: 6 cycleSpeed: 2 setCycle: End self)
;(= cycles 20)
)
(17
(aSoda setCel: 0) ;Soda machine stops.
(aIvana setCycle: Walk setLoop: -1 setMotion: MoveTo 143 173 self) ;Ivana starts walk back to counter.
(self changeState: 18)
)
(18 ;Ivana walks path back behind counter
(aIvana setMotion: MoveTo 87 179 self)
)
(19 ;Ivana walks path back behind counter
(aIvana setMotion: MoveTo 111 119 self)
)
(20 ;Ivana walks path back behind counter
(aIvana setCycle: Beg setMotion: MoveTo 78 120 self)
)
(21 ;Ivana walks path back behind counter
(aIvanaScript changeState: 0)
)
)
)
)