Game Development Community

dev|Pro Game Development Curriculum

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:
  • 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
The following topics ARE NOT covered in this resource:
  • Combat resolution[li]Dual Wielding[li]Comprehensive AFX Design[li]AFX Creator Details[li]Weapon Crafter Details
On that note, I present the afxWeapon system!

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
Step 3: Copy new files:
  • 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
Step 4: Building:
  • Add afxWeapon.h and afxWeapon.cc to your project/solution[li]Recompile your debug and release builds
Step 5: Script Implementations:
  • In examplearcane.fxserverscriptsgame.cs, place the following code:
  • [b]// In function onServerCreated(), below exec("./aiPlayer.cs")[/b]
    exec("./afxWeapons.cs");
  • 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.
#21
04/18/2008 (12:21 pm)
so how you go about making this sword wieldable? I just need some good pointers to get me going in the right direction, i haven't done any work on my game yet.
#22
04/18/2008 (12:36 pm)
@Matt - By wielding it, do you mean doing damage?
#23
04/18/2008 (3:19 pm)
yup
#24
04/18/2008 (4:36 pm)
the game crashes if you die with the sword, but if i don't pick up the sword it's fine.
#25
04/18/2008 (4:45 pm)
i changed it so it unequips on death, and it works fine now.
#26
04/18/2008 (4:45 pm)
something to do with respawning with the sword.
#27
04/18/2008 (4:50 pm)
@Matt - Nice catch on the crash. If I ever get a chance to update this, I'll try and do a safe release for the afxEffectron.

As far as wielding it to cause damage, that's a bit out of bounds of this learning project. That kind of functionality is game design dependent. A solution for a hack n' slash will be a lot different than timed MMORPG attacks.

You could do ray picking, mesh to mesh collision, line to mesh, distance calculation, etc.
#28
04/18/2008 (11:30 pm)
ok ok, i think i know what i need to do, i was trying to figure it out backwards.
#29
04/18/2008 (11:33 pm)
this is probably more of a question for afx, but how would i test to see if the effect was in effect(ie, the player is holding the sword).
#30
04/19/2008 (6:24 am)
In player.h and player.cc, there are two variables you can check: mCurrentWeapon and mWeaponEffID.

These variables are set to NULL by default. If the player has "equipped" the weapon, you can check those variables to see what weapon they are using.
#31
04/19/2008 (11:27 am)
so there is no way to do it in script, unless i expose them to script? or are they already?
#32
06/18/2008 (7:00 pm)
Has anyone tried converting this to AFX for TGEA?
#33
06/19/2008 (5:06 am)
@Michael - See my post in the forum thread: AFXWeapon?
#34
07/31/2008 (6:52 pm)
With a little wrenching and alot of advice from Jeff Faust I got this ported to TGEA Finally
#35
08/07/2008 (10:18 am)
Announcement:

A couple of cool ideas can be found in the AFX forums on expanding this resource, but afxWeapon had two purposes:

1. Help me learn AFX
2. Implement the mounting, displaying, and "prettying up" of melee weapons using AFX.

Due to my new job and project, it's going to be a long time before I can even begin to think about programming again.

I openly welcome anyone to expand on the resource, port it (as Michael Branin has), or completely rip it off as a new resource with bonus features.
#37
02/10/2009 (5:09 am)
Michael Perry, could you mail me the file of afxWeaponResource.rar ?

thanks!

btw, I think you can take use of the Google Groups to upload your file.
#38
02/10/2009 (10:20 am)
Hey everyone. So I've pulled everything down from my FTP and cleaning it all out. I also have to run hard drive recovery software because I think I accidentally deleted some files.

It's going to be a couple days, then I will post a new link.
#39
02/17/2009 (9:55 am)
Huzzah! Files are back on my server! Please post if you have any download problems.
#40
02/18/2009 (1:22 am)
Michael, It's ok now, thanks.