| 05-01-2008, 12:38 AM | #1 | |
Assistance System 1.20
![]() A complete, 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. Why did I make this? Vile had originally made and released one here a while back, but I never really cared for his method or triggering. I had need of such a system recently, so I wrote this, with a little help from Viles original system. I think this is a good git more optimized and more functional then his. If there is a better method for achieving this goal, I don't know of it, but would sure like to be enlightened. Pros:
Read Me:
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 Version History:
|
| 05-01-2008, 01:10 AM | #2 |
Instead of doing bounty, messages, etc for us, I would prefer to be able to register a function, then access a global unit group with all the assisting units in it. Or, at least globals to customise the message. |
| 05-01-2008, 02:17 AM | #3 |
I wanted to make this too! But I was just too lazy, and these kinds of things are quite tedious to me. +Sex |
| 05-01-2008, 02:35 AM | #4 |
There's already one in the database that uses the same syntax and everything as you, you even made mention of it in the original post. I'm not able to check currently, but what makes yours any better that we should have yours in the database and not the old one? If it's just a "Different way to code it" as you said, that doesn't merit approving it. I don't consider displaying split gold as something that means anything, either. |
| 05-01-2008, 01:30 PM | #5 | ||
Quote:
that can be aranged as far as customizing the message, since its pretty dynamic, realistically, the only parts that could be changed would probably be: "With assistance from" and "+xx gold!" though I consider those pretty staple to the system, if you have better ideas let me know Quote:
i don't know what you are refering to by syntax, but, other then a few local variable names(which I use simply because I liked the naming scheme), everything else should be completely different, atlest what matters optimization is the major reasons this is better, though there are a few other reasons:
not sure what you are talking about with the "Split gold is stupid" comment, Viles has the option and I completely agree that a new system should not be warranted simply because its coded differently, but that is hardly what this is, else I would not have released this I am surprised you thought otherwise, and I really suggest you read through my code again if you mis-took this for Viles written slightly differently |
| 05-01-2008, 02:05 PM | #6 | |||
Quote:
Quote:
Quote:
|
| 05-01-2008, 02:22 PM | #7 | |||
Quote:
that would be a problem, as it would with Viles I believe it would also require attaching to units, I think, unless you can somehow design arrays to be specific for a pair of units, that is out of my league quite frankly Quote:
I can honestly say it never crossed my mind, though now I can see how simply obvious it should have been (especially when there is a previously accepted system already on the board), will do Quote:
don't know what to say, seemed like a good idea at the time |
| 05-01-2008, 04:06 PM | #8 |
Just to let you know, requiring vJass makes it harder to import than Vile's system, since you have to use JNGP to use this system. Sure, we all agree that everyone should use JNGP, but not everyone does. Just thought I'd mention that. I really think that being able to distinguish heroes for assists would seriously merit approving this, otherwise it's really just an optimization. I guess that's not bad, though, so let me go through it and we'll see. |
| 05-01-2008, 05:50 PM | #9 | ||
I think it makes it less globally accepted, however, its still far easier to import if you fall in the catagory of JNGP Users, which, as you said, everyone serious about mapping, or using pre-made system should It is impossible to import if you're not a JNGP user, I think would be more accurate, w/o serious editing Quote:
can't say I understand what you mean by this..... Quote:
agreed, Viles had all the options I could think to add, and other then tracking assists, its still just an configurable assistance system, far more optimized, using vJASS syntax |
| 05-01-2008, 06:04 PM | #10 |
On another note, wasn't your Knockback System, just an optimized version of what vile already had? So an optimized Assist System, surely would full into the same category? EDIT: Could you update this please, so it takes into account team killing/denying & suiciding? In the test map I killed an ally and got 250 gold!! |
| 05-01-2008, 07:09 PM | #11 | ||
Quote:
Quote:
|
| 05-02-2008, 07:39 AM | #12 | |
Quote:
It was not in anyway intended to be a hostile attack or neither intended to insult your integrity, I was just making a 'blunt' observation. - You seemed very anti vile's knockback system, advising ppl not to use it & went through the trouble of posting an optimization. - Emjlr3's comes along & seems to pretty much do the same thing, I thought you'd only be happy with that. (Correct me if I'm wrong but, I didn't see any new features in your knockback system, mainly seemed like an overall optimization). === Emjlr3, just incase didnt see above reply (as I edited it later), please add in consideration for teamkilling/suiciding. |
| 05-02-2008, 12:37 PM | #13 |
the test map does not differentiate between ally killing and the lot, nor does it stop ally attacking however, the assistance system will not give assistance for doing so, it can distinguish the difference and, the hero kill message in the demo map has nothing to do with the assistance system |
| 05-02-2008, 02:28 PM | #14 | |||
Quote:
Quote:
Quote:
|
| 05-02-2008, 03:29 PM | #15 |
perhaps I being dumb but I really can't think of a good method for doing that (though I can't say I have really thought about it too indepth), if I can think of one, or you can suggest one, I would be happy to implement it (would prolly end up being a huge overall to the system, as my storage algorithm would change dramatically), but until then.... as it stands, what is holding this back form being accepted? |
