Spell Is Not Working Correctly

_whelp

New Member
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
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?
 

Executor

I see you
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
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.
  • Varine Varine:
    Good luck to the hurricane path people. Is TH still in Houston?
  • Ghan Ghan:
    I think so
    +1
  • The Helper The Helper:
    Yeah we got nothing here did not even rain
  • Ghan Ghan:
    We could use some rain.
  • The Helper The Helper:
    I am not complaining though Hurricanes are not fun I have been through alot of them
  • Blackveiled Blackveiled:
    I evacuated for it just incase since I live in La Porte pretty much right on the water (in Houston area). Didn't see anything. It's a good thing for me anyways.
  • Ghan Ghan:
    It's too bad that Blizzard messed up so terribly with Reforged.
  • Ghan Ghan:
    Still has a 0.6 user metacritic score.
  • Ghan Ghan:
    (Out of 10)
  • Varine Varine:
    I haven't even tried it yet because everyone said it sucked. How do you get .6 out of ten?
  • The Helper The Helper:
    I am waiting for Dwarf Fortress to come out on Steam then I am on it.
  • Accname Accname:
    I play Dwarf Fortress from time to time.
  • Accname Accname:
    Its Okay.
  • Accname Accname:
    But the performance is sub-par. Does not seem to be well optimized.
  • Varine Varine:
    Is the Steam version coming with a graphical overlay or is it using the ASCII graphics still?
  • tom_mai78101 tom_mai78101:
    Steam version has the graphical overlay.
  • The Helper The Helper:
    Steam Version has graphics, a new interface and will be integrated in the steam mod stuff
  • Blackveiled Blackveiled:
    I didn't think WC3 Reforged was that bad. It pretty much did what it stated (to me at least), but then again I can care less about reforged campaigns and all that. I just care about gameplay.
  • Varine Varine:
    I think people were hoping for a resurgence in mod support. I have little interest in the actual game tbh
  • Varine Varine:
    Plus I know they added that Dota precedent clause where Blizzard can steal your shit which isn't cool.
  • Ghan Ghan:
    They sold Reforged to the community as primarily a huge graphical uplift with high res textures and redone cinematics.
  • Ghan Ghan:
    They even showed one of the redone cinematics at Blizzcon and that very cinematic wasn't even in the released game.
  • Ghan Ghan:
    So I think folks were angry about that.
  • Varine Varine:
    Didn't the backwards compatability have issues too?
  • Accname Accname:
    I never had any hopes for that. Blizzard is not the same company it was 10 years ago.

    Members online

    No members online now.

    Affiliates

    Hive Workshop
    Top