LearningCode
New Member
- Reaction score
- 24
This spell was based on Avaleirra's spell request under the GUI section.
One part of the spell is malfunctioning.
[lJASS]call SetUnitState(u, UNIT_STATE_MAX_LIFE, HP)[/lJASS]
To be more accurate:
When my hero has 3550 HP and casts the spell, BJDebugMsg shows me 1775.00 (Correct) but my Spawn has only 1 hp
When my hero has 1800 HP and casts the spell, BJDebugMsg shows me 900.00 (Correct) but my Spawn has only 1 hp
My spawn always has 1 hp and I can't fix that =/
The object editor (By default) gives the spawn 1hp
One part of the spell is malfunctioning.
[lJASS]call SetUnitState(u, UNIT_STATE_MAX_LIFE, HP)[/lJASS]
JASS:
function SpawnAct takes nothing returns nothing
local real xC = GetUnitX(GetTriggerUnit())
local real yC = GetUnitY(GetTriggerUnit())
local real x
local real y
local real r = 100.00
local unit u
local real rad = (GetUnitFacing(GetTriggerUnit()) * bj_DEGTORAD)
local integer AGI = GetHeroAgi(GetTriggerUnit(), true)
local real HP = GetUnitState(GetTriggerUnit(), UNIT_STATE_MAX_LIFE)/2
local integer i = 2
local integer time = 20
local location l
local real SpawnHP
set x = xC + r * Cos(rad)
set y = yC + r * Sin(rad)
call BJDebugMsg(R2S(HP))
if GetUnitAbilityLevel(GetTriggerUnit(), 039;A01P039;) > 0 then
set u = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 039;nlv2039;, x, y, GetUnitFacing(GetTriggerUnit()))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", x, y))
call SetUnitState(u, UNIT_STATE_MAX_LIFE, HP)
elseif GetUnitAbilityLevel(GetTriggerUnit(), 039;A01T039;) > 0 then
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl", x, y))
set u = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 039;nlv3039;, x, y, GetUnitFacing(GetTriggerUnit()))
call SetUnitState(u, UNIT_STATE_MAX_LIFE, HP)
endif
call UnitAddAbility(u, 039;AInv039;)
loop
exitwhen i == AGI
call UnitAddItemById(u, 039;I001039;)
set i = i+1
endloop
call UnitRemoveAbility(u, 039;AInv039;)
loop
exitwhen time == 0
set l = GetUnitLoc(u)
call TriggerSleepAction(1.00)
call CreateTextTagLocBJ( I2S(time), l, 0, 10, 10, 80, 10, 0 )
call SetTextTagLifespanBJ( bj_lastCreatedTextTag, 0.50 )
call SetTextTagPermanentBJ( bj_lastCreatedTextTag, false )
call RemoveLocation(l)
set l = null
set time = time-1
endloop
if GetWidgetLife(u)>=4.05 then
call SetUnitOwner(u, Player(12), true)
set SpawnHP = GetUnitState(u, UNIT_STATE_MAX_LIFE)/200
set AGI = AGI + R2I(SpawnHP)
call SetHeroAgi(GetTriggerUnit(), AGI, true)
set l = GetUnitLoc(GetTriggerUnit())
call TriggerSleepAction(1.00)
call CreateTextTagLocBJ( "+"+I2S(R2I(SpawnHP))+" AGI", l, 0, 10, 100, 80, 80, 0 )
call SetTextTagLifespanBJ( bj_lastCreatedTextTag, 1.50 )
call SetTextTagPermanentBJ( bj_lastCreatedTextTag, false )
call RemoveLocation(l)
set l = null
endif
endfunction
function SpawnCond takes nothing returns boolean
return GetSpellAbilityId() == 039;A020039;
endfunction
//===========================================================================
function InitTrig_Spawn takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer i = 0
loop
exitwhen i == 8
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i+1
endloop
call TriggerAddCondition(t, Condition(function SpawnCond))
call TriggerAddAction( t, function SpawnAct )
endfunction
To be more accurate:
JASS:
local real HP = GetUnitState(GetTriggerUnit(), UNIT_STATE_MAX_LIFE)/2
call BJDebugMsg(R2S(HP))
if GetUnitAbilityLevel(GetTriggerUnit(), 039;A01P039;) > 0 then
set u = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 039;nlv2039;, x, y, GetUnitFacing(GetTriggerUnit()))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", x, y))
call SetUnitState(u, UNIT_STATE_MAX_LIFE, HP)
elseif GetUnitAbilityLevel(GetTriggerUnit(), 039;A01T039;) > 0 then
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl", x, y))
set u = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 039;nlv3039;, x, y, GetUnitFacing(GetTriggerUnit()))
call SetUnitState(u, UNIT_STATE_MAX_LIFE, HP)
endif
When my hero has 3550 HP and casts the spell, BJDebugMsg shows me 1775.00 (Correct) but my Spawn has only 1 hp
When my hero has 1800 HP and casts the spell, BJDebugMsg shows me 900.00 (Correct) but my Spawn has only 1 hp
My spawn always has 1 hp and I can't fix that =/
The object editor (By default) gives the spawn 1hp