Home   Help Search Login Register  

Author Topic: Respawning in SP  (Read 1784 times)

0 Members and 1 Guest are viewing this topic.

Lean Bear

  • Guest
Respawning in SP
« on: 30 Dec 2004, 14:00:38 »

Yes, it can be done. But I can't get my script to work.

Here's what I've got so far:

Code: [Select]
_WestForces = ["wgroup1","wgroup2","wgroup3","wgroup4","wgroup5","wgroup6"]
count _WestForces

#CheckHealth

not(alive "wgroup1"): goto "Respawnw1"
not(alive "wgroup2"): goto "Respawnw2"
not(alive "wgroup3"): goto "Respawnw3"
not(alive "wgroup4"): goto "Respawnw4"
not(alive "wgroup5"): goto "Respawnw5"
not(alive "wgroup6"): goto "Respawnw6"


#Respawnw1

"wgroup1" setPos getMarkerPos "westmarker1" [0]: "wgroup1" setDamage 0

goto "CheckHealth"

#Respawnw2

"wgroup2" setPos getMarkerPos "westmarker2" [0]: "wgroup2" setDamage 0

goto "CheckHealth"

#Respawnw3

"wgroup3" setPos getMarkerPos "westmarker3" [0]: "wgroup3" setDamage 0

goto "CheckHealth"

#Respawnw4

"wgroupw4" setPos getMarkerPos "westmarker4" [0]: "wgroup4" setDamage 0

goto "CheckHealth"

#Respawnw5

"wgroup5" setPos getMarkerPos "westmarker5" [0]: "wgroup5" setDamage 0

goto "CheckHealth"

#Respawnw6

"wgroup6" setPos getMarkerPos "westmarker6" [0]: "wgroup6" setDamage 0

goto "CheckHealth"

exit

I've probably made a really basic error, but I can't find out what it is :P

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Respawning in SP
« Reply #1 on: 30 Dec 2004, 14:23:27 »
You appear to have : instead of ; throughout.   Also I don't get the
  • bit.  And the checkhealth lines should each start with ?.    And the alive command takes a unit as argument, not a string.


This will work fine for AI, but not for the human player:  he will respawn ok but the death sequence will still start.
« Last Edit: 30 Dec 2004, 14:24:31 by macguba »
Plenty of reviewed ArmA missions for you to play

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #2 on: 30 Dec 2004, 14:29:37 »
But isn't ";" used for ends of lines and not "then". Doesn't ":" mean "then".

Quote
Also I don't get the
  • [/i] bit.
Me neither, it was recomended I put it in by a friend.

Basically, I'm trying to make a script so that the enemy - AI (the player doesn't matter) continues to respawn when dead.

But I don't know what to put to check if the whole group on the West side is alive ??? As you said:

Quote
And the alive command takes a unit as argument, not a string.


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Respawning in SP
« Reply #3 on: 30 Dec 2004, 15:02:02 »
Lol if you put something in a script you don't understand, it is BOUND not to work.
 ;D

: is indeed "then".  ; is used to separate commands, as in your #Respawnw2 bits.   You don't need anything at the end of a line in a script.   (You do in a function.)

What is wgroup1?   A unit or a group?    The script looks like it is meant to be a unit.

For groups

"alive _x" count units grp1 == 0

or something.

Plenty of reviewed ArmA missions for you to play

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #4 on: 30 Dec 2004, 15:44:42 »
wgroup1 is indeed a group.

So, if I had something like:

Code: [Select]
_WestForces = ["wgroup1","wgroup2","wgroup3","wgroup4","wgroup5","wgroup6"]
count _WestForces

#CheckHealth

?"alive _x" count units wgroup1 == 0 : goto "Respawnw1"
?"alive _x" count units wgroup2 == 0 : goto "Respawnw2"
?"alive _x" count units wgroup3 == 0 : goto "Respawnw3"
?"alive _x" count units wgroup4 == 0 : goto "Respawnw4"
?"alive _x" count units wgroup5 == 0 : goto "Respawnw5"
?"alive _x" count units wgroup6 == 0 : goto "Respawnw6"


#Respawnw1

"wgroup1" setPos getMarkerPos "westmarker1"; "wgroup1" setDamage 0

goto "CheckHealth"

#Respawnw2

"wgroup2" setPos getMarkerPos "westmarker2"; "wgroup2" setDamage 0

goto "CheckHealth"

#Respawnw3

"wgroup3" setPos getMarkerPos "westmarker3"; "wgroup3" setDamage 0

goto "CheckHealth"

#Respawnw4

"wgroupw4" setPos getMarkerPos "westmarker4"; "wgroup4" setDamage 0

goto "CheckHealth"

#Respawnw5

"wgroup5" setPos getMarkerPos "westmarker5"; "wgroup5" setDamage 0

