• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Collision Missles w/ Caster System problem

Status
Not open for further replies.
Level 3
Joined
Jul 14, 2007
Messages
34
Alright, I can't believe I can't figure this out, but all I want to do is create a collision missile that looks like an arrow and have it deal damage to the unit it collides with, so what's wrong with this code? Also, another problem I have although it's purely cosmetic is moving the creation point of the collision missile so that it actually looks like it comes from the tip of the bow, I'm using Shandaris as the archer model right now if any of yall have the free time to make it pretty for me also; Here's the code:
JASS:
function Trig_Shoot_Arrow_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Shoot_Arrow_OnImpact takes nothing returns nothing
        local unit c = GetSpellAbilityUnit()
        local unit u = GetTriggerUnit()
        call UnitDamageTarget(c,u,150,false, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_AXE_MEDIUM_CHOP)
        set u = null
        set c = null
endfunction
    
function Trig_Shoot_Arrow_Actions takes nothing returns nothing
    local location l = GetUnitLoc(GetSpellAbilityUnit())
    local location t = GetSpellTargetLoc()
    local unit m
    set m = CollisionMissile_CreateLoc("Abilities\\Weapons\\Arrow\\ArrowMissile.mdl",l,AngleBetweenPoints(l,t),700,0,850,200,true,200,function Shoot_Arrow_OnImpact)
    call RemoveLocation(l)
    call RemoveLocation(t)
    set l = null
    set t = null
    set m = null
endfunction

//===========================================================================
function InitTrig_Shoot_Arrow takes nothing returns nothing
    set gg_trg_Shoot_Arrow = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shoot_Arrow, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Shoot_Arrow, Condition( function Trig_Shoot_Arrow_Conditions ) )
    call TriggerAddAction( gg_trg_Shoot_Arrow, function Trig_Shoot_Arrow_Actions )
endfunction

Ak! This needs to be in the spells subsection sorry about that!
 
Last edited:
Level 9
Joined
Mar 25, 2005
Messages
252
GetSpellAbilityUnit() and GetTriggerUnit() return null in your onImpact function.
You should store your caster to the collision missile m and then in the onImpact function get that caster back from the triggering collision missile and damage enemies close to the missile. GetTriggerCollisionMissile returns the triggering collision missile. The collision missile has a struct stored to its user data which you can use as the index of a global unit array to which you can store the caster.
I haven't tried this myself though so I'm not 100% sure that this works.
 
Level 3
Joined
Jul 14, 2007
Messages
34
Hmm, I'm pretty sure I get what you're saying, but when I tried it the missile still never impacted with anything, it simply flies through enemies.
 
Level 8
Joined
Jul 23, 2005
Messages
329
JASS:
function Shoot_Arrow_OnImpact takes nothing returns nothing
        local unit c = GetSpellAbilityUnit()
        local unit u = GetTriggerUnit()
        call UnitDamageTarget(c,u,150,false, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_AXE_MEDIUM_CHOP)
        set u = null
        set c = null
endfunction
That's what he was saying XD... c and u are both empty variables here, so this trigger has no idea who the triggering or the target unit is (Thus causing it to fly through).
 
Level 3
Joined
Jul 14, 2007
Messages
34
... Ohhhhh... Reading through the collision missile explanations located in the caster system I was lead to believe that GetTriggerUnit() would return the unit it impacted with, but it doesn't? So how would I store the variables from the other function, I haven't had experience with that before.
 
Status
Not open for further replies.
Top