• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How To Add Ability at HP%

Status
Not open for further replies.
Level 11
Joined
Aug 25, 2009
Messages
1,221
Ok, what I am asking is how do you add an ability to ANY UNIT so when it goes to 30% HP it will gain an ability which decreases armor by 5. If it goes above 30%, it will loose the ability and regain the 5 armor, and so on.

Also, I have another question. How do I change it so agility does not increase armor?

+1rep for each question answered :D
 
Level 8
Joined
Jul 28, 2008
Messages
211
This should be moved to Trigger/Scripts section since you need a trigger that fires when a unit goes below 30% life, and fires again when a unit goes above 30%. I can only make a JASS version, since I'm lazy to open the editor (and I gotta go to bed now) and I haven't worked with GUI in a long time. Oh, there's no event that fires when a unit goes below 30% life. I'll make a JASS version that checks every 0.1 seconds.

EDIT: I don't have enough time to do it today. I'll do it tomorow if nobody else does it before me.
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
This should be moved to Trigger/Scripts section since you need a trigger that fires when a unit goes below 30% life, and fires again when a unit goes above 30%. I can only make a JASS version, since I'm lazy to open the editor (and I gotta go to bed now) and I haven't worked with GUI in a long time. Oh, there's no event that fires when a unit goes below 30% life. I'll make a JASS version that checks every 0.1 seconds.

EDIT: I don't have enough time to do it today. I'll do it tomorow if nobody else does it before me.

Actually theres such an event:
  • Unit - <Unit> life becomes Less than <Real>
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here's one way:

First copy and paste Spellbook ability. It's in Special - Items. Then copy and paste Item Armor Bonus (+1). Edit Data- Defense bonus field, click the field and then hit shift + Enter, and set it to -5. Then go to the Spellbook ability, change minimum spells to 1, and remove all spells from the list, add your armor bonus spell into the list and change Stats - Item ability to false.

