Game Development Community

dev|Pro Game Development Curriculum

Simple Melee System

by Skylar Kelty · 08/17/2006 (12:07 pm) · 185 comments

I know there are many resources on this, but none of them worked with the head or they were hard to integrate so I have packaged up a simple melee system.

This resource includes:
-> All necessary engine code, integrated into stock TGE 1.5.2
-> All necessary script, integrated into stock TGE 1.5.2
-> All player animations
-> A sword

Most of this code is from realmwars and other resources, I have just integrated it into stock TGE and packaged it up.

You need winrar or any .rar extractor to extract. I recommend you use WinMerge to make sure you get all the code copied.

That said, good luck integrating this and good luck with your game :)

Due to filesize limit you can download the file from here

TGEA version can be found here.

Notes
-> If you are using a custom slash animation, you will to have an animation sequence name "look".
-> Each melee weapon needs a "damageStart" node and a "damageEnd" node embedded in the model.
-> Thanks to Ryan Edmar for spotting my stupid error

Updates
-> Updated for integration with TGE 1.5.2 (thanks to James McGhee)
-> 10/08/07 - one or two very minor updates (no reason to re-download)
Page «Previous 1 2 3 4 5 6 7 Last »
#1
07/28/2006 (11:20 am)
Looks like you are missing some resources in this - I just did a clean build from the HEAD release and got the following errors..

------ Build started: Project: Torque Demo, Configuration: Release Win32 ------

wheeledVehicle.cc
..\engine\game\vehicles\wheeledVehicle.cc(408) : error C2065: 'mGenerateShadow' : undeclared identifier

vehicle.cc
..\engine\game\vehicles\vehicle.cc(111) : error C2065: 'Vehicle_GenericShadowLevel' : undeclared identifier
..\engine\game\vehicles\vehicle.cc(112) : error C2065: 'Vehicle_NoShadowLevel' : undeclared identifier

flyingVehicle.cc
..\engine\game\vehicles\flyingVehicle.cc(255) : error C2065: 'mGenerateShadow' : undeclared identifier

tsStatic.cc
..\engine\game\tsStatic.cc(330) : error C2065: 'StaticShape_NoShadowLevel' : undeclared identifier
..\engine\game\tsStatic.cc(337) : error C2065: 'StaticShape_GenericShadowLevel' : undeclared identifier

staticShape.cc
..\engine\game\staticShape.cc(34) : error C2065: 'StaticShape_GenericShadowLevel' : undeclared identifier
..\engine\game\staticShape.cc(35) : error C2065: 'StaticShape_NoShadowLevel' : undeclared identifier
..\engine\game\staticShape.cc(140) : error C2065: 'mShadow' : undeclared identifier
..\engine\game\staticShape.cc(142) : error C2227: left of '->setMoving' must point to class/struct/union/generic type
        type is ''unknown-type''
..\engine\game\staticShape.cc(145) : error C2227: left of '->setAnimating' must point to class/struct/union/generic type
        type is ''unknown-type''

shapeBase.cc
..\engine\game\shapeBase.cc(45) : fatal error C1083: Cannot open include file: 'synapseGaming/contentPacks/lightingPack/sgLighting.h': No such file or directory

player.cc
..\engine\game\player.cc(97) : error C2065: 'TurretObjectType' : undeclared identifier
..\engine\game\player.cc(259) : error C2065: 'Player_GenericShadowLevel' : undeclared identifier
..\engine\game\player.cc(260) : error C2065: 'Player_NoShadowLevel' : undeclared identifier
..\engine\game\player.cc(844) : error C2065: 'mGenerateShadow' : undeclared identifier
..\engine\game\player.cc(4260) : error C2065: 'mRenderShadow' : undeclared identifier

item.cc
..\engine\game\item.cc(60) : error C2065: 'Item_GenericShadowLevel' : undeclared identifier
..\engine\game\item.cc(61) : error C2065: 'Item_NoShadowLevel' : undeclared identifier
..\engine\game\item.cc(1074) : error C2065: 'mShadow' : undeclared identifier
..\engine\game\item.cc(1076) : error C2227: left of '->setMoving' must point to class/struct/union/generic type
        type is ''unknown-type''
..\engine\game\item.cc(1077) : error C2227: left of '->setAnimating' must point to class/struct/union/generic type
        type is ''unknown-type''

Torque Demo - 22 error(s), 0 warning(s)
========== Build: 6 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

** Edit - Looking through the errors it looks like you are making 1 call to the TLK resource - sgLighting.h
#2
07/28/2006 (1:11 pm)
Oh BIG woops, put the wrong files in the archive :0
#3
07/28/2006 (1:22 pm)
Is it fixed? This looks like a nice resource to implement.
#4
07/28/2006 (4:34 pm)
Compiles ok now, thanks.

