- Joined
- Aug 9, 2006
- Messages
- 2,384
This Script creates 8 rocks which !should! rotate and get faster and faster, but it does not work. And i have no Idea why.
JASS:
scope MagmaBarricade
public struct Data
real x1
real y1
real facing
integer RockCount = 0
unit array RockUnit [8]
unit MagmaCaster = GetTriggerUnit()
real y = GetUnitY(.MagmaCaster)
real x = GetUnitX(.MagmaCaster)
player MagmaCasterOwner = GetOwningPlayer(.MagmaCaster)
real cangle = 2
real knockbackr = 200
timer t = CreateTimer()
endstruct
function MagmaBarricadeConditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function MagmaBarricadeRotate takes nothing returns nothing
local Data kd
local integer count = 0
set kd.facing = 0
set kd.y = GetUnitY(kd.MagmaCaster)
set kd.x = GetUnitX(kd.MagmaCaster)
loop
exitwhen count == 8
set kd.x1 = kd.x + 100.00 * Cos((kd.facing + kd.cangle) * bj_DEGTORAD )
set kd.y1 = kd.y + 100.00 * Sin((kd.facing + kd.cangle) * bj_DEGTORAD )
call SetUnitPosition(kd.RockUnit[count], kd.x1, kd.y1)
set kd.facing = kd.facing + 45
set count = count + 1
endloop
set count = 0
if kd.cangle < 20 then
set kd.cangle = kd.cangle + 0.02
set kd.knockbackr = kd.knockbackr + 0.1
endif
if (GetUnitAbilityLevel(kd.MagmaCaster, 'B000') == 0) then
loop
exitwhen count == 8
call RemoveUnit(kd.RockUnit[count])
set count = count + 1
endloop
call kd.destroy()
endif
endfunction
function MagmaBarricadeSetUp takes nothing returns nothing
local Data kd = Data.create()
loop
exitwhen kd.RockCount == 8
set kd.x1 = kd.x + 100.00 * Cos(kd.facing * bj_DEGTORAD )
set kd.y1 = kd.y + 100.00 * Sin(kd.facing * bj_DEGTORAD )
call DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\DemolisherFireMissile\\DemolisherFireMissile.mdl", kd.x1, kd.y1))
set kd.RockUnit[kd.RockCount] = CreateUnit(kd.MagmaCasterOwner, 'n000', kd.x1, kd.y1, 0.00)
call SetUnitTimeScale(kd.RockUnit[kd.RockCount], 0 * 0.01)
set kd.RockCount = kd.RockCount + 1
set kd.facing = kd.facing + 45
endloop
call TimerStart(kd.t, 0.02, true, function MagmaBarricadeRotate)
endfunction
//===========================================================================
function InitTrig_MagmaBarricade takes nothing returns nothing
local integer index = 0
set gg_trg_MagmaBarricade = CreateTrigger( )
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_MagmaBarricade, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( gg_trg_MagmaBarricade, Condition( function MagmaBarricadeConditions ) )
call TriggerAddAction( gg_trg_MagmaBarricade, function MagmaBarricadeSetUp )
endfunction
endscope