Home   Help Search Login Register  

Author Topic: Need some script help....  (Read 921 times)

0 Members and 1 Guest are viewing this topic.

TerranAce007

  • Guest
Need some script help....
« on: 02 Feb 2003, 03:34:11 »
;AI Respawning

_Group = _this select 0

_listunits = units _Group

_start = getmarkerpos "spawn"
_x = _start select 0
_y = _start select 1
_z = _start select 2

_A = 0
_B = count _listunits
#KEEPSENDING
?not alive (_listunits select _a): _listunits select _a setdammage 0
_listunits select _a setpos [_x, _y, _z]
_listunits select _a setbehaviour "combat"
_A=_A+1
?_B >_A:goto "KEEPSENDING"
MoveNext = TRUE
exit


What I want:
I have a trigger that detects if more than half of the group is dead then executes the script. The dead guys come back to life and everyone starts back at base.

What happens:
Sometimes it doesn't even work, but most of the time just the group leader comes back, while the rest of the guys stay dead.

The major problem is that anyone killed before the squad leader is not part of the group when the script is called, and doesnt respawn. If you kill the leader first, everyone comes back.

What do I need to change? Is there a better way to do this?
« Last Edit: 02 Feb 2003, 03:43:50 by TerranAce007 »

RunAwayScientist

  • Guest
Re:Need some script help....
« Reply #1 on: 03 Feb 2003, 07:11:54 »

     Hmmm, we've all seen it happen eh?

          My Advice:

              Scripts don't have to be so complicated. Change your variables to something I UNDERSTAND...

             This is probably the most un-neccesarily complicaticarily scriptarily I've seen yet. Eh, I can't fix it, but I can give you another idea...A go-around...Heh, like an aircraft...


        Number One:
    OK, let me get this straight. You like peanut-butter, without jam?
          Or, more to the point, you want your units  to respawn, ONCE, half- of - the - team has jumped the One-Way Train to the Training Grounds, right?

          First, you'll need a trigger to detect who's dead and when. So, in editor mode make your Trigger, and in the conditions field, enter "(not(alive Unit1)) AND (Unit1Dead = false)".

              In the activations, enter "TeamDeadCount = TeamDeadCount + 1; Unit1Dead = true; [] exec CheckIfRespawn.sqs ". Copy the Trigger, and repeat the proccess for the whole team, changing any word with Unit1, to Unit2 and so on.

     What your doing here, is making a trigger that checks to see if each unit is dead, and that "Unit1Dead" is still equal to false, meaning that this trigger hasn't already fired. If the Conditions are true, meaning he's dead and he hasn't already fired the trigger, then it will "Tally" his death as a +1 under "TeamDeadCount". Then it will execute the respawn script, BUT, we'll set it up to check if the TeamDeathCount is over half-of the total number of team-members, eh?

     Now we're getting somewhere eh?

           So, make your "CheckIfRespawn.sqs", and open 'er up. Enter this in there (I'll use a team of 12 as an example):
"
?(TeamDeadCount => 6): TeamDeadCount == 0; Unit1 setdammage 0; Unit1Dead = false; Unit1 setpos getpos Unit1Res; Unit2Dead = false; Unit2 setdammage 0; Units2 setpos getpos Unit2Res; exit [And so on, and so on]
?(TeamDeadCount < 6): exit
"

     Now, is that non-complicated or what? So, what's going on here, is that when the script is fired, It will find the total tally of the Dead Teammembers. If it's over half (6 In this Example) then it will set every-body's health to normal, and then set them at their respawn locations, which you set with this command in their Ini. fields : "Unit1Res = getpos Unit1".

     It'll require some effort, but it's just about as simple as pie, that is cherry. Wait no, I'm eating Cherry Pie. Man, things do get corny. I'm lactose intolerant, I can't eat corn...


       I hope this helps you out. If you don't under-stand it, just reply to the post, or e-mail me. If it doesn't work, then make sure other people know what *cough*.

      To tell you the truth I just made this entire script up as I went along. I just started typing, and I came out with this. Heh, what do you know eh? I didn't even have to THINK about this before I s-...Wait, this makes you look bad doesn't it? Hmph, I'll shut-up now....


     -RunAWayScientist (Cheese PLease!)
« Last Edit: 03 Feb 2003, 07:38:58 by RunAwayScientist »

RunAwayScientist

  • Guest
Re:Need some script help....
« Reply #2 on: 03 Feb 2003, 07:35:23 »
    Update: I noticed a mistake...Err, left out something.

          In this part of the Respawn Script:

?(TeamDeadCount => 6): Unit1 setdammage 0; Unit1 setpos getpos Unit1Res; Unit2 setdammage 0; Units2 setpos getpos Unit2Res; exit [And so on, and so on]

      I forgot to include "Unit1Dead = false". So it should be instead:

?(TeamDeadCount => 6): Unit1 setdammage 0; Unit1Dead = false; Unit1 setpos getpos Unit1Res; Unit2Dead = false; Unit2 setdammage 0; Units2 setpos getpos Unit2Res; exit [And so on, and so on]

      Sorry about that...

- RunAwayScientist


  UPDATE: ACk, I forgot something else...

     You'll need to set the counter of the number of Dead Teammates to zero again, so it should be this time :

?(TeamDeadCount => 6): TeamDeadCount == 0; Unit1 setdammage 0; Unit1Dead = false; Unit1 setpos getpos Unit1Res; Unit2Dead = false; Unit2 setdammage 0; Units2 setpos getpos Unit2Res; exit [And so on, and so on]
« Last Edit: 03 Feb 2003, 07:38:39 by RunAwayScientist »

Pointman

  • Guest
Re:Need some script help....
« Reply #3 on: 04 Feb 2003, 01:36:38 »
in INIT.SQS

aMyGroup = units LEADER_GUY_NAME
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


The trigger:
[aMyGroup] exec "ai_respawn.sqs"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;AI Respawning

_Group = _this select 0

_listunits = units _Group

_listunits = _this select 0

_start = getmarkerpos "spawn"
_x = _start select 0
_y = _start select 1
_z = _start select 2

_A = 0
_B = count _listunits
#KEEPSENDING
?not alive (_listunits select _a): _listunits select _a setdammage 0
_listunits select _a setpos [_x, _y, _z]
_listunits select _a setbehaviour "combat"
_A=_A+1
?_B >_A:goto "KEEPSENDING"
MoveNext = TRUE
exit