goto "CheckHealth"

#Respawnw6

"wgroup6" setPos getMarkerPos "westmarker6"; "wgroup6" setDamage 0

goto "CheckHealth"

exit

Would this work?

Also, what's with the "alive _x"? - I might as well understand what it is I'm putting in a script :P

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #5 on: 30 Dec 2004, 15:56:26 »
Hmm, just realised that I only changed the #CheckHealth part for groups.

edit

So, how about this:

Code: [Select]
_WestForces = ["wgroup1","wgroup2","wgroup3","wgroup4","wgroup5","wgroup6"]
count _WestForces

#CheckHealth

?"alive _x" count units "wgroup1" == 0 : goto "Respawnw1"
?"alive _x" count units "wgroup2" == 0 : goto "Respawnw2"
?"alive _x" count units "wgroup3" == 0 : goto "Respawnw3"
?"alive _x" count units "wgroup4" == 0 : goto "Respawnw4"
?"alive _x" count units "wgroup5" == 0 : goto "Respawnw5"
?"alive _x" count units "wgroup6" == 0 : goto "Respawnw6"


#Respawnw1

"_x setPos getMarkerPos "westmarker1"" forEach units "wgroup1"; "_x setdammage 0" forEach units "wgroup1"

goto "CheckHealth"

#Respawnw2

"_x setPos getMarkerPos "westmarker2"" forEach units "wgroup2"; "_x setdammage 0" forEach units "wgroup2"

goto "CheckHealth"

#Respawnw3

"_x setPos getMarkerPos "westmarker3"" forEach units "wgroup3"; "_x setdammage 0" forEach units "wgroup3"

goto "CheckHealth"

#Respawnw4

"_x setPos getMarkerPos "westmarker4"" forEach units "wgroup4"; "_x setdammage 0" forEach units "wgroup4"

goto "CheckHealth"

#Respawnw5

"_x setPos getMarkerPos "westmarker5"" forEach units "wgroup5"; "_x setdammage 0" forEach units "wgroup5"

goto "CheckHealth"

#Respawnw6

"_x setPos getMarkerPos "westmarker6"" forEach units "wgroup6"; "_x setdammage 0" forEach units "wgroup6"

goto "CheckHealth"

exit

btw I found out what the _x was all about while browsing the com refs :)
« Last Edit: 30 Dec 2004, 16:08:14 by Lean Bear »

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #6 on: 30 Dec 2004, 16:34:42 »
It keeps getting stuck on the first line. Now I'm using:

Code: [Select]
_WestForces = ["wgroup1","wgroup2","wgroup3","wgroup4","wgroup5","wgroup6"]
count _WestForces

#CheckHealth

"_x == 0" count units "wgroup1" : goto "Respawnw1"
"_x == 0" count units "wgroup2" : goto "Respawnw2"
"_x == 0" count units "wgroup3" : goto "Respawnw3"
"_x == 0" count units "wgroup4" : goto "Respawnw4"
"_x == 0" count units "wgroup5" : goto "Respawnw5"
"_x == 0" count units "wgroup6" : goto "Respawnw6"

Also, I tried de-activating the script and putting the "_x == 0" count.... line in a trigger, but it came up with an error about the units command.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Respawning in SP
« Reply #7 on: 30 Dec 2004, 17:32:44 »
it should be:

_WestForces = [wgroup1,wgroup2,wgroup3,wgroup4,wgroup5,wgroup6]
count _WestForces

#CheckHealth

?"alive _x" count units wgroup1 == 0: goto "Respawnw1"
?"alive _x" count units wgroup2 == 0: goto "Respawnw2"
?"alive _x" count units wgroup3 == 0: goto "Respawnw3"
?"alive _x" count units wgroup4 == 0: goto "Respawnw4"
?"alive _x" count units wgroup5 == 0: goto "Respawnw5"
?"alive _x" count units wgroup6 == 0: goto "Respawnw6"

what the "alive _x" does is specify which units to consider when counting them. so it is telling the script to count the living units in each group, and when that count has nothing in it (i.e. == 0) it respawns them all

I don't get why you have all your groups as strings....
« Last Edit: 30 Dec 2004, 17:36:50 by Triggerhappy »

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #8 on: 30 Dec 2004, 18:05:55 »
The scipt that you put is what I had been using and it wasn't working.

Quote
I don't get why you have all your groups as strings....

Why not?

edit

You're right. Why am I using them as strings? It turns out that was where all the errors were coming from.

Problem is, now there's a bigger issue. The lines of script don't seem to work.

I think it might be the way I've set up the groups as there is no error message now or anything.

I've got the following in the leader's init field:

wgroup1 = group this

