Jump to content

Loop Response


Stalker

Recommended Posts

For what it's worth I have just been doing some mission scripting today and wanted to separate the Player Platoon into it's teams so I could teleport each team to a different insertion zone. I though I'd post it as it's a very good example of using a loop.

_________________________________

Group: <Default>

Comment:

Trigger Event:

The simulation is starting.

Responses:

Set PlayerPlatoon to (The player-controlled platoon).

Use GetPlayerTeams to loop over all teams in PlayerPlatoon after this block.

Group: GetPlayerTeams

Comment:

Trigger Event:

A team loop is ready to process ThisTeam.

Responses:

Allow this block to be reactivated.

Increment PlayerTeamCount.

Set Charlie to ThisTeam.

Continue executing responses if ((The value of PlayerTeamCount) is less than 3).

Set Bravo to ThisTeam.

Continue executing responses if ((The value of PlayerTeamCount) is less than 2).

Set Alpha to ThisTeam.

'NextTeam' is just an ActorReference you create to give the program a 'handle' so it can loop the platoon.

EDIT: Just be a little careful with this script. If there is only one team then that team will have all the names Alpha, Bravo and Charlie. If there are two teams then Bravo will also have the name Charlie. So if you have script that does something based on a query of the team name you can see it may lead to trouble. Make sure you first query the number of teams before applying any responses designed for Bravo or Charlie. Alternatively put the scripts in seperate Blocks for each team, and only enable the Group if the team exists.

For example:

Group: GetPlayerTeams

Comment:


Trigger Event:

A team loop is ready to process ThisTeam.

Responses:

Allow this block to be reactivated.

Increment PlayerTeamCount.

Set Charlie to ThisTeam.

Enable the Charlie script blocks.

Continue executing responses if ((The value of PlayerTeamCount) is less than 3).

Set Bravo to ThisTeam.

Enable the Bravo script blocks.

Disable the Charlie script blocks.

Continue executing responses if ((The value of PlayerTeamCount) is less than 2).

Set Alpha to ThisTeam.

Enable the Alpha script blocks. (or omit this and use the Default Group for Alpha)

Disable the Bravo script blocks.

___________________________________________________

Once you have the teams identified you can then use 'QueueLoop Actors in Team' and teleport them where you like.

___________________________________________________

Here is how to split up the player members and teleport them to an effect to simulate a para drop:

You need to place 9 effects where you want the players to be teleported to (or six if it is for single pplayer only), making sure they are not going to land on top of a building or similar. Caution: don't go too high on urban maps or you may have problems. Trial and error will get you there ;)

Make the player platoon invincible in the StartUp block .

1) This one requires less scripting but may cause lag.

Trigger Event:

The simulation is starting.

Responses:

Set PlayerPlatoon to (The player-controlled platoon).

Use ParaDrop to loop over all actors in PlayerPlatoon after this block. (you have to create this new group)

Group: Paradrop

Trigger: An actor loop is ready to process NextActor.

Responses:

Allow this block to be reactivated.

Increment ParaDropCounter. (you will need to create this counter)

Teleport NextActor to Effect_9.

ContinueIf ParaDropCounter is less than 9

Teleport NextActor to Effect_8.

ContinueIf ParaDropCounter is less than 8

Teleport NextActor to Effect_7.

ContinueIf ParaDropCounter is less than 7

Teleport NextActor to Effect_6.

ContinueIf ParaDropCounter is less than 6

Teleport NextActor to Effect_5.

ContinueIf ParaDropCounter is less than 5

Teleport NextActor to Effect_4.

ContinueIf ParaDropCounter is less than 4

Teleport NextActor to Effect_3.

ContinueIf ParaDropCounter is less than 3

Teleport NextActor to Effect_2.

ContinueIf ParaDropCounter is less than 2

Teleport NextActor to Effect_1.

2) For this one in addition to what's below, you will need to create a new Group with one block only and with the Teleport function in each - this is for the Redirect. It is a bit more involved but if you are having trouble with lag, use it instead.

Allow this block to be reactivated.

Increment ParaDropCounter.

ReDirectIf ParaDropCounter is equal to 1 (Redirect to Group ParaDrop_1)

ReDirectIf ParaDropCounter is equal to 2 (Redirect to Group ParaDrop_2)

ReDirectIf ParaDropCounter is equal to 3 (Redirect to Group ParaDrop_3)

ReDirectIf ParaDropCounter is equal to 4 (Redirect to Group ParaDrop_4)

ReDirectIf ParaDropCounter is equal to 5 (Redirect to Group ParaDrop_5)

ReDirectIf ParaDropCounter is equal to 6 (Redirect to Group ParaDrop_6)

ReDirectIf ParaDropCounter is equal to 7 (Redirect to Group ParaDrop_7)

ReDirectIf ParaDropCounter is equal to 8 (Redirect to Group ParaDrop_8)

ReDirectIf ParaDropCounter is equal to 9 (Redirect to Group ParaDrop_9)

Jack out . . . :o=

Link to comment
Share on other sites

In Igor under the View menu select Map Labels. Now any map objects will display their names. If it contains <dyn> it means it is dynamic and can (usually) be hidden or destroyed. You can even hide most of the buses on the Embassy map although there will still be a sizable collision zone where it normally is.

