• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Replace Gold Mine with Haunted Gold Mine.

Status
Not open for further replies.
Level 2
Joined
Aug 10, 2010
Messages
6
Whenever i try to replace a gold mine with a haunted gold mine it creates a new gold mine next to it instead. Any workaround? (I need the possibility to replace the Haunted Gold Mine back to the Gold Mine afterwards)


  • Unit Group - Pick every unit in (Units owned by Player) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) is A structure) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in (Units within 512.00 of (Position of (Picked unit))) and do (Actions)
            • Loop - Actions
              • If ((Unit-type of (Picked unit)) Equal to Haunted Gold Mine) then do (Unit - Replace (Picked unit) with a Gold Mine using The old unit's relative life and mana) else do (If ((Unit-type of (Picked unit)) Equal to Entangled Gold Mine) then do (Unit - Replace (Picked unit) with a Gold Mine using The old unit's relative life and mana) else do (Do nothing))
        • Else - Actions
          • Do nothing
 

Attachments

  • upload_2017-5-5_23-35-11.png
    upload_2017-5-5_23-35-11.png
    23 KB · Views: 52
  • upload_2017-5-5_23-35-33.png
    upload_2017-5-5_23-35-33.png
    23 KB · Views: 82
Last edited:

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
This will help you posting triggers: How To Post Your Trigger

If you look at the JASS code behind the replace function, you can see, that it works differently, if you replace a gold mine with a haunted gold mine. It should work as intended.
In your trigger you replace a haunted gold mine with a gold mine. You can just kill the haunted gold mine (remove should work as well) and the gold mine will remain there.
 
Level 2
Joined
Aug 10, 2010
Messages
6
Thanks, problem solved :)

  • Set Player = (Triggering player)
  • Unit Group - Pick every unit in (Units owned by Player) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) is A town-hall-type unit) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in (Units within 1024.00 of (Position of (Picked unit))) and do (Actions)
            • Loop - Actions
              • If ((Unit-type of (Picked unit)) Equal to Haunted Gold Mine) then do (Unit - Kill (Picked unit)) else do (If ((Unit-type of (Picked unit)) Equal to Entangled Gold Mine) then do (Unit - Replace (Picked unit) with a Gold Mine using The old unit's relative life and mana) else do (Do nothing))
        • Else - Actions
          • Do nothing
Code for going back to undead:
  • Unit Group - Pick every unit in (Units owned by Player) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) is A town-hall-type unit) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in (Units within 1024.00 of (Position of (Picked unit))) and do (Actions)
            • Loop - Actions
              • If ((Unit-type of (Picked unit)) Equal to Gold Mine) then do (Unit - Replace (Picked unit) with a Haunted Gold Mine using The old unit's relative life and mana) else do (Do nothing)
        • Else - Actions
          • Do nothing
Code for going back to nightelf
  • Unit Group - Pick every unit in (Units owned by Player) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) is A town-hall-type unit) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in (Units within 1024.00 of (Position of (Picked unit))) and do (Actions)
            • Loop - Actions
              • If ((Unit-type of (Picked unit)) Equal to Gold Mine) then do (Unit - Replace (Picked unit) with a Entangled Gold Mine using The old unit's relative life and mana) else do (Do nothing)
        • Else - Actions
          • Do nothing
Thread can be closed.
 
Status
Not open for further replies.
Top