Home   Help Search Login Register  

Author Topic: Respawn only friendlies????  (Read 956 times)

0 Members and 1 Guest are viewing this topic.

Offline Barbolani

  • Members
  • *
Respawn only friendlies????
« on: 03 Jan 2008, 21:11:36 »
Hi all,

Im finding trouble with this simple respawn script. The problem is, they only respawn if the player is on the same side than the creatd units... I suppose its a creategroup issue, but i cant find the problem..

Quote
_marker1 = _this select 0
_marker2 = _this select 1
_group = _this select 2
_units = _this select 3

_countunits = _units
_group = creategroup east

#Update1

"soldierEB" createUnit [getMarkerPos _marker1, _group]

_countunits = _countunits -1

? _countunits > 0 : goto "Update1"

_group move getMarkerPos _marker2
{_x allowFleeing 0} foreach units _group

_countunits = _units

#Update2

? east countSide (units _group) < 1 : goto "Update1"

goto "Update2"

exit


Can u help me, scripting gurus??? Thnx in advance

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Respawn only friendlies????
« Reply #1 on: 03 Jan 2008, 22:18:02 »
I see some minor things here:

1) createUnit generally requires a handle (i.e.: _variable = "SoldierWB" createUnit....). In this case you don't need to recognize the unit created, so using nil should be fine:

Code: [Select]
nil="soldierEB" createUnit [getMarkerPos _marker1, _group]
Second, I have no idea how the createGroup command works, but if it works for you then great :D The problem with spawning is, perhaps, that ArmA generally needs at least one dummy unit for the side present on the map before it can begin spawning new ones (to initialize AI centers and stuff). Are there any east units present before you try running the script? If not, try putting one down and run it then (you can leave the dummy unit out on some island someplace).

Finally: What's up with the countSide in the final check? I'm guessing they're not changing side, so what you're looking for is probably waiting until they're all dead. Two problems:

1) There's no ~ (sleep) in the loop! I guess a simple check like that won't make your computer go gaga, but it's generally bad practice to have any kind of loop without giving the computer a chance to rest in between. I suggest a ~0.02 at least, if it's that important to check that often. But I bet having a ~ of several seconds won't markedly mess with the script in this case. The same can be said for the first loop  :o

2) A slightly better way, perhaps, of checking for if people are still alive in the group is something like
Code: [Select]
{alive _x} count units _group < 1. The above will count the number of units in _group that correspond to the code between the curled brackets (i.e., alive or not). If it's less than 1 (i.e., none), you can reset the loop and such...

Getting any other error messages etc?

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Barbolani

  • Members
  • *
Re: Respawn only friendlies????
« Reply #2 on: 03 Jan 2008, 22:47:24 »
Thnx man, I solved the problem creating dudes and grouping them with the same name than _group... thats not bad because i guess u can stop the script just killing them (good for take the base missions etc...)

About the pause, i forgot that, thnx

About the createunit, ive never understood whats the real difference between those two ways of creating units... the "mine" works perfectly

Im going to PM u, cos ive been one hour trying to insert your Dynamic Voice Script (is GREAT) and im finding some problems...