Melee port
by Skylar Kelty · in Torque Game Engine Advanced · 06/15/2008 (11:11 am) · 101 replies
About the author
#42
For the warnings - don't worry about them. You can cast them out, if you want them to go away.
03/05/2009 (8:50 am)
@teq0: This was just supposed to be an example of how to pull sequences off the shapeinstance - just change the variable to the one you want. I modified the code above to be a direct replacement.For the warnings - don't worry about them. You can cast them out, if you want them to go away.
#43
The errors are
As far as I can tell, this means that mDataBlock and action are undeclared identifiers. Does anybody see why this error is occurring and how to correctly declare the identifiers?
03/05/2009 (9:53 am)
@Jaimi: Thanks for both suggestions (the original and the revised one). This eliminates the sequence/shape problem. In my build, there appears to still be a similar but separate sequence of errors originating from the line PlayerData::ActionAnimation &anim = mDataBlock->actionList[action];
The errors are
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2342) : error C2065: 'mDataBlock' : undeclared identifier 12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2342) : error C2227: left of '->actionList' must point to class/struct/union/generic type 12> type is ''unknown-type'' 12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2342) : error C2065: 'action' : undeclared identifier.
As far as I can tell, this means that mDataBlock and action are undeclared identifiers. Does anybody see why this error is occurring and how to correctly declare the identifiers?
#44
03/05/2009 (11:24 am)
@Jeff: Please post the whole function - mDataBlock is still available in player, so it must be some other issue.
#45
Thanks for the reply. Here is the whole function.
Also, here is the entire list of errors in the compiler in case I am focusing on the wrong lines.
03/05/2009 (11:43 am)
@Jaimi:Thanks for the reply. Here is the whole function.
PlayerData::ActionAnimation &anim = mDataBlock->actionList[action];
if (anim.sequence != -1)
{
mActionAnimation.action = action;
mActionAnimation.forward = forward;
mActionAnimation.firstPerson = fsp;
mActionAnimation.holdAtEnd = hold;
mActionAnimation.waitForEnd = hold? true: wait;
mActionAnimation.animateOnServer = fsp;
mActionAnimation.atEnd = false;
mActionAnimation.delayTicks = (S32)sNewAnimationTickTime;
mActionAnimation.atEnd = false;
if (sUseAnimationTransitions && (isGhost()/* || mActionAnimation.animateOnServer*/))
{
// The transition code needs the timeScale to be set in the
// right direction to know which way to go.
F32 transTime = sAnimationTransitionTime;
if (mDataBlock && mDataBlock->isJumpAction(action))
transTime = 0.15f;
mShapeInstance->setTimeScale(mActionAnimation.thread,
mActionAnimation.forward ? 1.0f : -1.0f);
mShapeInstance->transitionToSequence(mActionAnimation.thread,anim.sequence,
mActionAnimation.forward ? 0.0f : 1.0f, transTime, true);
}
else
mShapeInstance->setSequence(mActionAnimation.thread,anim.sequence,
mActionAnimation.forward ? 0.0f : 1.0f);
}
}Also, here is the entire list of errors in the compiler in case I am focusing on the wrong lines.
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2342) : error C2065: 'mDataBlock' : undeclared identifier
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2342) : error C2227: left of '->actionList' must point to class/struct/union/generic type
12> type is ''unknown-type''
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2342) : error C2065: 'action' : undeclared identifier
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2343) : error C2059: syntax error : 'if'
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2344) : error C2143: syntax error : missing ';' before '{'
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2344) : error C2447: '{' : missing function header (old-style formal list?)
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2372) : error C2059: syntax error : '}'
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2372) : error C2143: syntax error : missing ';' before '}'
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2372) : error C2059: syntax error : '}'
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2375) : error C2143: syntax error : missing ';' before '{'
12>c:torquetgea_1_8_1enginesourcet3dplayer.cpp(2375) : error C2447: '{' : missing function header (old-style formal list?)
#46
03/05/2009 (12:06 pm)
Is it declared properly as part of player? The start of the function should have looked like this:void Player::setActionThread(U32 action,bool forward,bool hold,bool wait,bool fsp, bool forceSet)
{
if (mActionAnimation.action == action && !forceSet)
return;
#47
The good news is that the melee resource now appears to compile properly in TGEA 1.8.1. Now I can concentrate on the scripting portions of the resource.
03/05/2009 (12:33 pm)
Thanks very much, Jaimi. In case it helps anybody, my mistake was this: the resource said to add a code snippet after "SetActionThread," but I couldn't tell where the SetActionThread function ended and the next function began. So, I inadvertently split the function in half, and Jaimi's comment helped me to figure out how the complete function should look.The good news is that the melee resource now appears to compile properly in TGEA 1.8.1. Now I can concentrate on the scripting portions of the resource.
#48
03/05/2009 (1:40 pm)
@Jeff, Can you post how you got this resource working?
#49
with Jaimi's revised fix
(Jaimi was originally showing a code example but revised the line to be a direct replacement.)
I'm still working on the script and data parts of the resource, i.e. figuring out where to put the orc dts, dsq, and cs files and how to exec them in the correct files so that the melee system will work. So, the code changes to the engine are working for me but the scripted part is not yet. If you have any suggestions or thoughts as we both work on this resource, I'd definitely benefit from them.
03/05/2009 (2:58 pm)
@Tek0, I got the code/engine changes to the .cp and h files to compile correctly, but I haven't gotten the melee animations to fire yet. I got the code portions to compile correctly by replacing this lineS32 seq = mDataBlock->shape->findSequence("h1stun");with Jaimi's revised fix
S32 seq = mShapeInstance->getShape()->findSequence("h1stun");(Jaimi was originally showing a code example but revised the line to be a direct replacement.)
I'm still working on the script and data parts of the resource, i.e. figuring out where to put the orc dts, dsq, and cs files and how to exec them in the correct files so that the melee system will work. So, the code changes to the engine are working for me but the scripted part is not yet. If you have any suggestions or thoughts as we both work on this resource, I'd definitely benefit from them.
#50
03/05/2009 (4:45 pm)
Will you post your files with the new changes that works for TGEA 1.8.1 once you get everything working?
#51
03/05/2009 (6:40 pm)
Yes, I will post them, but it may take me a while to figure out the scripted parts of the resource because I am still pretty new at this. :)
#52
i think that all of the added variables from the resource code has no code for decleration. And i don't really like srugging off warings ya know? :)
have some suggestions plz?
and correct me if im wrong, cuz im still a novice :)
03/05/2009 (8:14 pm)
Hi I have been trying to figure out how to solve this problem. Tek0 came across this same problem in fact i have all those same problems but after reading the above im confussed. I mean do we need to add code to declare them? And the issue of the new variables not being members of the group there suppoused to be in, any word on that? i redownloaded & replaced the files & recomplied just now in case the link has been updated but no change.i think that all of the added variables from the resource code has no code for decleration. And i don't really like srugging off warings ya know? :)
have some suggestions plz?
and correct me if im wrong, cuz im still a novice :)
#53
I have been able to get the coded portions of the resource to compile without errors. I was originally having the same error as Tek0:
but I fixed this error by replacing this line
with this one
Like you, I also had some problems with undeclared identifiers, but for me this ended up being a result of pasting code into the wrong place and splitting a function in half. This meant that the identifiers weren't actually undeclared; the compiler thought they were undeclared because I had separated the declaration from the body of the function. As far as I can tell, the variables in the resource code are properly declared and will compile. (But I'm also a beginner and could be wrong.)
03/06/2009 (9:05 am)
@John:I have been able to get the coded portions of the resource to compile without errors. I was originally having the same error as Tek0:
12>..........enginesourceT3Dplayer.cpp(2259) : error C2039: 'shape' : is not a member of 'PlayerData'
but I fixed this error by replacing this line
S32 seq = mDataBlock->shape->findSequence("h1stun");with this one
S32 seq = mShapeInstance->getShape()->findSequence("h1stun");Like you, I also had some problems with undeclared identifiers, but for me this ended up being a result of pasting code into the wrong place and splitting a function in half. This meant that the identifiers weren't actually undeclared; the compiler thought they were undeclared because I had separated the declaration from the body of the function. As far as I can tell, the variables in the resource code are properly declared and will compile. (But I'm also a beginner and could be wrong.)
#55
03/06/2009 (11:06 am)
Looking at the C++ code, SetArmThread will return false if it doesn't find the sequence in the actionlist. Did you add the dsq files to the datablock?
#56
I tried to add the dts and dsq files that were in the melee resource in a way that would initialize all of them, though I'm a little unsure of how to add the dsq's to the datablock and could easily have missed a step. Here is what I've done. Can you see a step I might be missing that would cause the problem?
I've added the entire "orc" folder provided with the melee resource to scriptsandassets/data/shapes/players, along with a player.cs file that lists all of the dsqs.
That player.cs file contains the following animations
In order to load up these animations, I also have a different player.cs file in scriptsandassets/server/scripts/players/, which begins with these lines
03/06/2009 (1:04 pm)
@Jaimi, I tried to add the dts and dsq files that were in the melee resource in a way that would initialize all of them, though I'm a little unsure of how to add the dsq's to the datablock and could easily have missed a step. Here is what I've done. Can you see a step I might be missing that would cause the problem?
I've added the entire "orc" folder provided with the melee resource to scriptsandassets/data/shapes/players, along with a player.cs file that lists all of the dsqs.
That player.cs file contains the following animations
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
datablock TSShapeConstructor(PlayerDts)
{
baseShape = "./player.dts";
sequence0 = "./player_root.dsq root";
sequence1 = "./player_forward.dsq run";
sequence2 = "./player_back.dsq back";
sequence3 = "./player_side.dsq side";
sequence4 = "./player_lookde.dsq look";
sequence5 = "./player_head.dsq head";
sequence6 = "./player_fall.dsq fall";
sequence7 = "./player_land.dsq land";
sequence8 = "./player_jump.dsq jump";
sequence9 = "./player_diehead.dsq death1";
sequence10 = "./player_diechest.dsq death2";
sequence11 = "./player_dieback.dsq death3";
sequence12 = "./player_diesidelf.dsq death4";
sequence13 = "./player_diesidert.dsq death5";
sequence14 = "./player_dieleglf.dsq death6";
sequence15 = "./player_dielegrt.dsq death7";
sequence16 = "./player_dieslump.dsq death8";
sequence17 = "./player_dieknees.dsq death9";
sequence18 = "./player_dieforward.dsq death10";
sequence19 = "./player_diespin.dsq death11";
sequence20 = "./player_looksn.dsq looksn";
sequence21 = "./player_lookms.dsq lookms";
sequence22 = "./player_scoutroot.dsq scoutroot";
sequence23 = "./player_headside.dsq headside";
sequence24 = "./player_recoilde.dsq light_recoil";
sequence25 = "./player_sitting.dsq sitting";
sequence26 = "./player_celsalute.dsq celsalute";
sequence27 = "./player_celwave.dsq celwave";
sequence28 = "./player_standjump.dsq standjump";
sequence29 = "./player_looknw.dsq looknw";
// phdana hth ->
sequence30 = "./player_h1root.dsq h1root";
sequence31 = "./player_h1thrust.dsq h1thrust";
sequence32 = "./player_h1slice.dsq h1slice";
sequence33 = "./player_h1swing.dsq h1swing";
sequence34 = "./player_h1jumpattack.dsq h1jumpattack";
// phdana stun ->
sequence35 = "./player_h1stunde.dsq h1stun";
// <- phdana stun
// <- phdana hth
};In order to load up these animations, I also have a different player.cs file in scriptsandassets/server/scripts/players/, which begins with these lines
/ Load dts shapes and merge animations
exec("~/data/shapes/players/orc/player.cs");.
#57
The orc.cs file referenced at the end of this function is this:
03/06/2009 (1:05 pm)
There are also functions for loading the playerpicker data in client/scripts/init.cs. I added one for the Orc in the melee resource.function loadPlayerPickerData()
{
// Load the datablocks we need for picking a player.
// This function just needs to populate PlayerDatasGroup
// with a valid set of objects (could be ScriptObjects,
// PlayerDatas, or StaticShapeDatas for example). The
// objects just need to have a name and a "shapeFile"
// field. For now we are just pulling this directly from
// the same set of PlayerDatas that we load on the server
// since it will be much simpler for a new user to figure
// out what to change to add their own Player's to the
// picker but it would be a good optimization to use a
// lighter-weight object.
// Create our SimSet to hold the player datablocks for the picker
if (!isObject(PlayerDatasGroup))
new SimSet(PlayerDatasGroup);
// We have to load these audio profiles to avoid a set of warnings
exec("~/server/scripts/audioProfiles.cs");
// Load our default player script
exec("~/server/scripts/players/player.cs");
// Load our other player scripts
exec("~/server/scripts/players/BoomBot.cs");
exec("~/server/scripts/players/Elf.cs");
exec("~/server/scripts/players/ForgeSoldier.cs");
exec("~/server/scripts/players/SpaceOrc.cs");
exec("~/server/scripts/players/Spacesuit.cs");
exec("~/server/scripts/players/TorqueOrc.cs");
exec("~/server/scripts/players/orc.cs");
} The orc.cs file referenced at the end of this function is this:
// Load dts shapes and merge animations
exec("~/data/shapes/players/orc/player.cs");
datablock PlayerData(OrcData : DefaultPlayerData)
{
renderFirstPerson = false;
emap = true;
jumpTowardsNormal = false;
airControl = 0.4;
maxForwardSpeed = 100;
jumpForce = 30.0 * 90;
shapeFile = "~/data/shapes/players/orc/player.dts";
};
PlayerDatasGroup.add(OrcData);
#58
What puzzles me is that many people using both the simple melee resource and the server side melee resource encountered the exact error that I'm having, which suggests that it is a common issue and not a random anomaly. Many of the same people later state that the resource works for them, which suggests that it is a resolvable error.
Each time that someone mentioned the error in both these threads, different solutions were suggested as to how to fix it, and I've tried these solutions, such as deleting dso's and changing the setArmThreadPlayOnce function from a bool to a virtual bool. Some people have explained the problem by saying that a custom slash animation on a weapon requires a custom look animation named "look."
For example, one person writes,
"The engine is hardcoded to look for a sequence called 'look' when you use setArmThreadPlayOnce(). Without such a sequence you eventually crash when setArmThreadPlayOnce tries to access a null pointer. We just made a copy our root animation and called it look. Then we started swinging just fine."
However, I did not add a custom slash animation, so I'm not sure this is the problem. There also already seems to be a look animation already included in the actionlist, unless I need to set up an additional custom animation named differently.
Does anybody see what might be the problem or recall how they resolved this error?
03/07/2009 (7:51 am)
After more attempts to get the melee system working, I'm pretty sure that the dsq's are functioning correctly, because the new orc dts file that comes with the melee resource shows up fine in the playerpicker and in game. The orc has the correct sword image mounted to the correct slot, and he can run, strafe, and jump in all the ways provided by the dsq's. What puzzles me is that many people using both the simple melee resource and the server side melee resource encountered the exact error that I'm having, which suggests that it is a common issue and not a random anomaly. Many of the same people later state that the resource works for them, which suggests that it is a resolvable error.
scriptsAndAssets/server/scripts/weapons/weapon.cs (166): Unknown command setArmThreadPlayOnce. Object (2258) Player -> ShapeBase -> GameBase -> SceneObject -> NetObject -> SimObject ERROR in setArmThreadPlayOnce()
Each time that someone mentioned the error in both these threads, different solutions were suggested as to how to fix it, and I've tried these solutions, such as deleting dso's and changing the setArmThreadPlayOnce function from a bool to a virtual bool. Some people have explained the problem by saying that a custom slash animation on a weapon requires a custom look animation named "look."
For example, one person writes,
"The engine is hardcoded to look for a sequence called 'look' when you use setArmThreadPlayOnce(). Without such a sequence you eventually crash when setArmThreadPlayOnce tries to access a null pointer. We just made a copy our root animation and called it look. Then we started swinging just fine."
However, I did not add a custom slash animation, so I'm not sure this is the problem. There also already seems to be a look animation already included in the actionlist, unless I need to set up an additional custom animation named differently.
sequence4 = "./player_lookde.dsq look";
Does anybody see what might be the problem or recall how they resolved this error?
#59
The updated files are here.
Using the 1.7.1 source, just merge his changes into your own files and change one line:
To read:
(or just overwrite your original files with the ones in the zip) and then:
[u]Clean Solution[/u]
Compile.
There are 5 warnings, 3 of which are GG related and 2 are from this resource. They don't affect compiling the exe.
Hope that helps.
03/08/2009 (9:32 am)
To get this to work in 1.8.1 was actually quite simple.The updated files are here.
Using the 1.7.1 source, just merge his changes into your own files and change one line:
S32 seq = mDataBlock->shape->findSequence("h1stun");To read:
S32 seq = mDataBlock->mShape->findSequence("h1stun");(or just overwrite your original files with the ones in the zip) and then:
[u]Clean Solution[/u]
Compile.
There are 5 warnings, 3 of which are GG related and 2 are from this resource. They don't affect compiling the exe.
Hope that helps.
Torque Owner Jeff Howard
"12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2310) : error C2065: 'seq' : undeclared identifier"
and a series of cascading errors after that.
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2342) : error C2065: 'mDataBlock' : undeclared identifier
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2342) : error C2227: left of '->actionList' must point to class/struct/union/generic type
12> type is ''unknown-type''
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2342) : error C2065: 'action' : undeclared identifier
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2343) : error C2059: syntax error : 'if'
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2344) : error C2143: syntax error : missing ';' before '{'
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2344) : error C2447: '{' : missing function header (old-style formal list?)
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2372) : error C2059: syntax error : '}'
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2372) : error C2143: syntax error : missing ';' before '}'
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2372) : error C2059: syntax error : '}'
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2375) : error C2143: syntax error : missing ';' before '{'
12>c:\torque\tgea_1_8_1\engine\source\t3d\player.cpp(2375) : error C2447: '{' : missing function header (old-style formal list?)
I'd really appreciate any help in resolving what looks like a small issue surrounding how datablocks are declared. These are the last few steps in a very long tutorial that almost compiles, if these last few errors could be fixed.