• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Spell causing game being disable to start

Status
Not open for further replies.
Level 13
Joined
Mar 16, 2008
Messages
941
Well, is the titel correct english grammar? I don't know, just want to know it :p
I tried to do some stuff again and started a vJass spell with table, the first time in my life (*glorious moment*).
It's pretty simple: The spell creates a ward that ticks in a random amount of seconds and deals aoe damage, with limited tick-times and a live-duration.
But the spell keeps prohibiting warcraft from correct starting.
It always enters the warcraft menu instead of starting, but I dind't get any errors while compiling and RtC is disabled:

JASS:
scope SoilTotem initializer InitTotem

    globals
        private constant string TotemSFX = "Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl"
        private constant string HitSFX = "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl"
        
        private constant integer ABILITY_ID = 'A000'
        private constant integer TOTEM_ID = 'o000'
        
        private HandleTable TotemTable
        private integer TotemCount = 0
                    
        private player TempPlayer
    endglobals

    //Feel free to change to formulas below this comment (just the stuff behind the "return")
    //How long the totem will live
    private function GetTotemDuration takes integer level returns real
        return 5.*I2R(level)
    endfunction
    //How many ticks a totem can do at maximum
    private function GetTotemTicks takes integer level returns integer
        return 2*level
    endfunction
    //Time until the next tick, GetRandomReal(4.,8.) is a random value between 4 and 8
    private function GetNextTick takes integer level returns real
        return GetRandomReal(4., 8.)/I2R(level)
    endfunction
    //The damage done per tick
    private function GetSpellDamage takes integer level returns real
        return 100.*I2R(level)
    endfunction
    //The radius of the totem ticks
    private function GetTotemRadius takes integer level returns real
        return 500.+50*I2R(level)
    endfunction

    //Don't touch the stuff below THIS comment ;) it is the spell core and you can't change any values
    //here. Only change things if you want to change the way the spell works and you have enough knowledge of vJass.
    private struct TotemStruct
        unit caster
        unit totem
        real totemx
        real totemy
        player owner
        integer abillevel
        real damage
        real radius
        real maxtime
        integer maxcount
        
        real acttime
        integer actcount
        
        timer tim
        
        private static method Enemys takes nothing returns boolean
            return IsUnitEnemy(GetEnumUnit(), TempPlayer) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.405 and not IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)
        endmethod
        
        private static method RunAbility takes nothing returns nothing
            local timer t = GetExpiredTimer()
            local TotemStruct dat = TotemTable[t]
            local real tick
            local unit u
            local group g
            
            if GetUnitState(dat.totem, UNIT_STATE_LIFE) > 0.405 then
                call DestroyEffect(AddSpecialEffect(TotemSFX, dat.totemx, dat.totemy))
                set g = NewGroup()
                set TempPlayer = dat.owner
                call GroupEnumUnitsInRange(g, dat.totemx, dat.totemy, dat.radius, Condition(function TotemStruct.Enemys))
                loop
                    set u = FirstOfGroup(g)
                    exitwhen u == null
                    call UnitDamageTarget(dat.caster, u, dat.damage, false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                    call DestroyEffect(AddSpecialEffect(HitSFX, GetUnitX(u), GetUnitY(u)))
                    call GroupRemoveUnit(g, u)
                endloop
                call ReleaseGroup(g)
            else
                call dat.destroy()
            endif
        
            if dat.acttime >= dat.maxtime or dat.actcount >= dat.maxcount then
                call dat.destroy()
            else
                set tick = GetNextTick(dat.abillevel)
                set dat.acttime = dat.acttime+tick
                set dat.actcount = dat.actcount+1
                call TimerStart(dat.tim, tick, false, function TotemStruct.RunAbility) 
            endif
        endmethod
                
        static method create takes nothing returns TotemStruct
            local TotemStruct dat
            local integer level
            
            set dat = TotemStruct.allocate()
            set dat.caster = GetTriggerUnit()
            set dat.owner = GetOwningPlayer(dat.caster)
            set dat.totemx = GetSpellTargetX() 
            set dat.totemy = GetSpellTargetY()
            set dat.totem = CreateUnit(dat.owner, TOTEM_ID, dat.totemx, dat.totemy, GetRandomReal(0., 360.))
            set dat.abillevel = GetUnitAbilityLevel(dat.caster, ABILITY_ID)
            set dat.damage = GetSpellDamage(dat.abillevel)
            set dat.radius = GetTotemRadius(dat.abillevel)
            set dat.maxtime = GetTotemDuration(dat.abillevel)
            set dat.maxcount = GetTotemTicks(dat.abillevel)
            
            set dat.acttime = GetNextTick(dat.abillevel)
            set dat.actcount = 1
            
            set dat.tim = NewTimer()
            if TotemCount == 0 then
                set TotemTable = HandleTable.create()
            endif
            set TotemCount = TotemCount+1
            set TotemTable[dat.tim] = dat
            
            call TimerStart(dat.tim, dat.acttime, false, function TotemStruct.RunAbility)
            return dat
        endmethod
        
        private method onDestroy takes nothing returns nothing
            set .caster = null
            call KillUnit(.totem)
            set .totem = null
            set TotemCount = TotemCount-1
            if TotemCount == 0 then
                call TotemTable.destroy()
            endif
            call ReleaseTimer(.tim)
        endmethod
            
    endstruct
    
    private function StartTotem takes nothing returns boolean
        if GetSpellAbilityId() == ABILITY_ID then
            call TotemStruct.create()
        endif
        return true
    endfunction
    
    private function InitTotem takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        
        loop
            exitwhen i >= 16
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, BOOLEXPR_TRUE)
            set i = i+1
        endloop
    
        call TriggerAddCondition(t, Condition(function StartTotem))
    endfunction
    
