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

[JASS] How do I make the orbs to only drain life from organic units??

Status
Not open for further replies.
Level 19
Joined
Jul 14, 2011
Messages
875
Try adding something like:
JASS:
if a < 0 then
    set a = 1
endif
before the call UnitDamageTarget(dat.orb[i], dat.target[i], a, false, false, null, null, null)
The 2 falses are kinda of buggy - some combinations will make the function not deal any damage. I believe the first one has something to do with the damage being blocked, while the other one is whether the attack is ranged or not. I dont really know much about their uses.
 
Level 14
Joined
Jul 19, 2007
Messages
767
Try adding something like:
JASS:
if a < 0 then
    set a = 1
endif
before the call UnitDamageTarget(dat.orb[i], dat.target[i], a, false, false, null, null, null)
The 2 falses are kinda of buggy - some combinations will make the function not deal any damage. I believe the first one has something to do with the damage being blocked, while the other one is whether the attack is ranged or not. I dont really know much about their uses.
Well but there is actually no problem with the damage dealt as far as I can see.. It's just not enable to kill enemy units just to turn their hit points to 1 but I do not think it matters that much..
 
Level 12
Joined
Oct 16, 2010
Messages
680
but still it will never kill anything completely, just turn enemies Hit Points to 1.. Well I don't think it matters that much.

I checked the spell and it seems it is draining a percentage of current health
obviusly under 1 it drains about 0.01 or even less health
to change that use a fix number in this part (the line starting by set a =...)
JASS:
//****drain****
    set X = GetUnitX(dat.target[i])
    set Y = GetUnitY(dat.target[i])
    set a = GetWidgetLife(dat.target[i]) * GetDrainPercentage(dat.lvl)
    set dat.drained[i] = dat.drained[i] + a
    call UnitDamageTarget(dat.orb[i], dat.target[i], a, false, false, null, null, null)
        //****effects****

make it like
set a = GetWidgetLife(dat.target[i]) * GetDrainPercentage(dat.lvl) + 1
+1 will work like --> orbs will drain %hp+1

then units will die in the effect for shure
 
Level 4
Joined
Jul 25, 2014
Messages
57
I don´t know many about jass, but I think you can fix it easily. Just add a buff for the effected units, and when their health becomes 1, chech, that they have that buff, or doesn´t, if yes deal them 1 damage.
 
Level 14
Joined
Jul 19, 2007
Messages
767
I checked the spell and it seems it is draining a percentage of current health
obviusly under 1 it drains about 0.01 or even less health
to change that use a fix number in this part (the line starting by set a =...)
JASS:
//****drain****
    set X = GetUnitX(dat.target[i])
    set Y = GetUnitY(dat.target[i])
    set a = GetWidgetLife(dat.target[i]) * GetDrainPercentage(dat.lvl)
    set dat.drained[i] = dat.drained[i] + a
    call UnitDamageTarget(dat.orb[i], dat.target[i], a, false, false, null, null, null)
        //****effects****

make it like
set a = GetWidgetLife(dat.target[i]) * GetDrainPercentage(dat.lvl) + 1
+1 will work like --> orbs will drain %hp+1

then units will die in the effect for shure
Thank you but I think the spell is fine now, it doesn't matter if the units are killed or not by the life draining.. The important thing is that the life draining works the same as it was before even if it's counted as damage. But well I don't really get how the healing thing works like in this spell. In level 4 the Heal Percentage is 10% so it means each orb heals the caster for 10% of the amount of life the drained from enemies?
 
Level 14
Joined
Jul 19, 2007
Messages
767
I checked the spell and it seems it is draining a percentage of current health
obviusly under 1 it drains about 0.01 or even less health
to change that use a fix number in this part (the line starting by set a =...)
JASS:
//****drain****
    set X = GetUnitX(dat.target[i])
    set Y = GetUnitY(dat.target[i])
    set a = GetWidgetLife(dat.target[i]) * GetDrainPercentage(dat.lvl)
    set dat.drained[i] = dat.drained[i] + a
    call UnitDamageTarget(dat.orb[i], dat.target[i], a, false, false, null, null, null)
        //****effects****

make it like
set a = GetWidgetLife(dat.target[i]) * GetDrainPercentage(dat.lvl) + 1
+1 will work like --> orbs will drain %hp+1

then units will die in the effect for shure

10%(at lvl4) of total drain is healed to caster, exactly

dat.drained[i] * GetHealPercentage(dat.lvl)
Ok just had to know because I just couldn't get how it worked like :-/ but 10% of total amount of life drained for each orb is healing the caster when they returns.. WEll if I would change my mind to allow units to be killed by the life draining, then shouldn't it still be
JASS:
call UnitDamageTarget(dat.orb[i], dat.target[i], a, false, false, null, DAMAGE_TYPE_UNIVERSAL, null)
I saw u took away the damage type in your last script :-/
 
Status
Not open for further replies.
Top