lfnetwork.com mark read register faq members calendar

Thread: How can I make BUTTON_ATTACK as if pressed in cgame?
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 06-22-2006, 08:15 PM   #1
Vruki Salet
Junior Member
 
Vruki Salet's Avatar
 
Join Date: Aug 2005
Location: Somewhere else entirely
Posts: 443
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.
Vruki Salet is offline   you may: quote & reply,
Old 06-22-2006, 08:37 PM   #2
Tinny
 
Tinny's Avatar
 
Join Date: Apr 2002
Posts: 1,188
Well you can get rid of the qagame, but the client will still need the dll to have this to work I believe.


Redeemed!

An old school mod for jedi academy.
Tinny is offline   you may: quote & reply,
Old 06-22-2006, 09:05 PM   #3
Vruki Salet
Junior Member
 
Vruki Salet's Avatar
 
Join Date: Aug 2005
Location: Somewhere else entirely
Posts: 443
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?
Vruki Salet is offline   you may: quote & reply,
Old 06-23-2006, 07:01 AM   #4
Tinny
 
Tinny's Avatar
 
Join Date: Apr 2002
Posts: 1,188
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.


Redeemed!

An old school mod for jedi academy.
Tinny is offline   you may: quote & reply,
Old 06-23-2006, 10:49 AM   #5
Vruki Salet
Junior Member
 
Vruki Salet's Avatar
 
Join Date: Aug 2005
Location: Somewhere else entirely
Posts: 443
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 is offline   you may: quote & reply,
Old 06-23-2006, 11:37 AM   #6
Vruki Salet
Junior Member
 
Vruki Salet's Avatar
 
Join Date: Aug 2005
Location: Somewhere else entirely
Posts: 443
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?
Vruki Salet is offline   you may: quote & reply,
Old 06-23-2006, 02:06 PM   #7
razorace
Impressive, Terran!
 
razorace's Avatar
 
Join Date: May 2002
Posts: 9,171
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?


---Jedi Guardian of the Newbie Questions
---Masters of the Force Team Leader / Creator
---Open Jedi Project Lead Moderator / Co-Founder
razorace is offline   you may: quote & reply,
Old 06-23-2006, 02:44 PM   #8
Vruki Salet
Junior Member
 
Vruki Salet's Avatar
 
Join Date: Aug 2005
Location: Somewhere else entirely
Posts: 443
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.

Last edited by Vruki Salet; 06-23-2006 at 03:25 PM.
Vruki Salet is offline   you may: quote & reply,
Old 06-23-2006, 04:09 PM   #9
Vruki Salet
Junior Member
 
Vruki Salet's Avatar
 
Join Date: Aug 2005
Location: Somewhere else entirely
Posts: 443
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?
Vruki Salet is offline   you may: quote & reply,
Old 06-24-2006, 04:42 PM   #10
razorace
Impressive, Terran!
 
razorace's Avatar
 
Join Date: May 2002
Posts: 9,171
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.


---Jedi Guardian of the Newbie Questions
---Masters of the Force Team Leader / Creator
---Open Jedi Project Lead Moderator / Co-Founder
razorace is offline   you may: quote & reply,
Old 06-24-2006, 06:09 PM   #11
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
taunt and meditate are controlled via a gencmd which are hard coded.


iojamp project lead / coder
ensiform is offline   you may: quote & reply,
Old 06-24-2006, 06:38 PM   #12
razorace
Impressive, Terran!
 
razorace's Avatar
 
Join Date: May 2002
Posts: 9,171
Ok, I was mistaken.

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


---Jedi Guardian of the Newbie Questions
---Masters of the Force Team Leader / Creator
---Open Jedi Project Lead Moderator / Co-Founder
razorace is offline   you may: quote & reply,
Old 06-28-2006, 01:38 PM   #13
Vruki Salet
Junior Member
 
Vruki Salet's Avatar
 
Join Date: Aug 2005
Location: Somewhere else entirely
Posts: 443
The whole thing seemed easier to do & more reliable with buttons so that's what I did.
Vruki Salet is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > How can I make BUTTON_ATTACK as if pressed in cgame?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:54 PM.

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