I say this because I tried (on a completely blank mission) putting the player (so I could watch what's happening ::)) and one group of two men. The above line was in the leader's init field and I put a trigger which read:

On Activation: "_x setPos getMarkerPos westmarker1" forEach units wgroup1; "_x setdammage 1" forEach units wgroup1

And nowt happened. Since the script has been confirmed by numerous scripters as being ok and should work - I'm reckonin' its the way I've grouped the units.


« Last Edit: 30 Dec 2004, 18:46:25 by Lean Bear »

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #9 on: 30 Dec 2004, 19:26:38 »
Umm, ok well, the new script works.....sorta

Take a look:

Code: [Select]
_WestForces = [wgroup1,wgroup2,wgroup3,wgroup4,wgroup5,wgroup6]
count _WestForces

#CheckHealth

?"alive _x" count units wgroup1 == 0: goto "Respawnw1"
?"alive _x" count units wgroup2 == 0: goto "Respawnw2"
?"alive _x" count units wgroup3 == 0: goto "Respawnw3"
?"alive _x" count units wgroup4 == 0: goto "Respawnw4"
?"alive _x" count units wgroup5 == 0: goto "Respawnw5"
?"alive _x" count units wgroup6 == 0: goto "Respawnw6"


#Respawnw1

"_x setPos getMarkerPos westmarker1" forEach units wgroup1; "_x setdammage 0" forEach units wgroup1

goto "CheckHealth"

#Respawnw2

"_x setPos getMarkerPos westmarker2" forEach units wgroup2; "_x setdammage 0" forEach units wgroup2

goto "CheckHealth"

#Respawnw3

"_x setPos getMarkerPos westmarker3" forEach units wgroup3; "_x setdammage 0" forEach units wgroup3

goto "CheckHealth"

#Respawnw4

"_x setPos getMarkerPos westmarker4" forEach units wgroup4; "_x setdammage 0" forEach units wgroup4

goto "CheckHealth"

#Respawnw5

"_x setPos getMarkerPos westmarker5" forEach units wgroup5; "_x setdammage 0" forEach units wgroup5

goto "CheckHealth"

#Respawnw6

"_x setPos getMarkerPos westmarker6" forEach units wgroup6; "_x setdammage 0" forEach units wgroup6

goto "CheckHealth"

exit

OK, basically, I went up to a random guy (wgroup1 I think he was in) and started shooting him. He didn't die. He kept respawning on the same spot (as did all of them when I tried).

So, the script now works, there's no errors, but the men don't wait for the whole group to die and they keep respawning on the same spot.

btw Should I have the marker names as strings?
« Last Edit: 30 Dec 2004, 19:42:57 by Lean Bear »

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #10 on: 31 Dec 2004, 16:49:32 »
OK, now its only the men in wgroup1 that don't die (although I don't remeber changing anything :P).

All the other units in the mission die and then don't come back to life.

Whereas the units in wgroup1 just won't die.

I can't beleive this is such a hassle to get working ::) :P

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #11 on: 31 Dec 2004, 19:33:17 »
I know that I've posted about 3 or 4 times in a row now, but my cause should be well satisfied.

Thanks to looking through some scripts by High_Tex that were used in the Battle Over Hokkaido Mod, I have achieved a (probably temporary) state of OFP scripting enlightenment 8) Therefore I now understand all about the this select 0's etc and how various commands can be manipulated to acheive new commands that didn't wholely exist before.

So, I have decided to step my scripting up a level and completely re-write the script. Now, it will be activated by using triggers which will set what type, how many, and which side the respawned troops will be on.

So, in a trigger in the mission editor, you'd make a trigger with the following in the Condition field:

count units wgroup1 <= 0//and more if required.

and in the OnActivation field, a line in the following format:

[_pos, _grp, _name, _side, _type] exec "respawn.sqs"

so for example, if you had a marker called "Westwp1", a group called wgroup1 with a leader called wunit1 on the West side and you wanted the new group to be a group of M113s then you'd put:

[getMarkerPos "Westwp1", wgroup1, wunit1, 0, 3] exec "respawn.sqs"

The variables that can be set are selected in the "respawn.sqs" script as follow:

_pos = _this select 0
_grp = _this select 1
_name = _this select 2
_side = _this select 3
_type = _this select 4

? _side == 0 : goto "West"
? _side == 1 : goto "East"
? _side == 2 : goto "Res"
? _side == 3 : goto "Civ"


Then, as in the eg, the side was West...

#West

? _type == 1 : goto "InfantryW"
? _type == 2 : goto "MechanizedW"
? _type == 3 : goto "ArmorSoftW"
? _type == 4 : goto "ArmorHeavyW"
? _type == 5 : goto "ChopperW"

#ArmorSoftW

then a list of createUnits depending on the _type and leader etc.


