• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Need a trigger to replace certain type of buildings with another type.

Status
Not open for further replies.
Level 5
Joined
Feb 27, 2009
Messages
115
I'm not sure how to make a trigger for this one. It should be easy, but I am having difficulty.

When my map starts, depending on what race the player is, their towers will be their race's (for example, Undead will have ziggeraut, not 'cannon tower'.) There are many, many towers to replace.

I could make 100 small locations and specifically 'create' the towers there out of thin air. However, this would be time consuming to do, would clutter the map with locations, and I don't like it.

I have placed the towers all of a certain type and have tried to replace them all with another. But I haven't been able to figure out how to do this. Maybe it is possible in the flexibility of JASS, I have been going in circles in the GUI.

Another possibility I thought was starting everyone out with scout towers and just make a trigger 'upgrade' them to the way they are supposed to go.

Is there any way to replace a building with another without a specific location for that one building?
 
Level 8
Joined
Apr 30, 2009
Messages
338
You could do something like this:

For each integer from 1 to (number of towers)
Pick a random (tower) from units matching conditions
-(conditions: unit type is equal to the type of tower you want replaced)
Save the position of picked unit to a variable
Destroy/Remove picked unit
Create a (new tower) at the position you saved as a variable
Clear the variable
---repeat---

If you are replacing ALL the towers of a certain type, then the "pick random" will work (if you have 6 towers and it picks a random one to replace 6 times, it will have to replace all of them). If not, you will have to pick each tower individually (by making each tower a unit variable or putting regions on each tower).
 
Level 5
Joined
Feb 27, 2009
Messages
115
Theoretically, yes. What is tripping me up is the event to trigger it all in the first case.

For example, I have successfully been able to have a tower become another tower when it is blown up. However, I do not want to wait until it is 'blown up'. I want to replace it at the beginning due to race. So the event "Tower X is destroyed" and action "Create Tower Y at triggering unit location" wouldn't be useful, even though they work, since I cannot get the correct event (if one exists).

Anyone know if towers will cleanly upgrade to a very different tower? Perhaps I could trigger all the towers to upgrade to Tower X if race Human, Tower Y if race Undead, etc. I'll give that a try.
 
Level 5
Joined
May 12, 2008
Messages
80
When the trigger where the race is chosen ends you could start the replace trigger. This shouldnt be a problem.

Did i understand you the right way? It is not the problem to replace the towers but when or how to start the trigger?
 
Level 5
Joined
May 12, 2008
Messages
80
This would be one posibility. or u use the action run trigger (checking conditions) at the end of the race choosing trigger. then there is no event needed
 
Level 11
Joined
May 31, 2008
Messages
698
Just do an event when the race is picked...
This could be anything depending on what your race selection system is.
If you start with a builder just do a unit enters map then pick all the towers owned by that player and do some condition to determine the race. Remeber to turn this trig off like .5 seconds after it is over so it doesnt work everytime a unit enters
 
Status
Not open for further replies.
Top