- Joined
- Dec 12, 2008
- Messages
- 7,385
This is an Advanced Streak System that handles:
-Player Kill Streaks
-Player Assists
-Configurable strings and sounds on a units death (Heroes specifically)
-Player Multikill Streaks
It's also quite dynamic (I sacrificed file size for that)
You can create streaks in game and you can change anything you want anytime you want
I hope you like it
Credits aren't required, but they would be highly appreciated.
It requires:
- DamageEvent by Nestharus
- UnitIndexer by Nestharus
- SoundUtils by Rising_Dusk
- Table by Bribe
There's a testmap attatched if you want to try this system out
Unfortunately, assists can't be tested yet :/
I did a lot of debugging to see if they would work though
-Player Kill Streaks
-Player Assists
-Configurable strings and sounds on a units death (Heroes specifically)
-Player Multikill Streaks
It's also quite dynamic (I sacrificed file size for that)
You can create streaks in game and you can change anything you want anytime you want
I hope you like it
Credits aren't required, but they would be highly appreciated.
JASS:
//
// _ ___ ___ ____________________________________
// /_\ / __|/ __| || A D V A N C E D S T R E A K ||
// / _ \\__ \\__ \ || S Y S T E M ||
// /_/ \_|___//___/ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// v3.0.0.0 By Magtheridon96
//
//
// What is ASS?
// ¯¯¯¯¯¯¯¯¯¯¯¯
// This is an advanced player streak system. It isn't MUI
// because you would rarely find an AoS map involving a player
// with more than one hero. Either way, the results will be
// somewhat similar.
//
// This system will keep track of all player sprees and
// player assists. It also has a Multikill feature to detect
// consecutive player kills.
//
// This system is very dynamic. You can create new streaks in game
// at anytime without bugging the system.
//
// I did not provide you with any sounds. You should
// configure those yourself.
//
//
// Configurable functions:
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// - GetBounty ( integer m, integer n, unit k, unit d )
// - m: Player Id of killing player
// - n: Player Id of dying player
// - k: Killing Unit
// - d: Dying Unit
//
// - GetLostGold ( integer g )
// - g: The gold earned by the killer
//
// - GetAssistGold ( integer g, integer n )
// - g: The gold earned by the killer
// - n: The number of assisting players including the killer
//
//
// API:
// ¯¯¯¯
// struct StreakSystem:
//
// - static method newStreak takes string streakname, string streakdisplay, string soundpath, integer duration returns nothing
// - string streakname: The name of this streak.
// - string streakdisplay: The string that will be concatenated with the player's name when he gets this streak.
// - string soundpath: The file path of the streak sound.
// - integer duration: The duration of the sound in milliseconds.
//
// - This function creates a new streak and adds it to the stack.
//
// - static method newMulti takes string text, string soundpath, integer duration returns nothing
// - string text: The string that will be concatenated with the player's name when he gets this multikill.
// - string soundpath: The file path of the multikill sound.
// - integer duration: The duration of the sound in milliseconds.
//
// - This function creates a new multikill and adds it to the stack.
//
// - static method enableTexttags takes nothing returns nothing
// - This function enables the texttags
//
// - static method disableTexttags takes nothing returns nothing
// - This function disables the texttags
//
// - static method areTexttagsEnabled takes nothing returns boolean
// - This function tells whether texttags are enabled or not
//
// - static method enableAssistGold takes nothing returns nothing
// - This function allows assists to go rewarded
//
// - static method disableAssistGold takes nothing returns nothing
// - This function disables the assist gold
//
// - static method isAssistGoldEnabled takes nothing returns boolean
// - This function tells whether assists give gold or not
//
// - static method enableGoldGain takes nothing returns nothing
// - This function allows players to gain gold from a kill
//
// - static method disableGoldGain takes nothing returns nothing
// - This function disables gold gain from kills
//
// - static method isGoldGainEnabled takes nothing returns boolean
// - This function tells whether players get gold from kills or not
//
// - static method enableGoldLoss takes nothing returns nothing
// - This function makes players lose gold from a death
//
// - static method disableGoldLoss takes nothing returns nothing
// - This function disables gold loss from a death
//
// - static method isGoldLossEnabled takes nothing returns boolean
// - This function tells whether players lose gold from deaths or not
//
// - static method enableSuicideStreakEnder takes nothing returns nothing
// - This function enables streak ending on suicides
//
// - static method disableSuicideStreakEnder takes nothing returns nothing
// - This function disables streak ending on suicides
//
// - static method suicideEndStreaks takes nothing returns boolean
// - This function tells whether suicides end streaks or not
//
// - static method getBountyBase takes nothing returns integer
// - This function returns the Bounty base value
//
// - static method setBountyBase takes integer i returns nothing
// - integer i: The new Bounty base value
//
// - This function configures the Bounty base value
//
// - static method getBountyIncrement takes nothing returns integer
// - This function returns the Bounty Increment Value
//
// - static method setBountyIncrement takes integer i returns nothing
// - integer i: The new Bounty Increment value
//
// - This function configures the Bounty Increment Value
//
//
// Requirements:
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
// 1- DamageEvent - Nestharus
// 2- UnitIndexer - Nestharus
// 3- Table - Bribe
// 4- SoundUtils - Rising_Dusk
//
//
library ASS requires DamageEvent, UnitIndexer, SoundUtils, Table
// CONFIGURATION
globals
// Max interval between Multikills
private constant integer MULTITIME = 10
// Are sounds 3D?
private constant boolean S3D = false
// Firstblood bonus
private constant integer FIRSTGOLD = 200
// Duration of the text messages
private constant real TEXTDURATION = 8.00
// Initial Gold base
private integer baseGold = 210
// Gold increment according to formulas
private integer goldIncrement = 10
// Does Suicide end a spree?
private boolean endSuicide = false
// Do you lose gold when you die?
private boolean loseGold = true
// Do you gain gold when you kill?
private boolean gainGold = true
// Do you want floating texts?
private boolean text = true
// Give gold among assisters?
private boolean fair = true
endglobals
private module InitM
private static method onInit takes nothing returns nothing
set firstSound = DefineSound("Sound\\Interface\\GoodJob.wav",2548,false,S3D)
// Feel free to configure these
call thistype.newStreak("","","",0) // This was intended because I wanted to add 2 empty instances to the stack.
call thistype.newStreak("","","",0) // Without these, 1 kill would count as a streak.
call thistype.newStreak("|cff80ff80killing spree|r", "is on a |cff80ff80killing spree|r!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newStreak("|cffff80c0dominating|r", "is |cffff80c0dominating|r!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newStreak("|cffffff80mega-kill|r", "has a |cffffff80mega-kill|r!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newStreak("|cffff8000unstoppable|r", "is |cffff8000unstoppable|r!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newStreak("|cff00ffa2wicked sick|r", "is |cff00ffa2wicked sick|r!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newStreak("|cffff0080monster kill|r", "has a |cffff0080monster kill|r!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newStreak("|cffff0000GODLIKE|r", "is |cffff0000GODLIKE|r!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newStreak("|cffffa500beyond Godlike|r", "is |cffffa500beyond Godlike. SOMEONE KILL HIM|r!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newMulti("got a |cff0028ffDouble Kill|r!!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newMulti("got a |cff40ff40Triple Kill|r!!!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newMulti("got an |cff00bfffUltra-Kill|r!!!!", "Sound\\Interface\\GoodJob.wav", 2548)
call thistype.newMulti("is on a |cff00ced1Rampage|r!!!!!", "Sound\\Interface\\GoodJob.wav", 2548)
set thistype.colors[0] = "|cffff0303"
set thistype.colors[1] = "|cff0042ff"
set thistype.colors[2] = "|cff1ce6b9"
set thistype.colors[3] = "|cff540081"
set thistype.colors[4] = "|cfffffc01"
set thistype.colors[5] = "|cfffeba0e"
set thistype.colors[6] = "|cff20c000"
set thistype.colors[7] = "|cffe55bb0"
set thistype.colors[8] = "|cff959697"
set thistype.colors[9] = "|cff7ebff1"
set thistype.colors[10] = "|cff106246"
set thistype.colors[11] = "|cff4e2a04"
endmethod
endmodule
private keyword spree
// FORMULAS
private function GetBounty takes integer m, integer n, unit k, unit d returns integer
return baseGold + goldIncrement * spree(n+1).streak + goldIncrement * spree(m+1).streak
endfunction
private function GetLostGold takes integer g returns integer
return g / 2
endfunction
private function GetAssistGold takes integer g, integer n returns integer
return g / n
endfunction
// *******************************************
// DO NOT EDIT BELOW THIS LINE!! YOU HEAR ME??
// *******************************************
struct StreakSystem extends array
readonly static integer maxSpree = 0
readonly static integer minSpree = 1
readonly static integer maxMulti = 1
readonly static integer firstSound
readonly static integer array sounds
readonly static integer array multiSound
readonly static string array strings
readonly static string array multiString
readonly static string array endString
readonly static string array colors
static boolean firstblood = false
static method newStreak takes string streakname, string streakdisplay, string soundpath, integer duration returns nothing
if ""==streakname then
set minSpree = minSpree + 1
set maxSpree = maxSpree + 1
return
endif
set maxSpree = maxSpree + 1
set strings[maxSpree] = " " + streakdisplay
set endString[maxSpree] = "'s " + streakname
set sounds[maxSpree] = DefineSound(soundpath,duration,false,S3D)
endmethod
static method newMulti takes string text, string soundpath, integer duration returns nothing
set maxMulti = maxMulti + 1
set multiString[maxMulti] = " " + text
set multiSound[maxMulti] = DefineSound(soundpath,duration,false,S3D)
endmethod
static method enableTexttags takes nothing returns nothing
set text = true
endmethod
static method disableTexttags takes nothing returns nothing
set text = false
endmethod
static method areTexttagsEnabled takes nothing returns boolean
return text
endmethod
static method enableAssistGold takes nothing returns nothing
set fair = true
endmethod
static method disableAssistGold takes nothing returns nothing
set fair = false
endmethod
static method isAssistGoldEnabled takes nothing returns boolean
return fair
endmethod
static method enableGoldGain takes nothing returns nothing
set gainGold = true
endmethod
static method disableGoldGain takes nothing returns nothing
set gainGold = false
endmethod
static method isGoldGainEnabled takes nothing returns boolean
return gainGold
endmethod
static method enableGoldLoss takes nothing returns nothing
set loseGold = true
endmethod
static method disableGoldLoss takes nothing returns nothing
set loseGold = false
endmethod
static method isGoldLossEnabled takes nothing returns boolean
return loseGold
endmethod
static method enableSuicideStreakEnder takes nothing returns nothing
set endSuicide = true
endmethod
static method disableSuicideStreakEnder takes nothing returns nothing
set endSuicide = false
endmethod
static method suicideEndStreaks takes nothing returns boolean
return endSuicide
endmethod
static method getBountyBase takes nothing returns integer
return baseGold
endmethod
static method setBountyBase takes integer i returns nothing
set baseGold = i
endmethod
static method getBountyIncrement takes nothing returns integer
return goldIncrement
endmethod
static method setBountyIncrement takes integer i returns nothing
set goldIncrement = i
endmethod
implement InitM
endstruct
private struct spree extends array
integer streak
integer counter
integer multikills
boolean on
endstruct
// You mad Jesus4Lyf?
private struct assist extends array
integer number
Table bool
method reset takes nothing returns nothing
set .number = 0
call .bool.flush()
endmethod
static method index takes nothing returns nothing
set thistype(GetIndexedUnitId()).number = 0
set thistype(GetIndexedUnitId()).bool = Table.create()
endmethod
static method deindex takes nothing returns nothing
set thistype(GetIndexedUnitId()).number = 0
call thistype(GetIndexedUnitId()).bool.destroy()
endmethod
static method filter takes unit u returns boolean
return IsUnitType(u,UNIT_TYPE_HERO)
endmethod
implement UnitIndexStruct
endstruct
private function DataBuffer takes nothing returns boolean
local integer i = GetPlayerId(GetTriggerPlayer())
if null == GetUnitById(DamageEvent.sourceId) or not IsUnitType(GetUnitById(DamageEvent.targetId),UNIT_TYPE_HERO) or assist(DamageEvent.targetId).bool.boolean[i] then
return false
endif
set assist(DamageEvent.targetId).bool.boolean[i]=true
set assist(DamageEvent.targetId).number=assist(DamageEvent.targetId).number+1
return false
endfunction
private function MultiBuffer takes nothing returns nothing
local integer i=1
loop
exitwhen i>12
set spree(i).counter=spree(i).counter-1
if 0==spree(i).counter then
set spree(i).multikills = 0
endif
set i=i+1
endloop
endfunction
private function OnLeave takes nothing returns boolean
set spree(GetPlayerId(GetTriggerPlayer())+1).on = false
return false
endfunction
private function Print takes player m, player n, unit k, unit d returns nothing
local integer i=0
local integer q=GetPlayerId(m)
local integer r=GetPlayerId(n)
local integer h=GetPlayerState(m,PLAYER_STATE_RESOURCE_GOLD)
local string v=""
local string w=StreakSystem.colors[q]+GetPlayerName(m)+"|r"
local string z=StreakSystem.colors[r]+GetPlayerName(n)+"|r"
local player p = null
local texttag tt = null
local integer x = GetUnitUserData(d)
local integer g = GetBounty(q,r,k,d)
if assist(x).number>1 then
set v=" Assists: "
loop
exitwhen i>11
set p=Player(i)
if assist(x).bool.boolean[i]==true and i!=q and i!=r and IsPlayerAlly(m,p) then
set v=v+StreakSystem.colors[i]+GetPlayerName(p)+"|r/"
if fair then
call SetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)+GetAssistGold(g,assist(x).number))
if text then
set tt=CreateTextTag()
call SetTextTagText(tt,"+"+I2S(g),0.023)
call SetTextTagPermanent(tt,false)
call SetTextTagLifespan(tt,2.00)
call SetTextTagFadepoint(tt,1.5)
call SetTextTagVelocity(tt,0.00,0.0355)
call SetTextTagVisibility(tt,GetLocalPlayer()==p)
call SetTextTagPos(tt,GetCameraEyePositionX(),GetCameraEyePositionY(),0.00)
set tt=null
endif
endif
endif
set i=i+1
endloop
set v=SubString(v,0,StringLength(v)-1)
endif
call assist(x).reset()
if gainGold then
call SetPlayerState(m,PLAYER_STATE_RESOURCE_GOLD,h+g)
if text then
set tt=CreateTextTag()
call SetTextTagText(tt,"+"+I2S(g),0.023)
call SetTextTagPermanent(tt,false)
call SetTextTagLifespan(tt,2.00)
call SetTextTagFadepoint(tt,1.5)
call SetTextTagVelocity(tt,0.00,0.0355)
call SetTextTagVisibility(tt,false)
call SetTextTagVisibility(tt,GetLocalPlayer()==m)
call SetTextTagPos(tt,GetCameraEyePositionX(),GetCameraEyePositionY(),0.00)
set tt=null
endif
endif
if loseGold then
call SetPlayerState(n,PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(n,PLAYER_STATE_RESOURCE_GOLD)-GetLostGold(g))
endif
if StreakSystem.firstblood then
if spree(r+1).streak>=StreakSystem.minSpree and spree(r+1).streak<=StreakSystem.maxSpree then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,TEXTDURATION,z+StreakSystem.endString[spree(r+1).streak]+" streak has been ended by "+w+" for |cffffcc00"+I2S(g)+"|r gold."+v)
elseif spree(r+1).streak>StreakSystem.maxSpree then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,TEXTDURATION,z+StreakSystem.endString[StreakSystem.maxSpree]+" streak has been ended by "+w+" for |cffffcc00"+I2S(g)+"|r gold."+v)
else
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,TEXTDURATION,w+" pwned "+z+"'s head for |cffffcc00"+I2S(g)+"|r gold."+v)
endif
if spree(q+1).streak>=StreakSystem.minSpree and spree(q+1).streak<=StreakSystem.maxSpree then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,TEXTDURATION,w+StreakSystem.strings[spree(q+1).streak])
call RunSound(StreakSystem.sounds[spree(q+1).streak])
elseif spree(q+1).streak>StreakSystem.maxSpree then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,TEXTDURATION,w+StreakSystem.strings[StreakSystem.maxSpree])
call RunSound(StreakSystem.sounds[StreakSystem.maxSpree])
endif
else
set StreakSystem.firstblood = true
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,TEXTDURATION,w+" just drew |cffff0000firstblood|r!")
call RunSound(StreakSystem.firstSound)
call SetPlayerState(m,PLAYER_STATE_RESOURCE_GOLD,h+FIRSTGOLD)
endif
set spree(q+1).multikills=spree(q+1).multikills+1
set spree(r+1).streak=0
if 0<spree(q+1).counter and spree(q+1).multikills>StreakSystem.maxMulti then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,TEXTDURATION,w+StreakSystem.multiString[StreakSystem.maxMulti])
call RunSound(StreakSystem.multiSound[StreakSystem.maxMulti])
elseif 0<spree(q+1).counter and spree(q+1).multikills>1 and spree(q+1).multikills<=StreakSystem.maxMulti then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,TEXTDURATION,w+StreakSystem.multiString[spree(q+1).multikills])
call RunSound(StreakSystem.multiSound[spree(q+1).multikills])
endif
set p=null
endfunction
private function Main takes nothing returns boolean
local unit d=GetTriggerUnit()
local unit k=GetKillingUnit()
local player n=GetTriggerPlayer()
local player m=GetOwningPlayer(k)
local integer q=GetPlayerId(m)
if IsUnitType(d,UNIT_TYPE_HERO) then
if q>11 or IsPlayerAlly(m,n) or null==k or null==m or not spree(q+1).on then
return false
endif
if n==m then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,TEXTDURATION,GetPlayerName(n)+" has killed himself!")
if endSuicide then
set spree(q+1).streak = 0
endif
return false
endif
set spree(q+1).streak=spree(q+1).streak+1
set spree(q+1).counter=MULTITIME
call Print(m,n,k,d)
endif
set d=null
set k=null
set n=null
set m=null
return false
endfunction
private module Init
private static method onInit takes nothing returns nothing
local trigger t=CreateTrigger()
local integer i=0
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(t,Condition(function Main))
call DamageEvent.ANY.register(Condition(function DataBuffer))
set t=CreateTrigger()
loop
exitwhen i>11
call TriggerRegisterPlayerEvent(t,Player(i),EVENT_PLAYER_LEAVE)
set spree(i+1).on = true
set i=i+1
endloop
call TriggerAddCondition(t,Condition(function OnLeave))
call TimerStart(CreateTimer(),1.00,true,function MultiBuffer)
set t=null
endmethod
endmodule
private struct Inits extends array
implement Init
endstruct
endlibrary
It requires:
- DamageEvent by Nestharus
- UnitIndexer by Nestharus
- SoundUtils by Rising_Dusk
- Table by Bribe
There's a testmap attatched if you want to try this system out
Unfortunately, assists can't be tested yet :/
I did a lot of debugging to see if they would work though
Attachments
Last edited: