Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Teamkill module

 
Post new topic   Reply to topic Printable version
 View previous topic  Friendly Damage Post :: Post Still Think There Needs To Be...  View next topic  
Author Message
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Tue Apr 15, 2003 5:14 pm    Post subject: Teamkill module Reply to topic Reply with quote

This is not only simplistic, and nerely useless, but if someone could tear it to pieces, i might learn something...

Code: Show/Hide

/******************* TEAMKILL REFEREE ******************************\
   Checks all arenas for teamkilling.
   Responds with configured chat messages in .conf

   [Teamkill]
   KillerChatResponse = <string>
      ;sent to teamkiller in chat
   VictimChatResponse = <string>
      ;same for the victim
   WarpVictim = <bool 1|0>
      ;if 1, will warp the victim back to their position
   WarpKiler = <bool 1|0>
      ;if 1, will set killer to ship 1 (or 2 if they are in a warbird)

   Obviously, many more options will become available as billing support comes online
\*******************************************************************/

//// INCLUDES ////
#include "asss.h"

////// GLOBAL VARS ///////
local Ichat *chat;
local Imodman *mm;
local Iconfig *cfg;
local Igame *game;

//// EVENT HANDLERS ////
void onChatMessage(Player *p, int type, Player *target, int freq, const char *text){
   
}
void onKill(Arena *arena, Player *killer, Player *killed, int bounty, int flags){
   //check for teamkill
   if (killer->p_freq == killed->p_freq){

      //message killer
      chat->SendMessage(killer,cfg->GetStr(GLOBAL,"Teamkill","KillerChatResponse"));

      //change killer ship to Warbird
      if(cfg->GetInt(GLOBAL,"Teamkill","WarpKiller",0) == 1){
         if(killer->p_ship == WARBIRD){ //already in warbird, send to Jav
            game->SetShip(killer,JAVELIN);
         }
         else{ //send to Warbird
            game->SetShip(killer, WARBIRD);
         }
      }

      //message victim
      chat->SendMessage(killed,cfg->GetStr(GLOBAL,"Teamkill","VictimChatResponse"));

      //warp victim?
      if(cfg->GetInt(GLOBAL,"Teamkill","WarpVictim",0) == 1){
         
         //build target struct, thanks Smong!
         Target t;
         t.type = T_PLAYER;
         t.u.p = killed;
         game->WarpTo(&t, killed->position.x, killed->position.y);
         
      }
   }
}

/******************** MAIN DLL BODY ************************/
EXPORT int MM_modbot(int action, Imodman *mm_, Arena *arena){

   if (action == MM_LOAD){
      mm = mm_;

      chat   = mm->GetInterface(I_CHAT, ALLARENAS);
      cfg      = mm->GetInterface(I_CONFIG,ALLARENAS);
      game   = mm->GetInterface(I_GAME,ALLARENAS);

      if(!chat)      return MM_FAIL;
      
      //game.h

         mm->RegCallback(CB_KILL,onKill,ALLARENAS);
      
      //chat.h
         mm->RegCallback(CB_CHATMSG,onChatMessage,ALLARENAS);
         return MM_OK;

   }
   else if (action == MM_UNLOAD){
         //game.h
         mm->UnregCallback(CB_KILL,onKill,ALLARENAS);

         //chat.h
         mm->UnregCallback(CB_CHATMSG,onChatMessage,ALLARENAS);

         mm->ReleaseInterface(chat);
         mm->ReleaseInterface(cfg);
         mm->ReleaseInterface(game);

         return MM_OK;
   }

   return MM_FAIL;
}


Perhpas this is very much workable through editing the game itself... this dawns on me now... so difficult thinking not in terms of circumventing, but working throgh now.
Offhand Question: Any new release news?
_________________
Signatures just seem so quaint.
Back to top
View users profile Send private message Add User to Ignore List
Grelminar
Creator of Asss


Joined: Feb 26 2003
Posts: 378
Offline

PostPosted: Wed Apr 16, 2003 2:54 am    Post subject: Reply to topic Reply with quote

Not too bad. A few things I'd change:

