afxWeapon
by Michael Perry · 06/20/2007 (8:42 am) · 62 comments
First, I must thank the following and give credit where credit is due:
Big thanks to Jeff for all his help. Without his guidance and instruction on using Arcane FX, particularly effectrons, this would have taken a lot longer.
Big thanks to Ed Johnson for helping me brush up on Maya and exporting.
Credit for the broadsword model goes to Tridinaut's Medieval Weapons Pack, which is worth so much more than what I payed =). Everyone should also thank Tridinaut for allowing me to supply the modified broadsword dts file for this resource.
Assets and general design for fire sword effect are derived from the Great Ball of Fire Spell, provided in the Arcane FX demo.
The following tech is recommended for this resource:
While developing Weapon Crafter and AFX Creator (in house Zombie Shortbus tools for creating AFX effects and melee weapons, that requires no scripting), I found I had put the cart before the horse. A weapon creation tool is worthless if no weapon system is in place. Since our project is built on TGE/AFX 1.5.2, I decided that our melee system should also be tied into the AFX classes.
Based on Jeff's advice and the AFX documentation, I built a custom class off of effectrons containing typical RPG data for stats, weapons, and damage. Let's get started:
Step 1: Download the files: afxWeaponResource.rar
Step 2: Back up original files:
Launch a mission, open the World Editor (F11), and drop in the new broadSword item. Make sure you enable collision and make the object non-static.[li]Take control of your OrcMagePlayer and run into your new Fire Sword If you followed the steps properly (and if I didn't make any errors (= ), you should see a quick set of effects I set up for a Fire Sword.
To keep this resource clean, I will be happy to answer detailed steps and questions in the comments section, and you can see the evolution of this resource in this thread: AFX Weapon?
Click here to see a larger screenshot
A word on expanding on this resource:
Earlier, I mentioned what is not covered in this resource, but that doesn't mean those features are not possible with this system. If you want a classic RPG or WoW combat system, you now have everything you need, and can do so from script. Coooool! How do I know? Because I've already created said systems in my scripts =).
Good luck, have fun, and submit bug reports when you find them!
*Note - Restored links to files.
Big thanks to Jeff for all his help. Without his guidance and instruction on using Arcane FX, particularly effectrons, this would have taken a lot longer.
Big thanks to Ed Johnson for helping me brush up on Maya and exporting.
Credit for the broadsword model goes to Tridinaut's Medieval Weapons Pack, which is worth so much more than what I payed =). Everyone should also thank Tridinaut for allowing me to supply the modified broadsword dts file for this resource.
Assets and general design for fire sword effect are derived from the Great Ball of Fire Spell, provided in the Arcane FX demo.
The following tech is recommended for this resource:
- TGE 1.5 - I'm working with 1.5.2[li]Arcane.FX - 1.5.2[li]3D Modeling Suite - I used Maya[li]Exporter - maya2Dts 7.0 used[li]Compiler - I used Visual Studio 2K5[li]Script Editor - Torsion ftw
- Combat resolution[li]Dual Wielding[li]Comprehensive AFX Design[li]AFX Creator Details[li]Weapon Crafter Details
While developing Weapon Crafter and AFX Creator (in house Zombie Shortbus tools for creating AFX effects and melee weapons, that requires no scripting), I found I had put the cart before the horse. A weapon creation tool is worthless if no weapon system is in place. Since our project is built on TGE/AFX 1.5.2, I decided that our melee system should also be tied into the AFX classes.
Based on Jeff's advice and the AFX documentation, I built a custom class off of effectrons containing typical RPG data for stats, weapons, and damage. Let's get started:
Step 1: Download the files: afxWeaponResource.rar
Step 2: Back up original files:
- enginegameplayer.h[li]enginegameplayer.cc
- Replace enginegameplayer.h and player.cc with the ones in the .rar archive[li]Copy afxWeapon.h and afxWeapon.cc into the engineafx directory[li]Copy afxWeapons.cs into examplearcane.fxserverscripts[li]Create a folder named "weapons" in the examplearcane.fxdatashapes[li]Copy the broadsword_maya.dts and broadsword.jpg into the new weapons directory
- Add afxWeapon.h and afxWeapon.cc to your project/solution[li]Recompile your debug and release builds
- In examplearcane.fxserverscriptsgame.cs, place the following code:
[b]// In function onServerCreated(), below exec("./aiPlayer.cs")[/b]
exec("./afxWeapons.cs");To keep this resource clean, I will be happy to answer detailed steps and questions in the comments section, and you can see the evolution of this resource in this thread: AFX Weapon?
Click here to see a larger screenshot
A word on expanding on this resource:
Earlier, I mentioned what is not covered in this resource, but that doesn't mean those features are not possible with this system. If you want a classic RPG or WoW combat system, you now have everything you need, and can do so from script. Coooool! How do I know? Because I've already created said systems in my scripts =).
Good luck, have fun, and submit bug reports when you find them!
*Note - Restored links to files.
About the author
Programmer.
#2
06/19/2007 (7:34 pm)
I am curious as to why it doesn't seem to be adding to the player's inventory quite right though. I will have to dig into it more later.
#3
AFX is an amazing piece of tech, with a lot of functionality (which you already know Will).
This weapon system is an effect. The only "physical" trace of it is in the stats and datablocks stored in the Player class.
Tracking inventory and actual combat seemed like a separate resource or add-on that I didn't want to clutter up the purpose of this particular module. However, I was extra-super-special-careful to leave a path for hooking this module into others.
06/19/2007 (7:38 pm)
It actually doesn't tie into the inventory system in its current state.AFX is an amazing piece of tech, with a lot of functionality (which you already know Will).
This weapon system is an effect. The only "physical" trace of it is in the stats and datablocks stored in the Player class.
Tracking inventory and actual combat seemed like a separate resource or add-on that I didn't want to clutter up the purpose of this particular module. However, I was extra-super-special-careful to leave a path for hooking this module into others.
#4
I am tying it to the melee system that we have set up now as well as the inventory.
As far as bugs I haven't seen many, but I have noticed is that when the player and weapon de-spawn the particle effects don't. They seem to be interested in hanging out a while.
06/19/2007 (11:10 pm)
I have noticed that you have some item data in there allowing for easy access to the player's inventory, way to think ahead! :))I am tying it to the melee system that we have set up now as well as the inventory.
As far as bugs I haven't seen many, but I have noticed is that when the player and weapon de-spawn the particle effects don't. They seem to be interested in hanging out a while.
#5
Forgot to call unequip() when the player is removed from the scene.
06/20/2007 (4:12 am)
Ah! Great bug catch Will! I'll post the new version shortly.Forgot to call unequip() when the player is removed from the scene.
#6
06/20/2007 (10:05 am)
Quick question...how is the sword in this example implemented as an object and mounted to the player? Is it mounted as an image, an object, or something else specific to AFX?
#7
06/20/2007 (10:14 am)
Read my new blogs Rubes.
#8
06/20/2007 (10:18 am)
Haha...I was actually reading them when I was notified of your response! Excellent stuff, thanks!
#9
06/20/2007 (11:57 am)
Great resource. Thanks!
#11
To be honest I was looking for something like this for a little bit of a different reason, however your sources have not only pointed me in the right direction, they have put wings on my shoes.
Thank you!
P.S
Jeff if you are still reading this... AFX is with out a doubt the best mod of TGE out to date. Your one smart cookie bro!
06/22/2007 (10:05 pm)
Great job Micheal. To be honest I was looking for something like this for a little bit of a different reason, however your sources have not only pointed me in the right direction, they have put wings on my shoes.
Thank you!
P.S
Jeff if you are still reading this... AFX is with out a doubt the best mod of TGE out to date. Your one smart cookie bro!
#12
afxWeapon.cpp
..\engine\afx\afxWeapon.cpp(991) : error C2039: 'setExtra' : is not a member of 'afxWeapon'
../engine\afx/afxWeapon.h(72) : see declaration of 'afxWeapon'
afxXM_Spin.cc
08/05/2007 (7:14 am)
Compiling...afxWeapon.cpp
..\engine\afx\afxWeapon.cpp(991) : error C2039: 'setExtra' : is not a member of 'afxWeapon'
../engine\afx/afxWeapon.h(72) : see declaration of 'afxWeapon'
afxXM_Spin.cc
#13
Which version of AFX are you using? setExtra is defined in afxChoreographer, which is not something I wrote. There's a chance you are using an older version that I didn't build on.
08/06/2007 (12:15 pm)
@Michael Branin - I'm not sure what happened with your build. I just downloaded the files and dropped them into a fresh build of AFX. I achieved a full compile without any errors.Which version of AFX are you using? setExtra is defined in afxChoreographer, which is not something I wrote. There's a chance you are using an older version that I didn't build on.
#14
When I compile new build, no errors, no problems. I drop in the new sword, its spinning and rotating. I run into it and it removes from the world, but does not mount in my hand.
In the console I get an error that equipWeapon is an unkown command. Line 276 of afxWeapons.cs
It says Fire Sword equipped...yet nothing
09/04/2007 (10:02 pm)
Using AFX CoreTech 1.0.2 and TGE 1.5.2:When I compile new build, no errors, no problems. I drop in the new sword, its spinning and rotating. I run into it and it removes from the world, but does not mount in my hand.
In the console I get an error that equipWeapon is an unkown command. Line 276 of afxWeapons.cs
It says Fire Sword equipped...yet nothing
#15
09/19/2007 (10:09 am)
What is the advantage of calculating the stats in the engine instead of just scripting it?
#16
@Wayne - Did you make the modifications in Player.h/.cc? This is where the ConsoleMethod equipWeapon is written.
@Ted - For the purpose of our game, it was beneficial to have our stats in the engine. What I didn't go into for this resource was exposing the stats to script. We have done so, but it wasn't pertinent to this resource.
10/07/2007 (10:38 am)
Sorry for the delay folks. Things are extremely crazy on my end right now.@Wayne - Did you make the modifications in Player.h/.cc? This is where the ConsoleMethod equipWeapon is written.
@Ted - For the purpose of our game, it was beneficial to have our stats in the engine. What I didn't go into for this resource was exposing the stats to script. We have done so, but it wasn't pertinent to this resource.
#17
11/24/2007 (9:23 am)
Added to my MMOToolkit codebase. Nice!
#18
12/14/2007 (8:42 am)
I have this successfully in, how would i use this like a player.inventory[afxweapondata] = 1 rather then as a code call, i have it equiping properly apon colliding, but not animations and its currently not very funtional other then as a pretty sword to run around with. Im hoping to create a something of a glowing sword. But first things first. Thanks in advance. Im looking for something similiar to the simple melee tutorial that doesnt need to select a targetin advance and simply uses collision between the afx weapon and the target.
#19
I've got this working in single player... but when testing it in multiplayer i found a strange problem.
when 2 clients facing each other, the effects of the firesword will not show up...
the game will also crash when one of the clients unequip the firesword.
the strange thing is that when 1 client is occluded from the other, everything works fine...
any ideas?
03/06/2008 (11:28 pm)
is this resource still being supported? I've got this working in single player... but when testing it in multiplayer i found a strange problem.
when 2 clients facing each other, the effects of the firesword will not show up...
the game will also crash when one of the clients unequip the firesword.
the strange thing is that when 1 client is occluded from the other, everything works fine...
any ideas?
#20
Have you made any other engine modifications?
03/07/2008 (6:13 am)
@Huimin Loi - Oh wow, that's a bug that hasn't been found. I'll look into it and see what I can find out.Have you made any other engine modifications?

Torque Owner Will Brown
I can't wait to get home and get this implemented. :))
[Edit]
It works like a charm on the first try. Excellent Job!!
I can think of a few interesting ways to utilize the afxWeapons classes that you wrote. I am interested in seeing what you came up with for the melee system that you had mentioned, but that can be saved for another day and another time.
Thank you again.