• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Question: What's wrong here?

Status
Not open for further replies.
Level 10
Joined
Jan 24, 2009
Messages
606
What's wrong with this script? it's not running, at all... There's "Nothing" wrong with the "script".

JASS:
//************************************************************
//* Created by: Naitsirk
//*Credits to: TriggerHappy(TimedHandles), Vexorian(JassHelper, TimerUtils)
//* How to implant: Copy this trigger, change where it stands that you should change, and copy the spell
//* in the Object editor.
//************************************************************
//* No need to credit me if used. I do this just for the fun.
//* If credited, then credit me under Krisier.
//************************************************************


library FireyCircle initializer init needs TimerUtils, TimedHandles

globals
        private     constant     string  EFFECT               = "Abilities\\Spells\\Items\\AIfb\\AIfbSpecialArt.mdl"
        private                  group   aGroup               = CreateGroup()
        private     constant     boolean DESTROY_DESTRUCTABLE = true//set this to false if you don't want destructables to be destroyed
        private     constant     integer SPELLID              = 'A001'//Change this to the RawCode of the ability.
        private                  timer   aTimer               
        private                  real    time                 = 60.
        private                  real    EffectX
        private                  real    EffectY
        private                  unit    caster
        private                  integer level
endglobals
private function damage takes integer level returns real
    return 50. * I2R(level)
endfunction


