- Joined
- Sep 20, 2015
- Messages
- 385
Hello as title says i want to make fire spread on my map. The fire effect is a unit with immolation so it burns nearby enemies and negative HP regen so it destroy itslef.
I used OE filed to achieve this becasue i think it's better than trigger these effects.
The fire spread is made by creating a fire unit next to another if the terrain type is grass.
The first tirgger is the one that start the effect, and is activated whenever a fire unit enters the map.
When a fire unit dies it changes the terrain to another type of grass(burned grass).
The problem is that the timer does not paused when there are no fire units in the map.
Also i don't know why only 7 fire units are created instead of 8.
Thanks in advance fo the help.
EDIT: I fixed the deg to rad thing. Now my concern is that i keep getting the fire spread off message if i test it with player 2,3,4....
I used OE filed to achieve this becasue i think it's better than trigger these effects.
The fire spread is made by creating a fire unit next to another if the terrain type is grass.
The first tirgger is the one that start the effect, and is activated whenever a fire unit enters the map.
JASS:
globals
group array FireUnitGroup
effect treeburnfx
integer spreadint
endglobals
function DestAoeDmgFireDOT takes nothing returns nothing
if IsDestructableAlive(GetEnumDestructable()) and IsDestructableTree(GetEnumDestructable()) then
//set treeburnfx = AddSpecialEffectLocBJ( GetDestructableLoc(GetEnumDestructable()), "Environment\\LargeBuildingFire\\LargeBuildingFire2.mdl" )
//call BlzSetSpecialEffectZ( treeburnfx, ( BlzGetLocalSpecialEffectZ(treeburnfx) + 200.00 ) )
call SetDestructableAnimation( GetEnumDestructable(), " stand hit")
call SetDestructableLife( GetEnumDestructable(), ( GetDestructableLife(GetEnumDestructable()) - 10) )
endif
endfunction
function fireunitactions takes nothing returns nothing
local unit pfu = GetEnumUnit()
local real frx = GetUnitX(GetEnumUnit())
local real fry = GetUnitY(GetEnumUnit())
local real frz = BlzGetUnitZ(GetEnumUnit())
local integer i = spreadint //GetPlayerId(GetOwningPlayer(GetEnumUnit()))
local real angle = 0
local real nfrx
local real nfry
local group tfg
loop
exitwhen(angle > 360)
if angle == 0 or angle == 90 or angle == 180 or angle == 270 then
set nfrx= frx + 129*Cos(angle)
set nfry= fry + 129*Sin(angle)
endif
if angle == 45 or angle == 135 or angle == 225 or angle == 315 then
set nfrx= frx + 181*Cos(angle*bj_DEGTORAD)
set nfry= fry + 181*Sin(angle*bj_DEGTORAD)
endif
set tfg = GetUnitsInRangeOfLocMatching(100, Location(nfrx,nfry), Condition( function fireunitbool) )
if CountUnitsInGroup(tfg) == 0 and GetTerrainType(nfrx, nfry) == 'Fgrd' then
call CreateUnitAtLoc( Player(i), 'n005', Location(nfrx, nfry), 0. )
endif
call SetUnitLifeBJ(pfu, ( GetUnitStateSwap(UNIT_STATE_LIFE, pfu) - 2 ) )
call DestroyGroup(tfg)
set angle = angle + 45
endloop
// D E S T R F I R E DOT D A M A G E
call EnumDestructablesInCircleBJ( 100.00, Location(frx,fry), function DestAoeDmgFireDOT )
endfunction
function fireunitpick1 takes nothing returns boolean
local integer i = spreadint
return ( GetOwningPlayer(GetFilterUnit()) == Player(i) )
endfunction
function FireSpreadLoop takes nothing returns nothing
local integer i = spreadint
set FireUnitGroup[i] = GetUnitsInRectMatching(GetPlayableMapRect(), And(Condition(function fireunitpick1), Condition(function fireunitbool)) )
if CountUnitsInGroup(FireUnitGroup[i]) > 0 then
call ForGroupBJ(FireUnitGroup[i],function fireunitactions)
endif
if CountUnitsInGroup(FireUnitGroup[i]) == 0 then
call PauseTimer(udg_FireSpreadTimer[i])
call DisplayTextToForce( GetPlayersAll(), "SpreadFireOFF " + I2S(i) )
//call DestroyEffect(treeburnfx)
endif
call DestroyGroup(FireUnitGroup[i])
endfunction
function Trig_FirespreadJASS_Actions takes nothing returns nothing
local integer i = GetPlayerId(GetOwningPlayer(GetEnteringUnit()))
local unit eu = GetEnteringUnit()
set spreadint = i
if GetUnitTypeId(eu) == 'n005' and GetOwningPlayer(eu) == Player(i) then
call DisplayTextToForce( GetPlayersAll(), "SpreadFireON " + I2S(i) )
call GroupAddUnit(FireUnitGroup[i], eu)
//call EnableTrigger( gg_trg_FireSpreadonYellowGrass )
//call DisableTrigger( GetTriggeringTrigger() )
call TimerStart( udg_FireSpreadTimer[i], 0.60, true,function FireSpreadLoop)
endif
endfunction
//===========================================================================
function InitTrig_FirespreadJASS takes nothing returns nothing
set gg_trg_FirespreadJASS = CreateTrigger( )
//call DisableTrigger( gg_trg_FirespreadJASS )
call TriggerRegisterEnterRectSimple( gg_trg_FirespreadJASS, GetPlayableMapRect() )
call TriggerAddAction( gg_trg_FirespreadJASS,function Trig_FirespreadJASS_Actions )
endfunction
When a fire unit dies it changes the terrain to another type of grass(burned grass).
JASS:
function Trig_FireUnitDie_Actions takes nothing returns nothing
local real dfux = GetUnitX(GetDyingUnit())
local real dfuy = GetUnitY(GetDyingUnit())
if GetUnitTypeId(GetDyingUnit()) == 'n005' then
if GetTerrainType(dfux, dfuy) == 'Fgrd' or GetTerrainType(dfux, dfuy) == 'Lgrd' then
call SetTerrainType(dfux, dfuy, 'Jgsb', -1, 1, 0)
endif
endif
endfunction
//===========================================================================
function InitTrig_FireUnitDie takes nothing returns nothing
set gg_trg_FireUnitDie = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_FireUnitDie, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_FireUnitDie, function Trig_FireUnitDie_Actions )
endfunction
The problem is that the timer does not paused when there are no fire units in the map.
Also i don't know why only 7 fire units are created instead of 8.
Thanks in advance fo the help.
EDIT: I fixed the deg to rad thing. Now my concern is that i keep getting the fire spread off message if i test it with player 2,3,4....
Last edited: