• 🏆 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!

To replace a unit after time/health

Status
Not open for further replies.
Level 3
Joined
Dec 14, 2007
Messages
44
  • Trigger
    • Events
      • Unit - (Your Unit's) life becomes Equal to 1.00
    • Conditions
    • Actions
      • Set OwnerOfUnit = (Owner of (Triggering unit))
      • Set NewUnitLocation = (Position of (Triggering unit))
      • Unit - Add a 20.00 second Generic expiration timer to (Triggering unit)
      • Trigger - Run Trigger 2 <gen> (checking conditions)
  • Trigger 2
    • Events
    • Conditions
    • Actions
      • Wait 20.00 seconds
      • Unit - Create 1 (New unit-type) for OwnerOfUnit at NewUnitLocation facing Default building facing degrees
Meh try that Im not sure if its the best way to do it but it should work if that's what you want to do
 
Last edited:
Level 24
Joined
May 9, 2007
Messages
3,563
Arrgg, O.K one sec. I'm starting up war3. Here we go.

  • Your Trigger 1
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to ReviveUnit
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Unit - Create 1 Your Unit for (Owner of (Triggering unit)) at TempPoint facing (Facing of (Triggering unit)) degrees
      • Set ReviveUnit = (Last created unit)
      • Custom script: call RemoveLocation(udg_TempPoint)
  • .
and at the start of the game

  • Map Inizilization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set ReviveUnit = Your Unit
This should work. If multiple units do the exact same thing but with a UNITGROUP instead of a UNIT variable.

The variables are.

ReviveUnit - This is a UNIT variable. Set it at the start of the game to desired unit. If Start of the game is unavailabe (it is not created yet) set it when the unit is created.

TempPoint - TempPoint is a point. It is to prevent leaks.

Hope this helps.
 
Level 49
Joined
Apr 18, 2008
Messages
8,421
>_< im a little stuck here... can u try to help me? heres the map, and abbilites done, and if u look a little in the object editor and in the trigger editor, u will get the main idea about how i want those respawns to work... btw, the models that has to respawn are:

Rocks(50)-into Gold Rocks(50)

Rocks(120)-into Gold Rocks(120)

Rocks(180)-into Gold Rocks(180)

Rocks(200)-into Gold Rocks(200)

Rocks(500)-into Gold Rocks(500)

if u will actualy do that, post the map on here please.
 
Level 3
Joined
Jun 3, 2008
Messages
52
There are abilities that you can add to a unit so that when that unit dies, another kind of unit spawns. (E.g. Hydra creeps often have those, one big hydra dies, two little ones pop up) You can use them to your favor.
Also, like what others said above, you can use expiring timers on units. I hope I got this right: a gold ore dies > spawn a rock; wait a while > change it to another gold ore, right? So here's what you do: add the hydra-like ability (modified, of course, so that it spawns a rock) to the gold ore. Do the same to the rock, so that when the rock dies, a gold ore spawns (make sure rock is invulnerable so your users won't kill it do get gold!).Then make a trigger that adds an expiration timer to the rock every time a rock is spawned.

On second thought, there's also the Phoenix morphing ability. Maybe you could try using that too. I.e. Flying phoenix = gold ore; Phoenix egg = iron ore. Customize duration and make sure that the flying phoenix, i.e. gold ore, doesn't burn itself to death by removing the phoenix fire ability from it. If you don't get what I'm saying then you can ask me to clarify...
 
Level 49
Joined
Apr 18, 2008
Messages
8,421
Well, thats actually worked. for 1 time. and thats was because of the trigger hawk900 telled me to do. so, the abbility doesnt work. can u make that in my map please? i dont really get how to do that. map is here. f u look a little in the object editor and in the trigger editor, u will get the main idea about how i want those respawns to work... btw, the models that has to respawn are:

Rocks(50)-into Gold Rocks(50)

Rocks(120)-into Gold Rocks(120)

Rocks(180)-into Gold Rocks(180)

Rocks(200)-into Gold Rocks(200)

Rocks(500)-into Gold Rocks(500)

if u will actualy do that, post the map on here please.
 
Level 13
Joined
Nov 4, 2006
Messages
1,239
add an expiration timer

  • Unit - add a xx seconds standart expiration timer to (last created Unit)
put this action after the rock is created, with the time you like, and store the newly created gold rocks in a variable, and change your trigger events to "variable" dies, then they will run more then once, don't forget to set the variable to "no Unit" when your rocks die
 
Level 3
Joined
Jun 3, 2008
Messages
52
I'll see what I can do with the map...