Basically, (although I haven't finished the scipt yet) when the groups are defeated (ie. have 0 units) then they are respawned at their starting location.

This is chosen as follows (I don't know if this is right yet):

Respawn_wp_leader=leader _grp
_wppos=getWPPos [Respawn_wp_leader,0]
[Respawn_wp_leader,0] setwppos _pos
~3

Respawn_wp_leader=leader _grp
[Respawn_wp_leader,0] setwppos _wppos


So the index "0" in the getWPPos lines are the starting locations for each of the groups which are automatically placed at the start of every mission.
« Last Edit: 31 Dec 2004, 19:34:49 by Lean Bear »

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #12 on: 01 Jan 2005, 17:04:44 »
OK, everything is working OK, but the new units aren't always replacing the old ones.

Here's the script for the West Infantry respawn:

#InfantryW

? (name leader _grp == format ["%1",_name]) : goto "skipofficerW"
"OfficerW" createUnit [_pos,_grp,"this addmagazine ""berettamag"";this addmagazine ""berettamag"";this addweapon ""beretta"";_name=this",0.6,"lieutenant"]

#SkipOfficerW

"SoldierWB" createUnit [_pos,_grp,"this addweapon ""binocular""",0.5,"sergeant"]
"SoldierWMG" createUnit [_pos,_grp,"",0.4,"sergeant"]
"SoldierWLAW" createUnit [_pos,_grp,"",0.4,"corporal"]
"SoldierWB" createUnit [_pos,_grp,"",0.4,"corporal"]
"SoldierWG" createUnit [_pos,_grp,"",0.4,"corporal"]
"SoldierWLAW" createUnit [_pos,_grp,"",0.4,"corporal"]
"SoldierWB" createUnit [_pos,_grp,"",0.2,"private"]
"SoldierWMG" createUnit [_pos,_grp,"",0.2,"private"]

~5
Respawn_wp_leader=leader _grp
_wppos=getWPPos [Respawn_wp_leader,0]
[Respawn_wp_leader,0] setWPPos _pos

~3
Respawn_wp_leader=leader _grp
[Respawn_wp_leader,0] setWPPos _wppos

exit


Can yous guys see anything wrong here? ie. that would mean that the created units aren't replacing the old ones?

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #13 on: 02 Jan 2005, 21:54:39 »
Oh man, I can't beleive I was so stupid ;D

I think you'll see that in the original script it went:

#CheckHealth

?"alive _x" count units wgroup1 == 0: goto "Respawnw1"
?"alive _x" count units wgroup2 == 0: goto "Respawnw2"
?"alive _x" count units wgroup3 == 0: goto "Respawnw3"
?"alive _x" count units wgroup4 == 0: goto "Respawnw4"
?"alive _x" count units wgroup5 == 0: goto "Respawnw5"
?"alive _x" count units wgroup6 == 0: goto "Respawnw6"

So, I shortened it down first:

_group = _this select 0
_marker = _this select 1

#CheckHealth

?"alive _x" count units _group == 0: goto "Respawn"

Then I realised why it had kept respawning the units even when I didn't want them to. ie. before no units were left. Because I didn't have an "exit" or "goto" command. So it kept reading the respawning bit anyway :P

So I added a:

goto "CheckHealth" afterwards.

The problem now lies in the fact that the units don't respawn where I want them to (at the marker).

Here's what I have so far:

#Respawn

"_x setPos getMarkerPos _marker" forEach group _group
"_x setdammage 0" forEach units _group

goto "CheckHealth"

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Respawning in SP
« Reply #14 on: 02 Jan 2005, 22:09:54 »
marker names i believe are strings.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Respawning in SP
« Reply #15 on: 02 Jan 2005, 22:17:56 »
Try

"_x setPos getMarkerPos {_marker}"

or some variation thereon.
Plenty of reviewed ArmA missions for you to play

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #16 on: 09 Jan 2005, 16:06:39 »
Hmm, no such luck :(

I've heard you need to getPos of the object before you setPos it, perhaps I need to do that?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Respawning in SP
« Reply #17 on: 09 Jan 2005, 16:50:21 »
Perhaps it should be:

"_x setPos getMarkerPos {_marker}" forEach units group _group

Try it anyway.


Planck
« Last Edit: 09 Jan 2005, 16:51:00 by Planck »
I know a little about a lot, and a lot about a little.

Lean Bear

  • Guest
Re:Respawning in SP
« Reply #18 on: 10 Jan 2005, 11:01:32 »
Should I do that for all the lines with that format in it?

eg. "_x setDammage 0" forEach units group _group

as supposed to what I currently have (without the "group")

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Respawning in SP
« Reply #19 on: 10 Jan 2005, 11:44:59 »
I haven't dug through the whole thread and script, but the answer is that it depends on what you have and what you want.

The forEach command takes an array as its last argument.    You need to combine the commands units and group to turn your local variable into the array you want.
Plenty of reviewed ArmA missions for you to play