All of these map objects can also be used for tank targets which can be very useful. For example, you can give a tank a plan to DestroyTarget 303_<n><door>01, which might be on the other side of the map somewhere. If there are objects between the tank and the target it will still shoot towards it but the shells will strike the intervening objects. In this way you can give the illusion that it is shooting at something else.

Jack :ph34r:

Link to comment
Share on other sites

In Igor under the View menu select Map Labels. Now any map objects will display their names. If it contains <dyn> it means it is dynamic and can (usually) be hidden or destroyed. You can even hide most of the buses on the Embassy map although there will still be a sizable collision zone where it normally is.

All of these map objects can also be used for tank targets which can be very useful. For example, you can give a tank a plan to DestroyTarget 303_<n><door>01, which might be on the other side of the map somewhere. If there are objects between the tank and the target it will still shoot towards it but the shells will strike the intervening objects. In this way you can give the illusion that it is shooting at something else.

Jack :ph34r:

That's something I've been looking for. Though unfortunately soldiers won't blow a door down. Maybe wrong ordnance (tried it with a dude carrying an M16/203) or just plain doesn't work. Would work nice for a few missions. As for the Map Labels, thanks Jack57, now I can probably tweak a few more stuff as well..

Link to comment
Share on other sites

ok, I want to assign all players of the playersplatoon a specific weaponkit:

should it look like this:

Trigger Event: Startup

Response: Use <Weapon> to loop over all actors in the player controlled platoon

Trigger Event: Loop Actors ( an actor loop is ready to process <Next Platoon Member>

Response: block preserve

Set actor kit.......... (assign <OICW.kit> to <Next Platoon Member>

???????????????????????????????? (hope thats right)

Link to comment
Share on other sites

Though unfortunately soldiers won't blow a door down. Maybe wrong ordnance (tried it with a dude carrying an M16/203) or just plain doesn't work.

Give him a kit with rockets then give him a destroy target plan. Works like charm :rocky:

If you make a new kit with rockets as the primary he will also use rockets against the players :devil:

Link to comment
Share on other sites

  • 4 months later...

Hi jack I was reading you post recently about the queue loops . Just one thing i couldnt work out and which you dont make plainly obvious in your explanation.

Trigger Event:

A team loop is ready to process NextTeam.

Responses:

Set Alpha to NextTeam.

Ok what response is "Set Alpha to NextTeam" I cant find it . Is it queue loop teams in platoon? and query? how do you arrive there?

Would appreciate your help in this.

NGRU Crazy 1 out.

Link to comment
Share on other sites

"Set Alpha to NextTeam" is the VariableSetTeam response - as this loop block doesn't have a block preserve, it will only execute once. So, the first team to be processed by the loop will have the variable team reference 'Alpha' assigned to it - the loop will then be deleted so it won't process any more teams. (The tags 'Alpha' and 'NextTeam' are created by you and can have any name you wish.)

Hope that helps?

Jack :)

Link to comment
Share on other sites

:huh: Ok. How do you make a loop just go over all the actors in a company once? Like when triggered by a timer. Thirty seconds has elapsed, use loop bla bla bla over all actors in company bla after this block. Then how do I make it only go over them once? It is doing it twice each time around. Edited by X69RZX
Link to comment
Share on other sites

Then how do I make it only go over them once? It is doing it twice each time around.

Yeah Matt's right - if it's doing it twice something in the script must be telling it to do it twice. Maybe you have a BlockPreserve in the TimeElapsed trigger block? If not then use the search function with the summary to look for the name of the loop block (group) to see if it's being called from somewhere else as well.

Cheers, Jack :)

Link to comment
Share on other sites

Ok. Every 30 secs a block is triggered. It ques a call to a block that uses a loop for actors. That loop makes some determinations, then posts a readout. The readout is coming out twice. This is a MP script, and yes, I am using block preserve, because I want it to repeat every 30 secs. :wall: Should I use call? That isn't the same as a loop right?

Link to comment
Share on other sites

A call is different from a loop. But they work with the same basic principles. I don't think in this case you need a call because all you should do is have the block preserve on the 30 sec trigger and use the loop. I see no need for the timer.

Link to comment
Share on other sites

QueueCalls just call a block and execute it - once for each time it is called. QueueLoops also call a block but they execute it once for each of the sub-entities in the entitiy that you have specified for it to loop through.

Your problem might lie in where you execute the DisplayMessage response. If it is in the loop block then it will display each time the condition is met. There are two ways around this - use a Display Box so that successive messages will display on top of previous ones, or use a counter and a StopIf query (below the block preserve, so you can use it again), then each time you call the loop block reset the counter.

Jack :rocky:

Link to comment
Share on other sites

Thanks Jack, I have been using flags in place of the counters, but I see that would be the same if you reset the counter to zero every rotation, then increment and continue if. I will continue to fight the good fight. Soon all will hopefully benifit. ;)

Link to comment
Share on other sites

  • 6 months later...

I am really stuck. :huh:

I have made a plan so quite a few platoons of actors walk to a point and I want each actor to disappear (HideThing) when they reach it. Can I use loops so each actor disappears individually instead of hiding the whole platoon when the first one reaches the zone (what I have now)?

Please help me! :help:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...