- Joined
- Jul 29, 2007
- Messages
- 5,174
Well, I changed my shooting system and also created a new spell and they both have all kind of weird errors that just can't be true.
I searched for any mistakes because I know that the WE is a noobish thing and it creates tons of new errors when it gets a real error but I couldn't find anything.
Here are both of the scripts
Shooting
Lightning Storm
The lightning storm just basicly makes a few dummies that look like clouds, and then every 3 seconds create a dummy unit at a random place near the target area that looks like lightning and damages the area he was created in.
I searched for any mistakes because I know that the WE is a noobish thing and it creates tons of new errors when it gets a real error but I couldn't find anything.
Here are both of the scripts
Shooting
JASS:
function Shoot_Con takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function TimerActions takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit summon = GetHandleUnit(t, "summon" )
local integer i = GetHandleInt(t, "i" )
local real a = GetUnitFacing(summon) * bj_DEGTORAD
local real x = GetUnitX(summon) + 20 * Cos(a)
local real y = GetUnitY(summon) + 20 * Sin(a)
// start of summon height
local real height = GetHandleReal(t, "height")
local real distance = GetHandleReal(t, "distance")
local real currentheight = GetUnitFlyHeight(summon)
call SetUnitFlyHeight(summon, currentheight+height/(distance/10))
// end of summon height
call SetUnitPosition( summon, x, y )
if i >= 100 then
call FlushHandleLocals(t)
call DestroyTimer(t)
call KillUnit(summon)
else
call SetHandleInt(t, "i", i + 1)
endif
set t = null
set summon = null
endfunction
function Shoot takes nothing returns nothing
local timer t = CreateTimer()
local unit u = GetTriggerUnit()
local real a = GetUnitFacing(u) * bj_DEGTORAD
local real x = GetUnitX(u) + 50 * Cos(a)
local real y = GetUnitY(u) + 50 * Sin(a)
local integer i = 0
local unit summon = CreateUnit(GetOwningPlayer(u), 'h000', x, y, GetUnitFacing(u))
// start of target location height check
local location oldloc = Location(x,y)
local location loc = GetSpellTargetLoc()
local real oldx = GetLocationX(loc)
local real oldy = GetLocationY(loc)
local real oldheight = GetLocationZ(oldloc)
local real height = GetLocationZ(loc)
local real distance = DistanceBetweenPointsXY(oldx,oldy,x,y)
set height = height-oldheight
call SetHandleReal(t, "height", height)
call SetHandleReal(t, "distance", distance)
// end of target location height check
call SetHandleHandle( t, "summon", summon )
call SetHandleInt( t, "i", i )
call TimerStart( t, 0.02, true, function TimerActions )
set t = null
set u = null
set summon = null
set oldloc = null
set loc = null
endfunction
//===========================================================================
function InitTrig_Shooting_System takes nothing returns nothing
set gg_trg_Shooting_System = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Shooting_System, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Shooting_System, Condition( function Shoot_Con ) )
call TriggerAddAction( gg_trg_Shooting_System, function Shoot )
endfunction
Lightning Storm
JASS:
function Trig_LightningStorm_Cons takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
endfunction
function TimerActionsLightningStorm takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetHandleUnit(t, "caster")
local real oldx = GetHandleReal(t, "x")
local real oldy = GetHandleReal(t, "y")
local location oldloc = Location(oldx,oldy)
local location loc = PolarProjectionBJ(oldloc, GetRandomReal(0, 350.00), GetRandomReal(0, 359.00))
local real x = GetLocationX(loc)
local real y = GetLocationY(loc)
local unit lightningbolt = CreateUnit(GetOwningPlayer(u), 'h002', x, y, 0)
local integer i = GetHandleInt(t, "i")
call UnitDamagePoint(u, 0, 50, x, y, 100, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_LIGHTNING, WEAPON_TYPE_WHOKNOWS)
call UnitApplyTimedLife( 0.50, 'BTLF', lightningbolt )
if i >= 10 then
call FlushHandleLocals(t)
call DestroyTimer(t)
else
call SetHandleInt(t, "i", i + 1)
endif
set t = null
set u = null
set lightningbolt = null
set oldloc = null
set loc = null
endfunction
function Trig_LightningStorm_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local location loc = GetSpellTargetLoc()
local real x = GetLocationX(loc)
local real y = GetLocationY(loc)
local timer t = CreateTimer()
local integer i = 0
local integer int = 0
call SetHandleInt(t, "i", i)
call SetHandleHandle(t, "caster", u)
call SetHandleReal(t, "x", x)
call SetHandleReal(t, "y", y)
loop
exitwhen int > 5
call CreateNUnitsAtLoc( 1, 'h001', GetOwningPlayer(GetTriggerUnit()), PolarProjectionBJ(GetRectCenter(GetPlayableMapRect()), GetRandomReal(0, 300.00), GetRandomReal(0, 359.00)), bj_UNIT_FACING )
call UnitApplyTimedLife( 30, 'BTLF', GetLastCreatedUnit() )
set int = int+1
endloop
call TimerStart(t, 3, true, function TimerActionsLightningStorm)
set u = null
set loc = null
set t = null
endfunction
//===========================================================================
function InitTrig_Lightning_Storm takes nothing returns nothing
set gg_trg_LightningStorm = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_LightningStorm, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_LightningStorm, Condition( function Trig_LightningStorm_Cons ) )
call TriggerAddAction( gg_trg_LightningStorm, function Trig_LightningStorm_Actions )
endfunction
The lightning storm just basicly makes a few dummies that look like clouds, and then every 3 seconds create a dummy unit at a random place near the target area that looks like lightning and damages the area he was created in.