slird
  • slird
  • 50.25% (Neutral)
  • Major Topic Starter
12 years ago
So I am having another dilemma...
The effect I am attempting to achieve is that once a patrol team is destroyed it will continue to re-spawn at the barracks until the barracks is destroyed. I had it working at one point where it would spawn an additional team each time the team was destroyed ( two teams totaling 4 units, 3 teams totaling 6 units, etc.) which was great and I loved it, except something changed somewhere and now it re-spawns a constant flow of two man teams once a team member is destroyed and I have no idea what happened.
I have the same setup for a patrolling sentry drone which works flawlessly and I would like to at least get my infantry team back to spawning one additional team each time if not one team each time, either one would suit me fine.

My setup for the sentry drone is as follows:

Re-spawn Sentry Drone-

(this script is active, is not subroutine, and is not deactivated)
***IF***
Unit 'Sentry Drone' has been killed and is finished dying
*AND* Player 'PlyrAmerica' has Greater Than 1 unit or structure of type 'AmericaWarFactory'
***THEN***
Spawn unit 'sentry Drone' of type 'AmericaVehicleSentryDrone' on team 'Sentry Drone' at waypoint
Move team 'sentry Drone' to waypoint
Team 'sentry drone' executes script 'start sentry drone patrol'

Start Sentry Drone Patrol-

(this script is active, is subroutine, and is not deactivated)
***IF***
True
***THEN***
Team 'sentry drone' executes script 'sentry drone patrol sequentially, 0 times

Sentry Drone Patrol-

(this script is active, is subroutine, and is not deactivated)
***IF***
True
***THEN***
Patrol...(I know how to do this part)

As I said, the sentry drones run flawlessly. They will patrol and respawn until the factory is destroyed. I would however like to pause the patrol until an enemy unit enters the area...still trying to figure that part, but my real problem is the infantry patrol.

My setup for the infantry is as follows:

Re-spawn Infantry (two man team)-

***IF***
Team 'infantry' has been destroyed
*AND* Player 'PlyrAmerica' has Greater Than 1 unit or structure of type 'AmericaBarracks'
***THEN***
Spawn an instance of Team 'Infantry' at Waypoint
Move Team 'Infantry' to Waypoint
Team 'Infantry' executes Script 'Start Infantry Patrol' sequentially

The rest of the scripts are identical to the sentry drone scripts.
The only difference I can see is that one spawns a unit and the other spawns a team.
And as I said, it used to work and now it doesnt. Any suggestions on how to fix this?
Sponsor
i^love^mixery
12 years ago
As your code shows, teams and units are different. Unit names are unique. You can never spawn multiple units with the same name (for the same player). But team names are not unique. You can spawn as many teams with the same name as you want. That's why the first routine works as desired, the second doesn't.

In order to fix it you could use a variable (flag).


Once at the start of the game:
***IF***
True
***THEN***
Flag Infantry = false

***IF***
Team infantry destroyed
AND
Flag Infantry = false
***THEN***
Flag Infantry = true
Spawn team infantry

Subroutine for the team in the create event:
***IF***
True
***THEN***
Flag Infantry = false

If you can't get that to work by yourself I can help you of course.
slird
  • slird
  • 50.25% (Neutral)
  • Major Topic Starter
12 years ago
Very interesting. Ill give it a go.
Thanyou!
slird
  • slird
  • 50.25% (Neutral)
  • Major Topic Starter
12 years ago
Well, when I tried the flag scripts as you suggested I achieved the same result...a multicolored wave of units flowing from the waypoint. I dont know if I am using the correct flag script, as I can see more than one of them, or if I should use a flag in the drop down menu, or simply rename it...this is my first time using the flags so it is a bit confusing.
i^love^mixery
12 years ago
You should put in a name for the flag. Use the same name for the same team. Every team that you want to script this way needs an individual flag.
slird
  • slird
  • 50.25% (Neutral)
  • Major Topic Starter
12 years ago
I did as you suggested and still achieved the same result of a flood of units emerging from the waypoint.
I did ,however, change the 'on create' behavior to a patrol subroutine to see what would happen and it spawned a team as desired but would only do it one time.
The only other thing I know to do is to make a script for each individual team member, but that is a bit more scripting than I care to do as I plan on having quite a few patrols scattered around the map...but if we cant figure something out then I guess thats what will end up happening.
i^love^mixery
12 years ago
Upload the map please.
slird
  • slird
  • 50.25% (Neutral)
  • Major Topic Starter
12 years ago
Here is the test map I used to setup the scripts as per your recommendations...   hunt wander test.zip (3kb) downloaded 11 time(s).
i^love^mixery
12 years ago
Try this   hunt wander test.zip (4kb) downloaded 29 time(s).
slird
  • slird
  • 50.25% (Neutral)
  • Major Topic Starter
12 years ago
Bravo! Top notch!
Exactly the effect I was attempting to achieve!
Thankyou very much.
Whoda thunk that turning it FALSE would have made such a difference.
My next question is that since the script is false, how would I implement the barracks into the scripting to stop the team spawn upon its destruction?
i^love^mixery
12 years ago
Simply outsource the barracks IF condition.

Make the spawn script disabled by default and then do something like this:

***IF***
Unit "barracks" has been destroyed.
***THEN***
Enable script "spawn".
slird
  • slird
  • 50.25% (Neutral)
  • Major Topic Starter
12 years ago
That has the reverse effect. The team will not respawn until the barracks has been destroyed...thus the team is respawning from a waypoint where there is no barracks...
I attempted to implement a flag into the spawn script upon turning false when the barracks was destroyed, but it successfully crashed the game three times out of three...
i^love^mixery
12 years ago
Then how about this?


***IF***
Unit "barracks" exists and is alive.
***THEN***
Enable script "spawn".
***ELSE***
Disable script "spawn".
slird
  • slird
  • 50.25% (Neutral)
  • Major Topic Starter
12 years ago
Almost! Except the team would not spawn upon destruction.
But I tinkered with it a bit and found the solution!
I changed the 'enable script' to 'null: does nothing'.
The final result is as follows:

[ns A nd]
*** IF ***
Unit 'barracks' exists and is alive.
*** THEN ***
Null operation. (Does nothing.)
*** ELSE ***
Disable Script 'spawn'.

[ns A nd]
*** IF ***
Team 'hunters' is owned by Player ''
*** THEN ***
Null operation. (Does nothing.)
*** ELSE ***
Spawn an instance of Team 'hunters' at Waypoint 'spawn'.

Brilliant work!
Thanks a million, couldnta done it without your help.
If and when this map ever reaches its final stages of development you, and the rest who have helped me, will be credited in the readme file.
Thanks again.