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

[Trigger] And also more questions

Status
Not open for further replies.
Level 6
Joined
Sep 13, 2013
Messages
155
1- How to make a spell that damages self (or ally) but doesn't kill the caster when the caster's health point is lower than the spell's health cost.
2- How to make a spell that makes you undying, you take every damage and your HP gets low but you don't die, something like Dazzle's Shallow Grave
3- Is there more unit targeting silence spell in warcraft 3 but Doom ?
4- If not, can we make a unit silence through triggers/GUI ?
5- Can we put items for sell inside a spellbook ? (This one has no business with this section i think)
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
#1
  • Actions
    • Set NewHP = (Max(1.00, ((Life of CasterUnit) - HealthCost)))
    • Unit - Set life of CasterUnit to NewHP
This will decrease Health of CasterUnit by the "HealthCost" of the spell. If he should end up with less than 1 health this way, his health will be set to 1 instead.

You don't need to use variables like I did in the example - you can make the calculation in the "Unit - Set life" line, I just put it in the "NewHp" variable so it is easy to take in.


#2
First, you need to catch when the unit takes damage.
If you want this spell for specific unit only (like some specific hero), you will need to use the event "Unit - Unit takes damage". If you want to use this for many units and you don't know how many (for example for Footman unit, etc.), the best way is to use Damage Detection System.

This is how the trigger looks for specific unit:
  • Trigger
    • Events
      • Unit - "Your Unit" Takes damage
    • Conditions
    • Actions
      • Set unit_var = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Life of unit_var) - (Damage taken)) Less than 0.41
        • Then - Actions
          • Unit - Set life of unit_var to ((Damage taken) + 0.41)
        • Else - Actions
      • Set unit_var = No unit
You check if the "Current health - damage taken" is less than 0.41 (units with less health are considered dead). If yes, you increase health by "Damage taken" amount.
(tbh this may not even require the whole ITE block as you may want to put the ITE's condition into the Condition block of the trigger)

The bad thing is that if unit takes damage, which is greater than that unit's total health, it will still kill it (this, however, is "fixed" in DDS).

If you use DDS, the trigger will be practically the same, but the "Event" will be different and instead of "Damage Taken" you will use a variable.

#3
If you mean an AoE Silence, then there is a Silence ability used by Dark Ranged or Cloud ability used by Dragonhawk Rider. If you mean specific target, there is Soul Burn used by Fire Lord.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
@Nichilus
The term "damages" and "reduce" health is different.
Because by "damaging" a unit, it can be detected via trigger but if you "reduce" the HP of a unit, it won't be detected.

So, you should really damage the unit, pure damage (ignores magic resistance).
The Source and Target should both be from the same unit.

This way, it can capture that the unit has self damage itself - allowing the event to be captured for another use such as disabling certain item upon taking damage (example).


@OP
#5
There's an ability called Charge Gold and Lumber whereby, when you cast the spell, it deducts your Gold and Lumber (according to your pre-set values in Object Editor).
Use this spell as a dummy for the actual item - link it via indexes.

Here's an example of how you should set up;
  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Ability[1] = Claws of Attack
      • Set Ability[2] = Ring of Regeneration
      • Set Item[1] = Claws of Attack +12
      • Set Item[2] = Ring of Regeneration
      • Set MaxItem = 2
  • Buy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • For each (Integer LoopingInteger) from 1 to MaxItem, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Ability[LoopingInteger]
            • Then - Actions
              • Hero - Create Item[LoopingInteger] and give it to (Triggering unit)
            • Else - Actions
For each ability, you must have a different Data - Base Order ID, else, the ability would collide.

Here's a test map if you wish to seek more info.
 

Attachments

  • SellingUnit.w3x
    17 KB · Views: 40
Level 28
Joined
Sep 26, 2009
Messages
2,520
Level 33
Joined
Mar 27, 2008
Messages
8,035
I thought he wanted a spell to cost health as well :D

Lol, damaging the unit does cost health to cast.
Technically it costs your health, you initiate a self-damage ability.
Before the damaging part occurs, you should calculate your current HP and the HP after reduction from the spell.

  • Cost Health
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Reduce Health
    • Actions
      • Set CurrentHP = (Life of (Triggering unit))
      • Set AfterHP = (CurrentHP - Damage)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AfterHP Greater than 0.41
        • Then - Actions
          • Unit - Cause (Triggering unit) to damage (Triggering unit), dealing Damage damage of attack type Chaos and damage type Universal
        • Else - Actions
          • Unit - Order (Triggering unit) to Stop
 
Status
Not open for further replies.
Top