On mission load and startup I got the following error.
Compiling starter.fps/server/scripts/game.cs...
starter.fps/server/scripts/game.cs Line: 311 - Syntax error.
The problem wasn't line 311 though it was line 308 which is this:
%player.setInventory(CrossbowAmmo,999);}s
Replace with:
%player.setInventory(CrossbowAmmo,999);
Now it loads ok.

Next question.. when hitting Korg with the sword I am not doing any damage.

*** EDIT ***

I found the following errors in the log from playing with this for awhile:
starter.fps/data/shapes/sword.dts - Collision mesh names should start with Col or LOSCol, encountered 'damageStart' in detail level 3
starter.fps/data/shapes/sword.dts - Collision mesh names should start with Col or LOSCol, encountered 'damageEnd' in detail level 3
#5
07/28/2006 (11:58 pm)
@Raasta - Thanks, See this is why I needed testers - I make so many mistakes
Those collision mesh errors dont cause the no damage thing btw


Updated Archive
#6
07/29/2006 (12:08 am)
@ Plague - Yes its fixed
#7
07/29/2006 (2:21 am)
@James -
What are your "improvements" to this resource? I've already implemented melee into my code, just wondering if there is anything you've added that I might benefit from.
#8
07/29/2006 (2:58 am)
@ Andrew - If you have a working system, dont bother with this one. This is just so people struggeling with getting melee working can have a working system
#9
07/29/2006 (9:24 am)
Ok it all seems to work now, I found 1 more issue. The player wasn't swinging the sword properly. I checked the file player.cc against the original server side melee tutorial and noticed that the following code block needs to be commented out or removed:
if (mArmAnimation.thread) {
      // Adjust arm position to avoid collision.
      F32 tp = mControlObject? 0.5:
         (mHead.x - mArmRange.min) / mArmRange.delta;
      mShapeInstance->setPos(mArmAnimation.thread,mClampF(tp,0,1));
   }
Now it seems to be working and swings correctly.
#10
07/30/2006 (6:54 am)
Commenting that makes this a random melee system, if thats what you want great :)
Did you notice that exact same code is wrapped in a new 'if' that checks to see if we are doing melee?
#11
07/31/2006 (12:48 pm)
Thank you very much, I've needed to implement melee for a long time.
#12
08/21/2006 (5:16 am)
Alittle fix. in weapon.cs

change :
%vplayer.setArmThreadTransitionOnce("h1stun");

To:
%vplayer.setArmTransitionOnce("h1stun");



It is almost working for me . Except the idle animation while holding the sword is still not correct .

Any clues ?



Great resource .Thx
Aun
#13
08/24/2006 (6:19 am)
Thanks for the fix Aun, erm no idea sorry maybe changing your model/idle anim?
#14
09/13/2006 (11:59 pm)
Alittle question .

I created my own model and animation. What do I have to do in order to make my animation work with this resource ?

It seems to be crashing because
mArmAnimation.action = null
in Player::setArmThread

How can i prevent this from happening ?

Thanks .
Aun

*Edit : Ok got it working have to set the custom look animation = "look"
#15
09/16/2006 (5:44 am)
OK I downloaded the code files, recompiled Torque, copied the script files in place and when I run the game and try to slash the sword, all I get is ERROR in setArmThreadPlayOnce().

I haven't touched any of the code, simply extracted the files into my Torque directory. Any info?

--Amr
#16
09/16/2006 (9:47 am)
@ Amr Bekhit

It seems that if you are using a custom slash animation ,you will to have an animation sequence name "look".
#17
09/24/2006 (6:32 pm)
Thank you for the resource , Greatly anticipating a working melee system. I used the default files above with a fresh unziped 1.4 and with a new cvs build. each time the sword will not swing and i also get this in the console -

starter.fps/server/scripts/weapon.cs (165): Unknown command setArmThreadPlayOnce.
object (2157) Player -> ShapeBase -> GameBase -> SceneObject -> NetObject -> SimObject
ERROR in setArmThreadPlayOnce()

Is the Look animation needed for the included files or just custom characters?

Where is the key mapping for the sword swings? I've searched in this file and the rw files.
I'm Must have went Blind - any help could restore some sight to an old blind man who is not ready to accept the darkness.
Being such a newbie any info would be educational - Thanks again.
#18
09/25/2006 (8:06 am)
Lets see...

Unknown command setArmThreadPlayOnce
Seems a few people are having this issue, ill look into it

Is the Look animation needed for the included files or just custom characters?
You need the extra animations included in this resource for any character who will be able to melee

Where is the key mapping for the sword swings?
The system uses the fire button (default left mouse) there are no special binds
#19
09/25/2006 (8:27 am)
Updated archive to fix a few problems and get it in 1.4.2
#20
09/25/2006 (12:07 pm)
Thanks for the information makes perfect sence. I'll rebuild and reimplement after the day job is done.
Page «Previous 1 2 3 4 5 6 7 Last »