MasterOfRa
New Member
- Reaction score
- 10
I am trying to add to my map, a event that on death, will give the player visibility. but also, when i use the restart command, remove it. I looked at the BJs, and did what i thought made sense, but it didnt work. is it not possible to store a fogmodifier to a variable? or should i just use a dummy unit or something?
JASS:
globals
fogmodifier array Fog
constant real MAP_SIZE = 23 * 128 - 100
endglobals
JASS:
library MagiDies initializer Init uses UnitProperties
//===========================================================================
private function Actions takes nothing returns nothing
local unit killee = GetDyingUnit()
local unit killer = GetKillingUnit()
local player owner = GetOwningPlayer(killee)
local MagiProperties data = GetUnitIndex(killee)
local properties prop = properties(GetUnitId(data.owner))
set data.owner = null
if GetUnitAbilityLevel(killer,AID_DEVOUR) == 0 then
if GetLocalPlayer() == owner then
call DisplayTextToPlayer(GetLocalPlayer(), 0.52, -1.00,"You have been Killed!")
else
call DisplayTextToPlayer(GetLocalPlayer(), 0.52, -1.00,GetPlayerName(owner)+" has been Killed!")
endif
endif
call prop.destroy()
call data.destroy()
call TriggerSleepAction(4.0)
call FogModifierStart(Fog[GetPlayerId(owner)])
set killee = null
set killer = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(trig,Player(0),EVENT_PLAYER_UNIT_DEATH,null)
call TriggerRegisterPlayerUnitEvent(trig,Player(1),EVENT_PLAYER_UNIT_DEATH,null)
call TriggerRegisterPlayerUnitEvent(trig,Player(2),EVENT_PLAYER_UNIT_DEATH,null)
call TriggerRegisterPlayerUnitEvent(trig,Player(3),EVENT_PLAYER_UNIT_DEATH,null)
call TriggerRegisterPlayerUnitEvent(trig,Player(4),EVENT_PLAYER_UNIT_DEATH,null)
call TriggerRegisterPlayerUnitEvent(trig,Player(5),EVENT_PLAYER_UNIT_DEATH,null)
call TriggerRegisterPlayerUnitEvent(trig,Player(6),EVENT_PLAYER_UNIT_DEATH,null)
call TriggerRegisterPlayerUnitEvent(trig,Player(7),EVENT_PLAYER_UNIT_DEATH,null)
call TriggerAddAction(trig,function Actions)
endfunction
endlibrary
JASS:
library Init initializer Init uses Globals, Waves
globals
private real AngleDelta
endglobals
private function CreateStuff takes nothing returns nothing
local MagiProperties prop
local integer count = 0
local unit u
local real x
local real y
local real angle = 0
set Magi = 0
set AngleDelta = 360/CountPlayers()
call TriggerSleepAction(001)
loop
if GetPlayerSlotState(Player(count)) == PLAYER_SLOT_STATE_PLAYING then
call SetPlayerState(Player(count),PLAYER_STATE_RESOURCE_GOLD,0)
set x = GetStartLocationX(GetPlayerStartLocation(Player(count)))
set y = GetStartLocationY(GetPlayerStartLocation(Player(count)))
set u = CreateUnit(Player(count),UID_MAGI,x+300*CosBJ(angle),y+300*SinBJ(angle),angle-200)
set magi[count] = u
call CreateUnitProperties(u)
call UnitSetMaxLife (u,100)
call UnitSetMaxMana (u,1000)
call UnitSetMoveSpeed (u,300)
set prop = GetUnitIndex(u)
set prop.owner = u
set prop.manaGen = 35
set prop.lifeGen = 0.7
set MagiProperties<u> = prop
set angle = angle + AngleDelta
set Magi = Magi + 1
endif
set count = count + 1
exitwhen count >= MAX_MAGI
endloop
endfunction
function Restart takes nothing returns nothing
local properties prop
local MagiProperties data
local group g = NewGroup()
local unit u
local integer count = 0
call Waves_Restart()
loop
call FogModifierStop(Fog[count])
if magi[count] != null then
set prop = GetUnitId(magi[count])
set data = GetUnitIndex(magi[count])
set data.owner = null
call prop.destroy()
call data.destroy()
call RemoveUnit(magi[count])
set Magi = Magi - 1
endif
set count = count + 1
exitwhen count >= MAX_MAGI
endloop
call GroupEnumUnitsInRange(g,0,0,6000,Filter_Alive())
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g,u)
call RemoveUnit(u)
endloop
call CreateStuff()
endfunction
private function Init takes nothing returns nothing
local trigger trig = NewTrigger()
local integer count = 0
local integer x = 0
local integer y
call TriggerRegisterPlayerChatEvent( trig , Player(0), "-game.restart" , true )
call TriggerAddAction( trig , function Restart)
set trig = null
loop
set magi[count] = null
set count = count + 1
set Fog[count] = CreateFogModifierRadius(Player(count),FOG_OF_WAR_VISIBLE,0,0,MAP_SIZE,true,false)
exitwhen count >= MAX_MAGI
endloop
call CreateStuff()
endfunction
endlibrary</u>