Raised This Month: $100 Target: $400
 25% 

Bot Apology for TK


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Fun Stuff        Approver:   Exolent[jNr] (178)
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-13-2009 , 01:38   Bot Apology for TK
Reply With Quote #1

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.
Attached Files
File Type: sma Get Plugin or Get Source (amx_bot_apology.sma - 954 views - 3.1 KB)
File Type: ini bot_apology.ini (213 Bytes, 1171 views)

Last edited by fysiks; 02-17-2016 at 20:07. Reason: Updated coding style.
fysiks is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 02-13-2009 , 10:48   Re: Bot Apology for TK
Reply With Quote #2

Quote:
Originally Posted by fysiks View Post
This is supposed to be in the Server Management Category (I'm sure I selected that)
You can change the category after. Just press the button "Go advanced" on edit.

Last edited by SnoW; 02-13-2009 at 14:30.
SnoW is offline
Send a message via MSN to SnoW
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-13-2009 , 13:14   Re: Bot Apology for TK
Reply With Quote #3

Upadted: See Changelog.
fysiks is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-19-2009 , 19:13   Re: Bot Apology for TK
Reply With Quote #4

Updated to 1.2.
fysiks is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 02-19-2009 , 19:23   Re: Bot Apology for TK
Reply With Quote #5

Good job
BOYSplayCS is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-19-2009 , 19:44   Re: Bot Apology for TK
Reply With Quote #6

random_num(0,99) should be random_num(0,100)

;)
__________________
joaquimandrade is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-19-2009 , 19:47   Re: Bot Apology for TK
Reply With Quote #7

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
Arkshine is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-19-2009 , 19:55   Re: Bot Apology for TK
Reply With Quote #8

Quote:
Originally Posted by arkshine View Post
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
If you want it perfect, add also enableham/disableham if there are bots or not, in the server.

Edit: arkshine, why would the classname be other than "player"?
__________________

Last edited by joaquimandrade; 02-19-2009 at 19:58.
joaquimandrade is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-19-2009 , 20:09   Re: Bot Apology for TK
Reply With Quote #9

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:
If you want it perfect, add also enableham/disableham if there are bots or not, in the server.
Yep, I did not mention it because I've suggested DeathMsg but I forget he could use unregister_message(). Would already fine if all the suggestions are followed. :p :

Last edited by Arkshine; 02-19-2009 at 20:11.
Arkshine is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-19-2009 , 20:16   Re: Bot Apology for TK
Reply With Quote #10

Quote:
Originally Posted by arkshine View Post
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.



Yep, but for some reasons I did not mention it. Would already fine if all the suggestions are followed. :p
Ok, i never played cz. You're right then.

Edit:

Can you unregister events with "unregister_message"?
__________________

Last edited by joaquimandrade; 02-19-2009 at 20:21.
joaquimandrade is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:19.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode