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

[JASS] Position Lightning the right way..

Status
Not open for further replies.
Level 2
Joined
May 27, 2004
Messages
4
Hi there i have just started playing with jass again havent done mutch b4 i created 2 spells i happy with one of em but the other dosent look 100% the way i want to to how do i place the start of the lightning at the middle(heigth) of the units?
my code:
JASS:
function Trig_Mana_Deflector_Conditions takes nothing returns boolean
    return UnitHasBuffBJ(GetAttackedUnitBJ(), 'B00M')
endfunction

function DeflectorDoDamage takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local real damage = GetHandleReal(t, "damage")
    local unit caster = GetHandleUnit(t, "caster")
    local unit enemy = GetHandleUnit(t, "enemy")
    local integer i = GetHandleInt(t, "i")
    local lightning li
    if (i == 0) then
        set li = AddLightning("CHIM",true, GetUnitX(caster), GetUnitY(caster), GetUnitX(enemy), GetUnitY(enemy))
        call UnitDamageTarget(caster, enemy, damage, true, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null)
        call SetHandleHandle(t, "li", li) 
    elseif (i == 5) then
        set li = GetHandleLightning(t, "li")
        call DestroyLightning(li)
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
        set t = null
        
    else
        set li = GetHandleLightning(t, "li")
        call MoveLightning(li, true, GetUnitX(caster), GetUnitY(caster), GetUnitX(enemy), GetUnitY(enemy)) 
    endif
    set i = i + 1
    call SetHandleInt(t, "i", i)
    set t = null
    set caster = null
    set enemy = null
    set li = null
endfunction

function Trig_Mana_Deflector_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local unit caster = GetAttackedUnitBJ()
    local unit enemy = GetAttacker()
    local integer heroLevel = GetHeroLevel(caster)
    local integer spellLevel = GetUnitAbilityLevel(caster, 'A03G')
    local real damage = heroLevel * 10 + 25.0 * spellLevel
    
    call SetHandleHandle(t, "caster", caster)
    call SetHandleHandle(t, "enemy", enemy)
    call SetHandleReal(t, "damage", damage)
    call SetHandleInt(t, "i", 0)
    call TimerStart(t, 0.10, true, function DeflectorDoDamage) 
endfunction

//===========================================================================
function InitTrig_Mana_Deflector takes nothing returns nothing
    set gg_trg_Mana_Deflector = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Mana_Deflector, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Mana_Deflector, Condition( function Trig_Mana_Deflector_Conditions ) )
    call TriggerAddAction( gg_trg_Mana_Deflector, function Trig_Mana_Deflector_Actions )
endfunction

note this is my second spell so if there is any thing else wrong pls tell me!!!
if you got a good idear how to make the lightning look a bit better at the start and end pls tell me :p
Tnx alog!! :)
 
Level 2
Joined
May 27, 2004
Messages
4
native AddLightningEx takes string codeName, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns lightning

JassCraft is such a useful tool...

well sure that helps me a bit but is there no way to get the center of the model? what i use this spell on a tiny tiny unit or a giant one it sould look good any way...
 
Status
Not open for further replies.
Top