[script] handicap

Intended for use on live public servers.
6 posts Page 1 of 1 First unread post
Dr.Morphman
Scripter
Scripter
Posts: 73
Joined: Sun Feb 24, 2013 9:55 am


so for all those mlg players who are getting tired of wrecking the entire enemy team alone:

this script can modify your damage multiplier according to your wishes (more or less)

by simply typing /handicap 0.5 for example, you will deal only 50% of the total damage
Attachments
handicap.py
there isnt much to say about that
(852 Bytes) Downloaded 293 times
a girl
Scripter
Scripter
Posts: 85
Joined: Thu Nov 15, 2012 6:32 am


Cool concept, though I haven't tested it yet. I actually had an idea to take this one step further. If you set up the script to dynamically change your handicap value, for instance multiply your damage by the inverse of your kill/death ratio. Any player with a 10:1 kill:death ratio would have their damage value at .1. Any player with a ratio of 2:1 would have their handicap at .5. This might be a little radical, but it would level the playing field in a non-discriminating way AND aimbots would have their killing ability obliterated the more they cheat.

Basically, the whole server is instantly on even playing grounds. Pros can have fun killing noobs. Noobs have a chance against pros. Aimbots have to score something like 3 or more headshots (depending on the player) which is more than enough of a chance for the victim to get to cover or to snipe back.

I'm not sure if it would be a good idea for people with less than a 1.0 K/D ratio to have their damage improved. If you do, i'd set a limit for it to be no more than 1.5 times as powerful.

Also, you could make the damage more specific to each player. If both players have a similar K/D ratio, then damage values would be pretty close to normal. If player A with KD of 2.8 shoots player B with KD of 1.4, it could have the handicap factor equal to the ratio of the two ratios, inverted. So A would shoot B with a damage factor of .5, while B could shoot A with a damage factor of 2.

Anyway, I took a look at your script and noticed that you never called connection.on_hit(...) so any script that uses on_hit that is loaded after handicap.py wouldn't work. If banhammer or analyze or aimbot2 were loaded after it, they probably wouldn't run. ALWAYS call the hook again, even if you don't plan on returning it. The hook has to be called exactly once. If you don't call it at all, no other scripts containing this hook will run the code pertaining to that hook. If you call it multiple times, then those scripts will run their code multiple times.
Last edited by a girl on Sat Apr 19, 2014 5:44 am, edited 1 time in total.
Dr.Morphman
Scripter
Scripter
Posts: 73
Joined: Sun Feb 24, 2013 9:55 am


hm yeah now that you mention it , it certainly renders other scripts useless
but calling connection.on_hit will deliver the original damage value no matter what thus turning this handicap thingy useless so i have got honestly no idea
maybe i have to modify set_hp as well idk
i will see what i can do though

the balanced handicap seems to be a good idea imo
a girl
Scripter
Scripter
Posts: 85
Joined: Thu Nov 15, 2012 6:32 am


Dr.Morphman wrote:
but calling connection.on_hit will deliver the original damage value no matter what thus turning this handicap thingy useless
Edit: Original post retracted as it was absurdly long, difficult to understand and based on incorrect assumptions.

connection.on_hit(...) will only deliver the original damage if you return it. There is no harm in calling it, storing the returned value in a variable, then returning your own modified value. This will give all scripts a chance to at least work with the original hit values.

value = connection.on_hit(...)
#value will either be None or it will be an integer for the new damage value.
#it's important to note that the current script stops here while the other scripts are run first.
#after they are done running, the current script continues.

return connection.on_hit(...)
#again, the connection.on_hit(...) will either become None or an integer for the new damage value.
#if you directly return it as in this case, you aren't over-riding the value, just returning the value passed by other scripts


example:

value = on_hit(...) #ask all other scripts if they have any other feedback. Forces them to run
return 17 #ignores all possible input from other scripts and returns 17
#this will work just fine if you want to make every hit equal to 17 and makes sure that every script runs
Last edited by a girl on Sat Apr 19, 2014 5:47 am, edited 2 times in total.
Dr.Morphman
Scripter
Scripter
Posts: 73
Joined: Sun Feb 24, 2013 9:55 am


uh while i am grateful for this detailed description i am afraid i still dont get it at all

as far as i understood you (i might even be wrong there) i have to do it like this
Code: Select all
        def on_hit(self, hit_amount, hit_player, type, grenade):
            kitten = connection.on_hit(self, hit_amount, hit_player, type, grenade)
            try:
                kitten = trunc(kitten * self.handicap_value) 
                return kitten
            except: return False
but that doesnt work at all since connection.on_hit always returns None (or False) there
a girl
Scripter
Scripter
Posts: 85
Joined: Thu Nov 15, 2012 6:32 am


Okay, this hook behaves differently than what I was thinking... I did some testing before spouting crap out of my butt this time.

connecton.on_hit(...) will return None ONLY if no other script is trying to override the value.
It will return False if another script wanted the shot to be thrown away.

If a script wants to change the value, it must return the new value or it can simply return the hook call if it doesn't want to change anything. I assumed that the damage value expressed as an integer would be returned no matter what. I didn't expect it to return None if no change was needed.

Anyway, I'll go retract some of that crap I've been spouting, but here's the working (only lightly tested) code. Anyway, this code that I'm posting uses the same concept. Call the hook function and store it in a variable. If it does not return a None value, then some other script overwrote the value and that value should be returned instead.

Also, instead of truncating the float, I just cast it as an integer which is just a simple way of rounding it and nothing needs to be imported.
Attachments
handicap2.py
(1.25 KiB) Downloaded 241 times
6 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 22 guests