Home   Help Search Login Register  

Author Topic: Pleeeease I need help with CrashnBurn Creat Units (respawn) script!! Pleeease!  (Read 1473 times)

0 Members and 1 Guest are viewing this topic.

CptBravo

  • Guest
Hi guys,

I am unsing the Crash n Burn creat script and its awesome! I got it to work. I just have one little problem...

I am using a few triggors to creat units when a west unit walks through it.
Problem: Units are created as planned in triggor 1. But the second trig which takes place 20 seconds later does not creat same units?? I am using same logic and same unit to creat. Only time it will creat if the first group is already dead! If only 2 soldiers died from that group then it creats only 2 new soldiers!!! Any way I can make it creat a FULL SQUAD even if the original groupo is still alive??

Thank you very much!

I have attached the  mission  to demo the problem.

I really appreciate any help I get in advance!!

CptBravo

  • Guest
Releated question
« Reply #1 on: 24 Jul 2003, 03:39:10 »
The other releated question is if I want to add a script in the init field of the created units .. how do I do that? I added one between the quotes and I kept getting an error.

Its the spray script that makes unit fire inccuratly.

Here is what I have:


;begin script

_pos = _this select 0
_grp = _this select 1

"sdoc_uce_russianOfficer" createunit [getpos _pos,_grp,"",1,"LIEUTENANT"]
"sdoc_uce_russianMedic" createunit [getpos _pos,_grp,"this addeventhandler ["fired", {_this exec "spray.sqs"}]",0.5,"SERGEANT"]
"sdoc_russianMachinegunnerRPK74" createunit [getpos _pos,_grp,"this addeventhandler ["fired", {_this exec "spray.sqs"}]",0.2,"CORPORAL"]
~1
_units = units _grp
_grp setformation "LINE"
_grp setbehaviour "AWARE"
_grp setcombatmode "GREEN"
"_x allowfleeing 0" foreach _units

#loop
?(("Alive _x" count _units) == 0): "deletevehicle _x" foreach _units; exit
~random(10) + 10
goto "loop"


Any help is grrrrrrrreatly appreciated!

CrashnBurn

  • Guest
The script is doing what its supposed to do. You can only have 12 units to a group alive at the same time. If you call the script again to create a full squad for the same group, the script is only going to create enough units to fill the group back up to 12 units. If you want more troops, use more groups.

Also, if you're going to create the same type of soldiers for each group, you can do it with only one create script by putting a variable into the top of the script such as creating=true and then making it false at the bottom before the script exits. Add ! creating to the condition of your triggers and make sure creating=false is declared at mission load in your init.sqs or players initialization. You don't need the part of the script that checks how many are alive unless you intend for the script to create again automatically. Since you use triggers you dont need those lines.

When using the voice effects in a trigger, the voice will come from the origin of the trigger. It's better to just have the player say the voice line so you can hear it if he leaves the trigger area (on a delayed trigger)...ie- player say "Eng37". The only other alternative for the effects is to group the trigger to the unit and he will say the voice effect with lip movements, but the radius of the trigger must be large enough that the unit is within the radius when the effect is activated. The first method I described is probably the best.

You didnt include the spray.sqs so I can't troubleshoot that for you. I took a quick look at the editors depot but didnt see it.

Have a look at this modified example mission based on your test mission. No addons are used for this example.
« Last Edit: 24 Jul 2003, 18:08:45 by CrashnBurn »

CptBravo

  • Guest
Hi CrashnBurn,

Thank you for responding so quick.

Here is the spray script, which makes units not so deadly accurate with thier shooting:


_man = _this select 0
   _count = 0
   _start1 = "start1"
   _start2 = "start2"
   _start1_and_start2_array = [_start1, _start2]
   _random = random (count _start1_and_start2_array)
   _random = _random - _random % 1
   _randomstart = _start1_and_start2_array select _random
   _man removealleventhandlers "fired"
   _mandir = getdir _man
   goto _randomstart

#start1
   _man setdir _mandir
   _mandir = _mandir + 0.06
   _count = _count + 1
   ? _count > 50: goto "end"
   ~0.01
   goto "start1"

#start2
   _man setdir _mandir
    _mandir = _mandir - 0.06
   _count = _count + 1
   ? _count > 50: goto "end"
   ~0.01
   goto "start2"
#end
   _man addeventhandler ["fired", {[_this select 0]  exec "spray.sqs"}]
exit


It works great with normal units. Now I am trying to use it your creat script so each soldier created will have this script .. Question is how do I put it in their init field and get it to work?

As usual your feed back is always appreciated.

 

CptBravo

  • Guest
Here is the script attached for those who might want it :)

CrashnBurn

  • Guest
Hey Captain, this seems to work-

_pos = _this select 0
_grp = _this select 1

