Home   Help Search Login Register  

Author Topic: help with crouch loop script?  (Read 1238 times)

0 Members and 1 Guest are viewing this topic.

Guru

  • Guest
help with crouch loop script?
« on: 07 Oct 2002, 17:10:43 »
ok ive got this loop in a script that keeps dude crouched
-
#loop
unitsname setUnitPos "UP"; Unit switchMove "crouchToCombat"
~.02
goto "loop"
-
and it works. but i want many crouched dudes. how can i get this 1 script to work on all of em.(without naming them all in the script) it names the dude in the script, which i know needs to go. but how i change it to command any guy ordered to execute the "crouchloop" script in a trigger or init: line  ????????? i dont want 100 scripts for all my dudes :( i know its probably easy but im lost..

Bremmer

  • Guest
Re:help with crouch loop script?
« Reply #1 on: 07 Oct 2002, 17:51:21 »
Put this in each units init line

[this] exec "crouchloop.sqs"
puting this in brackets passes the soldiers name to the script allowing you to use the same script as many times as you want. You could also put the soldiers name in the brackets (eg [bob] exec "crouchloop.sqs") but using this lets you copy and paste from one unit to the next = much faster.

Amend your crouchloop script thus:

_unit = _this select 0
;this bit select the soldiers name to execute the script
;the underscore _ makes the variable local to this script
;do a search for local / global variables on this forum for more info

_unit setUnitPos "UP"
#loop
_unit switchMove "CrouchToCombat"
~0.2
goto "loop"


That should be it  :)


tai mai shu

  • Guest
Re:help with crouch loop script?
« Reply #2 on: 08 Oct 2002, 00:12:14 »
this is the way you should do it:

in the script put:

_crouchguy = _this select 0

_crouchguy setunitpos "up"
#loop
_unit switchmove "crouchtocombat"
~0.2
goto "loop"

than in a trigger, make it large enough to cover all your guys you want to be affected.  Make the trigger,"anybody present"

and in activation, put:

"[_x] exec ""crouch.sqs""" foreach thislist

that should do it

Guru

  • Guest
Re:help with crouch loop script?
« Reply #3 on: 12 Oct 2002, 14:41:54 »
sorry i didnt get to this sooner was out of town a couple days
well i tried em both an neither worked i wrote .sqs like this
-
-
 _unit = _this select 0
 _unit setUnitPos "UP"
 #loop
 _unit switchMove "CrouchToCombat"
 ~0.2
 goto "loop"
-
-
did i do something wrong?
got a error "typed object expected array"
-the second solution crashes OFP an kicks me to windows?
i have OFP not Resistance does that make a diff?
must have done something wrong i guess?
hopefully there's still a solution
thx for the help guys  ;D
« Last Edit: 12 Oct 2002, 14:45:41 by Willy Makeit »

Bremmer

  • Guest
Re:help with crouch loop script?
« Reply #4 on: 12 Oct 2002, 23:41:46 »
You did remember to use the line

[this] exec "crouchloop.sqs"

or

[unitname] exec "crouchloop.sqs"

to initiate the scripts right? I really can't see anything else wrong  :-\

Looking at the script again I think you would be better off the switchmove "crouch", and a shorter delay (~0.02 as you originally had it looks OK).
Incidentally, you do realise that looping a switchmove like this will paralyse the unit - it wont react, and will stay crouched even when dead. A much better way to get a unit to crouch is to put:

this setBehaviour "COMBAT"; this setUnitPos "UP"; this switchMove "combattocrouch"

in its init field.

Cheers

Guru

  • Guest
Re:help with crouch loop script?
« Reply #5 on: 13 Oct 2002, 02:10:43 »
yes i had the init line in there. but this new way works great!!!! ;D so i tossed the script lol.
thx for the help!! appreciation by the bucket full for you ;D