Where do player triggers go?
by Brodycat · in Torque Game Engine · 08/19/2005 (7:22 am) · 8 replies
I've been trying to find where trigger functions for firing the weapon go (LMB) to mimc it for a new trigger I want to make (making the player run faster). However, in the script, I can only find the key binding, and then a general trigger function in player.cs. Where, specifically, is the LMB trigger function located? Is it in the engine itself, or am I not looking in the scripts hard enough?
About the author
#2
function jump(%val)
{
$mvTriggerCount2++;
}
...but I cannot find where the variable "$mvTriggerCount2" goes. Where does it call the jumping animation?
08/22/2005 (8:10 am)
Well, there's still an issue. For example, in the default.bind.cs, the jump function (already bound to the space bar) just implements a count increase, like so:function jump(%val)
{
$mvTriggerCount2++;
}
...but I cannot find where the variable "$mvTriggerCount2" goes. Where does it call the jumping animation?
#3
Usually, the mvTriggerCount's are not binded to an absolute function in code from what I know, they are more flexible. But in this case, the C++ code assumes the triggerCount2 will always be jump.
They are processed in ShapeBase.cc - processTick(), like this:
So from what I understand, there are a certain number of trigger states, that are passed from client to server via the Move struct. So, in script when you do $mvTriggerCount2++, you are saying "Trigger number two has fired." Then, when that info gets to the server, it is processed in the above code block.
So, onTrigger will be called on the serverside script for the trigger that has fired.
You could just use a different trigger, like number 3, and have that do something. Try doing a search through the scripts for onTrigger and see what you find.
Disclaimer: This is how I *think* it works. I haven't done a lot of work in this area. Someone please correct whatever is incorrect.
08/22/2005 (9:00 am)
This happens in the player.cc code. Look up the processTick function and do a search for trigger[Usually, the mvTriggerCount's are not binded to an absolute function in code from what I know, they are more flexible. But in this case, the C++ code assumes the triggerCount2 will always be jump.
They are processed in ShapeBase.cc - processTick(), like this:
// Call script on trigger state changes
if (move && mDataBlock && isServerObject()) {
for (S32 i = 0; i < MaxTriggerKeys; i++) {
if (move->trigger[i] != mTrigger[i]) {
mTrigger[i] = move->trigger[i];
char buf1[20],buf2[20];
dSprintf(buf1,sizeof(buf1),"%d",i);
dSprintf(buf2,sizeof(buf2),"%d",(move->trigger[i]?1:0));
Con::executef(mDataBlock,4,"onTrigger",scriptThis(),buf1,buf2);
}
}
}So from what I understand, there are a certain number of trigger states, that are passed from client to server via the Move struct. So, in script when you do $mvTriggerCount2++, you are saying "Trigger number two has fired." Then, when that info gets to the server, it is processed in the above code block.
So, onTrigger will be called on the serverside script for the trigger that has fired.
You could just use a different trigger, like number 3, and have that do something. Try doing a search through the scripts for onTrigger and see what you find.
Disclaimer: This is how I *think* it works. I haven't done a lot of work in this area. Someone please correct whatever is incorrect.
#4
08/22/2005 (10:59 am)
Drew is pretty much right. Nice explanation Drew. :) If you google for "control object" and "move stream" and "move manager" and similar things you should fine several other in-depth discussions of this aspect of the engine.
#5
08/22/2005 (10:36 pm)
Thanks for the information. Looking at the code, it just seems like this is how the triggers actually works, not really calling specific trigger functions, unless I am missing something. Do you think I should be able to make a trigger for running (hold a button down, make the polyer go faster) in script only, or will I have to get into the engine?
#6
08/23/2005 (12:18 am)
Go in the engine most likely. It won't be a heavy change though.
#7
Thanks for your help though. :)
::dives into the engine, never to be seen again::
08/24/2005 (7:08 am)
NooooooooooooooooThanks for your help though. :)
::dives into the engine, never to be seen again::
#8
When I have to figure out a new part of the engine, I try to keep notes in a Word file while I trace through it, so I won't forget later. This has worked pretty well for me to keep track of all the new things I uncover in TGE.
The Move manager is really cool. I'm getting into it some more for some player control tied to camera work.
08/24/2005 (7:12 am)
Hey Ben, thanks. :) I thought that was close, but you never know, I've been pretty far off before with some of my understandings of TGE, so I thought a disclaimer might be a good idea.When I have to figure out a new part of the engine, I try to keep notes in a Word file while I trace through it, so I won't forget later. This has worked pretty well for me to keep track of all the new things I uncover in TGE.
The Move manager is really cool. I'm getting into it some more for some player control tied to camera work.
Torque Owner Matthew Livingstone
To make the player run faster by clicking I would suggest either modifying the mouseFire function in the "starter.fps/client/scripts/default.bind.cs" but only do this is you don't plan on having any other weapons...Otherwise I would make a new weapon (could use an invisible model to make it look like just hands or w/e) and change it's WeaponName::onFire() function to make the player run faster.
Hope it helps :)