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.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      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