Bot Apology for TK
7 Attachment(s)
Bot Apology for TK
Many servers that I play on have friendly fire turned on and many also "require" an apology for team kills. If you have bots, why not let them set a good example? Description: This plugin will make a bot apologize, in chat, for it's team kills. Cvars: amx_bot_apology <1|0> - Turn plugin on or off. amx_bot_apology_prob <0-100> - The probability that the bot will apologize for a TK. amx_bot_apology_method <0-100> - Probability that team chat will be used. (0 -> public, 100 -> team) amx_bot_apology_delay <#> - The time between the TK and the apology (from last TK if there was another within the delay time of the previous TK). Note: Cvar changes take effect on map change. I only play Day of Defeat but I would assume that it would work on other Mods as it is very simple with no Mod specific code. Thanks for feeback and suggestions: - Vet - Arkshine - Exolent Changelog: v1.3 - Removed unnecessary(?) condition checks. - Changed Death detection from Ham Hook to Event Hook. v1.4 - Added is_bot global array instead of is_user_bot (set on putinserver). - Remove task on disconnect. - Rearranged some code. v1.5 - Changed method for assigning is_bot values. - Changed on/off cvar usage. v2.0 - Added cvar to allow using team chat. v3.0 - Added bot_apology.ini for apology phrases. - Changed "chance" to a macro. - Using copy for string assignment. |
Re: Bot Apology for TK
Quote:
|
Re: Bot Apology for TK
Upadted: See Changelog.
|
Re: Bot Apology for TK
Updated to 1.2.
|
Re: Bot Apology for TK
Good job :)
|
Re: Bot Apology for TK
random_num(0,99) should be random_num(0,100)
;) |
Re: Bot Apology for TK
Here some thoughts :
- g_sorry_phrases <= use const before since it's something constant and don't harcode '6', no need. - Since it's for bots, you should not use Ham, if the bot's classname is not "player" it will not work. More appropriate to use DeathMsg event which is perfectly fine. - Cache the value of is_user_bot(). Just save it into a var in client_putinserver(). - Doing a check if victim/killer is connected in the death function is useless here. - Don't check if task exists, no need here, you can remove directly. - set_task ; why did you pass the killer id ? The message will be showed only for the killer and not the victim. I think this message should be showed for all players, so using 0. - In say_sorry() function, the check for bot is useless ; same for is_user_connected assuming you pass 0, and you engclient_cmd() should be : engclient_cmd(0,"say %s",g_sorry_phrases[random_num(0, sizeof g_sorry_phrases - 1)]) Did you test your plugin ? :s |
Re: Bot Apology for TK
Quote:
Edit: arkshine, why would the classname be other than "player"? |
Re: Bot Apology for TK
cz bots are not "player" for example. So it's possible that others bots is not "player" though most are "player". Using DeathMsg is fine.
Quote:
|
Re: Bot Apology for TK
Quote:
Edit: Can you unregister events with "unregister_message"? |
Re: Bot Apology for TK
Quote:
If I use "<=" I can use 1 to 100. Quote:
Quote:
Quote:
Quote:
Code:
L 02/20/2009 - 00:37:07: [DODX] Invalid player 15Quote:
Using zero gives this: Code:
|RIP| Fysiks |mR killed his teammate Sgt.EVILswede with garandQuote:
I check is_user_connected because the bot could leave (and not be replaced) in the time set with the delay cvar. Also, engclient_cmd deos not work like that. "say" is the command and g_sorry_phrase[#] is arg1. Quote:
|
Re: Bot Apology for TK
Updated to 1.3.
|
Re: Bot Apology for TK
Quote:
Edit: forget it. I was tought that you were using random but you are using random_num |
Re: Bot Apology for TK
Quote:
Quote:
Quote:
But, anyway, you should remove the task on client_disconnect, so the check is_user_bot would be useless and also avoiding possible problems. Quote:
Anyway, you should avoid this way of coding, returning each time something. It will generate more code. You could do something like : PHP Code:
PHP Code:
|
Re: Bot Apology for TK
Quote:
Also, I was thinking that if it was a bot then I wouldn't need to do the "killed self" check or the TK check by returning PLUGIN_CONTINUE first and thus minimizing the execution time when there are no bots on the server (which is the time you want it to do as little as possible). Any thoughts on this would be great. Thanks for all your help :). EDIT: Updated to 1.4 |
Re: Bot Apology for TK
Not need to do that Vet. If player is a bot, it will return 1 otherwise 0. So, no need to "clear".
By the way : Code:
if(is_user_bot(id))Code:
is_bot[id] = is_user_bot(id);Quote:
|
Re: Bot Apology for TK
Your right ark, I realized that later and sheepishly deleted the post.
|
Re: Bot Apology for TK
Updated. I think we are close :). It's only been tested on DOD still, as far as I know.
|
Re: Bot Apology for TK
This plugin needs testing. If anyone can report that it does or doesn't work, please post.
If you would like any information regarding possible adjustments you could make or things you could do to make this better, please feel free to post here or PM me. Approval pending on changes. |
Re: Bot Apology for TK
fysiks... first you used ham to hook the death and that was good, ham is fast. so i think you should go back to ham.
why do ya do this: Code:
that is not needed at all, just use is_user_bot(id). if you want something random to happen you can do something like this: Code:
i dont understand your chance thing either... and not your Code:
if i where you i would start allover, and first thing i would do was to find how exec that say cmd on a bot, and after that find a good way to do get the random thing to happen... if i should make the random say txt i would do like this in a function: Code:
cheers |
Re: Bot Apology for TK
FYI, we run this plugin on our server and it appears to do the job quite well.
Programming wise, like I always say, there's many ways to skin a cat (I prefer pliers). So unless the code is in a critical routine (like a prethink), 'to each his own'. |
Re: Bot Apology for TK
Apparently you have not run my plugin with bots yet. :). I guaruntee it will work on DOD with Shrikebot. It's running on a public server right now.
Ham ::: I had a bit of trouble with Ham. I was required to check a alot more stuff (maybe not alot, but enough to be annoying). I was getting killerids like 59, 639, 520, . . . (59 is electric ally on dod_caen). If you are saying Ham is quicker to the draw, it doesn't matter, the response is delayed anyways. Also, if it can be done with only one include and I don't need to do anything like supercede this way is great afaik. is_user_bot(id) ::: Go back and read arkshine's comments. (minimize native calls) Random ::: No. For the phrases I want random (just plain random, well, pseudorandom :)). chance(prob) ::: chance(100) returns true 100% of the time. chance(50) returns true 50% of the time (statistically). chance(1) returns true 1% of the time (statistically). chance(0) returns true 0% of the time (i.e. always returns false.) engclient_cmd() ::: You can't send a client command to a bot (i.e. can't use client_cmd) afaik. engclient_cmd sends a command to the server as if it is coming from the client and it works great! Why would I use a case structure if I can just assign a variable and pass that variable to the command? Quote:
Quote:
|
Re: Bot Apology for TK
That would be my server. Working fine.
From HLSW Quote:
|
Re: Bot Apology for TK
1. Would be better to have a .ini file so they could put their own apology messages.
2. Code:
3. Code:
Also, random numbers should be 1-100 Code:
Approval pending upon changes. |
Re: Bot Apology for TK
I greatly appreciate your input.
ini file: Should I use dynamic arrays for retrieving the apology messages or should I hard code a cap (max) (with a #define probably)? Chance: If using '>=' you must use 1-100 but if using only the '>' 0-99 is correct. I'll get to work on this. |
Re: Bot Apology for TK
I would suggest dynamic arrays, but it's however you wish.
As for the chance calculation, you are correct. I just use 1-100 because it's more readable. |
Re: Bot Apology for TK
Updated. Let me know if I can improve it anymore. I will look into using dynamic arrays for phrases sometime in the near future.
I have a max of 10 phrases (this can be changed in the code: "SORRYS_MAX"). Thanks everybody. |
Re: Bot Apology for TK
Quote:
|
Re: Bot Apology for TK
GJ my man
|
Re: Bot Apology for TK
Wahooo! Thanks guys.
|
Re: Bot Apology for TK
Wow really nice idea :)
thx Fysiks |
Re: Bot Apology for TK
great plugin could you add a cvar that makes bots also apologize in TA?
like amx_bot_apology_ta |
Re: Bot Apology for TK
Quote:
|
Re: Bot Apology for TK
Quote:
lol gonna be funny |
Re: Bot Apology for TK
1 Attachment(s)
Try this. If it doesn't work I will see what I can do, but hopefully there is no problem :)
Cvar: amx_bot_apology_ta "1" - |
Re: Bot Apology for TK
installed it..dunno if it works. join !!!!
edit seems it works! nice plugin m8! :D |
Re: Bot Apology for TK
Oh my god, that bot have just apologized me = ))
|
| All times are GMT -4. The time now is 17:12. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.