• 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.

Replace trigger?

Status
Not open for further replies.
Level 4
Joined
Jul 19, 2010
Messages
99
So i am trying to make a newer version of World War Z, but i am stuck on the simplest trigger... how to replace a city when zombies attack it. Like place an infected city and remove the human city. I swear, i know its so easy but yet i can't figure it out. I have tried using hashtables to save the old unit location and the owning player of the killing unit so it goes something like this..
Event = Generic event, a unit dies
Condition = Dying unit is equal to city
Action;
If, then else multiple function;
Condition = (Owner of (killing unit)) is equal to player 12 (brown)
Action = Save player handle (owner of killing unit) as 2 of 1 in Location, Save Location of (Dying unit) as 1 of 2 in location, create 1 (City) for (load player handle 2 of 2 in (Location)) at (Load 1 of 2 in (Location))
Else Actions = None
Else Actions = None


Help?
 
Level 4
Joined
Jul 19, 2010
Messages
99
If im not mistaken there is an action in Unit - replace
there is also another way, you can set position of your building to variable, remove the building and immidiately after create new, infested one.
Remember to clear leaks after by removing location via custom script.

i do think i have it. so when the cities health gets below 500 it removes it but even if i save the location in the hashtable, it doesn't create ad new one as needed.
 
Level 4
Joined
Jul 19, 2010
Messages
99

Attachments

  • snip742.JPG
    snip742.JPG
    55.9 KB · Views: 97
Use
  • tags and end it with /trigger (in [ ]). If you look on message editor look for it on the right side of taskbar.
  • Back to code, At first, don't use Do nothing.
  • At second, you clear hash every time condition returns false (hope you created hashtable in map initialization trigger, and set a CityPosition to last created hashtable).
  • Now, you save point in hash and you dont reffer to it, just to center of region.
  • Your trigger leaks.
 
You dont need hashtables here, its too simple trigger.
  • If (All conditions are true) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Attacking unit) belongs to an enemy of Player 1 (Red)) Equal to True
      • (Integer(Life of (Attacked unit))) Less than 500
    • Then - Actions
      • Set your_point = Position of (Attacked unit)
      • Set player_force = Player group (Owner of (Triggering unit))
      • Unit - Remove (Attacked unit) from the game
      • Unit - Create 1 your_unit for player_force at your_point facing Default buildging facing degrees
      • Custom script: call RemoveLocation (udg_your_point)
      • Custom script: call DestroyForce (udg_player_force)
    • Else - Actions
Hope im not mistaken with owner part, writng this without editor around.
And because of it i cant test Replace function, which should work here too.

EDIT added condition about life.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Try this:
  • Create Building
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Castle
      • (Owner of (Killing unit)) Equal to Player 12 (Brown)
    • Actions
      • Set DyingLoc = (Position of (Triggering unit))
      • Unit - Create 1 Black Citadel for (Triggering player) at DyingLoc facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_DyingLoc)
This will replace the Castle with Black Citadel once the castle is dead/destroyed.
 
Status
Not open for further replies.
Top