Server Side Melee System
by Josh Moore · 03/19/2004 (7:56 pm) · 357 comments
Download Code File
This tutorial will show you how to add a sever side melee system. The code is from Realm Wars, but it may be hard for some poeple to find everything thats needed. The tutorail is in the download. For the RW orc and sword
Enjoy.
I uplaoded the RW orc and sword to my website. Don't use the tut in the download, use the one at the top of the page.
Edit:Link doesn't work right, just post in your browser.
Sword and Player models:
http://www.freewebs.com/t2theforce/meleeTutorial.zip
The movie shows a shielded attack, an attack that hit, and a sword rebound.
Movie:
http://www.freewebs.com/t2theforce/meleeCombat.zip
The screenshot shows me blocking two attacks from some orcs with my shield.
For shields and sword rebounding, add this to your weapons.cs file.
After:
To shield a player, just set %shieldObject.shielded = 1;
This tutorial will show you how to add a sever side melee system. The code is from Realm Wars, but it may be hard for some poeple to find everything thats needed. The tutorail is in the download. For the RW orc and sword
Enjoy.
I uplaoded the RW orc and sword to my website. Don't use the tut in the download, use the one at the top of the page.
Edit:Link doesn't work right, just post in your browser.
Sword and Player models:
http://www.freewebs.com/t2theforce/meleeTutorial.zip
The movie shows a shielded attack, an attack that hit, and a sword rebound.
Movie:
http://www.freewebs.com/t2theforce/meleeCombat.zip
The screenshot shows me blocking two attacks from some orcs with my shield.
For shields and sword rebounding, add this to your weapons.cs file.
After:
if (%target.getState() !$= "Dead" && %target.getId() !$= %player.getId())
{Add:// shields and sword rebounding - JM The_Force
if(%target.shielded || %target.hthDamageSeqPlaying)
{
if(%target.hthDamageSeqPlaying)
%swordBlock = 1;
%block = 1;
// Now we see if we hit from behind...
%forwardVec = %target.getEyeVector();
%objDir2D = getWord(%forwardVec, 0) @ " " @ getWord(%forwardVec,1) @ " " @ "0";
%objPos = %target.getPosition();
%dif = VectorSub(%objPos, %player.getPosition());
%dif = getWord(%dif, 0) @ " " @ getWord(%dif, 1) @ " 0";
%dif = VectorNormalize(%dif);
%dot = VectorDot(%dif, %objDir2D);
// 120 Deg angle test...
// 1.05 == 60 degrees in radians
if (%dot >= mCos(1.05))
%block = 0;
}
if(%block == 1)
{
//error("attack blocked!!");
//%player.playAudio(0,ShieldImpactSound);
//makeSparks(%pos);
stunPlayer(%player,%attack);
pushPlayerBack(%player,%pos,%target,%attack);
if(%swordBlock == 1)
{
stunPlayer(%target,%attack);
pushPlayerBack(%target,%pos,%player,%attack);
}
return;
}To shield a player, just set %shieldObject.shielded = 1;
About the author
#342
07/11/2009 (10:47 pm)
Oh nevermind.
#343
07/11/2009 (10:48 pm)
You have to compile the engine first before you can use it.
#344
If someone can help with this it would be great ;) i work on TGE 1.5.2
07/12/2009 (9:59 am)
I get this error 1/server/scripts/Weapon.cs (428): Unable to find object: '' attempting to call function 'setArmThreadPlayOnce' If someone can help with this it would be great ;) i work on TGE 1.5.2
#345
07/29/2009 (6:14 am)
Anyone tried to implement this for Torque3D?
#346
08/02/2009 (12:20 pm)
You have to compile the engine before you can use it. You can find the answers on how to compile the engine on Torque Developer Network.
#347
08/02/2009 (12:21 pm)
Problem I am having now is that the ai won't work with this server side melee system. Anyone figured out how to implement ai with server side melee?
#348
08/13/2009 (2:51 pm)
hmmm. . .
#349
Can anybody help me? Please?
The ai works most of the time now.
08/13/2009 (11:57 pm)
Ok everything is good except when two characters, either me and an ai bot or a bot attacking another bot, attack at the same time, it crashes the game. What's up with that?Can anybody help me? Please?
The ai works most of the time now.
#350
1. When I swing the sword, it goes into a mid-swing animation frame. I've noticed that the animation sequence itself is controlled by mouse pitch... Which is not good. Is there a way to just make it play the animation instead of that?
2. When the animation "resets" after the swing animation stops, the player seems to teleport to some distant point and move quickly back. This is only really apparent as being the case when I set $timescale to 0.25, but otherwise it's an awkward blink on the screen, and the player plays the "land" animation as if they fell to the spot on which they're standing.
Has anyone come across either of these, or have any suggestions as far as remedies?
I'm using TGE 1.5.2, by the way.
08/27/2009 (12:46 am)
I'm having a couple rather interesting issues with this, that nobody else seems to have reported. I have everything working... To an extent. No issues as far as compiling or error reports, just some wigginess when I swing. All assets are the starter.fps with the sword and orc models and animations etc. downloaded from the links in the resource post.1. When I swing the sword, it goes into a mid-swing animation frame. I've noticed that the animation sequence itself is controlled by mouse pitch... Which is not good. Is there a way to just make it play the animation instead of that?
2. When the animation "resets" after the swing animation stops, the player seems to teleport to some distant point and move quickly back. This is only really apparent as being the case when I set $timescale to 0.25, but otherwise it's an awkward blink on the screen, and the player plays the "land" animation as if they fell to the spot on which they're standing.
Has anyone come across either of these, or have any suggestions as far as remedies?
I'm using TGE 1.5.2, by the way.
#351
10/10/2009 (4:04 pm)
can anyone help explain how to get this into T3D?
#352
11/30/2009 (3:42 pm)
I get these errors in TGE 1.5.2 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 3I have looked all the comments through but can't seem to find a solution to this. i bet it's just a parse error but i really can't find it any suggestions?
#353
01/27/2010 (3:55 pm)
im trying to get this to run in 1.5.2 and when i try to call the attack it says that setArmThreadPlayOnce is an unknown command, has anyone else ran into this problem. and if so any known fixes?
#354
I had it in 1.0.1 via the TGEA 1.8.1 port with a few minor workarounds, but no such luck now. I'm getting all sorts of compile errors and I'm not proficient enough w/c++ to dig in and solve them. Working with Beta 1.1 Alpha.
Any links to updated ports would be nice.
3/22/2010
@Tek0
You can get the original art from here: www.freewebs.com/t2theforce/meleeTutorial.zip
03/16/2010 (12:34 pm)
Any resources to get this into T3D?I had it in 1.0.1 via the TGEA 1.8.1 port with a few minor workarounds, but no such luck now. I'm getting all sorts of compile errors and I'm not proficient enough w/c++ to dig in and solve them. Working with Beta 1.1 Alpha.
Any links to updated ports would be nice.
3/22/2010
@Tek0
You can get the original art from here: www.freewebs.com/t2theforce/meleeTutorial.zip
#355
tek0.net/meleeT3D1.1beta1.rar
03/20/2010 (9:05 am)
Can someone test this code out for me? I currently don't have any art asset to test out the code. I added the server side melee to T3D 1.1 Beta 1.tek0.net/meleeT3D1.1beta1.rar
#356
03/22/2010 (9:01 am)
Tek0, I will check this out for you.. I actually just converted this over to T3D 1.0 over the weekend. I will compare it to the conversions that I did.
Torque Owner Justin Nelson