- Joined
- Oct 24, 2012
- Messages
- 6,545
get killing unit doesnt work right can anyone see y ?
JASS:
function Trig_Battlegrounds_Kills_Actions takes nothing returns nothing
local integer i
local integer p
local integer v
local integer c
local boolean b
local unit u
local multiboarditem mbi
local string color = "|r"
local region r
local unit ku
set u = GetTriggerUnit()
set p = GetPlayerId( GetOwningPlayer( u ) )
set ku = GetKillingUnit()
set v = GetUnitPointValue( u )
set b = false
set r = CreateRegion()
call RegionAddRect( r, gg_rct_King_of_the_Battlegrounds )
if p == 0 then // player 0
set i = 2
set c = 0
elseif p == 1 then // player 1
set i = 3
set c = 1
elseif p == 2 then // player 2
set i = 4
set c = 2
elseif p == 3 then // player 3
set i = 5
set c = 3
elseif p == 11 then // player 11
set i = 1
set c = 6
endif
if ( u == Selected_Hero_Player ) then
set b = true
endif
if ( (IsUnitInGroup( u, Battlegrounds_Group_Player ) or u == Selected_Hero_Player) and IsUnitInRegion( r, u ) ) then
set Battlegrounds_Counter_Player = Battlegrounds_Counter_Player - v
if ( IsUnitInGroup( u, Battlegrounds_Group_Player ) and IsUnitInRegion( r, u ) == true and b == false ) then
call GroupRemoveUnit( Battlegrounds_Group_Player, u )
endif
set Lumber_Income_Player = Lumber_Income_Player + ( v / 2 )
set mbi = MultiboardGetItem( battlegroundsMultiboard, 2, i )
call MultiboardSetItemValue( mbi, playerColors[c] + I2S(Battlegrounds_Counter_Player) + color )
endif
if ku == Selected_Hero_Player then
set Hero_Kills_Player = Hero_Kills_Player + 1
call DisplayTextToForce( GetPlayersAll(), "hero kills" )
set mbi = MultiboardGetItem( battlegroundsMultiboard, 1, i )
call MultiboardSetItemValue( mbi, playerColors[c] + I2S(Hero_Kills_Player) + color )
endif
call TriggerExecute( trg_Battlegrounds_Leader_Checker )
set u = null
set ku = null
set r = null
set mbi = null
set color = null
endfunction
//===========================================================================
function InitTrig_Battlegrounds_Kills takes nothing returns nothing
local trigger t
set t = CreateTrigger()
call TriggerRegisterPlayerUnitEvent( t, Player(0), EVENT_PLAYER_UNIT_DEATH, null )
call TriggerRegisterPlayerUnitEvent( t, Player(1), EVENT_PLAYER_UNIT_DEATH, null )
call TriggerRegisterPlayerUnitEvent( t, Player(11), EVENT_PLAYER_UNIT_DEATH, null )
call TriggerAddAction( t, function Trig_Battlegrounds_Kills_Actions )
set t = null
endfunction