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

Two simple spells for heroes

Status
Not open for further replies.
Level 2
Joined
Dec 2, 2015
Messages
16
Howdy. I am trying to find an efficient way to trigger the following spells. It sounds pretty simple, but I still cannot figure out how do I make it.

First one is passive spell, like "cornered rat". When the HP of the hero is below 25%, the hero defence increases, making it harder to finish him. So when he regenerates or heals above 25%, the effect removes.

The second is basicly a goblin mine, but with some additional stuff. Every mine costs mana, there could be only 5 mines on the map to prevent spamming them. The mine on first lvl simply explodes, mine on the second lvl also lower enemy attack in range and mine on the third lvl also slows enemies in range. So, i have problem here with putting cool explosion effect and adding buffs on enemies.

Any ideas how do I make them? No Jass pls.
 
Level 7
Joined
Nov 19, 2015
Messages
283
Howdy. I am trying to find an efficient way to trigger the following spells. It sounds pretty simple, but I still cannot figure out how do I make it.

First one is passive spell, like "cornered rat". When the HP of the hero is below 25%, the hero defence increases, making it harder to finish him. So when he regenerates or heals above 25%, the effect removes.

The second is basicly a goblin mine, but with some additional stuff. Every mine costs mana, there could be only 5 mines on the map to prevent spamming them. The mine on first lvl simply explodes, mine on the second lvl also lower enemy attack in range and mine on the third lvl also slows enemies in range. So, i have problem here with putting cool explosion effect and adding buffs on enemies.

Any ideas how do I make them? No Jass pls.

1. By defence, I assume you mean armour. You can add the armour aura (forgot name) with low area of effect in a disabled spell book. This means the icon won't show up but the buff will still appear. Use a damage detection system or a periodic timer to check the unit health. Add or remove the ability as needed.

2. I prefer creating my own custom spell and triggering the unit created. If you want the first mine to disappear when you cast the 6th mine. You will have to save each mine in an array and shift them over to cycle them. Or if you just want to stop them casting mines all together when the max is hit, just add it in the trigger. Or (especially if you are not making custom spell and basing off goblin landmine) yoou can add requirements for abilities which can blank out an ability when the requirement is not met. The effects can be made by creating dummy units to cast the spells on the targets.

Just ask if you don't understand any of it and I will try to go into more detail.
 
Level 2
Joined
Dec 2, 2015
Messages
16
K thx for some tips. I will just post my first spell trigger here, I guess.
1. I am using the Ring of defence item abbility (or how is this thing called, my wc is not english).

