Assistance System 1.20
A completely customizable assistance system.
A completely customizable assistance system.
What is an Assistance System you ask? Well quite simply, when you have allies on your team with heroes, and more often, when the game is specifically designed to just use heroes, people can get angry when they help to get hero kills yet reap no reward for doing so. This system allows you to display who helped make kills, record how many times each player has done so, and divvy out rewards for said help.
Read Me:
Assistance System 1.20
by: emjlr3
Setup is very simple. Just copy the AssistanceSystem trigger to your map. If you do not have the GetPlayerNameColored library, you must copy that over too, but if you already have that trigger you do not need to.
Save your map. if it saves, everything is ready, if not, delete it all and try again. Once it saves, go through the Config. options and set them to whatever you want.
To use the system, simply call:
AssistanceSystem_Register(unit to register)
to allow players who help kill that unit to get assists for doing so.
The system is then loaded for that unit. You can only do this once per unit, and doing so more often will result in error messages.
The system stores the number of assists a unit has in the integer array AssitanceSystem_Assists[playerid]
This system is not MUI currently, it is PUI. Only 1 unit can be registered per player.
And that is all, the system is setup, and your heroes are registered. Enjoy!
by: emjlr3
Setup is very simple. Just copy the AssistanceSystem trigger to your map. If you do not have the GetPlayerNameColored library, you must copy that over too, but if you already have that trigger you do not need to.
Save your map. if it saves, everything is ready, if not, delete it all and try again. Once it saves, go through the Config. options and set them to whatever you want.
To use the system, simply call:
AssistanceSystem_Register(unit to register)
to allow players who help kill that unit to get assists for doing so.
The system is then loaded for that unit. You can only do this once per unit, and doing so more often will result in error messages.
The system stores the number of assists a unit has in the integer array AssitanceSystem_Assists[playerid]
This system is not MUI currently, it is PUI. Only 1 unit can be registered per player.
And that is all, the system is setup, and your heroes are registered. Enjoy!
System Code:
JASS:
library AssistanceSystem initializer Init_AssistanceSystem, needs GetPlayerNameColored
//=====Assistance System 1.20=====\\
globals
// Configuration Options:
private constant real Time = 10. // Time after latest damage after which no more assistance given
private constant integer Award = 125 // Bonus gold for getting an assist
private constant boolean Split = true // Whether to split award gold between all players who get an assist
private constant string Msg1 = "With assistance from " // Starting portion of assistance message
private constant string Msg2 = " gold!" // Message after the amount of gold is displayed
private constant string Msg3 = " gold a piece!" // Same as above, except for multiple assisters
private constant string GoldColor = "" // Color code for the color you would like the bounty value displayed in
//=====Don't touch past this point=====\\
private unit array Targets
private timer array Timers
private timer array T
private trigger Trigger1 = CreateTrigger()
private trigger Trigger2 = CreateTrigger()
private group Heroes = CreateGroup()
private integer Skip
private integer Total
public integer array Assists // Can be accessed publically as AssistanceSystem_Assists[playerid]
endglobals
//*************************************************************************
private function Reset takes nothing returns nothing
local integer i = 0
local timer t = GetExpiredTimer()
loop
exitwhen Timers<i>==t
if i>Total then
call BJDebugMsg("AS Error: |cffff0000No reset timer found.")
set t = null
return
endif
set i = i + 1
endloop
call PauseTimer(t)
set t = null
set Timers<i> = null
set Targets<i> = null
endfunction
private function Timer takes nothing returns nothing
local unit dam = GetEventDamageSource()
local player pdam = GetOwningPlayer(dam)
local unit targ = GetTriggerUnit()
local player ptarg = GetOwningPlayer(targ)
local integer i = GetPlayerId(ptarg)+(Skip*GetPlayerId(pdam))
if not IsUnitEnemy(dam,ptarg) or pdam==ptarg or GetEventDamage()<.1 then
set targ = null
set dam = null
return
endif
if Timers<i>==null then
if T<i>==null then
set T<i> = CreateTimer()
endif
set Timers<i> = T<i>
set Targets<i> = targ
call TimerStart(Timers<i>,Time,false,function Reset)
else
call PauseTimer(Timers<i>)
call TimerStart(Timers<i>,Time,false,function Reset)
endif
set dam = null
set targ = null
endfunction
private function Death takes nothing returns nothing
local unit killer = GetKillingUnit()
local player pkill = GetOwningPlayer(killer)
local unit dieer = GetTriggerUnit()
local integer i = GetPlayerId(GetOwningPlayer(dieer))
local integer id = i
local player array pa
local integer count = 0
local integer playid
local string msg
local string endmsg = Msg2
local integer gold = Award
loop
exitwhen i>Total
if Targets<i>==dieer then
if pkill!=Player((i-id)/Skip) then
set count = count + 1
set playid = (i-id)/Skip
set pa[count] = Player(playid)
set Assists[playid] = Assists[playid] + 1
endif
set Targets<i> = null
call PauseTimer(Timers<i>)
set Timers<i> = null
endif
set i = i + Skip
endloop
if count==0 then
set killer = null
set dieer = null
return
elseif count>1 then
set endmsg = Msg3
endif
if Split then
set gold = Award/count
endif
set i = 1
set msg = Msg1 + GetPlayerNameColored(pa<i>)
loop
exitwhen i>count
call SetPlayerState(pa<i>, ConvertPlayerState(1), GetPlayerState(pa<i>, ConvertPlayerState(1)) + gold)
set i = i + 1
endloop
set i = 2
set count = count - 1
loop
exitwhen i>count
set msg = msg + ", " + GetPlayerNameColored(pa<i>)
set i = i + 1
endloop
if count>0 then
set msg = msg + " and " + GetPlayerNameColored(pa<i>)
endif
set msg = msg + ". +"+GoldColor+I2S(gold)+"|r"+endmsg
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,msg)
set killer = null
set dieer = null
endfunction
// Start the system for the unit
public function Register takes unit u returns nothing
if IsUnitInGroup(u,Heroes) then
call BJDebugMsg("AS Error: |cffff0000"+GetUnitName(u)+" has already been registered with the system.")
return
endif
call GroupAddUnit(Heroes,u)
call TriggerRegisterUnitEvent(Trigger1, u, EVENT_UNIT_DAMAGED)
call TriggerRegisterUnitEvent(Trigger2, u, EVENT_UNIT_DEATH)
endfunction
private function Init_AssistanceSystem takes nothing returns nothing
local integer i = GetPlayers()-1
call TriggerAddAction( Trigger1, function Timer)
call TriggerAddAction( Trigger2, function Death)
set Skip = i+1
set Total = (Skip*i)+i-1
endfunction
endlibrary</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
Version History:
- 1.20 - Minor coding updates
More configuration options, mainly message oriented
No longer creates and destroys timers dynamically, reuses the same ones
Minor test map updates, and an easter egg added - 1.10b - Slight Read Me updates
- 1.10 - Users no longer need to manually input the number of players
Fixed a minor bug in the displayed message when only 1 player got an assist
Minor coding updates
Assists are now recorded and can be accessed globally
Minor updates to the test map, including a proper minimap image and a multiboard to display assists and other stats - 1.00 - Initial Release