Don't pass the result of a cfg->GetStr right into something else. That will return NULL if the requested setting doesn't exist. So assign it to a variable and check it first.

Don't pass non-constant strings as the format parameter in a SendMessage, or Log, or any other function that passes arguments to printf. That leaves you wide open to format string attacks (imagine what happens when someone puts a %s in that config setting). Always use "%s" as the format string, and the text from the config file as the first extra parameter.

Don't use GLOBAL for the config file, because you want to be able to customize this per-arena. Use arena->cfg.

To warp someone, give them the warp prize with game->GivePrize.

I think there's a chance that the position.x,y will reflect the new spawn position rather than the position before the kill, depending on the order the packets come in. If there's a spawn delay it should always work, but I'm not sure if it'll be reliable enough if there isn't.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Wed Apr 16, 2003 4:07 pm    Post subject: Reply to topic Reply with quote

...thanks, ill post an update later
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Thu Apr 17, 2003 5:35 pm    Post subject: Reply to topic Reply with quote

Attached is the source for my upgraded version of Helicon's teamkill module (even though they called it modbot). You need to compile it with util.c and link pthread.lib (which makes it about 20k bigger).

This version of teamkill either spec's the tk'er or warps them to a penalty box and then repeatedly depletes energy for a set time. Settings are per arena and the tk message is now red. I took the liberty of adding some appropriate(?) sounds.

Commands:
*tkunlock <optional message> - Incase they were wrongly accused
*tkstats or ?tkstats <case-sensitive-name> - how mnay tk's since detected
?tkclear - wipe the internal list of tk'ers
*tktest - make it look like someone tk'd you

.conf:
[Teamkill]
KillerMessage=Canniball! (If you are absolutely sure you didn't TK, log out then back in again)
VictimMessage=Notice anything strange lately?
PenaltyTime=15
Action=2
;0 = no action
;1 = spec
;2 = warp (see below)
WarpX=553
WarpY=512

And here's a compiler warning:
Quote:


118 C:\Dev-Cpp\Examples\asss-20030327\ref_teamkill.c
[Warning] assignment discards qualifiers from pointer target type

Code: Show/Hide

109:   char *KillerChatResponse;
117:   KillerChatResponse = cfg->GetStr(killer->arena->cfg, "Teamkill",
118:      "KillerChatResponse");




ref_teamkill.h - 1.09 KB
File downloaded or viewed 60 time(s)

ref_teamkill.c - 10.22 KB
File downloaded or viewed 55 time(s)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Thu Apr 17, 2003 5:45 pm    Post subject: Reply to topic Reply with quote

i feel owned. 'Cept for that compile error new_evil.gif
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Thu Apr 17, 2003 5:49 pm    Post subject: Reply to topic Reply with quote

Try this:

Code: Show/Hide
const char *KillerChatResponse;


Since GetStr returns a const char*, i'll assume thats the warning its giving you.
Back to top
View users profile Send private message Add User to Ignore List Send email
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Thu Apr 17, 2003 9:37 pm    Post subject: Reply to topic Reply with quote

wouldnt there be a way to deny teamkills(yeah, opposite of my other thread) via the packets? could one do it without calculating the damage vs energy?
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Apr 18, 2003 10:04 am    Post subject: Reply to topic Reply with quote

Not without calculating which bombs will team kill.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Fri Apr 18, 2003 2:15 pm    Post subject: Reply to topic Reply with quote

i thought not
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Fri Apr 18, 2003 3:20 pm    Post subject: Reply to topic Reply with quote

Don't worry Helicon, I've left some stuff for you to do biggrin.gif . Player's entering and leaving need to be handled, mainly because their Player *p might change causing the module to send an energy deplete prize or ship change to an invalid pointer icon_exclaim.gif . The only reason I haven't done this is because last time I had an onPlayerAction() callback Asss crashed on me icon_cry.gif .



Enchanced Teamkill module
(source, doc's, dll, groupdef's)

ref_teamkill.zip - 14.47 KB
File downloaded or viewed 59 time(s)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 677 page(s) served in previous 5 minutes.

phpBB Created this page in 0.471358 seconds : 37 queries executed (90.7%): GZIP compression disabled