Server Help

ASSS Questions - Kill a player via Python module? possible?

Rog - Mon Oct 29, 2007 5:43 pm
Post subject: Kill a player via Python module? possible?
Is there a way I can suicide / kill a player via a Python module? I have an endgame scenario that involves nuking / exploding the other team upon winning and I'd prefer to do as much in Python as possible (I'm really not much of a C coder, d'oh).

I don't see anything in the game interface that's available via Python for this, but maybe I'm missing something?
Dr Brain - Mon Oct 29, 2007 6:39 pm
Post subject:
Make a fake player and have it send L4 (3 in the packet; levels start at 0) thors on top of everyone you want to kill.
k0zy - Mon Oct 29, 2007 6:40 pm
Post subject:
Couldn't you just send the player the death packet showing him that he died? If I understand the protocol correctly it's not meant to work, but i'd still try.
Rog - Mon Oct 29, 2007 11:21 pm
Post subject:
Dr Brain wrote:
Make a fake player and have it send L4 (3 in the packet; levels start at 0) thors on top of everyone you want to kill.


Which leads to the next question, do Fake players work via Python and if so, how?

I tried fake.CreateFakePlayer and it just locked up my server, plus I don't think game.FakePosition is available via Python. I'll admit, I don't know much about how the Fake stuff works in the first place, just what I've searched here. I could be doing it wrong but the Python implementation seems unfortunately incomplete. =(

Seems like a complicated solution/workaround for something that I'd have hoped would be simple. Thanks for any info tho, I'm still finding my footing on so much of this stuff. Any ideas or examples I'd appreciate.
Smong - Thu Nov 01, 2007 4:32 pm
Post subject:
It's not possible from python. You could create a C module that does the job and exposes an interface to it, then recompile the pymod module so it knows about the new interface. That's the long and painfull way round, the "easier" way would be to convert what you currently have to C (the entire module). I ended up doing this when I ported merv's CTF plugin.
Rog - Thu Nov 01, 2007 4:49 pm
Post subject:
Thanks Smong, good to know.

I haven't decided yet if I'm going to do it the long way (would be kind of nice to expose more to Python), just do it in C, or some kind of other workaround (more likely in the short term, heh).


*glances at that old C for Dummies on his bookshelf*
Dr Brain - Thu Nov 01, 2007 5:51 pm
Post subject:
Take a look at this module for Hyperspace. You'll have to convert the .h file to have the python comments. I'm not sure the exact syntax for that.

I made it into a module to handle things like safe zones and killing adjacent players.
Rog - Fri Nov 02, 2007 5:31 am
Post subject:
Dr Brain wrote:
Take a look at this module for Hyperspace. You'll have to convert the .h file to have the python comments. I'm not sure the exact syntax for that.

I made it into a module to handle things like safe zones and killing adjacent players.


Dr Brain you rock. icon_biggrin.gif

Your zip was missing hscore_shipnames.h but I snagged that from http://forums.minegoboom.com/viewtopic.php?t=7409

I just sorta went by example via other files, but here's how I added the comments for pymod into hs_kill.h
Code: Show/Hide
#ifndef HS_KILL_H
#define HS_KILL_H

#define I_HS_KILL "hs_kill-3"

typedef struct Ihskill
{
   INTERFACE_HEAD_DECL
   /* pyint: use */
   void (*kill)(Player *p, const char *killer, int blast, int onlyTeam); //kill a player. blast will make it affect others, onlyTeam will limit the blast to teammates
   /* pyint: player, string, int, int -> void */

   void (*load)(const char *name, Arena *arena); //load a killer into the arena
   /* pyint: string, arena -> void */

   void (*unload)(const char *name, Arena *arena); //unload a killer
   /* pyint: string, arena -> void */
} Ihskill;

#endif //HS_KILL_H


And of course I included hs_kill.h into pymod.c

It worked like a charm! Thanks very much.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group