• 🏆 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!

[Solved] Charge Ability

Status
Not open for further replies.
Level 17
Joined
Mar 21, 2011
Messages
1,597
Hi, i'm using BPower's Missile System / Stun Engine and i'm stuck with a problem.

Ability: Charges towards the target, stunning it on impact.

Now, because the Stun System uses hoofstomp, and the missiles' "OnFinish" will execute as soon as the missile is at the exact same spot as the target, both units get stunned. I want the missile to have a collision radius, so that it just needs to get in close rage of the target, however missile.collision does not change anything. I could check "OnPeriodic" and null the missile as soon as it gets close i guess, but is there a "natural way" that the system provides?

JASS:
library Charge initializer Init uses SpellIndex

    private struct Charge extends array
       
        private static method onPeriod takes Missile missile returns boolean
            if not (UnitAlive(missile.source) and UnitAlive(missile.target)) then
            endif
            return false
        endmethod
       
        static method onFinish takes Missile missile returns boolean
            local unit caster = missile.dummy
            local unit target = missile.target
           
            call SetUnitPathing(caster, true)

           
            set udg_STE_TARGET = target
            set udg_STE_DURATION = 3.00
            set udg_STE_STACK_TIME = false
            set udg_STE_ADD_STUN = true
            call TriggerEvaluate(udg_STE_TRIGGER)
           
            set caster = null
            set target = null
            return true
        endmethod
       
        implement MissileStruct
    endstruct

    private function OnCast takes nothing returns boolean
        local unit caster = GetTriggerUnit()
        local Missile missile
       
       
        call SetUnitPathing(caster, false)
       
       
        set missile = Missile.createEx(caster, GetSpellTargetX(), GetSpellTargetY(), GetUnitDefaultFlyHeight(caster))
        set missile.target = GetSpellTargetUnit()
        set missile.speed = 20.
        set missile.collision = 32.
        call Charge.launch(missile)
       
       
        set caster = null
        return false
    endfunction

    private function Init takes nothing returns nothing
        call RegisterSpellEffectEvent('A002', function OnCast)
    endfunction
   
endlibrary
 
Level 15
Joined
Mar 25, 2016
Messages
1,327
You could move the missile away right before calling the stun system. If I understood it correctly the stun system uses warstomp with a very small aoe, so only targets at the exact position are stunned. Moving it 1 distance unit away won't be noticeable.
I am not familiar with these two systems, so that might be not working at all.
 
Level 15
Joined
Mar 25, 2016
Messages
1,327
You can use onCollide, set missile.collision accordingly and check whether the colliding unit is the target unit.
From what I understood onFinish is exact target destination and onCollide uses missile.collision.
onPeriod is obviously always possible, but probably not the fastest.
 
Level 7
Joined
Jan 23, 2011
Messages
350
You can't create a new unit variable on your struct, then use it on your onPeriodic method to change the current target point of the missile? The system won't recognize it as Homing missile, you would be emulating it. Or perhaps, you could change the caster position onFinish to be on front
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
i dont want to create a new unit variable. the system works like this: as soon as i save a unit into the target variable, the missile will be homing. you have some other functions and variables, but i could not find anything that fixes my problem. the missile.collision sounded very promising for me, but unfortunately it is not meant to be used in homing missile actions.

edit: i played around with OnCollide and finally got a result. solved
 
Last edited:
Level 17
Joined
Mar 21, 2011
Messages
1,597
JASS:
        private static method onCollide takes Missile missile, unit hit returns boolean
          
            if (hit == missile.target) then
              
                //Do your stuff here

                return true
            endif

        endmethod

you need to set the collision on missile launch via missile.collision
 
Status
Not open for further replies.
Top