Raised This Month: $12 Target: $400
 3% 

Bot Apology for TK


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-20-2009 , 01:58   Re: Bot Apology for TK
Reply With Quote #11

Quote:
Originally Posted by joaquimandrade View Post
random_num(0,99) should be random_num(0,100)
Incorrect. I thought this over hard. Checked my boundaries and I need 99. If I set the cvar to 100 and random_num() returns 100 --> 100 !> 100 and therefore would execute the command even though it should 100% of the time. Also, 0 to 100 is 101 numbers.

If I use "<=" I can use 1 to 100.

Quote:
Originally Posted by arkshine View Post
- g_sorry_phrases <= use const before since it's something constant and don't harcode '6', no need.
Will do.

Quote:
Originally Posted by arkshine View Post
- 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.
Once I had a taste of the HamSandwich I crave it all the time . I'll get it switched.

Quote:
Originally Posted by arkshine View Post
- Cache the value of is_user_bot(). Just save it into a var in client_putinserver().
I assume you say this because it will be faster/more efficient?

Quote:
Originally Posted by arkshine View Post
- Doing a check if victim/killer is connected in the death function is useless here.
I was trying to prevent this runtime error: (in case the victim or killer gets disconnected for some reason)
Code:
L 02/20/2009 - 00:37:07: [DODX] Invalid player 15
L 02/20/2009 - 00:37:07: [AMXX] Displaying debug trace (plugin "test.amxx")
L 02/20/2009 - 00:37:07: [AMXX] Run time error 10: native error (native "get_user_team")
Quote:
Originally Posted by arkshine View Post
- 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.
It's not a print_chat message. It's emulating the user(bot) saying something in chat. And therefore will be shown to everyone.

Using zero gives this:
Code:
|RIP| Fysiks |mR killed his teammate Sgt.EVILswede with garand
|RIP| Fysiks |mR: sorry
Sgt.Dayglow_abortions: sorry
Sgt.ObiWan: sorry
Sgt.Polymorph: sorry
Sgt.KristineKochanski: sorry
Sgt.QuagaarWarrior: sorry
Sgt.Gilderk_the_Minotaur: sorry
Sgt.EVILcommando: sorry
...
Quote:
Originally Posted by arkshine View Post
- 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)])
I check if it's a bot because in 3 seconds time (or what ever time set with the cvar) the bot could leave and a real player enters. I don't want the real player to say sorry for that which he has not done.
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:
Originally Posted by arkshine View Post
Did you test your plugin ? :s
WOW, that is quite the insult. Yes, why wouldn't I. I would not have posted it if it didn't work, I test my plugins after nearly every change in code I make. It works exactly as I expect it to. Of course I only play DOD so that is what I tested it on.

Last edited by fysiks; 02-20-2009 at 04:11.
fysiks is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-20-2009 , 03:53   Re: Bot Apology for TK
Reply With Quote #12

Updated to 1.3.
fysiks is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-20-2009 , 05:09   Re: Bot Apology for TK
Reply With Quote #13

Quote:
random ( max )
random - Returns a pseudo-random number in the range of 0 to max-1.
random(100) doesn't return 100

Edit: forget it. I was tought that you were using random but you are using random_num
__________________

Last edited by joaquimandrade; 02-20-2009 at 05:21.
joaquimandrade is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-20-2009 , 06:44   Re: Bot Apology for TK
Reply With Quote #14

Quote:
I assume you say this because it will be faster/more efficient?
Yep. Always better to avoid unnecessary native call. Bot will keep a bot so it's not bad to save one time the value in putinserver into a global var.

Quote:
It's not a print_chat message [...] Also, engclient_cmd deos not work like that. "say" is the command and g_sorry_phrase[#] is arg1.
You're right. I did not think that when I reviewed your plugin.

