Home   Help Search Login Register  

Author Topic: Thank You for your help  (Read 1759 times)

0 Members and 1 Guest are viewing this topic.

Diealot

  • Guest
Thank You for your help
« on: 07 Nov 2002, 04:53:36 »
Everything  has been going smoothly and I thank all of you for your help. I have run into another small problem. You have given me the answer on how I can make a car wait until all people in a grp are in or out of the car before it moves to the next waypoint. You have also given me the answer on how I can respawn a player at a differant location to wait for rest of group if he dies. I Thank You for this.
Now the problem I have a player at location x and the rest of the group is at location y getting into the car. But the car will not move until all players have boarded. Player at loc x cannot board car. Script I have now is "_x in car" count units group == west countside units group. This script works great. Thank You Sui and Ranger  How do I change this so that it will work if a player is at another location not with the main group and the car will move to next waypoint to pick up player at spawn location.
« Last Edit: 07 Nov 2002, 07:29:11 by Diealot »

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Thank You for your help
« Reply #1 on: 07 Nov 2002, 23:05:40 »
No problem at all, Diealot.  I'm always happy to help an appreciative person!

There are a few ways you can do what you want.  Let's assume your car is named car1, your squad is named squad1, and your respawning unit is named p1.  The following solution assumes that your car is following a set of linear waypoints that will always drive the squad to the respawn point.

1. In your respawn code, make it remember which unit respawned.  In this example, I'm using a variable named respawner.  Thus, the code would look like this:

respawner = respawning unit

Replace respawning unit with whatever temporary variable you use in your respawn code that indicates which unit is respawning.

2. Instead of using Get In and Load waypoints for the squad and car, respectively, create Move waypoints close together, one for each group (the squad and the car).  Do not synchronize them.

3. In the car's waypoint's condition field, put the following code:

"_x in car1" count units squad1 == west countSide ((units squad1) - [respawner])

This assumes that squad1 is a west squad.  If not, change the code as appropriate.

So, this code checks how many units in squad1 are in car1, but it removes the respawner unit from the squad1 array.  Thus, as long as everyone but respawner is in car1, the condition is met.

4. In squad1's waypoint's activation field, put the following code:

"_x assignAsCargo car1" forEach ((units squad1) - [respawner]); ((units squad1) - [respawner]) orderGetIn true

This orders everyone in squad1 *except* for the respawned unit to get into car1.

5. Give car1 a waypoint that makes it drive to the respawn location.

6. Do your normal waypoints from here, such as Load for car1 and Get In for p1.

That should do it.

Now, you might have some timing issues with this setup.  For example, if squad1 reaches their Move waypoint before car1, they will probably go running off after the car, no matter how far away it is.

If this indeed an issue, one possible solution is to synchronize squad1's Move waypoint with a trigger that detects if car1 is within 20 meters (or any relatively short distance).  You would do this by grouping the trigger with car1 (grouping, not synchronizing), and having the trigger check if "vehicle" is "present".

Again this solution assumes that squad1 and car1 are following a linear set of waypoints in order to get from where they are to the respawn location.  If, on the other hand, your mission is set up so that this is supposed to be dynamic, let me know and I"ll tell you how to do a dynamic pick up.
Ranger

Diealot

  • Guest
Re:Thank You for your help
« Reply #2 on: 08 Nov 2002, 01:19:20 »
These will be players and not AI units that will be respawing.
here is the senerio. Car arrives at point "A" all 7 players get out. Car moves out of way to point "B" and waits there for players to get back in before it moves onto HQ. Lets say 3 players die while attacking the town. I have it now so that they respawn at HQ and join the squad again. Just using a Marker with "respawn west" in it at HQ. I have a group of AI sitting there for the players to respawn into with named "s1 to s7 join squad" in the init field of each one. 7 Seperate AI units.
Now the fight is over at the town and the remainding players get into the car. with the condition that we are using to check if all players are in the car it will not move to next waypoint because some players are sitting at HQ. Ahhhh I think what I have to do is not have the respaned players join the group until after the fight is over and the car is already en-route to HQ.

New senerio.....The players that have died are at HQ no longer in my group. So now when the rest get into car the condition will be true. The car will move on to HQ. I need a trigger somewhere between the town and HQ that will place the respawned players back into the group.  My player names are p1 to p7 . My AI units back at HQ beside the resawn marker are named s1 to s7.  Player p3 dies and should respawn into s1. So I need something that will remember which AI unit is now a player unit and when the car passes the trigger it will add them to the group again.

I hope that I have made this clear enough. What I want to elimante in my map is players turning into birds and not being able to finish the rest of the missions. They will have to sit out the current mission but rejoin the group for the next one. Kind of like picking up reinforcements.

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Thank You for your help
« Reply #3 on: 08 Nov 2002, 21:51:43 »
Try using respawn type "base".  This might allow you to eliminate needing an extra squad for the players to respawn into.


respawn = "base"
respawndelay = time


