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

Trigger Enchancing Spells HELP

Status
Not open for further replies.
Level 4
Joined
Aug 30, 2008
Messages
82
So heres what ive got..

Events:
-A unit starts the effect of an ability-

Conditions:
-(ability being cast) Equal to immolation-

Actions:
Modify Strength of (casting unit): add ????

the question marks at the end is where i need help
Basicly the goal is so when a hero activates immolation, all his stats begin going up until he reaches a maximum. the maximum value would be the event response triggering units level.

So for example if your hero is level 25, and you turn on immolation, all your stats would start to increase by 1, every 0.3 seconds. so over 7.5 seconds you would have +25 to all stats.

this spell is for my upcoming DBZ ORPG map, which is atm comming together nicely, but i feel that this immolation spell will play a big part in the game.

if you can help, i will definitely give credit, your name will be on top of the credits!

thanks...

EDIT:
also when a unit deactivates immolation, there stats go back to normal.
 
Level 7
Joined
Jul 29, 2009
Messages
276
using the odify Strength of (casting unit): add X will increase the attribute and you'll have to remember and check how much it did it and stuff, so i would suggest you to do it in another way.

make a custom abilty based on "Attribute Bonus" (its in neutral hostile -> hero).

make it a unit ability, mark the "hide button" true and give it as much levels as you want, with each lvl giving an ability bonus equel to it (lvl 26 will give you 26+ to stats).

when the effect starts you should add the caster to a unit group made for the ability, then in another trigger (that fires each 0.3 secends) you pick all the group members and set (and give if need) the ability level for +1 and i think you know the rest.. XD
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
With triggers its easy. The problem is if you want it to show +X str or just add to the units stats (the +X needs abilities while the adding is just a native).

Your system needs 3 parts.
The on activation which I believe counts as a spell cast.
The on deactivation, which is an order with no taget.
The incrimental timer which ups the stats (may be static timer (1 looping through all spell instances) or dynamic timers (1 timer per unit active)).

For +X, you will need a system which converts integers into +X stat on the hero via actual unit abilities.

The idea is to keep track of how many stats you have added, and not the heroes total stats. I would use an instance system whereby it attaches the bonus stats (spell instance) to the hero and each hero can have only one instance at a time.

On spell activate
Set up spell instance (I wouold use a struct here with 1 integer for the ammount added to all attributes and a unit to represent the owner).
Add spell to timer loop (turning timer on if number of instances to loop through is 0).
Attach spell instance to unit via hashtable.

On timer
Loop through all spell instances.
If attributes added for that instance is less than the heroes level.
Add 1 to attributes for that instance.
Increase hero stats by 1 for the instance hero.
endif
endloop

On turnoff
Get spell instance from hero unit via hashtables.
Remove the instance from the hashtables (to save memory).
Remove the that instance's attributes from all hero stats.
Remove the spell instance from the timer loop (and turn off timer if it is the only instance).
Destroy the spell instance so that it may be recycled for efficency (structs are good for this).

For bonus efficiency you can remove the instance from the timer loop as soon as max atributes are reached.
If you want a variable attribute increase rate, you may wish to use dynamic timers, whereby each instance has a unique timer attached to it controling the rate of gain for that instance.

All in all an easy spell to do, Should be easilly under 100 lines of JASS, including comments.
(Note I am not making it, purly outlining how).
 
  • Trigger
  • Events
    • Unit - A unit is issued an order with no target
  • Conditions
    • (Issued order) Equal to (order(immolation))
  • Actions
    • Set HowMuch = (Strength of (Triggering unit)) //Real variable
    • Unit Group - Add (Triggering Unit) to (AttributeGroup)
  • Trigger2
  • Events
    • Time - Every 0.3 seconds of game-time
  • Conditions
    • ((AttributeGroup) is empty) Equal to False
  • Actions
    • Unit Group - Pick up every unit in (AttributeGroup) and do (Actions)
      • Loop - Actions
        • Hero - Modify Strength of (Picked unit): Add 1
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Strength of (Picked unit)) Equal to (Level of (Picked unit)) // Integer Comparison
          • Then - Actions
            • Unit Group - Remove (Picked unit) from (AttributeGroup)
          • Else - Actions
  • Trigger3
  • Events
    • Unit - A unit is issued an order with no target
  • Conditions
    • (Issued order) Equal to (order(unimmolation))
  • Actions
    • Hero - Modify Strength of (Triggering unit): Substract ((Level of (Triggering unit)) - (Real(HowMuch))
 
Level 6
Joined
May 1, 2009
Messages
215
That trigger won't work though. If the player's hero levels up while the spell is active, he'll lose the strength gain on his hero when he deactivates the spell.

I'd really suggest doing the attribute bonus way, that way you can also cap the amount of strength the hero can gain.
 
Status
Not open for further replies.
Top