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
Kill a player via Python module? possible?

 
Post new topic   Reply to topic Printable version
 View previous topic  BulletSpeed Post :: Post N00B coder question.  View next topic  
Author Message
Rog
Newbie


Joined: Oct 18 2007
Posts: 18
Offline

PostPosted: Mon Oct 29, 2007 5:43 pm    Post subject: Kill a player via Python module? possible? Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


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

PostPosted: Mon Oct 29, 2007 6:39 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Mon Oct 29, 2007 6:40 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Rog
Newbie


Joined: Oct 18 2007
Posts: 18
Offline

PostPosted: Mon Oct 29, 2007 11:21 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Thu Nov 01, 2007 4:32 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Rog
Newbie


Joined: Oct 18 2007
Posts: 18
Offline

PostPosted: Thu Nov 01, 2007 4:49 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


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

PostPosted: Thu Nov 01, 2007 5:51 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Rog
Newbie


Joined: Oct 18 2007
Posts: 18
Offline

PostPosted: Fri Nov 02, 2007 5:31 am    Post subject: Reply to topic Reply with quote

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.
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions 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: 59 page(s) served in previous 5 minutes.

phpBB Created this page in 0.462822 seconds : 35 queries executed (93.0%): GZIP compression disabled