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

Empowering

Status
Not open for further replies.
Level 10
Joined
Apr 22, 2010
Messages
421
Hi, so im trying to make a spell that is levelable(hero) where there hero would channel bounus strength to the target unit. To explain more clearly, the sequnce of events are listed below:

1- you cast spell at target allied unit(cannot target self)
2-you channel this spell(seen as a lighting effect between you and the target.
3- every second, you lose 15 mana(-1 mana cost each level)
4- every second the target gains +5 attack damage(+2 damage per level)(the effect stacks, so by 10 seconds, you have a +50 damage bounus)
IF you stop channeling, the target loses the bounuses but you stop losing mana.
IF the target goes out of range, the spell stops automaticly, and you stop losing mana(target also loses damage bounus.)

So how do i do this?:vw_wtf:
 
Level 10
Joined
Apr 22, 2010
Messages
421
The damage gained by the target doesn't have, limit ?

It all depends on the amount of mana you have, if you have an unlimited source, then yes, there is no limit.
EXAMPLE: lets say that you are next to a fountain of mana, and the rate the fountaian of mana replenishes your mana is faster then the rate your mana is drained, then the target will constantly gain damage until he moves too far away and breaks the connection.

But lets say you hjave super high intellect, and your mana regeneration becomes faster then you rate of mana drained, then there is another equatrion that is like this: you lose 5 + (MANA regeneration rate) MP per second your channeling.
 
Level 2
Joined
Feb 8, 2011
Messages
31
You most certainly would not want to make a damage bonus ability with that many levels. Use a damage bonus system instead:
  • Set dmg__Bonus[0] = DamageBonus +1
  • Set dmg__Bonus[1] = DamageBonus +2
  • Set dmg__Bonus[2] = DamageBonus +4
  • Set dmg__Bonus[3] = DamageBonus +8
  • Set dmg__Bonus[4] = DamageBonus +16
  • Set dmg__Bonus[5] = DamageBonus +32
  • Set dmg__Bonus[6] = DamageBonus +64
  • Set dmg__Bonus[7] = DamageBonus +128
  • Set dmg__Bonus[8] = DamageBonus +256
  • Set dmg__Bonus[9] = DamageBonus +512
  • Set dmg__Bonus[10] = DamageBonus +1024
  • Set dmg__Total = 10
  • -------- You can add more if you need to. --------
  • -------- dmg__Bonus is an ability array! --------
Then you can use functions like these:
JASS:
function dmg__Add takes unit target, integer amount returns nothing
    local integer i = 0
    local integer ii
    loop
        exitwhen amount == 0 or i > udg_dmg__Total
        set ii = R2I(Pow(2,i))
        if amount >= ii then
            set amount = amount - ii
            call UnitAddAbility(target,udg_dmg__Bonus[i])
        endif
        set i = i + 1
    endloop
endfunction

JASS:
function dmg__Remove takes unit target, integer amount returns nothing
    local integer i = 0
    local integer ii
    loop
        exitwhen amount == 0 or i > udg_dmg__Total
        set ii = R2I(Pow(2,udg_dmg__Total-i))
        if amount >= ii then
            set amount = amount - ii
            call UnitRemoveAbility(target,udg_dmg__Bonus[udg_dmg__Total-i])
        endif
        set i = i + 1
    endloop
endfunction
JASS:
function dmg__RemoveAll takes unit target returns nothing
    local integer i = 0
    loop
        exitwhen i > udg_dmg__Total
        call UnitRemoveAbility(target,udg_dmg__Bonus[i])
        set i = i + 1
    endloop
endfunction

The same thing can be used for other bonuses as well (like armor and health).
 
Level 2
Joined
Feb 8, 2011
Messages
31
@stranger, the problem is that i need a system that can support an UNLIMITED number, and the damage bounus is seen as the green text next to the attack damage area
So then make abilities for it all the way up to 1073741824 (2^30).
Doing that will let you add up to 2147483647 damage to a unit. Based on your formula, a level 3 ability would take 238609295 seconds to go over this limit (9 damage per second). Nobody will ever reach this in one game.

The only problem you will have is when a single unit is having this ability casted on it more than once (since you can't add the same ability twice).
Still, this is an easy fix.
 
Level 2
Joined
Feb 8, 2011
Messages
31
If you try to add 5 damage to a unit using the function dmg__Add, then it will add the Damage +4 ability and the Damage +1 ability. If you try to add 5 damage to it again, it will try to add Damage +4 and Damage +1, but because the unit already has those abilities, the unit can't get them again and its damage bonus will just stay at 5.

I'll make some examples of how you can fix this.

Edit:
5+(10-1)*2 = 23 (the amount of damage being added per second at level 10)
This will still take a very long time (almost 3 years) for a unit to reach the limit.
In fact, you would need 25936 units casting it on a single unit to reach the limit in just under an hour.
Like I said before, no one will ever reach this in one game.

Edit2:
The first thing you can do is edit the dmg__Add function:
JASS:
function dmg__Add takes unit target, integer amount returns nothing
    local integer i = 0
    local integer ii = 0
    loop
        exitwhen i > udg_dmg__Total
        if GetUnitAbilityLevel(target,udg_dmg__Bonus[i]) == 1 then
            set ii = ii + R2I(Pow(2,i))
            call UnitRemoveAbility(target,udg_dmg__Bonus[i])
        endif
        set i = i + 1
    endloop
    set i = i + 1
    set amount = amount + ii
    loop
        exitwhen amount == 0 or i > udg_dmg__Total
        set ii = R2I(Pow(2,i))
        if amount >= ii then
            set amount = amount - ii
            call UnitAddAbility(target,udg_dmg__Bonus[i])
        endif
        set i = i + 1
    endloop
endfunction

This will allow you to use it several times on the same unit without removing any bonuses.
The next thing you need to do is save the total bonus the target unit has from each spell instance. This is needed because when each spell has stopped, you need to remove the total bonus the target unit has from the spell.
 
Level 2
Joined
Feb 8, 2011
Messages
31
it doesent work, when i tested it, the bounus went from 100 to 358 then to 205, and then nothing, plus, the effect is not what i meant for the spell, just read my first post to see what i meant

It goes from 102 to 352 to 250 and then nothing because that's how I set it up for the example trigger (adds 102, then 250, then removes 150, then removes it all). This is just a damage bonus system you should use to stack damage during your spell because as it was stated before, having 1000000+ levels for an ability is insane.

As for the effect not being what you intended... I'm not really sure what you mean by that.
 
Last edited:
Level 2
Joined
Feb 8, 2011
Messages
31
but still dont know how to create my spell
all i se is the stacking syustem, what about the channeling, and the mana draining?

First off, you'll need something to create a lightning effect between the caster and the target, and then a script to constantly move it from one to the other. I know that such a system exists somewhere, most likely in vJASS. If you don't have JassHelper to compile vJASS then I can make you something in JASS.

Next you'll want your ability. Base it off of channel and make the follow through time something rediculous so the caster will never automatically stop casting the spell.

After you have that, you'll want to create two or three triggers:
1. Initialization Trigger (optional, setting all your setup variables in your main Initialization trigger won't hurt, though a lengthy trigger could make them hard to find)

2. Cast Trigger. When a unit casts the spell, you need to save the unit in an array, save the level of the ability in an array, and save the target in an array. You also need to keep track of the bonus being given to the target, and you must increase the variable that counts the amount of instances. I'm assuming you're using indexing over hashtables. You will also create your lightning effect at this part, which should also be saved into an array to destroy it when the spell has stopped.

3. Timer Trigger (runs every second). This will add damage to the target unit and remove mana from the caster. It also is responsible for detecting when the caster stops casting the spell, at which point the data created for that caster is replaced or removed.

For variables, you would need:
unit array for the caster
unit array for the target
lightning array for the lightning effect
integer array for the ability level
integer for an instance count
and any variables you want/need for an easy setup (maybe base damage and damage per level, as an example)
 
Status
Not open for further replies.
Top