"Nova"-like code messed up

Faust

You can change this now in User CP.
Reaction score
123
EDIT:
Shiiiiiiiiiiit, I put i > 0... fixed... but they still only move ~400 distance.

EDIT2: Meh, I calculated the timedlife duration myself, now it's fine...


Well, any optimization recommendations?


EDIT3: Well, timedlife is okay (I tested with visible units), but for some reason the fan of knives effect stay there for a second... wtf?

JASS:
scope ScryeLeaves initializer I

globals 
        group Group
        integer i = 0
endglobals

struct SL
    group AlreadyDamaged = CreateGroup()
    unit array Leaves [10]
    effect array LeaveEffects [10]
    timer clock = CreateTimer()
    unit caster 
    integer ticks = 0
    
    method onDestroy takes nothing returns nothing
        call PauseTimer(.clock)
        call ClearTimerStructA(.clock)
        call DestroyTimer(.clock)
        call DestroyGroup(.AlreadyDamaged)
        loop
        exitwhen i > 10
         call DestroyEffect(.LeaveEffects<i>)
         set i = i+1
        endloop
    endmethod
endstruct

private function C1 takes nothing returns boolean
    return GetSpellAbilityId() == &#039;A02T&#039;
endfunction

private function IsUnitAnEnemyP takes nothing returns boolean
    if IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), udg_Player) and GetUnitAbilityLevel(GetFilterUnit(), &#039;Aloc&#039;) == 0 and GetWidgetLife(GetFilterUnit()) &gt;= 1 and IsUnitInGroup(GetFilterUnit(), Group) == false then
     return true
    else
     return false
    endif
endfunction

private function H1 takes nothing returns nothing
    local SL dat = GetTimerStructA(GetExpiredTimer())
    local integer i = 0
    set udg_Player = GetOwningPlayer(dat.caster)
    loop
    exitwhen i &gt; 0
     set Group = dat.AlreadyDamaged
     call GroupEnumUnitsInRange(G, GetUnitX(dat.Leaves<i>), GetUnitY(dat.Leaves<i>), 75, Condition(function IsUnitAnEnemyP))
     loop
      set bj_lastCreatedUnit = FirstOfGroup(G)
     exitwhen bj_lastCreatedUnit == null
      call UnitDamageTarget(dat.caster, bj_lastCreatedUnit, GetHeroAgi(dat.caster, true) * 15, false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
      call CreateEffectOnUnit(&quot;Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl&quot;, bj_lastCreatedUnit, &quot;chest&quot;)
      call GroupRemoveUnit(G, bj_lastCreatedUnit)
      call GroupAddUnit(dat.AlreadyDamaged, bj_lastCreatedUnit)
     endloop
     set i = i+1
    endloop
    set dat.ticks = dat.ticks + 1
    if dat.ticks &gt; 10 then
     call dat.destroy()
    endif
endfunction

private function A1 takes nothing returns nothing
    local SL dat = SL.create()
    local integer i = 0
    local real Angle = 0
    local real x 
    local real y
    set dat.caster = GetTriggerUnit()
    loop
    exitwhen i &gt; 10
     set dat.Leaves<i> = CreateUnit(GetOwningPlayer(dat.caster), &#039;h03H&#039;, GetUnitX(dat.caster), GetUnitY(dat.caster), Angle)
     set dat.LeaveEffects<i> = CreateEffectOnUnit(&quot;Abilities\\Spells\\NightElf\\FanOfKnives\\FanOfKnivesMissile.mdl&quot;, dat.Leaves<i>, &quot;origin&quot;)
     call SetUnitMoveSpeed(dat.Leaves<i>, 522)
     call SetUnitFlyHeight(dat.Leaves<i>, 150, 0)
     call UnitApplyTimedLife(dat.Leaves<i>, &#039;lmao&#039;, 1.7)
     set x = GetUnitX(dat.caster) + 800 * Cos((36 * i) * bj_DEGTORAD)
     set y = GetUnitY(dat.caster) + 1000 * Sin(Angle * bj_DEGTORAD)
     call IssuePointOrder(dat.Leaves<i>, &quot;move&quot;, x, y)
     set i = i + 1
     set Angle = Angle + 36
    endloop
    call SetTimerStructA(dat.clock, dat)
    call TimerStart(dat.clock, 0.191, true, function H1)
endfunction

//============================================================================
private function I takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function C1))
    call TriggerAddAction(t, function A1)
endfunction

endscope</i></i></i></i></i></i></i></i></i></i>


This should spawn 10 units, attach the effect to each one of them, then order them outwards, creating some kind of fan of knives nova.
The problem is, it only spawns one unit, at 0 degrees (east), and it goes only for ~400 distance.
What did I mess up?

Oh here is the custom effect creation:
JASS:
function CreateEffectOnUnit takes string whateffect, unit u, string attachpoint returns effect
    if IsPlayerInForce(GetLocalPlayer(), SlowPC) == true then
     set whateffect = &quot;&quot;
    endif
    set bj_lastCreatedEffect = AddSpecialEffectTarget(whateffect, u, attachpoint)
    return bj_lastCreatedEffect
endfunction
 

cleeezzz

The Undead Ranger.
Reaction score
268
hmm so i guess your only problem now is the effect, i see you destroy it in the onDestroy so maybe its a problem with the death animation of the effect?

>optimization
JASS:

private function IsUnitAnEnemyP takes nothing returns boolean
    return IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), udg_Player) and GetUnitAbilityLevel(GetFilterUnit(), &#039;Aloc&#039;) == 0 and GetWidgetLife(GetFilterUnit()) &gt;= 1 and IsUnitInGroup(GetFilterUnit(), Group) == false
endfunction


i think you forgot to null the unit leaves in the onDestroy

not that it matters but you could change udg_Player to be global in your global block "Players"
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top