Finding things in code
by Rick Austinson · in Torque 3D Professional · 10/28/2013 (3:06 pm) · 5 replies
I'm using the 3D Action Adventure genre kit. It has a feature whereby when you hold the left mouse button it takes you into a camera mode. What I'd like to do is modify it so that its just always in that mode, change the "when mouse button is held down" to "all the time".
But after 2 weeks of sifting through forums, searching source code, reading outdated documentation, and tinkering, I am no closer to an answer. And this is just one of many examples of things I know I could modify if I could only find out where in the code it is. Its a little bit frustrating because its such a simple thing, yet I can't even do that.
Anyone have any ideas? I already asked over on the Ubiq Visuals forum but haven't had a responce. They're kind of dead over there.
Thanks!
But after 2 weeks of sifting through forums, searching source code, reading outdated documentation, and tinkering, I am no closer to an answer. And this is just one of many examples of things I know I could modify if I could only find out where in the code it is. Its a little bit frustrating because its such a simple thing, yet I can't even do that.
Anyone have any ideas? I already asked over on the Ubiq Visuals forum but haven't had a responce. They're kind of dead over there.
Thanks!
#2
10/30/2013 (4:54 pm)
If you have Torsion just search for the global variable $mvTriggerCount4++ and see what files declare it. In addition take a look at the Preferences files and see if its declared in there as well.
#3
the mv in $mvTriggerCount[] stands for move or movement. In the C++ code you will find several "move triggers" declared in the code. These are then used by the engine to perform certain actions when these inputs are activated - usually by a keypress.
These are used by stock code:
All that aside, $mvTriggerCount4 is setup to make the player switch to the prone pose, but is not utilized in the Templates. Knowing this I can only assume that the AAK changed this allow the camera type toggling you mention.
You'll have to search the source code for those changes. Likely places would be:
camera.cpp
movemanager.cpp
player.cpp
10/30/2013 (6:19 pm)
For the mvTriggers you'll have to delve into the code to see how they're used... not script. The only place you would see them mentioned in script would be the default.bind.cs file which is the goto location for what happens when you press a certain key.the mv in $mvTriggerCount[] stands for move or movement. In the C++ code you will find several "move triggers" declared in the code. These are then used by the engine to perform certain actions when these inputs are activated - usually by a keypress.
These are used by stock code:
- $mvTriggerCount0 = fire
- $mvTriggerCount1 = altfire (commented out), can also used for jetting but conflicts with weapons that have an alt-fire mode or if a 2nd wpn is mounted (dual weapons)
- $mvTriggerCount2 = jump or brakes (in a vehicle)
- $mvTriggerCount3 = crouch
- $mvTriggerCount5 = sprint
All that aside, $mvTriggerCount4 is setup to make the player switch to the prone pose, but is not utilized in the Templates. Knowing this I can only assume that the AAK changed this allow the camera type toggling you mention.
You'll have to search the source code for those changes. Likely places would be:
camera.cpp
"<h3>%Trigger Input</h3>\n\n" "Passing a move trigger ($mvTriggerCount0, $mvTriggerCount1, etc.) on to a Camera performs " "different actions depending on which mode the camera is in. While in Fly, Overhead or " "EditOrbit mode, either trigger0 or trigger1 will cause a camera to move twice its normal " "movement speed. You can see this in action within the World Editor, where holding down the " "left mouse button while in mouse look mode (right mouse button is also down) causes the Camera " "to move faster.\n\n" "Passing along trigger2 will put the camera into strafe mode. While in this mode a Fly, " "FreeRotate or Overhead Camera will not rotate from the move input. Instead the yaw motion " "will be applied to the Camera's x motion, and the pitch motion will be applied to the Camera's " "z motion. You can see this in action within the World Editor where holding down the middle mouse " "button allows the user to move the camera up, down and side-to-side.\n\n" "While the camera is operating in Newton Mode, trigger0 and trigger1 behave slightly differently. " "Here trigger0 activates a multiplier to the applied acceleration force as defined by speedMultiplier. " "This has the affect of making the camera move up to speed faster. trigger1 has the opposite affect " "by acting as a brake. When trigger1 is active a multiplier is added to the Camera's drag as " "defined by brakeMultiplier.\n\n" "@see CameraData\n" "@see CameraMotionMode\n" "@see Camera::movementSpeed\n\n" "@ingroup BaseCamera\n"
movemanager.cpp
for(U32 i = 0; i < MaxTriggerKeys; i++)
{
char varName[256];
dSprintf(varName, sizeof(varName), "mvTriggerCount%d", i);
Con::addVariable(varName, TypeS32, &mTriggerCount[i],
"Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.\n"
"@ingroup Game");
} player.cpp
// Move triggers static S32 sJumpTrigger = 2; static S32 sCrouchTrigger = 3; static S32 sProneTrigger = 4; static S32 sSprintTrigger = 5; static S32 sImageTrigger0 = 0; static S32 sImageTrigger1 = 1; static S32 sJumpJetTrigger = 1; static S32 sVehicleDismountTrigger = 2;
#4
10/30/2013 (6:27 pm)
Also, search for mTriggerCount[x] (different from script) in the C++ code to find other places in the code that affects these move or input triggers.
#5
As for finding stuff in the source, that can be very tricky. If you know what you're looking for (in this case, mvTriggerCount), I usually use Visual Studio's 'find in files' or 'find all references'. For TorqueScript, I just use grep in a git bash window (i.e. 'grep -r mvTriggerCount scripts/').
10/30/2013 (6:57 pm)
Quickest solution: when the client enters the game, set $mvTriggerCount4 to 1 and don't let them modify it!As for finding stuff in the source, that can be very tricky. If you know what you're looking for (in this case, mvTriggerCount), I usually use Visual Studio's 'find in files' or 'find all references'. For TorqueScript, I just use grep in a git bash window (i.e. 'grep -r mvTriggerCount scripts/').
Torque Owner Rick Austinson
Unofficial Dev Team
function altTrigger(%val)
{
$mvTriggerCount4++;
}
Now I just have to figure out how to modify it.