Quote:
I check if it's a bot because in 3 seconds time (or what ever time set with the cvar) the bot could leave and a real player enters. I don't want the real player to say sorry for that which he has not done.
I check is_user_connected because the bot could leave (and not be replaced) in the time set with the delay cvar.
is_user_bot, yes, but is_user_connected no because engclient_cmd() won't send if player is not in-game. There is only a check if id is not out of range.
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:
WOW, that is quite the insult.
Sorry, it was not my intention.


Anyway, you should avoid this way of coding, returning each time something. It will generate more code. You could do something like :

PHP Code:
public player_death ()
{
    if ( 
get_pcvar_numcvar_sorry_onoff ) )
    {
        new 
killerid read_data);
        new 
victimid read_data);
        
        if ( 
victimid != killerid && is_user_botkillerid ) && get_user_teamkillerid ) == get_user_teamvictimid ) )
        {
            
remove_taskkillerid );
            
set_taskget_pcvar_floatcvar_sorry_delay ), "say_sorry"killerid );
        }
    }

PHP Code:
public say_sorry id )
{
    if ( 
is_user_bot id ) && clampget_pcvar_numcvar_sorry_prob ), 0100 ) > random_num099 ) )
    {
        
engclient_cmdid"say"g_sorry_phrasesrandomsizeofg_sorry_phrases ) ) ] );
    }

Also you should add that attacker should be > 0, it will skip suicide and killed by world : register_event( "DeathMsg", "player_death", "a", "1>0" );
Arkshine is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-20-2009 , 13:30   Re: Bot Apology for TK
Reply With Quote #15

Quote:
Originally Posted by arkshine View Post
Anyway, you should avoid this way of coding, returning each time something.
I was wondering about that. With ham I was having trouble with killerids > 32 causing runtime errors with the get_user_team originally so I neede to exit before executing those two natives. But with DeathMsg, I won't need to worry about that.

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

Last edited by fysiks; 02-20-2009 at 18:31. Reason: Updated Plugin
fysiks is offline
Old 02-20-2009, 19:30
Vet
This message has been deleted by Vet. Reason: my bad dawg
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-20-2009 , 19:55   Re: Bot Apology for TK
Reply With Quote #16

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))
{  is_bot[id] = true;	}
else
{  is_bot[id] = false;	}
=>
Code:
is_bot[id] = is_user_bot(id);
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.
Not sure to fully understand. But it seems that you still return PLUGIN_CONTINUE, which you can avoid that, doing like I've done above. It will generate less code.
Arkshine is offline
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 02-20-2009 , 20:15   Re: Bot Apology for TK
Reply With Quote #17

Your right ark, I realized that later and sheepishly deleted the post.
__________________
=====================================
- My Plugins -
=====================================
Vet is offline
Send a message via MSN to Vet
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-21-2009 , 00:49   Re: Bot Apology for TK
Reply With Quote #18

Updated. I think we are close . It's only been tested on DOD still, as far as I know.
fysiks is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-23-2009 , 00:11   Re: Bot Apology for TK
Reply With Quote #19

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.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Dr.G
Senior Member
Join Date: Nov 2008
Old 02-23-2009 , 10:38   Re: Bot Apology for TK
Reply With Quote #20

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:
 
public client_putinserver(id)
{
 is_bot[id] = is_user_bot(id)
}

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:
 
new rN = random_num(1, 100)
if (rN <= 66)
if (rN <= 33)
if (rN <= 10)
are you 100% sure that engclient_cmd works here?

i dont understand your chance thing either... and not your
Code:
 
if(chance(get_pcvar_num(cvar_chat_method)))
what is the chance that it will return false and use the "else" part ?? its 1 out of 100 as i see it.

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:
 
switch(random_num(1,6)) 
{
 case 1:client_cmd(id,"say Something # 1")
 case 2: client_cmd(id,"say Something # 2") 
 case 3: client_cmd(id,"say Something # 3") 
 case 4: client_cmd(id,"say Something # 4")       
 case 5: client_cmd(id,"say Something # 5") 
 case 6: client_cmd(id,"say Something # 6")      
}
overall i think you make it way more complicated then it have to be...

cheers
__________________
Dr.G 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 22:19.


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