LucasForums

LucasForums (http://www.lucasforums.com/index.php)
-   JA Coding (http://www.lucasforums.com/forumdisplay.php?f=539)
-   -   How can I make BUTTON_ATTACK as if pressed in cgame? (http://www.lucasforums.com/showthread.php?t=166579)

Vruki Salet 06-22-2006 09:15 PM

How can I make BUTTON_ATTACK as if pressed in cgame?
 
I have made a command in g_cmds.c that needs the game to make like BUTTON_ATTACK has been pressed without the player really doing so.

in bg_pmove.c, within PM_Weapon, I have the following:

Code:


#ifdef QAGAME
        if (g_entities[pm->ps->clientNum].client->vsnSaberCombat.swingingSaber == qtrue)
                {
                pm->cmd.buttons |= BUTTON_ATTACK;
                }
#endif

As you can see it's only in QAGAME so it works fine if my client is the same as my server like when I run it as a non-dedicated listening server, but doesn't work for any clients when I run the code on a dedicated server.

How can I make the cgame also virtually press BUTTON_ATTACK at the same time?

PS.:

I tried out ways that avoided using #ifdef QAGAME but it didn't seem to help. "cmd.buttons |= BUTTON_ATTACK" still didn't work from cgame files though I tried it in various places. As it is now the QAGAME version is back since it's more convenient in other ways.

Tinny 06-22-2006 09:37 PM

Well you can get rid of the qagame, but the client will still need the dll to have this to work I believe.

Vruki Salet 06-22-2006 10:05 PM

I did get rid of QAGAME but I'll do it again to see what happens. Having the client isn't an issue at the moment.

Can you recommend an good place to put some version of "cmd.buttons |= BUTTON_ATTACK" into cgame?

Tinny 06-23-2006 08:01 AM

If you wanted it in just cgame you can use the #ifdef CGAME tag in pmove. I'm not sure if that's what you're asking though.

Vruki Salet 06-23-2006 11:49 AM

It turns out I made a mistake. I am using a modified copy of PM_SaberAttackForMovement and when I got rid of the QAGAME I forgot that the whole function is wrapped in #ifdef QAGAME so I didn't get rid of those. Now I got rid of them and it helps. Thanks for pointing me in the right direction Tinny.

Vruki Salet 06-23-2006 12:37 PM

Now there's another problem to address, maybe you can help again. It goes like this: I have a command set up in g_cmd.c that swings the saber in various directions by feeding a version of PM_SaberAttackForMovement virtual movement directions and then causing a simulated attack button press to fire within PM_Weapon in bg_pmove.c. This works great in standalone client games and listen servers, where I can use 7 numpad keys to make the saber swing all over the place, and I can do swing combos (like yellow scissors etc.) just like regular mouse-driven sabering in normal JKA. Transitions all work like they're supposed to. However now when I run the game as a dedicated server and join it, the buttons swing my saber in the right direction but I can't combo anymore, now in all stances the saber has to do a full swing 100% then come back all the way back to "ready" before it will let me swing again with the keys. There are no transitions and no flowing from one swing into another.

Any ideas why this might be happening?

razorace 06-23-2006 03:06 PM

How are you transmitting the data to the server and when are you handling the combos? On saber impact, or at the end of the animations?

Vruki Salet 06-23-2006 03:44 PM

If I get you right then the answer to the first question is that I make a console command and bind it to the key I want and it makes a command define in g_cmds.c go.

For the second question, I made it so that the next swing could only be commanded during certain times (experimented with various: e.g. once the original swing was 40% done), so the command wouldn't count outside of those times, but when I hit this current problem I opened it up to make the server allow the command at any time.

UPDATE: I have a variable (vsnInt1, essentially userInt1) that when greater than 0 tells the server to "press" BUTTON_ATTACK for me. It used to be "pressed" in bg_pmove.c but I moved it to pm_weaponlightsaber. (Both places behave the same.) I need it to be reset to 0 after a swing so it doesn't just swing forever once it's been made greater than 0 by the command in g_cmds.c, so I put "pm->ps->vsnInt1 = 0;" before returns in my equivalent of PM_SaberAttackForMovement at first, and then changed it to the end of pm_weaponlightsaber. (Both places behave the same.) This is giving a clue to the problem. Without the "pm->ps->vsnInt1 = 0" I swing perpetually once the first command is given. With it, I can make exactly 1 full swing at a time always returning to ready stance before I can swing again.

Vruki Salet 06-23-2006 05:09 PM

Hey is there a big lag problem with setting saber swings via g_cmd.c? I'm having second thoughts about the whole thing because of that. How much more priority are buttons given?

razorace 06-24-2006 05:42 PM

I'm not sure about this but I believe that placing it in g_cmd.c won't cause lag. I believe that the taunt and meditate emotes are controlled that way.

Basically, the command will be processed and applied to the playerstates on the game side. Technically it won't be applied until the next server frame, but that's the case no matter what you do. :)

ensiform 06-24-2006 07:09 PM

taunt and meditate are controlled via a gencmd which are hard coded.

razorace 06-24-2006 07:38 PM

Ok, I was mistaken. :)

Anyway, it really depends on how often you're going to be using this ability.

Vruki Salet 06-28-2006 02:38 PM

The whole thing seemed easier to do & more reliable with buttons so that's what I did.


All times are GMT -4. The time now is 03:48 AM.

Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
LFNetwork, LLC ©2002-2011 - All rights reserved.