HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

trigger question

06-14-2002, 04:51 PM#1
Guest
ive been looking through one of my maps and i decided that i would liek to change the leaderboared from gold to kills...iand I remembered most of the Towers D had this...so i went lookign through it, all i found relating to kills is an variable array which is set to 0 for all players...does this autoincriment eerytime a unit of the other team dies? Or is there a script that i bypassed that says if unit owned by player x dies, add 1 to killsarray[number of the killing person]?
anyways, reply back soon
[Noxz]
06-14-2002, 05:46 PM#2
Guest
I figured it by myself...after like 5 min of debugging a diff map i made i figures it out:
For a perfect kill counter make a variable called KillsArray which is an integer array, and paste the foloowing code for player 12 beign the ofender:

function Trig_piggy_dies_Copy_Actions takes nothing returns nothing
set udg_KillsArray[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))] = ( udg_KillsArray[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))] + 1 )
endfunction

//===========================================================================
function InitTrig_piggy_dies_Copy takes nothing returns nothing
set gg_trg_piggy_dies_Copy = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_piggy_dies_Copy, Player(11), EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_piggy_dies_Copy, function Trig_piggy_dies_Copy_Actions )
endfunction





thats for the adding...and for the leader bored:

function Trig_update_Copy_Func001003001 takes nothing returns boolean
return ( GetPlayerSlotState(ConvertedPlayer(GetForLoopIndexA())) == PLAYER_SLOT_STATE_PLAYING )
endfunction

function Trig_update_Copy_Func001003002 takes nothing returns nothing
call LeaderboardSetPlayerItemValueBJ( ConvertedPlayer(GetForLoopIndexA()), GetLastCreatedLeaderboard(), udg_KillsArray[GetForLoopIndexA()] )
endfunction

function Trig_update_Copy_Func001003003 takes nothing returns nothing
call LeaderboardRemovePlayerItemBJ( ConvertedPlayer(GetForLoopIndexA()), GetLastCreatedLeaderboard() )
endfunction

function Trig_update_Copy_Func001003 takes nothing returns nothing
if ( Trig_update_Copy_Func001003001() ) then
call Trig_update_Copy_Func001003002()
else
call Trig_update_Copy_Func001003003()
endif
endfunction

function Trig_update_Copy_Actions takes nothing returns nothing
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 11
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call Trig_update_Copy_Func001003()
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
call LeaderboardSortItemsBJ( GetLastCreatedLeaderboard(), bj_SORTTYPE_SORTBYVALUE, false )
endfunction

//===========================================================================
function InitTrig_update_Copy takes nothing returns nothing
set gg_trg_update_Copy = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_update_Copy, 0.50 )
call TriggerAddAction( gg_trg_update_Copy, function Trig_update_Copy_Actions )
endfunction



basicly all that these trigegrs do is this:
event- A unit owned by player 12 dies
actions- set killsarray[player number of(owner of(attacking unit))] = killsarray[player number of(owner of(attacking unit))] +1
and the leaderbored was just updating and really isnt needed...


[Noxz]
06-15-2002, 05:17 AM#3
3DGuy
Hang out on the IRC
irc.gamerscafe.net #wc3campaigns
This is where all the L337 coders are
06-15-2002, 02:49 PM#4
Guest
dude, it ownt let me, sayign that i have an insecure proxy, si there another server thats linked to it?
[Noxz]
06-15-2002, 03:01 PM#5
Silent Avenger
irc.draconia.net
06-15-2002, 07:46 PM#6
Guest
nope, it still says i have an insecure proxy or whatever...and im too lazy to get one installed..so find a diff one that doesnt check on that shit cuz most irc channels im allowed on
[Noxz]
06-19-2002, 11:36 PM#7
Guest
I basically reverse-translated this code into the retail trigger editor like such (and it works):

---------------------------------
TRIGGER: Kill Counter

EVENT:

Unit - A Unit owned by player 12 (brown) dies

ACTION:

Set a_nKills[(Player number of(Owner of (killing unit)))] = a_nKills[(Player number of(Owner of (killing unit)))] +1
---------------------------------

I'll leave it up to you how to figure out how to update the leaderboard with that info... I just set an event to occur every 1 second that loops thru all the players and changes their value