Need Help With This Spell (Rush spell)

Carl-Fredrik

New Member
Reaction score
51
Hello everyone... you might've seen my old thread about this spell I was trying to make. I decided to start out with making it non-MUI and then learn how to improve it later.. thing is; it doesn't work ^^

The script stops working when it picks the group I think :S
Any help appreciated...

The spell is supposed to move the target forward and damage all enemies in the way but instead it starts moving, doesn't damage anything and won't stop moving; it moves outside the camera bounds eventually and the game crashes.

The script:

JASS:
scope KodoRun initializer KodoRushInit

globals
    private timer TIMER = CreateTimer()
    private group ENUM_GROUP = CreateGroup()
    private group DAMAGED_GROUP = CreateGroup()
    private real INTERVAL = 0.03
    private integer FORLOOP = 1
    private real DAMAGE_BASE = 100.00
    private real DAMAGE_INCREASE = 50.00
    private unit HERO
    private filterfunc Filth
    private location LOC1
    private location LOC2
    private location LOC3
    private location MOVE
endglobals

private function Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == 'A05A')
endfunction

 function FilterFunction takes nothing returns boolean
    local unit u=GetFilterUnit()
    set LOC3 = GetUnitLoc(u)
    if IsUnitEnemy(u,GetOwningPlayer(HERO)) and not IsUnitInGroup(u,DAMAGED_GROUP) and GetWidgetLife( u ) > .405 then
        call GroupAddUnit(DAMAGED_GROUP, u)
        call UnitDamageTarget(HERO, GetEnumUnit(), (DAMAGE_BASE + (DAMAGE_INCREASE * I2R (GetUnitAbilityLevel(HERO, 'A05A')))), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\Human\\HumanBlood\\HeroBloodElfBlood.mdl", LOC3))
    endif
    set u=null
    return false
endfunction

private function DoThisTimer takes nothing returns nothing
    set LOC1 = GetUnitLoc(HERO)
    call SetUnitX(HERO, GetLocationX(MOVE))
    call SetUnitY(HERO, GetLocationY(MOVE))
    call GroupEnumUnitsInRange(ENUM_GROUP, GetUnitX(HERO), GetUnitY(HERO), 50, Filth)
    set FORLOOP = FORLOOP + 1
    if FORLOOP == 50 then
        call PauseUnit(HERO, false)
        call PauseTimer(TIMER)
        call SetUnitPathing(HERO, true)
        call GroupClear(DAMAGED_GROUP)
        call RemoveLocation(LOC1)
        call RemoveLocation(MOVE)
        set FORLOOP = 1
    else
    call RemoveLocation(LOC1)
    call RemoveLocation(MOVE)
    endif
endfunction

private function Actions takes nothing returns nothing
    set HERO = GetTriggerUnit()
    set LOC1 = GetUnitLoc(HERO)
    set LOC2 = GetSpellTargetLoc()
    call SetUnitFacing(HERO, AngleBetweenPoints(LOC1, LOC2))
    call PauseUnit(HERO, true)
    call SetUnitPathing(HERO, false)
    call RemoveLocation(LOC1)
    call RemoveLocation(LOC2)
    call TimerStart(TIMER, INTERVAL, true, (function DoThisTimer))
endfunction

private function KodoRushInit takes nothing returns nothing
    local trigger t = CreateTrigger()
    set Filth = Filter(function FilterFunction)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition (function Conditions))
    call TriggerAddAction( t, function Actions )
endfunction
endscope


Thanks in advance...

Edit: Updated script
 

Viikuna

No Marlo no game.
Reaction score
265
Im not so sure about GetFilterUnit working inside Condition..
Try Filter:

Declare a global filter:
JASS:
  private filterfunc Filth


Create it in initializer function:
JASS:
set Filth=Filter(function FilterFunction)


and use your filter like this:
JASS:
call GroupEnumUnitsInRange(DAMAGEGROUP, GetUnitX(HERO), GetUnitY(HERO), 50, Filth)


And you can do all those ForGroup actions in your Filter with some nice if/then/else ( No need for ForGroup, makes it faster ). Remember to make your filter return false, if you do this.

You also need 2 groups btw, because those units wont stay in DAMAGEGROUP. Just use one for GroupEnum, and then add FilterUnit to that another group by using GroupAddUnit. You also need to create those groups to make them work.
 

Jesus4Lyf

Good Idea™
Reaction score
397
>set LOC2 = GetSpellTargetLoc()
Much more serious problems. This is not reliable after ANY time as passed from the casting.

Try learning this system: KT2 (use the tutorial below perhaps)

It allows you to create a timed effect, and store data that can be loaded from within. For example, making a unit slide - you can make a struct with the unit in the struct, then load the struct from within your code that will run every x seconds. From there you can access your unit.

If you need further help, there's a tutorial on advanced spell crafting here. It will also teach you KT2.

Sorry I don't have time to help you in a more personal manner. That tutorial DEFINITELY teaches you how to make a unit move in a line and damage units on the way, though (MUI).

PS. Yeah, that tutorial should help. There's many little mistakes here... Like:
private group DAMAGEGROUP
Should be...
private group DAMAGEGROUP = CreateGroup()
:)
 

Carl-Fredrik

New Member
Reaction score
51
Hmm...

I updated the script, now the unit won't move at all!? Still seems like the script stop working when it comes to the group... :S

Edit: And I don't use LOC2 after any wait so it doesn't really matter :p
 

Tom Jones

N/A
Reaction score
437
Huh? That can't be the problem.. it worked before I put the Group actions in :S
If the previous code looked anything like the current code, it didn't work. I thought I made it pretty clear, however apparently I didn't. You're referencing an uninitialized variable.
 

Carl-Fredrik

New Member
Reaction score
51
If the previous code looked anything like the current code, it didn't work. I thought I made it pretty clear, however apparently I didn't. You're referencing an uninitialized variable.

Oh you're right.. now that's embarrassing :p
I must've removed it in some way... :S

Anyway it works now!
Thanks for everyone's help! :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top