struct action
    unit    u
        static method LA takes nothing returns nothing
        //please don't edit, this is the spell actions.(looping)
        local action new = action.allocate()
            call DestroyEffectTimed(AddSpecialEffect(EFFECT, EffectX, EffectY), time)
            call GroupEnumUnitsInRange( aGroup, EffectX, EffectY, 150, null)
            loop
                set new.u = FirstOfGroup(aGroup)
                exitwhen new.u == null
                if IsUnitEnemy(new.u, GetOwningPlayer(caster)) == true then
                    call UnitDamageTarget(caster, new.u, damage(level), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                endif
                set new.u = null
            endloop
            if(DESTROY_DESTRUCTABLE) then
                
            endif
        endmethod
endstruct

private function C takes nothing returns boolean
    return GetSpellAbilityId() == SPELLID
endfunction

private function A takes nothing returns nothing
    
    local real CasterX
    local real CasterY
    local integer int  = 12
    local location loc = GetSpellTargetLoc()
    set level = GetUnitAbilityLevel(caster, SPELLID)
    set caster = GetTriggerUnit() //this is to set the Casting unit, don't change this.
    set CasterX = GetUnitX(caster) //This is the Casting units X for the coordinates.
    set CasterY = GetUnitY(caster) //This is the Casting units Y for the coordinates.
    set EffectX = GetLocationX(loc) // This is the EffectX for the coordinates, don't change this.
    set EffectY = GetLocationY(loc)// This is the EffectY for the coordinates, don't change this either.
    set time = 60. // this is the time the SFX's lasts. Change this is wanted time is more or less.
    //don't edit.
    loop
        set int = int - 1
        exitwhen int == 0
        call TimerStart(aTimer, 0.10, false, function action.LA)
        set time = time - 5
        set EffectX = EffectX + 10.
        set EffectY = EffectY + 10.
    endloop
    //Cleaning the leaks.
    call GroupClear(aGroup)
    call RemoveLocation(loc)
    set caster = null
endfunction
//===========================================================================
function init takes nothing returns nothing
    local trigger gg_trg_Firey_Cricle// Please don't bug me that this has a typo.. I allready know, but it doesn't matter aslong as the code runs perfectly...
    set aTimer = NewTimer()
    set gg_trg_Firey_Cricle = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Firey_Cricle, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction(gg_trg_Firey_Cricle, function A)
    call TriggerAddCondition(gg_trg_Firey_Cricle, Condition(function C))
endfunction

endlibrary





I'll add the map in the attachments.
 

Attachments

  • Fiery Circle.w3x
    53.8 KB · Views: 52
I hope I've commented this enough so you can kind of follow where you're supposed to go. Also, this should be just using one timer and one instance instead of this many, but I don't want to change too much more because then you'll probably totally get lost..

JASS:
//************************************************************
//* Created by: Naitsirk
//*Credits to: TriggerHappy(TimedHandles), Vexorian(JassHelper, TimerUtils)
//* How to implement: Copy this trigger, change any of the configurables to your preference.
//************************************************************
//* No need to credit me if used. I do this just for the fun.
//* If credited, then credit me under Krisier.
//************************************************************


library FireyCircle initializer init requires TimerUtils, TimedHandles

globals
        private     constant     string  EFFECT               = "Abilities\\Spells\\Items\\AIfb\\AIfbSpecialArt.mdl"
        private     constant     boolean DESTROY_DESTRUCTABLE = true
        private     constant     integer SPELLID              = 'A001'
        
        
    //Non-configurables:
        private                  group   aGroup               = CreateGroup()
endglobals
    
    private function damage takes integer level returns real
        return 50. + 25. * (level - 1.0)   // I recommend you have a base damage like normal WC3 spells, then an increment per level, and you don't need I2R().
    endfunction
    
    
    struct action
        static thistype  I    // tracks the struct index during the GroupEnumeration.
        
        unit      caster      // the struct needs to remember these variables, they can't just be globals.
        real      x
        real      y
        real      damage
        real      time
        
        static method GroupEnum takes nothing returns boolean
        
            if IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(I.caster)) then
            
                call UnitDamageTarget(I.caster, GetFilterUnit(), I.damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            endif
            return false    //return false because returning true means units are added which is pointless.
        endmethod
        
        static method LA takes nothing returns nothing
            set I = GetTimerData(GetExpiredTimer())
            call ReleaseTimer(GetExpiredTimer())
            
            call DestroyEffectTimed(AddSpecialEffect(EFFECT, I.x, I.y), I.time)
            call GroupEnumUnitsInRange( aGroup, I.x, I.y, 150, Filter(function GroupEnum))
            
            if(DESTROY_DESTRUCTABLE) then
                
            endif
        endmethod
        
    endstruct
    
    
    private function A takes nothing returns nothing
    
     local unit caster  = GetTriggerUnit()
     local real CasterX = GetUnitX(caster)      // you should initialize your variables on their same declaration.
     local real CasterY = GetUnitY(caster)
     local real EffectX = GetSpellTargetX() // these are new functions in 1.24.  Use them instead of that location garbage.
     local real EffectY = GetSpellTargetY()
     local real offsetAngle = Atan2(EffectY - CasterY, EffectX - CasterX)
     
     local real time    = 60.00
     local real length  = 0.00
     
     local action new
     local timer t
     
     local integer i    = 0
     
        set time = 60.00
        loop
            set i      = i + 1
            exitwhen i == 12
            
            set new         = action.create()       //  move your allocator here, as you'll need multiple instances.
            set t           = NewTimer()            //  Set your timer here, instead.
            call SetTimerData(t, integer(new))
            set new.time    = time
            set new.caster  = caster
            set new.x       = EffectX + length * Cos(offsetAngle)            // you want a polar projection, not a simple "plus 10"
            set new.y       = EffectY + length * Sin(offsetAngle)
            set new.damage  = damage(GetUnitAbilityLevel(caster, SPELLID))   // set your damage here, instead of tracking the level.
            
            call TimerStart(t, 0.10, false, function action.LA)
            
            set time   = time - 5.00
            set length = length + 10.00
            
        endloop
        set caster = null
    endfunction
    
    private function C takes nothing returns boolean
        if GetSpellAbilityId() == SPELLID then
            call A()    // Embed your actions within the conditions
        endif
        return false    // return false because there's no reason to return true.
    endfunction
    
//*
//*
//* Initializer
//* ===========================================================================
    private function init takes nothing returns nothing     // "init" should be private.
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, Condition(function C))
    endfunction

endlibrary
 
Status
Not open for further replies.
Top