HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Problem with xecollider

04-02-2009, 07:12 PM#1
0zyx0
I am trying to make a spell using xecollider. Here is the script:
Collapse JASS:
scope ChargedStrike initializer init
private struct StrikeMissile extends xecollider
    unit c
    method onUnitHit takes unit hitTarget returns nothing
        local xedamage d
        debug call BJDebugMsg("onUnitHit")
        if IsPlayerAlly(GetOwningPlayer(.c), GetOwningPlayer(hitTarget)) or (IsUnitType(hitTarget, UNIT_TYPE_STRUCTURE) == true)then
            call .terminate()
            return
        endif
        set d = xedamage.create()
        call d.damageTarget(.c, hitTarget, 100*GetUnitAbilityLevel(.c, 'A00I'))
        call d.destroy()
        if IsUnitAliveBJ(hitTarget) then
            call Knockback(hitTarget, 256.0, .direction, 0.6)
        endif
        call .terminate()
    endmethod
    method onDestroy takes nothing returns nothing
        debug call BJDebugMsg("onDestroy")
        call SetUnitX(.c, .x)
        call SetUnitY(.c, .y)  
        call ShowUnit(.c, true)
        call SelectUnitForPlayerSingle( .c, GetOwningPlayer(.c))    
    endmethod
endstruct
private function Charged_Strike takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local unit c = GetSpellAbilityUnit()
    local real r = GetDistance(GetUnitX(c), GetUnitY(c), GetUnitX(u), GetUnitY(u))
    local StrikeMissile sm = StrikeMissile.create(GetUnitX(c), GetUnitY(c), r)
    set sm.fxpath = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageSpecial.mdl"
    set sm.collisionSize = 31
    set sm.speed = GetUnitMoveSpeed(c)
    set sm.acceleration = 50
    set sm.expirationTime = 3
    set sm.c = c
    call PolledWait(0.1)
    call ShowUnit(c, false)
    set u = null
    set c = null
endfunction

private function init takes nothing returns nothing
    call OnAbilityEffect('A00I', SCOPE_PRIVATE+"Charged_Strike")
endfunction

endscope

This doesn't work as it should. The caster is never unhiden, the missile doesn't move at all, it stays where it was created, but both onUnitHit and onDestroy are called. How do I make the missile move?
04-02-2009, 08:54 PM#2
Eznce
A couple things i do with xecollider:
Not that you have to do them but, it works for me.
1) I set the acceleration of my missile to about 300+ Might make the missile start going idk

2)set the owner to owner of your caster

3)set a .maxSpeed? still dunno

4)If you want the missile to go from caster to a targeted unit, i use the real
local real ang1 = Atan2( GetLocationY(GetUnitY(c)) - y, GetLocationX(GetUnitX(c)) - x)

5)Try setting a real speed like 500 instead of GetUnitMoveSpeed()(not that it is probably the problem, but i'd try everything to make sure it works)

6)Also try setting a boolean check: if (this.c != targetunit) then (run OnUnitHit)

Just suggestions =P
04-03-2009, 12:05 AM#3
Vexorian
What happens if:

Collapse JASS:
scope ChargedStrike initializer init
private struct StrikeMissile extends xecollider
    unit c
    method onUnitHit takes unit hitTarget returns nothing
        local xedamage d
        debug call BJDebugMsg("onUnitHit "+GetUnitName(.c) )
        if IsPlayerAlly(GetOwningPlayer(.c), GetOwningPlayer(hitTarget)) or (IsUnitType(hitTarget, UNIT_TYPE_STRUCTURE) == true)then
            call .terminate()
            return
        endif
        set d = xedamage.create()
        call d.damageTarget(.c, hitTarget, 100*GetUnitAbilityLevel(.c, 'A00I'))
        call d.destroy()
        if IsUnitAliveBJ(hitTarget) then
            call Knockback(hitTarget, 256.0, .direction, 0.6)
        endif
        call .terminate()
        call BJDebugMsg("}")
    endmethod
    method onDestroy takes nothing returns nothing
        debug call BJDebugMsg("onDestroy "+GetUnitName(.c))
        call SetUnitX(.c, .x)
        call SetUnitY(.c, .y)  
        call ShowUnit(.c, true)
        call SelectUnitForPlayerSingle( .c, GetOwningPlayer(.c))    
    endmethod
