| 07-20-2007, 02:08 AM | #1 |
I cannot even get this spell's timer to start...The spell is suppose to spin the unit around the caster with a lightning added for some eyecandy. The spell is based off of stampede. JASS://*********************************************************************************************** //*********************************************************************************************** // Joker(Div) Spellpack #1 // Author: Created By: Joker(Div) // Function: Lightning Whirl //*********************************************************************************************** //*********************************************************************************************** //********************************************************************************************** // Constant Functions //********************************************************************************************** constant function Lightning_Whirl_AbilityId takes nothing returns integer /////////////////////////////// return 'A003' //The Spell ID of the Ability// /////////////////////////////// endfunction constant function Lightning_Whirl_KnockbackDust takes nothing returns string ///////////////////////////// //The Knockback Dust String// ///////////////////////////// return "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl" endfunction constant function Lightning_Whirl_TimerInterval takes nothing returns real //////////////////////////////////////// return 0.02 //The Interval in which the timer runs// //////////////////////////////////////// endfunction constant function Lightning_Whirl_MaxSpin takes nothing returns real /////////////////////////////////////////////////////// return 360. //The Amount of Degrees that you will turn the target// //Higher the Number, the More You will Turn the Unit // /////////////////////////////////////////////////////// endfunction constant function Lightning_Whirl_LightningType takes nothing returns string ///////////////////////////// return "CLPB" //The Lightning Type String// ///////////////////////////// endfunction constant function Lightning_Whirl_MovementDivider takes nothing returns real /////////////////////////////////////////////////////////////// return 50. //The Amount That Divides the Speed of the Knockback. // //The Higher it is, the Slower the Movement Will be. // /////////////////////////////////////////////////////////////// endfunction constant function Lightning_Whirl_FacingInterval takes nothing returns real ///////////////////////////////////////////////////////////// return 10. //The Interval in Which the Target will rotate. // //The spin will be smoother if you lower this. (but slower)// ///////////////////////////////////////////////////////////// endfunction constant function Lightning_Whirl_OrderId takes nothing returns string ///////////////////////////// //The Order Id of the Spell// ///////////////////////////// return "stampede" endfunction constant function Lightning_Whirl_DamageAmplifier takes nothing returns real //////////////////////////////////////////////////////////////////////// return 1. //This Will be Multiplied to the Level of the Ability to // //Allow More Damage if Wanted. Multiply by 50 (Unless you changed the// //Timer Interval) to Get the Damage per Second // //////////////////////////////////////////////////////////////////////// endfunction //********************************************************************************************** // Lightning Whirl //********************************************************************************************** globals timer LW_Timer = CreateTimer() integer LW_Total = 0 LW_struct array LW_Ar endglobals struct LW_struct unit a unit b integer lvl boolean LWdestroy real spin_duration lightning l real f real dist endstruct function Lightning_Whirl_Conditions takes nothing returns boolean return GetSpellAbilityId() == Lightning_Whirl_AbilityId() endfunction function Lightning_Whirl_Effect takes nothing returns nothing local integer i = 0 local LW_struct dat local unit a local unit b local integer lvl local real ax local real ay local real bx local real by local real f loop call BJDebugMsg("2") exitwhen i == LW_Total set dat = LW_Ar[i] if dat.LWdestroy then set LW_Total = LW_Total - 1 set LW_Ar[i] = LW_Ar[ LW_Total ] call IssueImmediateOrder(a, "stop") call DestroyLightning(dat.l) call dat.destroy() set i = i - 1 else call BJDebugMsg("3") if dat.spin_duration < Lightning_Whirl_TimerInterval() then call BJDebugMsg("4") set a = dat.a set b = dat.b if GetUnitCurrentOrder(a) == OrderId(Lightning_Whirl_OrderId()) then set lvl = dat.lvl set ax = GetUnitX(a) set ay = GetUnitY(a) set f = GetUnitFacing(b)+Lightning_Whirl_FacingInterval() set bx = GetUnitX(b) + dat.dist/Lightning_Whirl_MovementDivider() * Cos(f * 0.017453) set by = GetUnitY(b) + dat.dist/Lightning_Whirl_MovementDivider() * Sin(f * 0.017453) set dat.spin_duration = dat.spin_duration + Lightning_Whirl_FacingInterval() call UnitDamageTarget(a, b, lvl, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_MAGIC, null ) if GetUnitX(b) > GetRectMaxX(bj_mapInitialPlayableArea) then call SetUnitX(b, GetRectMaxX(bj_mapInitialPlayableArea) ) set dat.LWdestroy = true elseif GetUnitX(b) < GetRectMinX(bj_mapInitialPlayableArea) then call SetUnitX(b, GetRectMinX(bj_mapInitialPlayableArea) ) set dat.LWdestroy = true elseif GetUnitX(b) > GetRectMaxY(bj_mapInitialPlayableArea) then call SetUnitY(b, GetRectMaxY(bj_mapInitialPlayableArea) ) set dat.LWdestroy = true elseif GetUnitX(b) < GetRectMinY(bj_mapInitialPlayableArea) then call SetUnitY(b, GetRectMinY(bj_mapInitialPlayableArea) ) set dat.LWdestroy = true endif call MoveLightning( dat.l, true, ax, ay, bx, by ) endif else set dat.LWdestroy = true endif endif if LW_Total == 0 then call BJDebugMsg("E") call PauseTimer(LW_Timer) endif set a = null set b = null endloop endfunction function Lightning_Whirl_Actions takes nothing returns nothing local unit a local real ax local real ay local unit b local real bx local real by local real x local real y local LW_struct dat if GetSpellTargetUnit() == null then call SimError( GetOwningPlayer(GetTriggerUnit()), "Must target a unit." ) else set a = GetTriggerUnit() set ax = GetUnitX(a) set ay = GetUnitY(a) set b = GetSpellTargetUnit() set bx = GetUnitX(b) set by = GetUnitY(b) set dat = LW_struct.create() set dat.a = a set dat.b = b set dat.lvl = GetUnitAbilityLevel( a, Lightning_Whirl_AbilityId() ) set dat.spin_duration = 0 set dat.l = AddLightning( Lightning_Whirl_LightningType(), true, ax, ay, bx, by ) set dat.f = bj_RADTODEG * Atan2( by-ay, bx-ax ) set LW_Ar[ LW_Total ] = dat set LW_Total = LW_Total + 1 set x = bx-ax set y = by-ay set dat.dist = SquareRoot(x*x+y*y) call SetUnitFacing(dat.b, dat.f ) call BJDebugMsg("S") if LW_Total == 0 and GetUnitCurrentOrder(a) == OrderId(Lightning_Whirl_OrderId()) then call BJDebugMsg("1") call TimerStart( LW_Timer, Lightning_Whirl_TimerInterval(), true, function Lightning_Whirl_Effect ) endif endif set a = null set b = null endfunction //=========================================================================== function InitTrig_Lightning_Whirl takes nothing returns nothing local integer i = 0 set gg_trg_Lightning_Whirl = CreateTrigger() loop call TriggerRegisterPlayerUnitEvent( gg_trg_Lightning_Whirl, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null ) exitwhen i == 11 set i = i + 1 endloop call TriggerAddCondition( gg_trg_Lightning_Whirl, Condition( function Lightning_Whirl_Conditions ) ) call TriggerAddAction( gg_trg_Lightning_Whirl, function Lightning_Whirl_Actions ) endfunction |
| 07-20-2007, 03:25 AM | #2 |
First problem - you messed up your indenting near the end of the function. Second problem - near the end of lightning_whirl_effect you have the line 'call IssueImmediateOrder(a, "stop")'. The variable a is not guaranteed to be initialized here. Third problem - don't use a and b for unit variables. u, v, w make a lot more sense. |
| 07-21-2007, 12:44 AM | #3 |
Ok your 1st and 3rd comments are not even close to being helpful. You are right about the 2nd though |
