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

If unit has mana at all - condition

Status
Not open for further replies.
Level 10
Joined
May 24, 2016
Messages
339
I do actually know how to check unit_state_mana, but the things is, when I try to check target unit if he has mana at all (meaning that he has no mp by default object editor value), to deal him additional damage,

JASS:
set tr = GetSpellTargetUnit()

set I = GetUnitAbilityLevel(c,'A032')
set r = GetUnitState(tr,UNIT_STATE_MANA)


if I == 1 then
set R = 100 // damage
set r2 = 100 // mp burn

elseif I == 2 then
set R = 200 // damage
set r2 = 200 // mp burn

elseif I == 3 then
set R = 300 // damage
set r2 = 300 // mp burn

endif
set bl = false // local boolean bl
if r <= r2 then
set r = r2-r

set bl = true
call SetUnitState(tr,UNIT_STATE_MANA,0)
else
call SetUnitState(tr,UNIT_STATE_MANA,r-r2)
endif


if bl == false then

call UnitDamageTarget(c,tr,R,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
else

call UnitDamageTarget(c,tr,R+r,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
endif

There's no actual respond at it, the condition returns bl as false. You know, it's like game thinks HE HAS MP and is not shown on the game. So how can I handle it, please?..
 
Level 10
Joined
May 24, 2016
Messages
339
I think I just need to debugg it one more time instead of writing a question topic on hiveworkshop. I debugged values on the script once and made it working. But since it's not working again, I better just dig into it once again.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,867
Just some example code of what you might be looking to do (I was bored). Maybe useful:
vJASS:
function Example takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local integer lvl = GetUnitAbilityLevel(u, GetSpellAbilityId())
    local real mana = GetUnitState(t, UNIT_STATE_MANA)
    local real maxMana = GetUnitState(t, UNIT_STATE_MAX_MANA)
    local real dmg = 100 * lvl
    local real burn = dmg

    // Reduce target's current mana
    call SetUnitState(t, UNIT_STATE_MANA, mana - burn)

    // Deal damage to target
    if maxMana > 0 then
        // Normal damage
        call UnitDamageTarget(u, t, dmg, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
    else
        // Bonus damage
        call UnitDamageTarget(u, t, dmg * 2, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
    endif

    set u = null
    set t = null
endfunction
 
Level 10
Joined
May 24, 2016
Messages
339
Just some example code of what you might be looking to do (I was bored). Maybe useful:
vJASS:
function Example takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local integer lvl = GetUnitAbilityLevel(u, GetSpellAbilityId())
    local real mana = GetUnitState(t, UNIT_STATE_MANA)
    local real maxMana = GetUnitState(t, UNIT_STATE_MAX_MANA)
    local real dmg = 100 * lvl
    local real burn = dmg

    // Reduce target's current mana
    call SetUnitState(t, UNIT_STATE_MANA, mana - burn)

    // Deal damage to target
    if maxMana > 0 then
        // Normal damage
        call UnitDamageTarget(u, t, dmg, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
    else
        // Bonus damage
        call UnitDamageTarget(u, t, dmg * 2, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
    endif

    set u = null
    set t = null
endfunction
My trigger skill deal damage to target and burns his mp (as seen above)
All the mana that is not getting burned (since unit supposedly lacks of that values) goes into +damage.

I fixed it already. I think I needed your UNIT_STATE_MAX_MANA value to check condition. Thx you

JASS:
elseif spellid == 'A032' then
set tr = GetSpellTargetUnit()

set I = GetUnitAbilityLevel(c,'A032')
set r = 0
set r = GetUnitState(tr,UNIT_STATE_MANA)
set R2 = GetUnitState(tr,UNIT_STATE_MAX_MANA)
if I == 1 then
set R = 100 // damage
set r2 = 100 // mp burn
//call SetUnitAbilityLevel(c,'A00J',1)
elseif I == 2 then
set R = 200 // damage
set r2 = 200 // mp burn
//call SetUnitAbilityLevel(c,'A00J',3)
elseif I == 3 then
set R = 300 // damage
set r2 = 300 // mp burn
//call SetUnitAbilityLevel(c,'A00J',5)
endif


if R2 > 0 then // maximum mana 

if r >= r2 
call SetUnitState(tr,UNIT_STATE_MANA,r-r2)

elseif r < r2
set R = R +(r-r2)
endif

else
set R = R + r2
endif

call UnitDamageTarget(c,tr,R,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
endif
 
Status
Not open for further replies.
Top