OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Jasper on 29 Jul 2004, 11:37:01

Title: Script problems
Post by: Jasper on 29 Jul 2004, 11:37:01
 have searched for an answer but I cant find the answer to this...  

I've got a simple script to simulate a simple conversation.  Its called chat.sqs.  I have two people (chat1 and chat2). There is a trigger covering them = East, Present, Once, [] exec "chat.sqs"

The script =

#repeat

? Alert1 : goto "Alert"
~1

chat1 playmove "EffectStandTalk"
? Alert1 : goto "Alert"
~1

chat2 playmove "FXCivilFoldOnesArms"
? Alert1 : goto "Alert"
~1

chat2 playmove "EffectStandTalk"
? Alert1 : goto "Alert"
~1

chat1 playmove "FXCivilHandMouth"
? Alert1 : goto "Alert"
~1

goto "repeat"

#Alert
(chat1) setbehaviour "combat"
(chat1) setspeedmode "normal"
(chat1) setcombatmode "red"

(chat2) setbehaviour "combat"
(chat2) setspeedmode "normal"
(chat2) setcombatmode "red"

chat1 switchmove "null"
chat2 switchmove "null"

goto "end"

#end
exit

When the mission starts the people start chatting.  When the Alert1 is true they both stop chatting and go to combat mode.

But, then after a couple of seconds they just start chatting again. The 'enemy' westerner is still alive, so the Alert1 stays true and the script goes to the end and the trigger is set to once so why does it loop?

I have tried using switch move and that doesnt work.

All help appreciated and if there is an easier way to simulate them chatting please point me in the right direction. Cheers.
Title: Re:Script problems
Post by: Jasper on 29 Jul 2004, 13:12:43
After 'extensive'  ;)  testing, it seems the 2 people are indeed stuck in their animations.

If i assign them to a group when Alert1 = true, they do join the group but they dont follow any orders you give them until they stop doing the animations.

So, the problem is getting them to 'forget' the list of animations.  I assumed that switchmove "null" did that but it obviously doesn't.

Has nobody else used a script to simulate talking in their missions?  If so , how did you get them to do something else?

I cant use switchmove instead of playmove to act out the conversation unless i put in wait times. But this would stop them from reacting to Alert1 because they would be waiting to finish the animation.

Is this just another limitation to OFp or am I overlooking something?
Title: Re:Script problems
Post by: macguba on 29 Jul 2004, 14:37:27
Try using both switchmove "null" and playmove "null".   Also put the command before the behaviour commands.
Title: Re:Script problems
Post by: Jasper on 29 Jul 2004, 16:22:30
Macguba, the playmove doesnt work at all, and what do you mean by

"put the command before the behaviour commands"

 ???
Title: Re:Script problems
Post by: macguba on 29 Jul 2004, 16:24:33
put this bit

chat1 switchmove "null"
chat2 switchmove "null"

before this bit

(chat1) setbehaviour "combat"
(chat1) setspeedmode "normal"
(chat1) setcombatmode "red"

(chat2) setbehaviour "combat"
(chat2) setspeedmode "normal"
(chat2) setcombatmode "red"


Get them out of the switchmoves before giving them other orders, that's all.     It might help, dunno, worth a try.
Title: Re:Script problems
Post by: Jasper on 29 Jul 2004, 16:28:05
Oh I see... ::)

Unfortunately I tried that and that doesnt work either... :(

This script is a mystery... ???
Title: Re:Script problems
Post by: macguba on 29 Jul 2004, 16:35:51
It is a mystery ... ok try longer gaps ~1 is not enough for a lot of animations.    They may be getting tied up in knots trying to do two at once.

Also try a "lite" version of your script with just one animation, see if you can get that to work.
Title: Re:Script problems
Post by: Jasper on 29 Jul 2004, 16:53:25
 :) Right we are getting somewhere...

This did work sort of, I just used the touch face animation.  1 out of the 3 times i ran it the man did as requested!! :cheers:

However the other 2 times he was still looping through the animation even though Alert1 was true  ???

If I was to increase the wait time from 1 second then they wouldnt react to Alert1 because they would have to wait for the set time before they checked it again.  Maybe there is no other way and I will have to decide between reaction time and conversation realism...

But surely not.. ;)
Title: Re:Script problems
Post by: macguba on 29 Jul 2004, 17:11:24
OK good it looks like we are getting somewhere.     Once you have ordered a loon to do an animation it is better to let him do it before telling him to do something else.    

By experiment you will be able to establish minimum times for each animation.    However I think you're just going to have to live with them finishing the animation before going to #alert.      
Title: Re:Script problems
Post by: Jasper on 29 Jul 2004, 17:15:14
Nooooooooooooooooooooooooooooooo

 ;) Ok then....... :'(
Title: Re:Script problems
Post by: Unnamed on 30 Jul 2004, 04:09:17
Have you tried switchmove or playmove to "combat"? Thats what I used to break out of some looped anims I made.
Title: Re:Script problems
Post by: Jasper on 30 Jul 2004, 11:19:55
That still doesnt work, The anims just cant seem to be 'forgotten'.

I have decided to just lose some realism in the conversation for the sake of quick reaction to the #Alert

Cheers anyway :D
Title: Re:Script problems
Post by: ACF on 30 Jul 2004, 12:06:24
I suspect the reason is that 'PlayMove' works like 'PlaySound'. If you execute a number of consecutive PlaySounds (even without pauses) the engine plays each sound, all the way through, one after the other.

If my assumption's correct, your chat script is setting up a list of anims for each unit that will be played sequentially.  Executing a behaviour command seems to terminate the current anim but not the other unplayed moves in the unit's list.  Of course, when these play they override the behaviour command.

So much for the theory.  I have a vague recollection that a PlaySound "null" or similar clears the list so you could try a PlayMove "null" (or, I stress, something like that - I haven't checked) before the SetBehaviour.

Hope it helps.
Title: Re:Script problems
Post by: Jasper on 30 Jul 2004, 13:25:15
Thats the same suggestion as Macguba!  ;) :P

But, no, playmove null doesnt work either.  The #Alert flips true and the two guys stop chatting but after a couple of seconds they revert to the 'chat'.

It seems that the list of anims stays in 'memory' until completed.  Even when assigned to a group and #Alert is true, they join the group but wont obey commands until they have finished the 'chat'.

Cheers anyway  ;D