System Assistance System 1.20

emjlr3

Change can be a good thing
Staff member
Assistance System 1.20



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!

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&gt;Total then
            call BJDebugMsg(&quot;AS Error: |cffff0000No reset timer found.&quot;)
            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()&lt;.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&gt;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&gt;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&gt;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&gt;count
        set msg = msg + &quot;, &quot; + GetPlayerNameColored(pa<i>)
        set i = i + 1
    endloop
    if count&gt;0 then
        set msg = msg + &quot; and &quot; + GetPlayerNameColored(pa<i>)
    endif
    set msg = msg + &quot;.  +&quot;+GoldColor+I2S(gold)+&quot;|r&quot;+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(&quot;AS Error: |cffff0000&quot;+GetUnitName(u)+&quot; has already been registered with the system.&quot;)
        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
 

Attachments

Larcenist

REP: Respect, Envy, Prosperity?
tried it and it looked great. Preformed a lot better than my GUI crap I wrote for assistance system too. One question since I do not know much JASS myself, is it possible to change an assist-score in a multiboard for each player with this system? So that is shows kills/deaths/assists?
 

emjlr3

Change can be a good thing
Staff member
tried it and it looked great. Preformed a lot better than my GUI crap I wrote for assistance system too. One question since I do not know much JASS myself, is it possible to change an assist-score in a multiboard for each player with this system? So that is shows kills/deaths/assists?
thnx for trying, id hope it was better then your "GUI Crap"
it would be a good idea for me to have assistance values interally to the system, which are maintaned and can be retrieved globally

good idea

It's pretty good and usefull, expecialy used in meele maps (tho it wound make map not meele anymore) but it's still ownage, gj
ty

Are you doin' some kind of AoS with all those systems? (duh, two -.-)
not really, but i sort of needed these, so i figured if i was going to make em, i might as well release em too
 

Larcenist

REP: Respect, Envy, Prosperity?
It's a lot better than my GUI system, the only thing it lacks is assistance values to add to a multiboard. If you would add this I'd surely be using this system instead. Keep up the good work.
 

emjlr3

Change can be a good thing
Staff member
ill update it tonight to include those, its a simple addition, but a good one

I am surprised no one has commented on my storage algorithm, i thought it was ingenious :) maybe thats just me, I know Viles was simply retarded in that department
 

Joker(Div)

Always Here..
Several Questions.

1. Why don't you use CCSafety? Your not pausing the timer before destroying and also why do you null globals timers (and units)? (all in Reset)

2. Any reason to not null local unit dam? (In Timer)

3. Any reason not to null local unit dieer? (In Death)

4. What's up with this? Why a seperate function for your actions?
JASS:
private function Init_AssistanceSystem takes nothing returns nothing
    call TriggerAddAction( Trigger1, function Timer)
    call TriggerAddAction( Trigger2, function Death)
endfunction


5. ConvertPlayerState(1), Keep those as w/e the bj vars were. Variables > calls

Your system seems a bit limited, but at least its short and does the job.
 

emjlr3

Change can be a good thing
Staff member
UPDATED!!!!

1. Who cares if I do not pause the timer??? You need to null it to see when it was expired, if you don't null it how are you to tell? Use a unit group/registered unit, and add/remove units from it? Its an option I suppose, but this is how I did it, if you can really think of a better method speak up. I suppose I could use a CSSafety variant, specifically for this system, though that would really be a case for nulling the globals stored in the array, else there would be huge problems
2 & 3. I figured for 99% of ppl this would be used for heroes, thus, they never leave, and do not need to be nulled. diier and dam will always be said hero. I updated it though just incase, to keep you happy
4. What???? I need to initiate the system, no? If you mean why not use 1 function for deaths and timer expiration? In that case, why doesn't everyone just use 1 function for their entire map???
5. Its a native, im not too worried, and its only called a few times every few seconds, tops. Its really not a big deal

Limited, in what sense of the word, the sense that it has no limits?? I fail to see what you mean by this....
 

Joker(Div)

Always Here..
1. I thought not pausing timers caused bugs ingame. You could use the TimerGetRemaining or TimerGetElapsed natives.
2/3. Eh..I guess its not all too important.
4. I don't see why you don't just put those actions in your function Register. (I guess since your using a global trigger it doesnt matter..)

