- Joined
- May 4, 2007
- Messages
- 2,260
Hi all. Well, I am making a funny spell, called "Stupid penguin".
The idea is simple - we create a penguin, and because the penguin is really stupid and only wonders around the map .... we make him grow and kill him !! BOOMM damaging all nearby foes... (lol).
The more you channel the more damage you can deal .... stupid penguin =P
Problem is, I have this weird message error, and I dunno why =S
I am trying to finish the spell, to make it JESP, so the code is not much clean by now ....
I also notest only 1 unit gets affected .... and i don't know why ...
Can you guys help me out please ?
For the sake of the penguin !!! =P
Oh, and I have this error screen shot =S
Can you guys help me out please ?
The idea is simple - we create a penguin, and because the penguin is really stupid and only wonders around the map .... we make him grow and kill him !! BOOMM damaging all nearby foes... (lol).
The more you channel the more damage you can deal .... stupid penguin =P
Problem is, I have this weird message error, and I dunno why =S
I am trying to finish the spell, to make it JESP, so the code is not much clean by now ....
I also notest only 1 unit gets affected .... and i don't know why ...
Can you guys help me out please ?
For the sake of the penguin !!! =P
JASS:
scope StupidPenguin initializer Init
private struct Mystruct
unit caster = GetTriggerUnit()
unit penguin
integer level
real currentScale = 1
timer t = CreateTimer()
real grow
trigger end = CreateTrigger()
triggeraction endAction
triggercondition endCondition
endstruct
//!=========================================================================!\\
//!============================SETUP START==================================!\\
//!=========================================================================!\\
globals
private constant integer AID = 'A000' //ability ID
private constant integer UNITID = 'npng'
endglobals
private constant function GrowTime takes integer level returns integer time
return 1 + (level * 0)
endfunction
private constant function Growth takes integer level returns real grow
return 0.3 * level
endfunction
private constant function Radius takes integer level returns integer radius
return 400 + (50 * level)
endfunction
private function Targets takes nothing returns boolean
local Mystruct data = GetTriggerStructA(GetTriggeringTrigger()) //you should ignore this
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(data.caster))
endfunction
//!=========================================================================!\\
//!============================SETUP END====================================!\\
//!=========================================================================!\\
//==========================================================================
private function End_Conds takes nothing returns boolean
return GetSpellAbilityId() == AID
endfunction
//==========================================================================
private function End_Acts takes nothing returns nothing
//catches the trigger and runs this function
local Mystruct data = GetTriggerStructA(GetTriggeringTrigger())
local group g = CreateGroup()
local unit f
local boolexpr b = Condition(function Targets)
call KillUnit(data.penguin)
call GroupEnumUnitsInRange(g, GetUnitX(data.penguin), GetUnitY(data.penguin), Radius(data.level), b)
loop
set f = FirstOfGroup(g)
exitwhen (f == null)
call UnitDamageTarget(data.penguin, f, data.currentScale + 100, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
endloop
call DestroyGroup(g)
call DestroyBoolExpr(b)
set b = null
set g = null
//removes the created trigger in the Code_acts function
call TriggerRemoveCondition(data.end,data.endCondition)
call TriggerRemoveAction(data.end,data.endAction)
call DestroyTrigger(data.end)
call ClearTriggerStructA(data.end)
//stops the repeator timer and ends the spell once and for all
call PauseTimer(data.t)
call DestroyTimer(data.t)
call ClearTimerStructA(data.t)
call data.destroy()
endfunction
//==========================================================================
private function Size takes nothing returns nothing
//catches the expired timer and runs this function
local Mystruct data = GetTimerStructA(GetExpiredTimer())
local group g
local unit f
local boolexpr b = Condition(function Targets)
if(GetWidgetLife(data.penguin) > 0.405) then
call SetUnitScale(data.penguin, data.currentScale + data.grow, data.currentScale + data.grow, data.currentScale + data.grow)
set data.currentScale = data.currentScale + data.grow
else
set g = CreateGroup()
call GroupEnumUnitsInRange(g, GetUnitX(data.penguin), GetUnitY(data.penguin), Radius(data.level), b)
loop
set f = FirstOfGroup(g)
exitwhen (f == null)
call UnitDamageTarget(data.penguin, f, data.currentScale + 100, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
endloop
call DestroyGroup(g)
endif
call DestroyBoolExpr(b)
set b = null
set g = null
endfunction
//==========================================================================
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == AID
endfunction
//===========================================================================
private function Actions takes nothing returns nothing
local Mystruct data = Mystruct.create()
local location loc = GetSpellTargetLoc()
set data.grow = Growth(GetUnitAbilityLevel(data.caster, AID))
set data.penguin = CreateUnit(GetOwningPlayer(data.caster), UNITID, GetLocationX(loc), GetLocationY(loc), 0)
set data.level = GetUnitAbilityLevel(data.caster, AID)
call SetTimerStructA(data.t, data)
call TimerStart(data.t, GrowTime(GetUnitAbilityLevel(data.caster, AID)), true, function Size)
call RemoveLocation(loc)
set loc = null
//creates the trigger that will end the spell when the hero stops channeling
call SetTriggerStructA(data.end, data)
call TriggerRegisterAnyUnitEventBJ( data.end, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
set data.endCondition = TriggerAddCondition( data.end, Condition( function End_Conds ) )
set data.endAction = TriggerAddAction( data.end, function End_Acts )
endfunction
//===========================================================================
private function Init takes nothing returns nothing
set gg_trg_Stupid_Penguin = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Stupid_Penguin, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
call TriggerAddCondition( gg_trg_Stupid_Penguin, Condition( function Conditions ) )
call TriggerAddAction( gg_trg_Stupid_Penguin, function Actions )
endfunction
endscope
Oh, and I have this error screen shot =S
Can you guys help me out please ?