"OfficerE" createunit [getpos _pos,_grp,"s1=this",1,"LIEUTENANT"]
"SoldierEB" createunit [getpos _pos,_grp,"s2=this",0.5,"SERGEANT"]
"SoldierEMG" createunit [getpos _pos,_grp,"s3=this",0.5,"SERGEANT"]
"SoldierEG" createunit [getpos _pos,_grp,"s4=this",0.5,"SERGEANT"]
"SoldierEB" createunit [getpos _pos,_grp,"s5=this",0.5,"SERGEANT"]
"SoldierELAW" createunit [getpos _pos,_grp,"s6=this",0.5,"SERGEANT"]
"SoldierEB" createunit [getpos _pos,_grp,"s7=this",0.5,"SERGEANT"]
"SoldierEB" createunit [getpos _pos,_grp,"s8=this",0.5,"SERGEANT"]
"SoldierEB" createunit [getpos _pos,_grp,"s9=this",0.5,"SERGEANT"]
"SoldierEMG" createunit [getpos _pos,_grp,"s10=this",0.5,"SERGEANT"]
"SoldierEB" createunit [getpos _pos,_grp,"s11=this",0.5,"SERGEANT"]
"SoldierEMedic" createunit [getpos _pos,_grp,"s12=this",0.5,"SERGEANT"]
~2
s1 addeventhandler ["fired",{[s1] exec "spray.sqs"}]
s2 addeventhandler ["fired",{[s2] exec "spray.sqs"}]
s3 addeventhandler ["fired",{[s3] exec "spray.sqs"}]
s4 addeventhandler ["fired",{[s4] exec "spray.sqs"}]
s5 addeventhandler ["fired",{[s5] exec "spray.sqs"}]
s6 addeventhandler ["fired",{[s6] exec "spray.sqs"}]
s7 addeventhandler ["fired",{[s7] exec "spray.sqs"}]
s8 addeventhandler ["fired",{[s8] exec "spray.sqs"}]
s9 addeventhandler ["fired",{[s9] exec "spray.sqs"}]
s10 addeventhandler ["fired",{[s10] exec "spray.sqs"}]
s11 addeventhandler ["fired",{[s11] exec "spray.sqs"}]
s12 addeventhandler ["fired",{[s12] exec "spray.sqs"}]
;------------------------------------------------------------------------------
_grp setformation "LINE"
_grp setbehaviour "AWARE"
_grp setcombatmode "GREEN"
"_x allowfleeing 0" foreach units _grp

exit

CptBravo

  • Guest
Hi CrashnBurn,

I am getting an error:

's3l#l'=this: error reserved variable in expression

Any help is appreciated thanks.

CrashnBurn

  • Guest
Make sure the other groups have different names. s13-s24 etc...
You can't use the same names for other groups. I tested what I posted and it works fine. Check your names and syntax. Make sure the names in the init string are in quotes, and you have the brackets around the names in the addeventhandler lines. I got an error there saying it expected an array, so the brackets fixed that.

s1 addeventhandler ["fired",{[s1] exec "spray.sqs"}]
                                              ^^^

« Last Edit: 26 Jul 2003, 02:50:31 by CrashnBurn »

CptBravo

  • Guest
Hey CrashnBurn,

Thanks for you very  much for your help. As always you are a saviour :)

Out of curiousty is therer an easier way to do it rather than do it for each unit in 20 different grps?

Eaither way, it worked and thanks!! :)
« Last Edit: 26 Jul 2003, 05:26:48 by CaptainBravo »

CrashnBurn

  • Guest
Maybe Sui or LCD or one of the other resident experts can give us better syntax to shorten things up a bit? There's a function available for createunit in the editors depot. I'm just starting to learn how it (and functions in general) work, so I don't feel safe to give any advice about using it.
« Last Edit: 26 Jul 2003, 05:43:03 by CrashnBurn »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Quote
Out of curiousty is therer an easier way to do it rather than do it for each unit in 20 different grps?

regular foreach command ;)

"_X addeventhandler [{fired},{[_X] exec {spray.sqs}}]" foreach [s1,s2,(insertallnamesneeded)]

or

"_X addeventhandler [{fired},{[_X] exec {spray.sqs}}]" foreach units groupname (i think u use _grp right ?)

i donno if it works in da init line of creatunie - but try putin in da init part of it (on every unit) somin like

this addeventhandler [{fired},{[this] exec {spray.sqs}}]

or

if dis doesnt work

unitname addeventhandler [{fired},{[unitname] exec {spray.sqs}}]


now - u were talkin bout da even handlers right ? i didnt mis nythin ::)

LCD OUT
« Last Edit: 26 Jul 2003, 08:26:29 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Zayfod

  • ECP Team
  • *
  • Llama, softest natural fibre in the world.
This is the latest version of  my spray.sqs that u may wanna use instead--Ive been busy on other things lately. Ill finish this up to final version some time soon.



Code: [Select]
  _soldier = _this select 0
   _count = 0
   _start1 = "start1"
   _start2 = "start2"
   _start1_and_start2_array = [_start1, _start2]
   _random = random (count _start1_and_start2_array)
   _random = _random - _random % 1
   _randomstart = _start1_and_start2_array select _random

   ; Sets up the spray value for a MG
   _spray_value = 0.11

   ; If firing single shot it then exits script and no change to soldier
   ? (_this select 3 == "single"): _soldier removealleventhandlers "fired"; goto "end"
   
   ; If soldier is firing a burst this resets the spray value to be less than a MG
   ? (_this select 3 == "burst"): _spray_value = 0.08


   _mandir = getdir _soldier
   _soldier removealleventhandlers "fired"
   goto _randomstart

#start1
   _soldier setdir _mandir
   _mandir = _mandir + _spray_value
   _count = _count + 1
   ? _count > 50: goto "end"
   ~0.01
   goto "start1"

#start2
   _soldier setdir _mandir
   _mandir = _mandir - _spray_value
   _count = _count + 1
   ? _count > 50: goto "end"
   ~0.01
   goto "start2"
#end
   _soldier addeventhandler ["fired", {_this  exec "spray.sqs"}]
exit


Note:Generalcoder has made another type of fire dispersion script that u may wanna try.


http://www.ofpec.com/yabbse/index.php?board=27;action=display;threadid=8586


His has some nice code but offers a differing result to mine. Recommend u check his one out. Maybe when i get sum time well take best code from each and finish it proper.

Zay

"I have come here to kick ass and chew bubble gum......an I'm all outta bubble gum!"