I was a bit confused at first glance because I'm not used to seeing global useage like this.

@Limited
I meant it doesn't have much features.
 

emjlr3

Change can be a good thing
Staff member
what features is it lacking?

ive had problems with timergetremaining and elapsed before not giving me correct values

why would i want to add the actions function to the trigger each time a unit is registered, that makes no sense
 

waaaks!

Zinctified
just the system im waiting for....i asked vile to fix it, but he didnt replied :( poor me...
now u made it, ill try it...

EDIT: works well
 

emjlr3

Change can be a good thing
Staff member
guess i could answer that a few ways

1. if u dont know what one is, you prolly dont need it
2. read the code and find out
3. you dont know what an assistance system is???
4. cant tell from the screenshot??
5. cant tell from testing the map??
6. maybe i should explain....
7. rinse and repeat
 

AceHart

Your Friendly Neighborhood Admin
> maybe I should explain

Well, yes. Would be an idea, now, wouldn't it?

My random guess here says:
- I get some extra Gold from being nearby some kill
- If I also damaged that special target unit
- And within 10 seconds of... of its... of... well, how knows what the heck. There's some timer involved. Somehow.

How much do I get? Don't ask me, I have no idea.
What about that timer?

No need to count the players? Nice... though I can't say I see why that would be needed anyway.


Anyway, some more details as to what exactly, and why, is going on wouldn't hurt.
 

cr4xzZz

Also known as azwraith_ftL.
Perfect! D*mn, you make such nice systems, and systems that I needed... ^^
Nobody knows what an Assistance System is if they don't play DotA (probably). I think this needs a long explanation, well, a decent one. Don't get me wrong, it does really show perfectly what it does but if some people are asking what it is... Well, nvm. Gj again :thup:
 

emjlr3

Change can be a good thing
Staff member
No need to count the players? Nice... though I can't say I see why that would be needed anyway.
when I eventually need to find out what timer expired, the less things I need to loop through the better

Ima add an explanation to the post now

**UPDATED!!!**
 

Larcenist

REP: Respect, Envy, Prosperity?
This is probably one of the most useful non-code enhancing systems around. This is going straight into my current project. Keep up the good work.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    My grandmother just passed away, she was 95. I might be going to Florida for a week.
  • The Helper The Helper:
    I have a buddy in Florida who has an extra office space for me with a computer so I can do anything so likely I will be going up there wednesday or thursday
  • Ghan Ghan:
    Let me know if there's anything I can do to help.
  • The Helper The Helper:
    thank you Ghan
  • jonas jonas:
    Sorry for your loss
    +1
  • Varine Varine:
    I'm sorry to hear that bro
  • Varine Varine:
    Not to distract but is anyone aware of any software to help visually impaired people interact with their PC?
  • Varine Varine:
    Also what's the best way to ship a PC? Should I just wrap the fuck out of it in the case or put the components in static bags and wrapped up individually?
  • Ghan Ghan:
    The GPU is the biggest danger typically.
  • Ghan Ghan:
    Some of the pre-built vendors use expanding foam to fill in the case and secure the GPU. Otherwise it might be best to remove it and ship it separately.
  • Ghan Ghan:
    Similar if the machine has a large tower CPU cooler installed. Those can experience huge forces and destroy the socket during shipment if they are heavy.
  • Varine Varine:
    So mainly just the heavier things that jut out? I'm planning on pulling out the SSD's too and anything that I don't have well secured. I'll probably be good leaving the motherboard and PSU screwed in there though if I bundle it up?
  • Ghan Ghan:
    Yeah, I'd expect those to be fine. It's mainly the heavy stuff that is also long/tall where dropping the case would cause it to exert a ton of force on the mount. The motherboard will be fine screwed into the board unless the case itself is somehow severely damaged.
  • Varine Varine:
    I have the original packaging for it, so I was going to just put it back in there
  • Varine Varine:
    I don't think I have the boxes for the components though and so I don't want to have a bunch of loose shit bouncing around
  • The Helper The Helper:
    damn I just read that lol
  • The Helper The Helper:
    when i read up and saw spray in foam I was like oh shit
  • The Helper The Helper:
    going to do the last controller giveaway in the NUON Dome forum because I just cannot sell them since I got them for free from a deceased NUON Legend. It is my last one from that.

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome
    Top