• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Problem with missiles

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,853
I made an spell based in the Leech Seed of the Dota hero Rooftrellen
vJASS:
scope Quell initializer Init

private struct Heal extends Missiles

    method onFinish takes nothing returns boolean
        call SetUnitState(this.target,UNIT_STATE_LIFE,GetUnitState(this.target,UNIT_STATE_LIFE)+this.damage)
        return true
    endmethod

endstruct

struct Quell extends array

    implement Alloc
    static group g=CreateGroup()
    unit caster
    unit target
    player owner
    real damage
    integer counter
    timer t

    method destroy takes nothing returns nothing
        call ReleaseTimer(this.t)
        set this.caster=null
        set this.target=null
        set this.owner=null
        set this.t=null
        call this.deallocate()
    endmethod

    method period takes nothing returns nothing
        local real x=GetUnitX(this.target)
        local real y=GetUnitY(this.target)
        local real z=50+GetUnitFlyHeight(this.target)
        local unit u
        local Heal missile
        call UnitDamageTarget(this.caster,this.target,this.damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
        call DestroyEffect(AddSpecialEffectTarget("war3mapImported\\Holy Light.mdx",this.target,"origin"))
        call GroupEnumUnitsInRange(thistype.g,x,y,500,null)
        loop
            set u=FirstOfGroup(thistype.g)
            exitwhen u==null
            if not IsUnitType(u,UNIT_TYPE_MECHANICAL) and not IsUnitType(u,UNIT_TYPE_STRUCTURE) and IsUnitAlly(u,this.owner) then
                set missile=Heal.create(x,y,z,GetUnitX(u),GetUnitY(u),50+GetUnitFlyHeight(u))
                set missile.speed=900.00
                set missile.arc=8.627
                set missile.model="Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl"
                set missile.damage=this.damage
                set missile.target=u
                call missile.launch()
            endif
            call GroupRemoveUnit(thistype.g,u)
        endloop
    endmethod

    static method callperiodic takes nothing returns nothing
        local thistype this=GetTimerData(GetExpiredTimer())
        set this.counter=this.counter+1
        if this.counter<6 and UnitAlive(this.target) then
            call this.period()
        else
            call this.destroy()
        endif
    endmethod

    static method create takes unit caster, unit target returns thistype
        local thistype this=thistype.allocate()
        set this.caster=caster
        set this.target=target
        set this.owner=GetOwningPlayer(this.caster)
        if Spell=='A07F' then
            set this.damage=15.00+20.00*Level
        else
            set this.damage=15.00+15.00*Level
        endif
        call this.period()
        set this.counter=0
        set this.t=NewTimerEx(this)
        call TimerStart(this.t,1.00,true,function thistype.callperiodic)
        return this
    endmethod

endstruct

//-- --

private function Actions takes nothing returns nothing
    if Spell=='A09G' then
        if Level<3 then
            set Spell='A07F'
        else
            set Level=Level-2
            set Spell='A082'
        endif
    endif
    if Spell=='A07F' or Spell=='A082' then
        call Quell.create(Caster,GetSpellTargetUnit())
    endif
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    call RegisterAnyPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT,function Actions)
endfunction
endscope
So I used the relativistic missiles instead of using a unit that fires the heal missiles like I did before, but for some reason after the second instance it create much more missiles than it must do and goes to random places and heights, what's wrong?
 
Units with 'Aloc' won't be selected by GroupEnumUnitsInRange, iirc.
But so you use older (before patch 1.31) version? Because in new versions effects instead of units are created.
In this case a filter like checking unit type 'dumi' or checking owning player != Player(NeutralPassive) should be used.
 
Level 24
Joined
Jun 26, 2020
Messages
1,853
But it would exclude also many other units, as it's not common to have 'Aloc', or?
It surprises me anyways that the dummy has no 'Aloc' ability, it's pretty common for a dummy.
Maybe you can also ensure all dummy have 'Aloc' and filter for AbilityLevel == 1
No, it has 'Aloc', and the condition worked, I don't think I wanna make my spells work in units with 'Aloc'.

Going off topic, where are the mayority of people of this forum from? because I see various people reply me in the early morning.
 
Status
Not open for further replies.
Top