Home   Help Search Login Register  

Author Topic: Respawning Script Help  (Read 790 times)

0 Members and 1 Guest are viewing this topic.

PBrain

  • Guest
Respawning Script Help
« on: 02 Jul 2006, 20:34:02 »
Here is my script so far. What happens is the soldiers are created only once and after you shoot one, they do not come back. Also, it only makes ai for one squad, instead of moving on to the next squad.

Quote
;["Soldiertype" (0),unit skill (1),number of guys per group (2),group target (3),respawn point (4),[group1,group2,etc.] (5)] exec "respawn.sqs"

_unittype = _this select 0
_unitskill = _this select 1
_unitnumber = _this select 2
_target = _this select 3
_respawn = _this select 4
_groups = _this select 5
_count = 0
_groupcount = 0

#create
_unittype createunit [(getpos _respawn),(_groups select _count),"",_unitskill,"PRIVATE"]
_groupcount = count units (_groups select _count)
leader (_groups select _count) move getpos _target

#check
~.5
?_groupcount != _unitnumber: goto "create"
?_groupcount == _unitnumber: goto "switchgroups"
?_count > count _groups: _count = 0
goto "check"

#swtichgroups
_count = _count + 1
_groupcount = count units (_groups select _count)
goto "check"

What I'm trying to make it do is first, create a squad for the first group. Then create a squad for the second group. It then constantly switches between the two groups to make sure they are at full strength and if they aren't, it tops them up. It is a very simple script but it will do just fine for what I have planned. The syntax is at the top.

Strango

  • Guest
Re: Respawning Script Help
« Reply #1 on: 12 Jul 2006, 22:50:03 »
Move
Code: [Select]
? _count > count _groups: _count = 0
to immediately after
Code: [Select]
_count = _count + 1
How you have it now you execute code with an out of bounds array before you check if your array is out of bounds.