By the way, if a rock is invulnerable there's no need for it to have 9999999 HP. Also I *think* invulnerable things can still be killed due to expiration (i.e. just like a Spirit Wolf "expires" after several sec passes). Correct me if I'm wrong. (If not there's other ways to get around that.)

Also the variable "TempPoint" should be a local variable (post #22) in order to work properly.
 
Level 3
Joined
Jun 3, 2008
Messages
52
I always thought that the "Invulnerable (Neutral)" ability automatically hides the max hp. I also learned that whenever max hp goes beyond 20000 it becomes hidden.

Anyway, I was trying to implement the ability in your map, but for some unknown reason the "Abilities - unit abilities" thingy isn't showing up... Weird world editor bug, i think. I'll work on it tomorrow.
 
Level 3
Joined
Jun 3, 2008
Messages
52
Because I don't have 24-hr Internet this week I wasn't able to reply yesterday... :sad:

Anyway, I got a few tries at the problem:
1. Giving gold: there are two likely ways to solve this:

- I can just use the "Give Bounty" option so that when a unit [i.e. Gold Rock] dies for Player 5 (Yellow), it automatically gives gold based on what is set in the Object Editor for each Gold Rock unit.

- Or, I can use a trigger to give gold. This is not as easily done as the first one, but after a few tries I chose this method because of a problem... (explained later)

2. Make Gold Rock units turn into Rock units after they die and then turn them back into Gold Rocks after a fixed amount of time: Three ways at this but each comes with a problem:

- I can use pure triggers. It's harder, and I failed to make it work before I gave up... Also, it's tough to make it leakless without using pure JASS. (I could probably make it work eventually, but you are going to have a tough time understanding it too.)

- I can use the "Phoenix Morph (Egg Related)" ability. Remember that when a Phoenix "dies", a Phoenix Egg "spawns"? And after a few seconds, a Phoenix "respawns"? Well, this is the ability that allows it to do so, and I'm using this ability to mimic the "Gold Rock dies > turns to Rock > wait some time > turns to Gold Rock" ability. It worked, but unfortunately "killing" the Gold Rock doesn't actually "kill" it. It merely leaves it at one hit points before turning into Rock. This is probably done that way so that enemy players cannot "kill" Phoenix and leave it as an egg to get XP for their heroes in melee games (i.e. they must completely destroy the egg in order to get XP). And this brings a problem for the give bounty method for giving gold, since if you don't really kill the Gold Rock, you can't get "bounty", or gold. So I needed to use a trigger to give gold instead. (This is the method I'm using)

- A third method involved using a "Spawn Hydra" ability, but instead of spawning hydra, a single Rock is spawned whenever a Gold Rock dies. This worked well, except that every time a Gold Rock dies, the spawned Rock doesn't always spawn at exactly the right point where the Gold Rock died, and this means over time, the rocks will start shifting to somewhere else. Also everytime a rock spawns, a "feral spirit" effect is shown, which is kinda ugly. (I'm referring to the "red lighting shock" special effect that is displayed every time you cast Feral Spirit, or every time a Feral Spirit vanishes.)

Okay, after all this trial and error, it works now (you can probably test it more thoroughly and see if it has any bugs). Also I added a special effect whenever the miner gets gold. :grin: (Reason: when I use the Give Bounty method of giving gold, it always makes that nice special effect, but using triggers means that there's no special effect, so I wanted to improvise.)

Here are the changes I made:
- Created a suite of abilities called "Respawn (###)" all of which are based on "Phoenix Morphing (Egg Related)". If you want to modify the duration during which the rock lives, change the "Stats - Duration - Hero" of the abilities.
- Created 2 triggers: "Ore Respawn Red" & "Ore Respawn Blue", one for each user player (Red & Blue). The triggers give the players gold whenever gold life goes < 1.
- Added custom script function "SpawnEffect", which is basically just decoration. It makes a nice special effect whenever the miner gets gold.
- Added the respective "Respawn (###)" abilities to each gold and rock unit. For example, Gold(500) and Rock(500) both get the ability "Respawn (500)".
- Changed the "Stats - Point Value" of each Gold unit, so that it matches the amount of gold the unit should give. (This is so that I don't have to hard code any gold values into the trigger, since the trigger can just give the amount of gold specified by the "Point Value". The "Point Value" is simply a custom value that each unit has, and can be pre-defined in the Object Editor.)
- Disabled all the "OreDead ***"-type triggers.

Oops, I forgot to attach the file before posting...

Also an extra note:
- I don't get if the gold rock is supposed to be 125 or 120. You have a Gold Rock(125) but a Rock(120)? :confused:

I suggest that you look at the map carefully to see all the changes I made and how the respawning works.
 

Attachments

  • GoldMinerVer.1.0.w3x
    745 KB · Views: 38
Last edited:
Level 49
Joined
Apr 18, 2008
Messages
8,421
Because I don't have 24-hr Internet this week I wasn't able to reply yesterday... :sad:

Anyway, I got a few tries at the problem:
1. Giving gold: there are two likely ways to solve this:

- I can just use the "Give Bounty" option so that when a unit [i.e. Gold Rock] dies for Player 5 (Yellow), it automatically gives gold based on what is set in the Object Editor for each Gold Rock unit.

- Or, I can use a trigger to give gold. This is not as easily done as the first one, but after a few tries I chose this method because of a problem... (explained later)

2. Make Gold Rock units turn into Rock units after they die and then turn them back into Gold Rocks after a fixed amount of time: Three ways at this but each comes with a problem:

- I can use pure triggers. It's harder, and I failed to make it work before I gave up... Also, it's tough to make it leakless without using pure JASS. (I could probably make it work eventually, but you are going to have a tough time understanding it too.)

- I can use the "Phoenix Morph (Egg Related)" ability. Remember that when a Phoenix "dies", a Phoenix Egg "spawns"? And after a few seconds, a Phoenix "respawns"? Well, this is the ability that allows it to do so, and I'm using this ability to mimic the "Gold Rock dies > turns to Rock > wait some time > turns to Gold Rock" ability. It worked, but unfortunately "killing" the Gold Rock doesn't actually "kill" it. It merely leaves it at one hit points before turning into Rock. This is probably done that way so that enemy players cannot "kill" Phoenix and leave it as an egg to get XP for their heroes in melee games (i.e. they must completely destroy the egg in order to get XP). And this brings a problem for the give bounty method for giving gold, since if you don't really kill the Gold Rock, you can't get "bounty", or gold. So I needed to use a trigger to give gold instead. (This is the method I'm using)

- A third method involved using a "Spawn Hydra" ability, but instead of spawning hydra, a single Rock is spawned whenever a Gold Rock dies. This worked well, except that every time a Gold Rock dies, the spawned Rock doesn't always spawn at exactly the right point where the Gold Rock died, and this means over time, the rocks will start shifting to somewhere else. Also everytime a rock spawns, a "feral spirit" effect is shown, which is kinda ugly. (I'm referring to the "red lighting shock" special effect that is displayed every time you cast Feral Spirit, or every time a Feral Spirit vanishes.)

Okay, after all this trial and error, it works now (you can probably test it more thoroughly and see if it has any bugs). Also I added a special effect whenever the miner gets gold. :grin: (Reason: when I use the Give Bounty method of giving gold, it always makes that nice special effect, but using triggers means that there's no special effect, so I wanted to improvise.)

Here are the changes I made:
- Created a suite of abilities called "Respawn (###)" all of which are based on "Phoenix Morphing (Egg Related)". If you want to modify the duration during which the rock lives, change the "Stats - Duration - Hero" of the abilities.
- Created 2 triggers: "Ore Respawn Red" & "Ore Respawn Blue", one for each user player (Red & Blue). The triggers give the players gold whenever gold life goes < 1.
- Added custom script function "SpawnEffect", which is basically just decoration. It makes a nice special effect whenever the miner gets gold.
- Added the respective "Respawn (###)" abilities to each gold and rock unit. For example, Gold(500) and Rock(500) both get the ability "Respawn (500)".
- Changed the "Stats - Point Value" of each Gold unit, so that it matches the amount of gold the unit should give. (This is so that I don't have to hard code any gold values into the trigger, since the trigger can just give the amount of gold specified by the "Point Value". The "Point Value" is simply a custom value that each unit has, and can be pre-defined in the Object Editor.)
- Disabled all the "OreDead ***"-type triggers.

Oops, I forgot to attach the file before posting...

Also an extra note:
- I don't get if the gold rock is supposed to be 125 or 120. You have a Gold Rock(125) but a Rock(120)? :confused:

I suggest that you look at the map carefully to see all the changes I made and how the respawning works.


OMG YOU TOTALLY OWN! Also this is 125, not 120. do you want to be my teammate at this hosted project(it will be hosted in the close future)?
Ofc, i give u more than half of the credits in my map and will give you as much +rep as i can, in each post in that thread(i dont know if it legal but i cannot say in words HOW MUCH u helped me!). Tas Dinog fellow! Oh, and Rui, NOW this problem should be moved to WEHZ solved problems.
 
Last edited:
Level 3
Joined
Jun 3, 2008
Messages
52
Glad to help.

I don't think I can work on the project full-time, but I can always provide some help if you need any in the future. :wink:
 
Status
Not open for further replies.
Top