|
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Tue Apr 15, 2003 5:14 pm Post subject: Teamkill module |
|
|
|
|
This is not only simplistic, and nerely useless, but if someone could tear it to pieces, i might learn something...
/******************* 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 |
|
|
Grelminar Creator of Asss
Joined: Feb 26 2003 Posts: 378 Offline
|
Posted: Wed Apr 16, 2003 2:54 am Post subject: |
|
|
|
|
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 |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Wed Apr 16, 2003 4:07 pm Post subject: |
|
|
|
|
...thanks, ill post an update later
|
|
Back to top |
|
|
Smong Server Help Squatter
Joined: 1043048991 Posts: 0x91E Offline
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Thu Apr 17, 2003 5:45 pm Post subject: |
|
|
|
|
i feel owned. 'Cept for that compile error
|
|
Back to top |
|
|
Mine GO BOOM Hunch Hunch What What
Age:40 Gender: Joined: Aug 01 2002 Posts: 3614 Location: Las Vegas Offline
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Thu Apr 17, 2003 9:37 pm Post subject: |
|
|
|
|
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 |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Fri Apr 18, 2003 10:04 am Post subject: |
|
|
|
|
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 |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Fri Apr 18, 2003 2:15 pm Post subject: |
|
|
|
|
i thought not
|
|
Back to top |
|
|
Smong Server Help Squatter
Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Fri Apr 18, 2003 3:20 pm Post subject: |
|
|
|
|
Don't worry Helicon, I've left some stuff for you to do . 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 . The only reason I haven't done this is because last time I had an onPlayerAction() callback Asss crashed on me .
Enchanced Teamkill module
(source, doc's, dll, groupdef's)
ref_teamkill.zip - 14.47 KB
File downloaded or viewed 62 time(s)
|
|
Back to top |
|
|
|
|
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
|
Software by php BB © php BB Group Server Load: 778 page(s) served in previous 5 minutes.
|