Obviously, replace "time" with however long you want the delay to be.

You'll need to make two markers with the following names:
Respawn_West
Respawn_East

Create the markers where you want the players to respawn, which will most likely be at the HQ for the player squad.  I'm not sure if the units will retain the names you gave to the original units, and I am unable to test this right now.  However, I'll assume that it does retain the names.

Regarding your vehicle, it sounds like you should use "virtual" waypoints instead of the real waypoints.  That way, you don't have to worry about the car driving off to other waypoints instead of following your orders to pick up the reinforcements.

In order to reduce some driving time and the number of waypoints, perhaps after the squad is dropped off the first time, the car should drive to the respawn area to wait.  That way, when the dead players respawn, they can jump into the car immediately.  The car will then take them to the location of the original group.

To do my ideas, try the following steps.  All of the following code assumes that all units in the players' squad are human-controlled.  In other words, I didn't include code that orders AI units to board/disembark the car.  If one or more units might be AI-controlled, input the appropriate code as necessary.  Otherwise, the group leader must order the AI into and out of the car.

1. Create gamelogics where you want the car's "waypoints" to be.  I see you needing at least 3: the HQ (respawn area), first combat zone, and second combat zone (or wherever they go after finishing the first fight). My suggestion for your gamelogic names:

hq: the HQ (respawn area)
wp1: first combat zone
wp2: second combat zone

2. Create a script with the following code.  I assume that the car will begin the mission close to the group.

[Begin Script]

; Check if the group is in the car, then order the car to move to wp1.

@ ("_x in car1" count units squad1 == west countSide units squad1)
car1 doMove getpos wp1

; Check if the group is out of the car when the car is within 50 meters of wp1, then order the car to move to hq.
 
@ (car1 distance wp1 < 50 and "not (_x in car1)" count units squad1 == west countSide units squad1)
car1 doMove getpos hq

; Check if the first task is done, then set the status of objective 1 to DONE and set wp1Done to true.

@ (Whatever you need to see if they are done, such as having killed all enemies in the area.)
"1" objStatus "DONE"
wp1Done = true

; Check if the reinforcements are in the car, if any.  reinforcements is the name of an array that contains all of the respawned units.  Then, order the car to move to squad1's position.

@ (wp1Done and "_x in car1" count reinforcements == west countSide units reinforcements)
car1 doMove getpos leader squad1

; Check if squad1 is in car1.  We don't need to see if the car actually made it to squad1's position, since that's irrelevant.  Then, move on to wp2.

@ ("_x in car1" count squad1 == west countSide units squad1)
car1 doMove getpos wp2

; And so on…
[End Script]

I hope you can handle any additions to the script from here.

What's going on in this script is that the @ (wait) command tells the script to wait until the indicated conditions are true, then continue.  It'll execute whatever code comes after the @ command until it reaches the next one.  It'll wait again until that condition is true, and so on.

Execute this script in the init.sqs script so that it begins running immediately.

For this script to function properly, you need to create and update an array (reinforcements) that stores the names of the units that have died and respawned.  That will obviously have to be managed in your respawning script, if you have one.  Maybe you have ideas on how to do that.  At the moment, I don't have access to the game, so I can't test any ideas.

I hope this gives you a boost in the right direction.  Good luck!
Ranger

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Thank You for your help
« Reply #4 on: 09 Nov 2002, 01:36:54 »
I have an idea on how to handle the respawning, but it requires Resistance (which I hope you're using).  Try doing the following steps:

1. In init.sqs, initialize the reinforcements array.

reinforcements = []

2. Use the new addEventHandler command.  I'm not sure if the following code will work, but try it and see.

"_x addEventHandler [{killed}, _x exec {respawn.sqs}]" forEach units squad1

If that doesn't work, maybe this will:

"_x addEventHandler [{killed}, {_x exec {killed.sqs}}]" forEach units squad1

In any case, put this code in init.sqs.  This will activate the killed.sqs script whenever any of the units in squad1 are killed.

3. Create the killed.sqs script.

[Begin Script]

_deadPlayer = _this

; Check if the dead unit is already in the reinforcements array.  If so, then exit the script.

? _deadPlayer in reinforcements : exit

; The dead unit is not in the reinforcements array, so add it.

reinforcements = reinforcements + [_deadPlayer]

exit

[End Script]

That should do it.

I must amend what I wrote previously, too.  I forgot to include code to handle what happens when the respawned units rejoin the original group.

[Begin Amendment]

; Check if squad1 is in car1.  We don't need to see if the car actually made it to squad1's position, since that's irrelevant.  Then, move on to wp2.

@ ("_x in car1" count squad1 == west countSide units squad1)
;Begin New Code
; If there are any reinforcements, make them join squad1, and then clear reinforcements.
? count reinforcements > 0 : reinforcements join squad1 ; reinforcements = []
;End New Code

car1 doMove getpos wp2

[End Amendment]

Okay, that should solve all of your questions.  Good luck!
Ranger