Home   Help Search Login Register  

Author Topic: Script Formatting basic commands and setbehavior usage  (Read 1476 times)

0 Members and 1 Guest are viewing this topic.

ReverseGeb

  • Guest
Hi. I'm trying to get some basic scripting done but I'm not clear on how to properly format my scripts. For instance, if I want to get a guy to do pushups using the switchmove command I get an error that says invalid operator 'switchmove'...however, if I put my code into a trigger things work fine. I assume what's going wrong is that I'm not setting up/initializing my scripts properly. I've taken a look at some scripts but I can't figure out what I'm missing (my trigger contains only the line 'Sarge switchmove "FXStandDip"').

Also, I was wondering about the setbehavior command. I can't get this one to work in a trigger (the editor says unknown operator 'setbehavior') and since I don't quite know how to get scripts working I can't do that either.

One more question: I want to make some soldiers stand around with their rifles slung over their backs. Am I right in thinking that the way to do this is setbehavior "careless"?

srk

  • Guest
Re: Script Formatting basic commands and setbehavior usage
« Reply #1 on: 05 Jul 2006, 10:45:44 »
Quote
Also, I was wondering about the setbehavior command. I can't get this one to work in a trigger (the editor says unknown operator 'setbehavior') and since I don't quite know how to get scripts working I can't do that either.
It's supposed to be 'SetBehaviour' not 'SetBehavior' ;)

Quote
One more question: I want to make some soldiers stand around with their rifles slung over their backs. Am I right in thinking that the way to do this is setbehavior "careless"?
Yes but if their behaviour is careless, they won't do anything if they see an enemy, if that's what you want.
If you use behaviour "safe" then they will engage the enemy once they see it.

ReverseGeb

  • Guest
Re: Script Formatting basic commands and setbehavior usage
« Reply #2 on: 05 Jul 2006, 11:23:40 »
Quote
It's supposed to be 'SetBehaviour' not 'SetBehavior'

*Smacks head on desk*

Thanks!

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Script Formatting basic commands and setbehavior usage
« Reply #3 on: 05 Jul 2006, 12:20:18 »
About the switchmove issue: it would be helpful to see the script which doesn't work.
But if nothing else happens in the script except this switchmove thingy, a trigger will do the job perfectly and keeps the mission file small  ;D

But only for completeness:

switchmove.sqs
Code: [Select]
_unit = _this select 0
_move = _this select 1

_unit switchmove _move
exit

and for calling the script in the trigger or in the unit init line insert:

[Sarge, "FXstandDip"] exec "switchmove.sqs"

assuming you named the unit Sarge.

But as you see, a simple trigger as you have it is easier for this simple task.

ReverseGeb

  • Guest
Re: Script Formatting basic commands and setbehavior usage
« Reply #4 on: 05 Jul 2006, 12:41:52 »
Well, my script only had the single line Sarge switchmove FXStandDip (which I thought had to be wrong...does the this tutorial cover this stuff?). Although you're right, a trigger works fine. Is there a way to make the guy do more than three pushups? I'm actually trying to script together a short cutscene mission, and I want the soldier to do pushups for the entire duration.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Script Formatting basic commands and setbehavior usage
« Reply #5 on: 05 Jul 2006, 13:01:41 »
Code: [Select]
loon_name switchmove "FXstandDip"

#loop
~2
loon_name playmove "FXstandDip"
?not (end_of_cutscene):goto "loop"

save that as a separate script and run it from the cutscene. the end_of_cutscene should be a global variable which you set to true when the cutscene ends. otherwise the script will continue in the background, eating up resources.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Script Formatting basic commands and setbehavior usage
« Reply #6 on: 05 Jul 2006, 14:16:26 »
If your script has the line exactly as you typed below (which is different from what you had typed in the trigger field in your first post) your  the problem is the lack of double quotes around FXSTandDip, i.e.
should be Sarge switchMove "FXStandDip", not Sarge switchMove FXStandDip

Well, my script only had the single line Sarge switchmove FXStandDip (which I thought had to be wrong...
urp!

ReverseGeb

  • Guest
Re: Script Formatting basic commands and setbehavior usage
« Reply #7 on: 07 Jul 2006, 02:33:08 »
Ah, I see. Missed the quotation marks.

My next question is how to get a character to salute, hold the salute for a second and then drop back to the normal stance. Here's my code (which isn't very complicated. I'm fairly clear on the camera commands, but I haven't yet got the the end of my cutscene which is why there's no camera shutdown code yet):

Code: [Select]
player setbehaviour "SAFE"

_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]

_cam camsettarget General
_cam camsetrelpos [-2,10,3]
_cam camcommit 0
~4

General switchmove "effectstandsalute"

_cam camsettarget basetent
_cam camsetrelpos [0,12,0]
_cam camcommit 0
@camcommitted _cam
~2
exit

As I'm sure you all know, just using switchmove immediately snaps the soldier to that pose - what I wantis for him to move his arm and salute like a normal human being.  :D (I had the same problem with the push-ups: there was no animation for the guy getting down on his hands and knees. One second he's standing, the next he's doing push-ups)

ReverseGeb

  • Guest
Re: Script Formatting basic commands and setbehavior usage
« Reply #8 on: 07 Jul 2006, 08:31:37 »
Okay, so a little searching and I've figured out to use playmove instead of switchmove. But check back in for whatever newbie problem I'm currently having real soon! Exciting! Wow!

And thanks for that code, bedges.