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

Lever as a unit

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
Hi,

I would like to make a custom unit that is basically a lever.

When it dies, it goes to off mode, and can be turned back on.

I tried making lever off of Human Farm, set decay to false, and gave it the model file for lever (Doodads\Cinematic\DungeonLever\DungeonLever).

When it dies, it does turn off, but then it disappears, even though I said it did not decay.

I want to make a lever unit based so that way I can scale its health (i.e. bonus mod) arbitrarily in game. Destructables don't have abilities, so cannot use a bonus mod system to add health if I use the plain jane lever WC3 provides.

So how can I make a lever that is unit based?
 
Level 7
Joined
Mar 29, 2009
Messages
139
Create two units. One unit is the lever turned on, the other one turned off. Create a trigger that replaces the unit with the other unit when it dies. Create a variable that remembers the amount you wanted in the ability or whatever you meant, then give it to the unit that replaced the other each time.
 
I am not sure what exactly you plan with it, when you change it to its death animation, but this could work:

  • Lever
    • Events
      • Unit - Lever 0000 <gen> Takes damage
    • Conditions
    • Actions
      • Custom script: if GetWidgetLife(GetTriggerUnit()) - GetEventDamage() < 0.405 then
      • Custom script: call UnitAddAbility (GetTriggeringUnit(), 'Aloc')
      • Animation - Play (Triggering unit)'s death animation
      • Custom script: endif
You can also set its life to full, if you want to repeat this and remove the Locust action. In that case you just need to save a boolean or an integer to see at which state it is.
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
Create two units. One unit is the lever turned on, the other one turned off. Create a trigger that replaces the unit with the other unit when it dies. Create a variable that remembers the amount you wanted in the ability or whatever you meant, then give it to the unit that replaced the other each time.

I couldn't use your solution because I need the handle id to not change when the lever comes back (i.e. same unit instance).

Ah many thanks Pharaoh. This is exactly what I was looking for--how to play a unit's animation.

And you answered my follow up question--how to toggle between on/off. Many thanks!

What is a unit's normal animation--i.e. what to do to switch it back on? "stand?"

Otherwise I think this is solved.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
"stand" will work, or the trigger action "reset animation", I forgot the exact text label.
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
"stand" works, but it doesn't play a lever sound.

any animation that would play the lever death sound when resetting it?

or would I need to manually play it as a 3-D sound?
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Either that or ask someone to edit the model to activate the sound event during the model's stand frame.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Sound plays with death animation.Sound doesn't play with stand because lever's stand animation(or call it resurrect whatever) doesn't have a sound.
 
Status
Not open for further replies.
Top