endscope
The spell is based on channel, the unit is a healtotem without the aura.

mfg Justify

PS: Table, TimerUtils, GroupUtils and BoolExprUtils required :) I love standarts :D
 
Last edited:
Level 4
Joined
Apr 16, 2009
Messages
85
(this doesn't fix your problem but i would do it anyway as destroying the table serves no purpose)

set TotemTable = HandleTable.create() i would move that to the init trigger and remove the call TotemTable.destroy() altogether and assign that value Condition(function TotemStruct.Enemys) on map init

about your problem: loads fine for me so i guess its something else and most likely one of these two candidates: did you update your jasshelper to the latest version and did you save DIRECTLY before pressing test map (don't click anywhere between clicking on save map and test map and you always have to save before testing)
or o/c this trigger is not the reason at all
 
Level 13
Joined
Mar 16, 2008
Messages
941
Well, tables are completly new for me and I thought it's better to free them as soon as possible, but okay :) I thought that Condition(function xyz) always uses the same boolexpr? Automaticly? But that's also ok :p
Well, I think I forgott the JassHelper, havn't done anything for months, I'll try it. And yes, I saved it :) thx, I'll edit any changes


EDIT: Lalala I s*ck (am I allowed to write this here?^^).
Had an old version of GroupUtils in the map, forgot to update it (was a testmap and I copied the systems from an older one) ... damn return bug, it's working (well, not the spell, but the map starts)^^ thanks a lot :p
 
Level 10
Joined
Aug 19, 2008
Messages
491
You state that your game doesn't start, so there's gotta be something with the initializer.
My first guess would be looping through 17 players, but previous posts state you don't. I suggest you try to replace that 16 with 15 and try again, just for the sake of it (will that 16th player cast the spell anyway?).
On the other hand, there might be something odd with another initializer. Try disabling a couple of new triggers one at a time and see if the map loads.
 
Level 4
Joined
Apr 16, 2009
Messages
85
about that
You state that your game doesn't start, so there's gotta be something with the initializer.
My first guess would be looping through 17 players, but previous posts state you don't. I suggest you try to replace that 16 with 15 and try again, just for the sake of it (will that 16th player cast the spell anyway?).
On the other hand, there might be something odd with another initializer. Try disabling a couple of new triggers one at a time and see if the map loads.

how about:

EDIT: Lalala I s*ck (am I allowed to write this here?^^).
Had an old version of GroupUtils in the map, forgot to update it (was a testmap and I copied the systems from an older one) ... damn return bug, it's working (well, not the spell, but the map starts)^^ thanks a lot :p

his problem was fixed long ago
 
Status
Not open for further replies.
Top