//===============================================
//CUSTOM BOUNTY SYSTEM - FUNCTIONS
//===============================================
function CB_SetBounty takes integer CreepId, integer Chance, integer Base, integer NumberOfDice, integer SidesPerDie returns nothing
call StoreInteger(udg_CB,I2S(CreepId),"Chance",Chance)
call StoreInteger(udg_CB,I2S(CreepId),"Base",Base)
call StoreInteger(udg_CB,I2S(CreepId),"NumberOfDice",NumberOfDice)
call StoreInteger(udg_CB,I2S(CreepId),"SidesPerDie",SidesPerDie)
endfunction
function CB_GetBountyChance takes integer CreepId returns integer
return GetStoredInteger(udg_CB,I2S(CreepId),"Chance")
endfunction
function CB_GetBounty takes integer CreepId returns integer
local integer Base = GetStoredInteger(udg_CB,I2S(CreepId),"Base")
local integer NoD = GetStoredInteger(udg_CB,I2S(CreepId),"NumberOfDice")
local integer SpD = GetStoredInteger(udg_CB,I2S(CreepId),"SidesPerDie")
return Base + GetRandomInt(NoD, SpD * NoD)
endfunction
function CB_AutoSetBountyAll takes integer Chance returns nothing
local group g = CreateGroup()
local unit u = null
call GroupEnumUnitsOfPlayer(g,Player(12),null)
loop
set u = FirstOfGroup(g)
call GroupRemoveUnit(g,u)
exitwhen u == null
if CB_GetBountyChance(GetUnitTypeId(u)) == 0 then
if GetUnitLevel(u) == 1 then
call CB_SetBounty(GetUnitTypeId(u),Chance,3,1,3)
elseif GetUnitLevel(u) == 2 then
call CB_SetBounty(GetUnitTypeId(u),Chance,5,1,3)
elseif GetUnitLevel(u) == 3 then
call CB_SetBounty(GetUnitTypeId(u),Chance,7,1,3)
elseif GetUnitLevel(u) == 4 then
call CB_SetBounty(GetUnitTypeId(u),Chance,9,2,3)
elseif GetUnitLevel(u) == 5 then
call CB_SetBounty(GetUnitTypeId(u),Chance,17,3,3)
elseif GetUnitLevel(u) == 6 then
call CB_SetBounty(GetUnitTypeId(u),Chance,40,4,3)
elseif GetUnitLevel(u) == 7 then
call CB_SetBounty(GetUnitTypeId(u),Chance,50,5,3)
elseif GetUnitLevel(u) == 8 then
call CB_SetBounty(GetUnitTypeId(u),Chance,70,6,3)
elseif GetUnitLevel(u) == 9 then
call CB_SetBounty(GetUnitTypeId(u),Chance,100,7,3)
elseif GetUnitLevel(u) == 10 then
call CB_SetBounty(GetUnitTypeId(u),Chance,150,8,3)
endif
endif
endloop
call DestroyGroup(g)
set g = null
endfunction
function CB_EnableBountyGainForPlayer takes player whichPlayer returns nothing
call StoreBoolean(udg_CB,"Player"+I2S(GetPlayerId(whichPlayer)-1),"BountyGain",false)
endfunction
function CB_DisableBountyGainForPlayer takes player whichPlayer returns nothing
call StoreBoolean(udg_CB,"Player"+I2S(GetPlayerId(whichPlayer)-1),"BountyGain",true)
endfunction
function CB_IsBountyGainEnabledForPlayer takes player whichPlayer returns boolean
return not GetStoredBoolean(udg_CB,"Player"+I2S(GetPlayerId(whichPlayer)),"BountyGain")
endfunction
function CB_PlayerGivesCustomBounty takes player whichplayer returns nothing
call TriggerRegisterPlayerUnitEvent(gg_trg_CB_GiveBounty, Player(GetPlayerId(whichplayer)-1), EVENT_PLAYER_UNIT_DEATH, null)
endfunction
Name | Type | is_array | initial_value |
CB | gamecache | No | |
CenterCreeps | group | Yes | |
CID | gamecache | No | |
gold_text | texttag | Yes | |
Leaderboard | multiboard | No | |
nextleveltimer | timer | No | |
nextleveltimerwindow | timerdialog | No | |
Player_Colours | string | Yes | |
Player_Names | string | Yes |
|--------------------|
|Custom Bounty System|
|by paskovich |
|--------------------|
The custom creep bounty system allows you to
-give a chance for dropping bounty
-set bounty in-game
-enable/disable specific players to receive bounty
========================
To set a custom bounty for a unit-type, use this formula:
call CB_SetBounty('creep raw code', chance , bounty base , number of dice , sides per die )
(The values "bounty base", "number of dice" , "sides per die" are similar to the values
you can set in the Object Editor's bounty fields.
Stats - Gold Bounty Awarded - Base
Stats - Gold Bounty Awarded - Number of Dice
Stats - Gold Bounty Awarded - Sides per Die)
Note: You can set a unit's bounty in-game with this function.
========================
To enable/disable bounty gain for a specific player, use this function:
call CB_EnableBountyGainForPlayer(Player( player number ))
call CB_DisableBountyGainForPlayer(Player( player number ))
Note: Initially all players gain bounty.
========================
Some custom maps may use a free player slot (like Player 12 - Brown) for their creeps.
To turn "gives bounty" on for a specific player, use this function:
call CB_PlayerGivesCustomBounty(Player( player number ))
Use the same player numbers as in GUI.
Neutral Hostile is Player(13).
Important!
Once you turned "gives bounty" on for a player, you cannot disable it!
You have to set custom bounty values manually to new unit-types!
========================
It may happen that you want only a few specific units to give a custom bounty,
and the others give the normal bounty. However, you can still set chance value to units.
(If you don't want to, simply set it to 100%)
You can preset all creeps' bounty to normal with this function:
call CB_AutoSetBountyAll( chance )
Note: If you already assigned a custom bounty to a unit-type,
this function will not overwrite it!
If you want to change these preset values, find the function in the custom script section,
and change the bounty.
This function presets bounty only for Neutral Hostile creeps, and only if they are already
placed on the map!
========================
IMPLEMENTATION:
1. Create a gamecache variable called "CID"!
2. Copy the "CB GiveBounty" trigger to your map!
3. Copy the Custom Bounty functions from the custom script section to your map's
custom script section!
4. At a map initialization trigger, preset your custom bounty options.
Don't forget to turn normal bounty off!
function Trig_CB_GiveBounty_Conditions takes nothing returns boolean
return CB_IsBountyGainEnabledForPlayer(GetOwningPlayer(GetKillingUnit())) and CB_GetBountyChance(GetUnitTypeId(GetTriggerUnit())) >= GetRandomInt(1,100)
endfunction
function Trig_CB_GiveBounty_Actions takes nothing returns nothing
local integer b = CB_GetBounty(GetUnitTypeId(GetTriggerUnit()))
local player p = GetOwningPlayer(GetKillingUnit())
local texttag tt = CreateTextTag()
local string path
call SetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD) + b)
call SetTextTagPos(tt, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 0.00)
call SetTextTagText(tt, "+"+I2S(b), 0.024)
call SetTextTagColor(tt, 255, 220, 0, 255)
call SetTextTagVelocity(tt, 0, 0.03)
call SetTextTagLifespan(tt, 3)
call SetTextTagFadepoint(tt, 1.2)
call SetTextTagPermanent(tt, false)
call SetTextTagVisibility(tt, false)
if GetLocalPlayer() == p then
set path = "UI\\Feedback\\GoldCredit\\GoldCredit.mdl"
call SetTextTagVisibility(tt, true)
endif
call DestroyEffect(AddSpecialEffect(path, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit())))
set tt = null
set p = null
endfunction
//===========================================================================
function InitTrig_CB_GiveBounty takes nothing returns nothing
set gg_trg_CB_GiveBounty = CreateTrigger()
set udg_CB = InitGameCache("CB")
call TriggerAddCondition(gg_trg_CB_GiveBounty, Condition(function Trig_CB_GiveBounty_Conditions))
call TriggerAddAction(gg_trg_CB_GiveBounty, function Trig_CB_GiveBounty_Actions)
endfunction