endstruct
private function Charged_Strike takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local unit c = GetSpellAbilityUnit()
    local real r = GetDistance(GetUnitX(c), GetUnitY(c), GetUnitX(u), GetUnitY(u))
    local StrikeMissile sm = StrikeMissile.create(GetUnitX(c), GetUnitY(c), r)
    set sm.fxpath = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageSpecial.mdl"
    set sm.collisionSize = 31
    set sm.speed = GetUnitMoveSpeed(c)
    set sm.acceleration = 50
    set sm.expirationTime = 3
    set sm.c = c
    call PolledWait(0.1)
    call ShowUnit(c, false)
    set u = null
    set c = null
endfunction

private function init takes nothing returns nothing
    call OnAbilityEffect('A00I', SCOPE_PRIVATE+"Charged_Strike")
endfunction

endscope

show the output
04-03-2009, 12:43 PM#4
0zyx0
It says:
onUnitHit Blademaster
onDestroy Blademaster

It doesn't display "}" at all.

However, i figured out that the collision missile collided with the caster itself (the Blademaster), so this could be solved by creating the missile at an offset.
04-03-2009, 01:04 PM#5
Vexorian
Quote:
However, i figured out that the collision missile collided with the caster itself (the Blademaster), so this could be solved by creating the missile at an offset.
You could add an if-then-else so that it ignores it when it collides with the caster.

} should display though, if the missile was colliding then the effect should also be destroyed, I think there's a bigger bug in there, should check terminate's code.

Try this:

Collapse JASS:
scope ChargedStrike initializer init
private struct StrikeMissile extends xecollider
    unit c
    method onUnitHit takes unit hitTarget returns nothing
        local xedamage d
        debug call BJDebugMsg("onUnitHit "+GetUnitName(.c) )
        if IsPlayerAlly(GetOwningPlayer(.c), GetOwningPlayer(hitTarget)) or (IsUnitType(hitTarget, UNIT_TYPE_STRUCTURE) == true)then
            call .terminate()
            return
        endif
        debug call BJDebugMsg("A")
        set d = xedamage.create()
        debug call BJDebugMsg("B")
        call d.damageTarget(.c, hitTarget, 100*GetUnitAbilityLevel(.c, 'A00I'))
        debug call BJDebugMsg("C")
        call d.destroy()
        debug call BJDebugMsg("D")
        if IsUnitAliveBJ(hitTarget) then
            call Knockback(hitTarget, 256.0, .direction, 0.6)
        endif
        debug call BJDebugMsg("E")
        call .terminate()
        call BJDebugMsg("}")
    endmethod
    method onDestroy takes nothing returns nothing
        debug call BJDebugMsg("onDestroy "+GetUnitName(.c))
        call SetUnitX(.c, .x)
        call SetUnitY(.c, .y)  
        call ShowUnit(.c, true)
        call SelectUnitForPlayerSingle( .c, GetOwningPlayer(.c))    
    endmethod
endstruct
private function Charged_Strike takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local unit c = GetSpellAbilityUnit()
    local real r = GetDistance(GetUnitX(c), GetUnitY(c), GetUnitX(u), GetUnitY(u))
    local StrikeMissile sm = StrikeMissile.create(GetUnitX(c), GetUnitY(c), r)
    set sm.fxpath = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageSpecial.mdl"
    set sm.collisionSize = 31
    set sm.speed = GetUnitMoveSpeed(c)
    set sm.acceleration = 50
    set sm.expirationTime = 3
    set sm.c = c
    call PolledWait(0.1)
    call ShowUnit(c, false)
    set u = null
    set c = null
endfunction

private function init takes nothing returns nothing
    call OnAbilityEffect('A00I', SCOPE_PRIVATE+"Charged_Strike")
endfunction

endscope
04-03-2009, 07:15 PM#6
0zyx0
Now I have fixed it, and } is also displayed correctly. I don't know how I made } to be displayed, it just happened when i fixed the rest. Thank you for helping me!