New trigger in the post below.

  • Untitled Trigger 002 Copy
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Temp_Group = (Units in (Playable map area))
      • Unit Group - Pick every unit in Temp_Group and do (Actions)
        • Loop - Actions
          • Trigger - Add to Untitled Trigger 004 <gen> the event (Unit - (Picked unit)'s life becomes Less than (0.30 x (Max life of (Picked unit))))
          • Trigger - Add to Untitled Trigger 038 <gen> the event (Unit - (Picked unit)'s life becomes Greater than or equal to (0.30 x (Max life of (Picked unit))))
      • Custom script: call DestroyGroup(udg_Temp_Group)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Disable Spell Book Armor for (Player((Integer A)))
  • Untitled Trigger 037
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Untitled Trigger 004 <gen> the event (Unit - (Triggering unit)'s life becomes Less than (0.30 x (Max life of (Triggering unit))))
      • Trigger - Add to Untitled Trigger 038 <gen> the event (Unit - (Triggering unit)'s life becomes Greater than or equal to (0.30 x (Max life of (Triggering unit))))
  • Untitled Trigger 004
    • Events
    • Conditions
    • Actions
      • Unit - Add Spell Book Armor to (Triggering unit)
  • Untitled Trigger 038
    • Events
    • Conditions
    • Actions
      • Unit - Remove Spell Book Armor from (Triggering unit)
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
You're right. This should work:

  • Untitled Trigger 002 Copy
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Temp_Group = (Units in (Playable map area))
      • Unit Group - Pick every unit in Temp_Group and do (Actions)
        • Loop - Actions
          • Trigger - Add to Untitled Trigger 004 <gen> the event (Unit - (Picked unit) Takes damage)
      • Custom script: call DestroyGroup(udg_Temp_Group)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Disable Spell Book Armor for (Player((Integer A)))
  • Untitled Trigger 037
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Untitled Trigger 004 <gen> the event (Unit - (Triggering unit) Takes damage)
  • Untitled Trigger 004
    • Events
    • Conditions
      • (Life of (Triggering unit)) Less than or equal to (0.30 x (Max life of (Triggering unit)))
    • Actions
      • Unit - Add Spell Book Armor to (Triggering unit)
      • Unit Group - Add (Triggering unit) to Armor_Timer_Group
      • Trigger - Turn on Timer <gen>
  • Timer
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Armor_Timer_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Picked unit)) Less than or equal to (0.30 x (Max life of (Picked unit)))
            • Then - Actions
            • Else - Actions
              • Unit - Remove Spell Book Armor from (Picked unit)
              • Unit Group - Remove (Picked unit) from Armor_Timer_Group
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Armor_Timer_Group is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
Level 5
Joined
May 31, 2009
Messages
122
For the Agility-Armor thing, go to "Advanced", then go to "Gameplay Constants" then go to "Hero Attributes - Defense Bonus per Agility Point", then set it at 0

oh dear... that's... complicated.... I need something more... simple... I mean, I've been able to turn really complicated spells that are like 5 triggers and each trigger like two pages long into like 1 trigger with mabye a 6th of the page and the same effect...



For the spell:
This should add/remove the ability when a unit's hitpoints reach 30%. However, it only works when they're attacked (then again, that's pretty much the only instance, unless you have some self-hitpoint sacrificing skills or something - in that case, it will still work, when they're attacked next.)

spell.jpg


under the big chunk of stuff (Condition - "Integer((life of (attacked )... etc." You start with: "Integer Comparison"
Then on one side: "Conversion of Real to Integer"
Then pick "Unit-Property" and set it to "(Life) of (attacked unit)"
On the other side: "Arithmetic"
And on one of that sides: "Conversion of Real to Integer"
And pick: "Integer (0.30)" ; the 0.30 is the 30%
And on the opposite end: "Conversion of Real to Integer"
And pick: "Unit-Property" and set it to "(Max Life) of (Attacked Unit)"

That's just incase you dont know how to get there.

Now where it says "Unit-Add spiked carapace", you should have your custom armor spell there instead. I picked spiked carapace, because you can copy and paste that, set armor at a negative value (shift-click on the armor value) and remove the damage return stuff, and you're good to go.
You have to add a buff to that skill though, and match that to the trigger where it says "Condition - Attacked Unit has Buff(Spiked Carapace) = True/False", otherwise it wont work.
You could also have an item effect (such as ring of protection, and set a negative value); just remember to add a corresponding buff to it, otherwise the trigger wont work.

You can also filter out unit types under the main Trigger Condition thing.
 
Level 2
Joined
Feb 8, 2009
Messages
16
If your asking were this is located then:

It's called "If, Then, Else, Multiple Functions" in the action part of the trigger editor.

NOTE: You want to avoid the use of "Do Nothing" in your triggers. If the trigger action does nothing then leave it BLANK.
 
Level 5
Joined
Feb 5, 2008
Messages
109
If you don't even know how to create If-blocks go through some tutorials first before you try to solve such problems.

I expect you to use Jass NewGen Pack, because otherwise you should stop mapping as it's a must-have and I use one of the methods it adds to the WE. If not shame on you and google it.

Forget every other trigger posted above, they are crap! Triggers which check every x seconds are always the last option and most times avoidable.

My triggers are not optimized since they are made for learning and I want to show you the important things. You got to do that yourself.


Adding

  • add ability to every existing unit
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Entire map)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to add ability to new units <gen> the event (Unit - (Picked unit)'s life becomes Greater than ((Max. Life of (Picked unit)) x 0.30))
          • Trigger - Add to remove ability from units <gen> the event (Unit - (Picked unit)'s life becomes Less than or equal ((Max. Life of (Picked unit)) x 0.30))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Picked unit)) Greater than ((Max. Life of (Picked unit)) x 0.30)
            • Then -Actions
              • Einheit - Add Spell book to (Picked unit)
            • Else -Actions
  • add ability to new units
    • Events
    • Conditions
    • Actions
      • Unit - Add Spell book to (Triggering unit)
  • add events to trigger which adds
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • Trigger - Add to add ability to new units <gen> the event (Unit - (Triggering unit)'s life becomes Greater than ((Max. Life of (Triggering unit)) x 0.30))

Removing

  • remove ability from units
    • Events
    • Conditions
    • Actions
      • Unit - Remove Spell book from (Triggering unit)
  • add events to trigger which removes
    • Events
      • Einheit - A unit enters (Entire map)
    • Conditions
    • Actions
      • Trigger - Add to remove ability from units <gen> the event (Unit - (Triggering unit)'s life becomes Less than ((Max. Life of (Triggering unit)) x 0.30))

Hiding

  • disable ability
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Deactivate Spell book for (Picked player)

If you don't use JNGP you have to replace the method used for adding events with custom script, for example
JASS:
call TriggerRegisterUnitLifeEvent( gg_trg_remove_ability_from_units, GetTriggerUnit(), LESS_THAN_OR_EQUAL, ( GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetTriggerUnit()) * 0.30 ) )

View the whole thing in the added test map. Have fun.
 

Attachments

  • Armor decrease.w3x
    13.7 KB · Views: 52
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
Didn't me and maker already disguss that this and tomes of health/hp upgrades wouldn't work?

Yes we did, and it doesn't work correctly, just as ikillforeyou said it wouldn't.

The triggers Triax posted are almost exactly the same I posted earlier, they do not work correctly.

However my second solution works quite nicely, and they're not complicated triggers at all.

Here's the map:

http://www.hiveworkshop.com/forums/pastebin.php?id=u45pf2
 
Level 5
Joined
May 31, 2009
Messages
122
How do I make the "If [All Conditions are True] then do [Then Actions] else do [Else Actions]"?


You go to "Add Action", then press "I", and then the first thing should be "If/Then/Else (Multiple Conditions)" or something like that. There should be no blue or red text in that thing; click okay, then after that, you should have an if statement thing, that has slots for "Conditions" , "Then" (The actions under this header are used when the conditions match), and "Else" (The actions under this header are used when the conditions don't match).

Also, i forgot one thing; If say, a hero dies, and you want them to resurrect without that thing, just add under the first If-Condition that the Hitpoints has to be greater than zero (copy the other integer thing and change that one). You may also has to make an or statement for the last trigger, but i'm too lazy to explain that xD
 
Status
Not open for further replies.
Top