Author |
Message |
Rog Newbie

Joined: Oct 18 2007 Posts: 18 Offline
|
Posted: 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?
|
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: 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. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me
|
|
Back to top |
|
 |
k0zy Server Help Squatter

Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: 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. _________________ It's a shark! Oh my god! Unbelievable!
|
|
Back to top |
|
 |
Rog Newbie

Joined: Oct 18 2007 Posts: 18 Offline
|
Posted: 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.
|
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: 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. _________________ ss news
Last edited by Smong on Thu Nov 01, 2007 5:18 pm, edited 1 time in total |
|
Back to top |
|
 |
Rog Newbie

Joined: Oct 18 2007 Posts: 18 Offline
|
Posted: 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*
|
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: 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.
hs_kill.zip - 3.58 KB
File downloaded or viewed 32 time(s)
|
|
Back to top |
|
 |
Rog Newbie

Joined: Oct 18 2007 Posts: 18 Offline
|
Posted: 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.
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
#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.
|
|
Back to top |
|
 |
|