Spell Is Not Working Correctly

_whelp

New Member
Reaction score
54
JASS:
struct SpikeTrap
    //Configuration
    
    private static constant integer ABILITY_ID = 'A000'
    //The raw code of the spell, use Ctrl+D in the object editor to find it
    
    private static constant string TRAP_EFFECT = "Abilities\\Spells\\Orc\\SpikeBarrier\\SpikeBarrier.mdl"
    //The model of the trap 
    
    private static constant string TRIGGER_EFFECT = "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl"
    //The effect emitted when the traps are triggered
    
    private static constant integer MAX_EFFECTS = 3
    //Maximum trap effects
    
    private static constant real EFFECT_SPACING = 45.
    //How far effects a created from the caster
    
    private static constant real RADIUS = 45.
    //How far a unit has to be from the center of a trap to be affected
    
    private static constant attacktype ATTACK_TYPE = ATTACK_TYPE_CHAOS
    //The attack type
    
    private static constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_UNIVERSAL
    //The damage type
    
    private static constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
    //The weapon type
    
    private static method DAMAGE takes integer level returns real
        return I2R(level) * 50 + 25
    endmethod
    //The damage
    
    private static method TRAP_DURATION takes integer level returns real
        return 16 - I2R(level) * 4
    endmethod
    //How long the traps last
    
    //End of Configuration
    
    private static group GROUP = CreateGroup()
    private static thistype TEMPORARY_INSTANCE
    private static filterfunc FILTER
    
    unit caster
    player owner
    real x
    real y
    fogmodifier visibility
    integer level
    integer tick
    effect array effects[.MAX_EFFECTS]
    boolean isTriggered = false
    
    private static method groupActions takes nothing returns boolean
        local unit u = GetEnumUnit()
        call BJDebugMsg(I2S(.TEMPORARY_INSTANCE))
        call BJDebugMsg("ZOMG1")
        if(IsUnitEnemy(u, .TEMPORARY_INSTANCE.owner) and IsUnitType(u, UNIT_TYPE_GROUND)) then
            call BJDebugMsg("ZOMG")
            set bj_lastCreatedEffect = AddSpecialEffect(TRIGGER_EFFECT, GetUnitX(u), GetUnitY(u))
            call DestroyEffect(bj_lastCreatedEffect)
            call .DAMAGE(.TEMPORARY_INSTANCE.level)
            
            set .TEMPORARY_INSTANCE.tick = T32_Tick
        endif
        
        return false
    endmethod
    
    private method periodic takes nothing returns nothing
        local integer i = 0
        
        if(this.tick >= T32_Tick) then
            call BJDebugMsg(I2S(this))
            set thistype.TEMPORARY_INSTANCE = this
            call GroupEnumUnitsInRange(thistype.GROUP, this.x, this.y, thistype.RADIUS + thistype.EFFECT_SPACING, thistype.FILTER)
        call BJDebugMsg("ZOMG0")
        else
            call BJDebugMsg("wee")
            call this.stopPeriodic()
            
            call PauseUnit(this.caster, false)
            call ShowUnit(this.caster, true)
            loop
                exitwhen i == thistype.MAX_EFFECTS
                call DestroyEffect(this.effects<i>)
                set i = i + 1
            endloop
            set this.caster = null
            
            call FogModifierStop(this.visibility)
            call DestroyFogModifier(this.visibility)
            call this.destroy()
        endif
        call GroupClear(thistype.GROUP)
    endmethod
    
    implement T32x
    
    private static method actions takes nothing returns nothing
        local thistype d = thistype.create()
        local unit u = GetTriggerUnit()
        local integer i = 1
        local real r = 0
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        
        set d.x = x
        set d.y = y
        set d.caster = u
        set d.owner = GetOwningPlayer(d.caster)
        set d.effects[0] = AddSpecialEffect(.TRAP_EFFECT, x, y)
        
        set d.visibility = CreateFogModifierRadius(d.owner, FOG_OF_WAR_VISIBLE, d.x, d.y, .RADIUS + .EFFECT_SPACING, true, false)
        call FogModifierStart(d.visibility)
        
        loop
            exitwhen i == .MAX_EFFECTS
            
            set x = d.x + .EFFECT_SPACING * Cos(360 / i * bj_DEGTORAD)
            set y = d.y + .EFFECT_SPACING * Sin(360 / i * bj_DEGTORAD)
            set d.effects<i> = AddSpecialEffect(.TRAP_EFFECT, x, y)
            
            set i = i + 1
        endloop
        
        set d.level = GetUnitAbilityLevel(d.caster, .ABILITY_ID)
        set d.tick = T32_Tick + R2I(.TRAP_DURATION(d.level) / T32_PERIOD)
        call PauseUnit(d.caster, true)
        call ShowUnit(d.caster, false)
        
        call d.startPeriodic()
    endmethod
    
    private static method condition takes nothing returns boolean
        if(GetSpellAbilityId() == .ABILITY_ID) then
            call .actions()
        endif
        
        return false
    endmethod
    
    private static method onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        set .FILTER = Filter(function thistype.groupActions)
        
        loop
            exitwhen i == 15
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            
            set i = i + 1
        endloop
        
        call TriggerAddCondition(t, Condition(function thistype.condition))
    endmethod
endstruct
</i></i>


It works, but the group enumeration thing and the fog modifier won't do anything... How do you fix it?
 

Executor

I see you
Reaction score
57
JASS:
        if(this.tick &gt;= T32_Tick) then
            call BJDebugMsg(I2S(this))
            set thistype.TEMPORARY_INSTANCE = this
            call GroupEnumUnitsInRange(thistype.GROUP, this.x, this.y, thistype.RADIUS + thistype.EFFECT_SPACING, thistype.FILTER)
        call BJDebugMsg(&quot;ZOMG0&quot;)
        else
            call BJDebugMsg(&quot;wee&quot;)
            call this.stopPeriodic()


do "I2S(this)" or "wee" show? => is the periodicfunc executed?

you mentioned, that the visibility modifier would'nt work, does the code beneath the visibility modifier setup fire?
 

_whelp

New Member
Reaction score
54
[ljass]I2S(this)[/ljass] and wee work... Everything under the visibility modifier works too.
 

Executor

I see you
Reaction score
57
Check whether GROUP is really not equal to null and whether the x and y coordinates are correct (via debug msgs). I see no reason for the enumeration not to work.
 

watermelon

New Member
Reaction score
2
Shouldn't GetEnumUnit() be GetFilterUnit()? You're using it in a filter function.

Random Comments about other parts of the Spell:
Instead of 360*bj_DEGTORAD, just do 6.283185301(2 times Pi). I think it's faster if you just use the numbers instead.
You forgot to null the variable u.
It's not necessary to inline TriggerRegisterAnyUnitEventBJ. Just for your info.

Edit: Actually, you don't even need u that much. You could have just done "set d.caster = GetTriggerUnit()" and set the coordinate variables, d.x and d.y, later on.
 
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