// Please copy these functions to your .w3x section.
// Example: In the trigger list you can see:
// Vile'sAssistanceSystem(v1.0).w3x
// It's located at the top. Click on it in your map and copy
// the following functions into it. If you already have these
// functions, dont copy them.
function GetPlayerNameColored takes player p returns string
local playercolor col=GetPlayerColor(p)
local string r=GetPlayerName(p)
if GetPlayerId(p) == 12 then
set r="the |CFF333429"+r+"|r"
elseif GetPlayerId(p) == 13 then
set r="the |cffc1c1ff"+r+"|r"
elseif GetPlayerId(p) == 14 then
set r="the |CFF333429"+r+"|r"
elseif GetPlayerId(p) == 15 then
set r="the |CFF333429"+r+"|r"
elseif col == PLAYER_COLOR_RED then
set r="|CFFFF0303"+r+"|r"
elseif col == PLAYER_COLOR_BLUE then
set r="|CFF0042FF"+r+"|r"
elseif col == PLAYER_COLOR_CYAN then
set r="|CFF1CE6B9"+r+"|r"
elseif col == PLAYER_COLOR_PURPLE then
set r="|CFF540081"+r+"|r"
elseif col == PLAYER_COLOR_YELLOW then
set r="|CFFFFFC00"+r+"|r"
elseif col == PLAYER_COLOR_ORANGE then
set r="|CFFFE8A0E"+r+"|r"
elseif col == PLAYER_COLOR_GREEN then
set r="|CFF20C000"+r+"|r"
elseif col == PLAYER_COLOR_PINK then
set r="|cffff80c0"+r+"|r"
elseif col == PLAYER_COLOR_LIGHT_GRAY then
set r="|CFF959697"+r+"|r"
elseif col == PLAYER_COLOR_LIGHT_BLUE then
set r="|CFF7FBFF1"+r+"|r"
elseif col == PLAYER_COLOR_AQUA then
set r="|CFF106246"+r+"|r"
elseif col == PLAYER_COLOR_BROWN then
set r="|CFF492A04"+r+"|r"
else
set r=""
endif
set col=null
return r
endfunction
function FadingTextSingle takes player p, string msg, integer red, integer green, integer blue, real x, real y, real vel, real fade, real life returns nothing
local texttag t=CreateTextTag()
call SetTextTagText(t,msg,0.024)
call SetTextTagPos(t,x,y, 0.00)
call SetTextTagColor(t,red,green,blue,255)
call SetTextTagVelocity(t,0,vel)
call SetTextTagVisibility(t,(GetLocalPlayer() == p))
call SetTextTagFadepoint(t, fade)
call SetTextTagLifespan(t, life)
call SetTextTagPermanent(t, false)
set t = null
endfunction
Name | Type | is_array | initial_value |
AssistanceTarget | unit | Yes | |
AssistanceTimer | timer | Yes |
//***************************************************************************
//* Assistance System
//*
//* Author: vile
//*
//* Requirements:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯
//* - The functions in the "Needed Functions" trigger
//* - Global unit variable array named: AssistanceTarget
//* - Global timer variable array named: AssistanceTimer
//* - Array sizes of both global vars set to 372 (Press CTRL+V)
//* - This trigger
//*
//* General Notes:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* Thank you for using my assistance system. This system was written
//* from scratch by me, and works flawlessly, as I have specifically
//* written it for my map, Age of Myths.
//* Feel free to spread this to as many maps as possible, but please
//* give me credits if you use it.
//* It is especially good for AOS type maps.
//* Below is the configuration section. This system supports
//* bounty sharing when heroes are dying. The gold share and bounty
//* can be configured below. It is completely triggered so you will
//* have to set your heroes bounty to 0 in the object editor.
//* This option is optional and you can set it below.
//*
//* NOTE: This assistance system only works on PRE PLACED UNITS!
//* That means only heroes that were placed on the map initially and
//* not created by a building or by a trigger.
//* If you want this to work on a created unit, just use the following:
//* Custom Script: call AssistanceSystem_Register(unit)
//*
//***************************************************************************
// Assistance System General Configuration Section
//***************************************************************************
constant function AssistanceSystem_SuicideMessage takes nothing returns string
return "has commited suicide" //This message displays when you kill yourself.
endfunction
constant function AssistanceSystem_DeathMessage takes nothing returns string
return "has been killed" //This is the generic death message of a hero.
endfunction
constant function AssistanceSystem_AssistMessage takes nothing returns string
return "with assistance from" //This is the generic assistance message.
endfunction
constant function AssistanceSystem_ResetValue takes nothing returns real
return 10. //How much time should pass until your assistance
//doesnt count anymore? (Seconds)
endfunction
//***************************************************************************
// Assistance System Bounty Configuration Section
//***************************************************************************
constant function AssistanceSystem_ShareBounty takes nothing returns boolean
return true //If shared bounty is on, when you kill a hero, a random bounty
//gold amount that you can specify down below will be shared and
//equally split among your assisters, if any.
//The gold is split like this:
//2 Assisters = gold is split by 2
//3 Assisters = gold is split by 3
//And so on.
//IF THIS OPTION IS SET TO FALSE, YOU CAN IGNORE
//THE REST OF THE CONFIGURATION BELOW!
endfunction
constant function AssistanceSystem_InitialRandom takes nothing returns integer
return 100 //This is the initial minimum gold amount that the
//killing hero gets for killing another hero.
//The final amount is a random between this and the
//EndingRandom value below. Then it is split amongst
//assisters.
endfunction
constant function AssistanceSystem_EndingRandom takes nothing returns integer
return 200 //The ending random amount value. The "maximum" value.
//Note that if you want a permanent amount, just set
//the two values to the same value.
endfunction
//***************************************************************************
// Assistance System code; don't touch it if you don't know jass.
//***************************************************************************
function AssistanceSystem_DeathCondition takes nothing returns boolean
return IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true
endfunction
function AssistanceSystem_Reset takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 372 or GetExpiredTimer() == udg_AssistanceTimer[i]
set i = i + 1
endloop
set udg_AssistanceTarget[i] = null
endfunction
function AssistanceSystem_Timer takes nothing returns nothing
local unit attacked = GetTriggerUnit()
local unit attacker = GetEventDamageSource()
local player p1 = GetOwningPlayer(attacked)
local player p2 = GetOwningPlayer(attacker)
local integer id1 = GetPlayerId(p1)
local integer id2 = GetPlayerId(p2)
if IsUnitEnemy(attacker, p1) and id2 < 12 then
loop
exitwhen id2 > 372 or udg_AssistanceTarget[id2] == attacked or udg_AssistanceTarget[id2] == null
set id2 = id2+20
endloop
if udg_AssistanceTarget[id2] == null then
call TimerStart(udg_AssistanceTimer[id2], AssistanceSystem_ResetValue(), false, function AssistanceSystem_Reset)
set udg_AssistanceTarget[id2] = attacked
elseif udg_AssistanceTarget[id2] == attacked then
call TimerStart(udg_AssistanceTimer[id2], AssistanceSystem_ResetValue(), false, function AssistanceSystem_Reset)
endif
endif
set attacked = null
set attacker = null
set p1 = null
set p2 = null
endfunction
function AssistanceSystem_DeathActions takes nothing returns nothing
local player array assister
local player array assistplayer
local unit d = GetDyingUnit()
local unit u = GetKillingUnit()
local player pd = GetOwningPlayer(d)
local player pu = GetOwningPlayer(u)
local integer i = 0
local integer i2 = 0
local force f = CreateForce()
local string array s
local boolean array bg
local integer gold = GetRandomInt(AssistanceSystem_InitialRandom(), AssistanceSystem_EndingRandom())
local string losegold
local boolean bounty = AssistanceSystem_ShareBounty()
//Add players to a force to prevent a force leak
//when messaging all players:
loop
exitwhen i > 11
call ForceAddPlayer(f, Player(i))
set i=i+1
endloop
set i=0
if bounty == true then
//If the the unit doesnt have the bounty gold to lose,
//set the gold lost to its current gold:
if GetPlayerState(pd, ConvertPlayerState(1)) <= gold then
set gold = GetPlayerState(pd, ConvertPlayerState(1))
endif
set losegold = "-" + I2S(gold)
//Display bounty only if the assister has more than 0 gold:
set i=1
loop
exitwhen i>13
set s[i] = "+" + I2S(gold)
set s[i+1] = "+" + I2S(gold / i+1)
set i=i+1
endloop
endif
set i = 0
set i2 = 0
//Start setting the assisters:
loop
exitwhen i > 11
loop
exitwhen i2 > 372 or udg_AssistanceTarget[i2+i] == d
set i2 = i2 + 20
endloop
if GetPlayerSlotState(Player(i)) != ConvertPlayerSlotState(0) and Player(i) != pu and udg_AssistanceTarget[i2+i] == d then
set assistplayer[i] = Player(i)
set udg_AssistanceTarget[i2+i] = null
endif
set i = i + 1
set i2 = 0
endloop
set i = 1
set i2 = 0
//Resort the assisters list so there wont be an empty
//assister slot:
loop
exitwhen i > 11
loop
exitwhen assistplayer[i2] != null or i2 > 11
set i2 = i2 + 1
endloop
if assistplayer[i2] != null then
set assister[i] = assistplayer[i2]
set assistplayer[i2] = null
endif
set i = i + 1
set i2 = 0
endloop
set i = 1
set i2 = 2
loop
exitwhen i > 11
if assister[i] == null then
loop
exitwhen i2 > 11 or assister[i2] != null
if assister[i2] != null then
set assister[i] = assister[i2]
set assister[i2] = null
endif
set i2 = i2 + 1
endloop
endif
set i = i + 1
set i2 = i + 2
endloop
set i = 1
if d == u then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_SuicideMessage() + ".")
elseif u == null and d != u then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + ".")
elseif assister[1] == null and assister[2] == null and assister[3] == null and assister[4] == null and assister[5] == null and assister[6] == null and assister[7] == null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + "!")
elseif assister[1] != null and assister[2] == null and assister[3] == null and assister[4] == null and assister[5] == null and assister[6] == null and assister[7] == null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + "!")
if bg[1] and bounty then
call FadingTextSingle(assister[1], s[2], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[1], ConvertPlayerState(1), GetPlayerState(assister[1], ConvertPlayerState(1)) + gold / 2)
endif
elseif assister[1] != null and assister[2] != null and assister[3] == null and assister[4] == null and assister[5] == null and assister[6] == null and assister[7] == null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + " and " + GetPlayerNameColored(assister[2]) + "!")
if bg[2] and bounty then
loop
exitwhen i > 2
call FadingTextSingle(assister[i], s[3], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 3)
set i = i + 1
endloop
endif
elseif assister[1] != null and assister[2] != null and assister[3] != null and assister[4] == null and assister[5] == null and assister[6] == null and assister[7] == null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + ", " + GetPlayerNameColored(assister[2]) + ", and " + GetPlayerNameColored(assister[3]) + "!")
if bg[3] and bounty then
loop
exitwhen i > 3
call FadingTextSingle(assister[i], s[4], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 4)
set i = i + 1
endloop
endif
elseif assister[1] != null and assister[2] != null and assister[3] != null and assister[4] != null and assister[5] == null and assister[6] == null and assister[7] == null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + ", " + GetPlayerNameColored(assister[2]) + ", " + GetPlayerNameColored(assister[3]) + ", and " + GetPlayerNameColored(assister[4]) + "!")
if bg[4] and bounty then
loop
exitwhen i > 4
call FadingTextSingle(assister[i], s[5], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 5)
set i = i + 1
endloop
endif
elseif assister[1] != null and assister[2] != null and assister[3] != null and assister[4] != null and assister[5] != null and assister[6] == null and assister[7] == null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + ", " + GetPlayerNameColored(assister[2]) + ", " + GetPlayerNameColored(assister[3]) + ", " + GetPlayerNameColored(assister[4]) + ", and " + GetPlayerNameColored(assister[5]) + "!")
if bg[5] and bounty then
loop
exitwhen i > 5
call FadingTextSingle(assister[i], s[6], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 6)
set i = i + 1
endloop
endif
elseif assister[1] != null and assister[2] != null and assister[3] != null and assister[4] != null and assister[5] != null and assister[6] != null and assister[7] == null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + ", " + GetPlayerNameColored(assister[2]) + ", " + GetPlayerNameColored(assister[3]) + ", " + GetPlayerNameColored(assister[4]) + ", " + GetPlayerNameColored(assister[5]) + ", and " + GetPlayerNameColored(assister[6]) + "!")
if bg[6] and bounty then
loop
exitwhen i > 6
call FadingTextSingle(assister[i], s[7], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 7)
set i = i + 1
endloop
endif
elseif assister[1] != null and assister[2] != null and assister[3] != null and assister[4] != null and assister[5] != null and assister[6] != null and assister[7] != null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + ", " + GetPlayerNameColored(assister[2]) + ", " + GetPlayerNameColored(assister[3]) + ", " + GetPlayerNameColored(assister[4]) + ", " + GetPlayerNameColored(assister[5]) + ", " + GetPlayerNameColored(assister[6]) + ", and " + GetPlayerNameColored(assister[7]) + "!")
if bg[7] and bounty then
loop
exitwhen i > 7
call FadingTextSingle(assister[i], s[8], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 8)
set i = i + 1
endloop
endif
elseif assister[1] != null and assister[2] != null and assister[3] != null and assister[4] != null and assister[5] != null and assister[6] != null and assister[7] != null and assister[8] != null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + ", " + GetPlayerNameColored(assister[2]) + ", " + GetPlayerNameColored(assister[3]) + ", " + GetPlayerNameColored(assister[4]) + ", " + GetPlayerNameColored(assister[5]) + ", " + GetPlayerNameColored(assister[6]) + ", " + GetPlayerNameColored(assister[7]) + ", and " + GetPlayerNameColored(assister[8]) + "!")
if bg[8] and bounty then
loop
exitwhen i > 8
call FadingTextSingle(assister[i], s[9], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 8)
set i = i + 1
endloop
endif
elseif assister[1] != null and assister[2] != null and assister[3] != null and assister[4] != null and assister[5] != null and assister[6] != null and assister[7] != null and assister[8] != null and assister[9] != null and assister[10] == null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + ", " + GetPlayerNameColored(assister[2]) + ", " + GetPlayerNameColored(assister[3]) + ", " + GetPlayerNameColored(assister[4]) + ", " + GetPlayerNameColored(assister[5]) + ", " + GetPlayerNameColored(assister[6]) + ", " + GetPlayerNameColored(assister[7]) + ", " + GetPlayerNameColored(assister[8]) + ", and " + GetPlayerNameColored(assister[9]) + "!")
if bg[9] and bounty then
loop
exitwhen i > 9
call FadingTextSingle(assister[i], s[10], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 8)
set i = i + 1
endloop
endif
elseif assister[1] != null and assister[2] != null and assister[3] != null and assister[4] != null and assister[5] != null and assister[6] != null and assister[7] != null and assister[8] != null and assister[9] != null and assister[10] != null and assister[11] == null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + ", " + GetPlayerNameColored(assister[2]) + ", " + GetPlayerNameColored(assister[3]) + ", " + GetPlayerNameColored(assister[4]) + ", " + GetPlayerNameColored(assister[5]) + ", " + GetPlayerNameColored(assister[6]) + ", " + GetPlayerNameColored(assister[7]) + ", " + GetPlayerNameColored(assister[8]) + ", " + GetPlayerNameColored(assister[9]) + ", and " + GetPlayerNameColored(assister[10]) + "!")
if bg[10] and bounty then
loop
exitwhen i > 10
call FadingTextSingle(assister[i], s[11], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 8)
set i = i + 1
endloop
endif
elseif assister[1] != null and assister[2] != null and assister[3] != null and assister[4] != null and assister[5] != null and assister[6] != null and assister[7] != null and assister[8] != null and assister[9] != null and assister[10] != null and assister[11] != null and assister[12] == null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + ", " + GetPlayerNameColored(assister[2]) + ", " + GetPlayerNameColored(assister[3]) + ", " + GetPlayerNameColored(assister[4]) + ", " + GetPlayerNameColored(assister[5]) + ", " + GetPlayerNameColored(assister[6]) + ", " + GetPlayerNameColored(assister[7]) + ", " + GetPlayerNameColored(assister[8]) + ", " + GetPlayerNameColored(assister[9]) + ", " + GetPlayerNameColored(assister[10]) + ", and " + GetPlayerNameColored(assister[11]) + "!")
if bg[11] and bounty then
loop
exitwhen i > 11
call FadingTextSingle(assister[i], s[12], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 8)
set i = i + 1
endloop
endif
elseif assister[1] != null and assister[2] != null and assister[3] != null and assister[4] != null and assister[5] != null and assister[6] != null and assister[7] != null and assister[8] != null and assister[9] != null and assister[10] != null and assister[11] != null and assister[12] != null then
call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + ", " + GetPlayerNameColored(assister[2]) + ", " + GetPlayerNameColored(assister[3]) + ", " + GetPlayerNameColored(assister[4]) + ", " + GetPlayerNameColored(assister[5]) + ", " + GetPlayerNameColored(assister[6]) + ", " + GetPlayerNameColored(assister[7]) + ", " + GetPlayerNameColored(assister[8]) + ", " + GetPlayerNameColored(assister[9]) + ", " + GetPlayerNameColored(assister[10]) + ", " + GetPlayerNameColored(assister[11]) + ", and " + GetPlayerNameColored(assister[12]) + "!")
if bg[12] and bounty then
loop
exitwhen i > 12
call FadingTextSingle(assister[i], s[13], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(assister[i], ConvertPlayerState(1), GetPlayerState(assister[i], ConvertPlayerState(1)) + gold / 8)
set i = i + 1
endloop
endif
endif
if bounty and IsUnitEnemy(d, pu) and GetPlayerState(pd, ConvertPlayerState(1)) > 0 then
call FadingTextSingle(pu, s[1], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call FadingTextSingle(pd, losegold, 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
call SetPlayerState(pu, ConvertPlayerState(1), GetPlayerState(pu, ConvertPlayerState(1)) + gold)
call SetPlayerState(pd, ConvertPlayerState(1), GetPlayerState(pd, ConvertPlayerState(1)) - gold)
endif
set i=0
call DestroyForce(f)
set d=null
set u=null
set pd=null
set pu=null
set f=null
endfunction
function AssistanceSystem_Register takes unit u returns nothing
call TriggerRegisterUnitEvent(gg_trg_AssistanceSystem, u, ConvertUnitEvent(52))
endfunction
function InitTrig_AssistanceSystem takes nothing returns nothing
local rect r = GetWorldBounds()
local group g = CreateGroup()
local unit temp
local trigger Death = CreateTrigger()
set gg_trg_AssistanceSystem = CreateTrigger()
call GroupEnumUnitsInRect(g, r, null)
loop
set temp=FirstOfGroup(g)
exitwhen temp==null
if IsUnitType(temp, UNIT_TYPE_HERO) then
call TriggerRegisterUnitEvent(gg_trg_AssistanceSystem, temp, ConvertUnitEvent(52))
endif
call GroupRemoveUnit(g,temp)
set temp=null
endloop
call DestroyGroup(g)
call TriggerRegisterAnyUnitEventBJ(Death, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(Death, Condition(function AssistanceSystem_DeathCondition))
call TriggerAddAction(Death, function AssistanceSystem_DeathActions)
call RemoveRect(r)
set g=null
set r=null
set Death=null
call TriggerAddAction( gg_trg_AssistanceSystem, function AssistanceSystem_Timer)
endfunction
//Thanks to Vexorian for the GetPlayerNameColored function.
//To implement these functions in your map, go to your map's main
//trigger and paste it there. Example:
//This map's main trigger is Vile'sAssistanceSystem(v1.0).w3x
//It is located to the left, at the top of the triggers list.
//Paste it there. If you already have these functions, don't paste them.
function GetPlayerNameColored takes player p returns string
local playercolor col=GetPlayerColor(p)
local string r=GetPlayerName(p)
if col == PLAYER_COLOR_RED then
set r="|CFFFF0303"+r+"|r"
elseif col == PLAYER_COLOR_BLUE then
set r="|CFF0042FF"+r+"|r"
elseif col == PLAYER_COLOR_CYAN then
set r="|CFF1CE6B9"+r+"|r"
elseif col == PLAYER_COLOR_PURPLE then
set r="|CFF540081"+r+"|r"
elseif col == PLAYER_COLOR_YELLOW then
set r="|CFFFFFC00"+r+"|r"
elseif col == PLAYER_COLOR_ORANGE then
set r="|CFFFE8A0E"+r+"|r"
elseif col == PLAYER_COLOR_GREEN then
set r="|CFF20C000"+r+"|r"
elseif col == PLAYER_COLOR_PINK then
set r="|cffff80c0"+r+"|r"
elseif col == PLAYER_COLOR_LIGHT_GRAY then
set r="|CFF959697"+r+"|r"
elseif col == PLAYER_COLOR_LIGHT_BLUE then
set r="|CFF7FBFF1"+r+"|r"
elseif col == PLAYER_COLOR_AQUA then
set r="|CFF106246"+r+"|r"
elseif col == PLAYER_COLOR_BROWN then
set r="|CFF492A04"+r+"|r"
else
set r=""
endif
set col=null
return r
endfunction
function FadingTextSingle takes player p, string msg, integer red, integer green, integer blue, real x, real y, real vel, real fade, real life returns nothing
local texttag t=CreateTextTag()
call SetTextTagText(t,msg,0.024)
call SetTextTagPos(t,x,y, 0.00)
call SetTextTagColor(t,red,green,blue,255)
call SetTextTagVelocity(t,0,vel)
call SetTextTagVisibility(t,(GetLocalPlayer() == p))
call SetTextTagFadepoint(t, fade)
call SetTextTagLifespan(t, life)
call SetTextTagPermanent(t, false)
set t = null
endfunction
Thanks for using my Assistance System.
If you have any bug reports or questions, feel free to check
out the latest version of this demo map at http://wc3campaigns.net
Give me credits if you use this in your map.
You can also contact me at:
MSN/Email: [email protected]
ICQ: 15370294
function Init takes nothing returns nothing
call BJDebugMsg("|CFFED1C24Testmap & Spell author: |CFF90FF90vile|r
|CFFFF8A00*CREDITS:|r
- |CFF008AFFVexorian|r for his GetPlayerNameColored function
|CFF90FF90Give me credits if you use this in your map.|r")
call FogEnable(false)
call FogMaskEnable(false)
call SetPlayerState(Player(0), ConvertPlayerState(7), IntegerTertiaryOp(true, 1, 0))
call SetPlayerState(Player(12), ConvertPlayerState(7), IntegerTertiaryOp(true, 1, 0))
call SetTimeOfDay(0)
call SelectUnitForPlayerSingle(gg_unit_Nplh_0051, Player(0))
call DestroyTimer(GetExpiredTimer())
endfunction
function Refresher_Cond takes nothing returns boolean
return GetSpellAbilityId() == 'ACro' or GetSpellAbilityId() == 'ANwm'
endfunction
function Refresher takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local integer id = GetSpellAbilityId()
if id == 'ACro' then
call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_MAX_LIFE))
call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA))
call UnitResetCooldown(u)
elseif id == 'ANwm' then
call SetHeroLevel(u, GetHeroLevel(u)+1, true)
endif
set u = null
endfunction
function Stuff_Actions takes nothing returns nothing
local unit d = GetDyingUnit()
local player p = GetOwningPlayer(d)
if IsUnitType(d, UNIT_TYPE_HERO) then
call TriggerSleepAction(5)
if d == gg_unit_Nplh_0051 then
call ReviveHero(d, -123.6, -9.4, true)
call SetCameraPositionForPlayer(p, GetUnitX(d), GetUnitY(d))
call SelectUnitForPlayerSingle(d, p)
else
call ReviveHero(d, GetUnitX(d), GetUnitY(d), true)
endif
else
call TriggerSleepAction(15)
call CreateUnit(p, GetUnitTypeId(d), GetUnitX(d), GetUnitY(d), GetRandomReal(0, 360))
endif
set d = null
set p = null
endfunction
function InitTrig_Stuff takes nothing returns nothing
local trigger refresh = CreateTrigger()
set gg_trg_Stuff = CreateTrigger()
call TimerStart(CreateTimer(), .01, false, function Init)
call TriggerRegisterAnyUnitEventBJ(gg_trg_Stuff, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddAction( gg_trg_Stuff, function Stuff_Actions)
call TriggerRegisterUnitEvent(refresh, gg_unit_Nplh_0051, EVENT_UNIT_SPELL_EFFECT)
call TriggerAddCondition(refresh, Condition(function Refresher_Cond))
call TriggerAddAction(refresh, function Refresher)
set refresh = null
endfunction
function Destructables_Actions takes nothing returns nothing
local destructable d = GetDyingDestructable()
call TriggerSleepAction(60)
call DestructableRestoreLife(d, GetDestructableMaxLife(d), true)
set d = null
endfunction
function InitTrig_Destructables_Register takes nothing returns nothing
call TriggerRegisterDeathEvent(gg_trg_Destructables_Revive, GetEnumDestructable())
endfunction
function InitTrig_Destructables_Revive takes nothing returns nothing
local rect r = GetWorldBounds()
set gg_trg_Destructables_Revive = CreateTrigger()
call EnumDestructablesInRect(r, null, function InitTrig_Destructables_Register)
call TriggerAddAction(gg_trg_Destructables_Revive, function Destructables_Actions)
call RemoveRect(r)
set r = null
endfunction