Server Help

ASSS Custom Projects - Attach process

Helicon - Sat Apr 26, 2003 1:01 pm
Post subject: Attach process
How much can ASSS alter the attach (F7) process?

My Goal:
Restrict attachments so that one must be within a certain distance of the target ship to attach.


Wasn't there an attachment event? I seem to remeber it passing Player structs. Or maybe that was MERV?

In either case... are the x/y coords at the event curent (player already attached) or not (pre-attachment)

I know this is a spacy post, please forgive me
Dr Brain - Sat Apr 26, 2003 1:11 pm
Post subject:
Yes, that would really help your arena, wouldn't it?

Well, if it can be done, let me know, that has other uses too.
Mine GO BOOM - Sat Apr 26, 2003 1:19 pm
Post subject:
From game.c:

Code: Show/Hide
void PAttach(Player *p, byte *pkt2, int n)
{
   int pid2 = ((struct SimplePacket*)pkt2)->d1;
   Arena *arena = p->arena;
   struct SimplePacket pkt = { S2C_TURRET, p->pid, pid2 };
   Player *to;

   if (!arena) return;

   to = (pid2 == -1) ? NULL : pd->PidToPlayer(pid2);

   if (to && to->status != S_PLAYING)
   {
      lm->LogP(L_MALICIOUS, "game", p, "tried to attach to bad pid %d", pid2);
      return;
   }

   if (pid2 == -1 ||
       ( p->arena == to->arena &&
         p->p_freq  == to->p_freq) )
   {
      p->p_attached = pid2;
      net->SendToArena(arena, NULL, (byte*)&pkt, 5, NET_RELIABLE);
   }
}


For your zone, you could just override that function the in the dll with whatever you want.
Helicon - Sat Apr 26, 2003 10:14 pm
Post subject:
how would i do that as a self-contained module... so that i could designate it as used or not for the arena....
or would i have to list game in the modules for each arena.. then specify the altered one for the specific arena?
Grelminar - Sun Apr 27, 2003 12:58 am
Post subject:
Actually, you can't just override that function without editing game.c and recompiling. I never considered that someone might want to do that, so I didn't add a hook for it.

If you want this feature, I think it's really something that should go in the client, because if it's just in the server, the client is still going to think it's attaching, and you'll get that effect where the ship disappears but doesn't go anywhere. Also, the client will be able to display an "out of range" message in the center of the screen, like it currently does for "can't attach to yourself" and "can't attach to specator", etc.

If you really want to do this right now, I can suggest a hack, but don't tell anyone you heard it from me! You'll want to write a module that adds a packet handler for C2S_ATTACHTO. In the handler, you should check whatever condition you want, and if you want to deny the attach, modify the packet that's passed to you so it looks like it's detaching (pid -1). In order for this to work, your custom module will have to be loaded _before_ the game module, so it can affect the packet that game sees. Again, this is really hacky and unsupported and don't complain if it doesn't work.
Mine GO BOOM - Sun Apr 27, 2003 3:08 am
Post subject:
Or edit game.c and compile. Ahhh... lieing to the client is so much fun :)
Helicon - Sun Apr 27, 2003 3:28 pm
Post subject:
let me get some clarification - add a separate handler in the game.c code to handle arenas which have certain attributes?

I really want to make these modifications without affecting the other arenas in the zone.

sorry if i missed something obvious
Mine GO BOOM - Sun Apr 27, 2003 3:44 pm
Post subject:
Helicon wrote:
I really want to make these modifications without affecting the other arenas in the zone.


Not possible without remaking the game.c, unless you want to try grel's suggestion, which may end up screwing up the client-server connection if done incorrectly.
Helicon - Sun Apr 27, 2003 3:52 pm
Post subject:
could i hardcode a specific handler in game.c for specific arena (pub maybe) and just allow other arenas to fall through to the default?
Mine GO BOOM - Sun Apr 27, 2003 10:53 pm
Post subject:
Sure, just check the arena values inside the process. Make a if check for it, and run the default for the else.
Helicon - Mon Apr 28, 2003 4:10 pm
Post subject:
i knew it i knew it i knew it... hahahahaha

You guys are awesome
Anonymous - Sat Jan 03, 2004 12:02 am
Post subject:
Grelminar wrote:
You'll want to write a module that adds a packet handler for C2S_ATTACHTO. ... In order for this to work, your custom module will have to be loaded _before_ the game module, so it can affect the packet that game sees.

So that the module is loaded after core:net but before game:game?

Done with net->AddPacket? can you add more than one callback function for a packet?

e.g.
Code: Show/Hide
core:net loads
Our module loads
Our module does "net->AddPacket(C2S_GREEN, PFoobar);"
game:game loads
game:game does "net->AddPacket(C2S_GREEN, PGreen);"

Is that okay?
...or would PFoobar have to call PGreen after it's done what it wants to do? (much like proxy dll's)

Close? or a million miles away? icon_smile.gif
Anonymous - Sat Jan 03, 2004 12:04 am
Post subject:
P.S. Apologies for the date difference / dragging up an old thread.

P.P.S. I really should sign up so I can edit my posts to do this. sa_tongue.gif
Anonymous - Sat Jan 03, 2004 11:58 am
Post subject:
Nevermind, what I wanted to do could of been done with "mm->RegCallback" on CB_PLAYERACTION, CB_SHIPCHANGE etc. but what I *had* wanted to do has already been written.... record.c, and better than I could have done (yet to test functionality, but have read through the code)

Nice job Grel. icon_smile.gif
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group