Event
Unit attacked
Condition
attacked unit = "Hero" (unit variable)
(health of "Hero") less or equal ((max health of (Attacked unit) / 4.00)
Action
If (All conditions are True) then do (Then Actions) else do (Else Actions)
If
(Level of Cornered Rat for "Hero") = 1
Then
Unit - add Item:Ring of defence (+3) to "Hero"
Else
Do nothing

Pretty the same Action thing for two more levels of spell.
K I just attacks hero to test the spell and when his HP is lesser then 25% then nothing happens.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
The first one is pretty easy as kingkwong explained very well how it could be done properly.

I would recommend you to download a damage detection system (Bribes will do for now) and use that instead of "Unit - A unit is attacked" as event.

Also, you should have the first check "If level of Cornered Rat for <unit> is greater than 0" as first check.
The check after that will be if the health is below 25%.
Also, do NOT use unit variables. Just use references like Triggering unit, Attacked unit (Damage source/ Damage target when you have installed the Damage Detection System)

Optionally, you can check if the unit already has the armor bonus ability.

Next to that... this will work kind of.
What you are missing is a "remove" function.
To do this easily, you can add the unit to a group.
Then create another trigger with a periodic timer event of 0.5 seconds (can be lower if preferred).
In that trigger, you loop through the unit group and check if their health is above 25%.
If so, you remove them from the group and you remove the armor bonus ability.

If the group is empty (after you removed a unit from it), you can then turn that trigger off.
It should also be turned off by default and it should be turned on when a unit is added to the group.

Optionally, you can keep track of how many units there are in that group by having an integer increment when you add a unit and decrement when you remove a unit.
In that case, you can check if that integer is 0 instead of checking if the group is empty.
You also have to remove the unit from the group if it is dead.

The second one is slightly harder so I recommend you to finish this one first.

Also, upload triggers in [TRIGGER ][/TRIGGER] tags. (without that space in the opening tag...)
Google: Warcraft 3 The Hive Workshop how to easily post triggers
 
Level 7
Joined
Nov 19, 2015
Messages
283
I think using the armour aura (devotion aura) [AHad] would look nicer as you can see a buff which can tell you if you have cornered rat active.

A periodic timer can also work as its not too important to instantly have the extra armour.
 
Level 2
Joined
Dec 2, 2015
Messages
16
Ok, thx for answers, I am not sure to go in some advanced stuff. What bad about unit variable? I mean, I am making single player campaign and there would be only one hero with this spell. Here I posts them, not working.
  • start
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • (health of "Hero") less or equal ((max health of ("Hero") / 4.00)
    • Actions
    • If (All conditions are True) then do (Then Actions) else do (Else Actions)
      • Conditions
        • (Level of Cornered Rat for "Hero") = 1
      • Then
        • Unit - add Cornered Rat (+3) to "Hero"
      • Else
        • Do nothing
So, I am just too lazy to translate other two bloks, they are same, but for another lvl of Cordered rat.
The thing that I adds to "Hero" is basicly Defence ring.
And
  • finish
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • (health of "Hero") above or equal ((max health of ("Hero") / 4.00)
    • Actions
      • Unit - Remove Cornered rat (+10) from "Hero"
      • Unit - Remove Cornered rat (+3) from "Hero"
      • Unit - Remove Cornered rat (+6) from "Hero"
Not working, have any ideas why?
 
Level 12
Joined
May 22, 2015
Messages
1,051
You should just have one trigger for this. Every 0.05 seconds can be a bit expensive (though this is a simple action - I just think it will be easier in one trigger).

Change it to like this:
  • cornered rat
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • (Level of Cornered Rat for "Hero") equal or greater than 1
    • Actions
    • If (All conditions are True) then do (Then Actions) else do (Else Actions)
      • Conditions
        • (health of "Hero") less or equal ((max health of ("Hero") / 4.00)
      • Then
        • if
          • Conditions
            • (Level of Cornered Rat for "Hero") = 1
            • Then
              • Unit - add Cornered Rat (+3) to "Hero"
            • Else
            • ----- The rest of the levels stuff ------
      • Else
        • Unit - Remove Cornered rat (+10) from "Hero"
        • Unit - Remove Cornered rat (+3) from "Hero"
        • Unit - Remove Cornered rat (+6) from "Hero"
Also remove the "Do Nothing" in all your triggers since it actually wastes processing time despite saying it doesn't do anything lol. It's a trap. Leave a comment there that says "Do Nothing" if you have to have something there.

Anyway, this should work, I think, unless you forgot to set the "Hero" variable or something. I guess that can't happen if it's a preplaced unit. Anyway, how are you setting the "Hero", if you are even doing that?
 
Level 2
Joined
Dec 2, 2015
Messages
16
Ok here is my second spell trigger, behold.
  • icemine
    • Events
      • Unit - A unit starts using abbility
    • Conditions
      • (Ability being cast) equals Explosion damage (ice goblin mine)
      • --------This spell is created from Explosion Damage goblin mine explosion--------
    • Actions
      • Unit - Remove (Triggering unit) from the game
      • --------The mine model have no death animation, so its used to remove it after explosion--------
      • Visual effects - Create a special effect at (Position of (Triggering unit)) using ArcaneExplosion.mdl
      • --------ArcaneExplosion.mdl is a path to cool model of explosion--------
      • Set explosionmine = (Last created special effect)
      • Set mines = (mines - 1)
      • Visual effects - Create a special effect attached to the body of (Target unit of ability being cast) using Abilities\Spells\Undead\FrostArmor\FrostArmorTarget.mdl
      • Set frost = (Last created special effect)
      • Unit - Add Damage (-4) to (Target unit of ability being cast)
      • Unit - Add Attack speed slow down (Gloves of speed) to (Target unit of ability being cast)
      • Unit - Add Speed slow down to (Target unit of ability being cast)
      • Set attackdamage = Damage (-4)
      • Set slowmovement = Speed slow down to
      • Set slowattacks = Attack speed slow down (Gloves of speed)
      • Wait 1.00 seconds
      • Visual effects - Destroy explosionmine
      • Wait 8.00 seconds
      • Visual effects - Destroy frost
      • Unit - Remove attackdamage from (Target unit of ability being cast)
      • Unit - Remove slowattacks from (Target unit of ability being cast)
      • Unit - Remove slowmovement from (Target unit of ability being cast)
Sorry for stupid names of items e.t.c., hope you get what it means.

Here goes mines limit.
  • limit
    • Events
      • Unit - A unit starts using abbility
    • Conditions
      • (Ability being cast) equals Chemical mine installation
      • --------Spell, created from Item - goblin mine, but for hero.
    • Actions
      • Set mines = (mines + 1)
      • --------mines - integer, 0 by default.--------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • mines less or equal 5
        • Then - Actions
          • Do nothing
        • Else - Actions
          • Unit - Order (Triggering unit) to Stop.
Ok, visual effect of explosion does not appears, and effects of cold and weakness does not spread on enemies. Pretty the same thing with lvl 1 and lvl 2 of the spell.
 
Level 12
Joined
May 22, 2015
Messages
1,051
I suggest every 0.05 second instead of damage detection as damage detection is very expensive ;p

Pretty sure that's what he did.

As for the mines, what are you using to slow the units? If it is based off of the boots of speed item ability, it doesn't stack nicely, so it could be buggy against units that have a move speed bonus from another source (actual boots of speed). I think it just uses the most recent one, but I don't actually know. It might also use the highest value which would make them immune to the slow for no reason.

I assume you want the mines to be AOE, right? I don't know what spell you based it off of, but "Target unit of ability being cast" will be nothing unless the spell requires you to specifically click on a unit. It also would only apply your effects to the target only and no one else around. I also want to point out that your spell wouldn't work properly if multiple mines blew up within a short amount of time (the special effect variables would get overwritten so it might skip deleting one of the special effects).

The easiest way to do your special effects with the mines is actually to just use a dummy to cast other AOE spells with the special effects you want.
For reduced damage: howl of terror
For the slow: thunderclap

If you are not familiar with dummy units, I can explain that further (there is also a nice tutorial somewhere). Anyway, you basically spawn the dummy, give him thunderclap and howl of terror and have him cast both those spells. Then you set the animations for the spells and their buffs so it looks nice with your mines.

Did your mine limit work? It looks like it would let you place 6 instead of 5 mines Nevermind I read it wrong :p. It might be better also to have it remove the oldest mine when you place one and there are too many instead of stopping mines. Anyway, I can help you with that if you want it like that.
 
Level 12
Joined
May 22, 2015
Messages
1,051
For triggers, you can slow units by setting the movement speed of the hero's default speed to (X), by doing so you must not have another trigger that does the same thing as it will bug out. It's a last resort kind of thing.

I think it is definitely easier to have a dummy cast a slow spell on everyone or just use thunderclap. Setting move speed manually has always felt to me more like something for a system so you have full control over movement speed management. You run into a lot of issues if you play with those numbers too recklessly.
 
Level 2
Joined
Dec 2, 2015
Messages
16
Well, I am not sure. The problem is in trigger, or in spells, or both? Is that right that I can change the TC and HOT to another names and rename their effects (slowness to freeze, howl of terror to weakness) and still reffer to them?
  • icemines
    • Events
      • Unit - A unit starts using abbility.
    • Conditions
      • (Ability being cast) equals Explosion damage (ice mine)
    • Actions
      • Unit - Create 1 dummyfrost for Player 1 (red) at (Position of (Casting unit)) facing some degrees
      • Unit - Order (Last created unit) to Mountain King (Alliance) - Thunder Clap
      • Unit - Order (Last created unit) to Pitlord (Neutral) - Howl of Terror
      • Unit - Remove (Triggering unit) from the game
      • Set mines = (mines - 1)
 
Level 12
Joined
May 22, 2015
Messages
1,051
Well, I am not sure. The problem is in trigger, or in spells, or both? Is that right that I can change the TC and HOT to another names and rename their effects (slowness to freeze, howl of terror to weakness) and still reffer to them?
  • icemines
    • Events
      • Unit - A unit starts using abbility.
    • Conditions
      • (Ability being cast) equals Explosion damage (ice mine)
    • Actions
      • Unit - Create 1 dummyfrost for Player 1 (red) at (Position of (Casting unit)) facing some degrees
      • Unit - Order (Last created unit) to Mountain King (Alliance) - Thunder Clap
      • Unit - Order (Last created unit) to Pitlord (Neutral) - Howl of Terror
      • Unit - Remove (Triggering unit) from the game
      • Set mines = (mines - 1)

What you have there is fine. It is hard to tell from looking at it from here, but basically, those orders translate into strings. On your abilities, there is a field called "order string" or something like that. When you look at the triggers in JASS, those strings will match if you did it right.

Anyway, as for not working, it might be that the spells still cost mana and your dummy has no mana.
The dummy should have cast point and cast back swing = 0.00 and it should have movement type = none and move speed 0.

You should also add an expiration timer to the dummy unit so that it doesn't stay there forever. It can eventually cause lag.
 
Level 2
Joined
Dec 2, 2015
Messages
16
Hm-hm~, I just found that the event is the place where everything messes up. I gonna find another way to activate trigger now.
 
Just make two dummies


Ya, do this!!!

It's probably backswing or casting time. Either way, 2 dummies is the easiest fix.

You can rename spells that are in triggers already and the name will change in the trigger.

Remove the dummies, and remove the leaks.
An expiration timer is fine for the dummies, also 'remove' fine.

Hm-hm~, I just found that the event is the place where everything messes up. I gonna find another way to activate trigger now.

  • Unit - a unit starts the effect of an ability.
 
Level 2
Joined
Dec 2, 2015
Messages
16
Ok I simply did
  • Events
    • Unit - A unit dies‚
  • Conditions
    • (Unit-type of (Triggering unit)) equals Mine
Two dummies goes there, etc.
Damage and buffs appears, but still visual effect is not working. Well, i have the same problem with another of my spells, so i am probably doing something wrong.
So, I am making dummy and spell, and then in spell I change Art - Caster to the effect I want to appear. Whats wrong?
 
Level 12
Joined
May 22, 2015
Messages
1,051
Ok I simply did
  • Events
    • Unit - A unit dies‚
  • Conditions
    • (Unit-type of (Triggering unit)) equals Mine
Two dummies goes there, etc.
Damage and buffs appears, but still visual effect is not working. Well, i have the same problem with another of my spells, so i am probably doing something wrong.
So, I am making dummy and spell, and then in spell I change Art - Caster to the effect I want to appear. Whats wrong?

I think this is because the dummies have no animation attachment points. You at least get the buffs you want, right?

Might need to just add the special effects with triggers. You could try just creating the ones you want and also adding "Destroy last created special effect" right after them. A lot of explosion special effects will finish their whole animation before disappearing, anyway.
 
Level 12
Joined
May 22, 2015
Messages
1,051
use model for dummies, you can even change the scaling, besides it's better because of that

The main problem with that is then you slowly add more and more dummy units for each spell / ability which can start to increase map load times (more object data to load). It is better, in the long run, to use just one dummy unit that you add abilities to and use special effects or other strategies for the animations (in another thread of mine, it was suggested that I download some model that is basically the dummy model, but with attachment points - it allows scaling and colouring of special effects without creating a whole new unit for it - in this case, you could even just use that model for the dummy unit to have the spell animations).
 
Level 2
Joined
Dec 2, 2015
Messages
16
Ok, both spells work as they should have, many thanks for advices! For the second one I used two dummy units and then put effects on them, also added some sound and thats it, looks cool and works cool.
The thread can be closed now. :grin:
 
Level 7
Joined
Nov 19, 2015
Messages
283
Ok, both spells work as they should have, many thanks for advices! For the second one I used two dummy units and then put effects on them, also added some sound and thats it, looks cool and works cool.
The thread can be closed now. :grin:

For the mines, I think you should try something like this.

Unit start the effect of an ability
Ability equal to land mine

Create mine
Set expiration timer of mine to x
Add unit to mine group
if number of unit in mine group > mine_max
Set mine=random unit in mine_group
pick every unit in mine group
-if expiration timer of picked unit < expiration timer of mine
-set mine = picked unit
remove mine from the game

This allows you to place new mines and the oldest mine will be destroyed. If you place 5 mines in a bad location, it means you can't cast any more mines. Also instead for the ice mine, why not just when the mine dies, pick every unit within X and crate a dummy unit that casts slow on them.
 
Status
Not open for further replies.
Top