Game Development Community

dev|Pro Game Development Curriculum

afxWeapon Effect Design Blog #1

by Michael Perry · 06/20/2007 (5:26 am) · 3 comments

[not to be confused with the AFX Spell-Design Blog series by Matthew Durante, though they are the inspiration for this blog]

Greetings all! With all the recent AFX related blogs popping up (great work Gareth Fouche and Gavin Bunney), I thought I'd announce some AFX tech I've been working on.

While working on Zombie Shortbus's in house tools, Weapon Crafter and AFX Creator, I realized I was missing quite a bit of tech to make these tools usable and effective. The first major piece of tech required grabbing a list of datablocks by their type and storing it in a script variable. With a little help, I came up with a solution, which was so useful, and capable of many other applications, I released it as a resource: Code: List Datablocks by type.

The next glaring absence in the code was a base weapon class and melee system. There are resources available, but none provide an actual base weapon class. I decided to make a simple weapon class that had your basic RPG functionality (min damage, max damage, stat modification, speed, type, etc). Well, what good is a stat modifier without player stats? So, I implemented a simple stat system for the Player class.

At this point, there was nothing that distinguished my weapon class from every other starter melee system out there. This is where AFX came to the rescue. I wanted weapon decorators, equip effects, un-equip effects, on-hit effects, and a simple way of mounting the weapon to the player without all the usual mounting procedures.

Formula: WeaponClass + afxEffectron = afxWeapon

afxEffectrons are amazing modules. Anyone who has ever had problems with mounting weapons and equipment on a player, this effect is your salvation!

So, in this blog I'll show you the final script result (plus screenshot), and in my next blog I'll break down the design and creation of The Fire Sword afxWeapon to get everyone started on their own afxWeapon creations.

Create the Fire Sword datablock:
datablock afxWeaponData(afxFireSword)
{
   duration = $AFX::INFINITE_TIME;     // Effect lasts until unequipped
   execOnNewClients = true;            // New clients must know about it
   
   // Add the broadsword effect
   addEffect = BroadSword_EW;          
   
   // Shockwave effect that animates on equip
   addEffect = FireSword_EquipShockwave_EW;  
   
   // Add 5 fire orbs that swirl around the sword tip
   // Lasts as long as the weapon is equipped
   addEffect = FireSword_FireOrb1_EW;           
   addEffect = FireSword_FireOrb2_EW;
   addEffect = FireSword_FireOrb3_EW;
   addEffect = FireSword_FireOrb4_EW;
   addEffect = FireSword_FireOrb5_EW;
   
   /////////////////////////////////////////
   // WEAPON DATA AND STATS 
   weaponName = "FireSword";           // Give it a name to reference
   
   minimumDamage = 5;                  // Does a minimum of 5 damage
   maximumDamage = 10;                 // Does a maximum of 5 damage
   weaponSpeed = 3;                    // Standard weapon speed
   weaponRange = 1;                    // Player must be within 1 unit of target
   weaponSkill = 5;                    // Player must have at least a "5" in edged weapons
   weaponType = 0;                     // WeaponType is 0 (1 handed edge)
   statMod1 = "Might 3";               // Add 3 to strength on equip
   statMod2 = "Wisdom -2";             // Subtract 2 from wisdom on equip
   // WEAPON DATA AND STATS 
   /////////////////////////////////////////
};

One method of equipping the Fire Sword, colliding with an item in the world:
datablock ItemData(broadSwordData)
{
   // Mission editor category
   category = "Weapon";

   // Add the Ammo namespace as a parent.  The ammo namespace provides
   // common ammo related functions and hooks into the inventory system.
   className = "Weapon";

   // Basic Item properties
   shapeFile = "~/data/shapes/weapons/broadsword_maya.dts";
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;

   // Dynamic properties defined by the scripts
[b]   pickUpName = "afxFireSword";     // IMPORTANT!!!!!![/b]
   maxInventory = 1;
};

function broadSwordData::onCollision(%this, %obj, %col)
{
   [b]// NEW CONSOLE METHOD: EQUIP THE FIRE SWORD TO THE PLAYER[/b]
   %col.equipWeapon(%this.pickUpName);
   echo("Fire Sword Equipped");
   %obj.respawn();
}


How about that? If you don't count the special effects (shockwave and fire orbs), it takes 2 datablocks to make the weapon, 1 function call (Player.equipWeapon(afxWeaponData) to use it, and you are ready to start scripting your combat and inventory system.

The next blog (or two), will show you how I set up the weapon in Maya, designed the weapon effect, and scripted the datablocks to make it all work.

Screenshot Section
i143.photobucket.com/albums/r128/jcverrastro/AFXWeapon/screenshot_003-00004.png
i143.photobucket.com/albums/r128/jcverrastro/AFXWeapon/screenshot_003-00001.png

#1
06/20/2007 (6:16 am)
Excellent work Michael and well blogged. I'm looking forward to seeing these effects evolve.
#2
06/20/2007 (6:23 am)
you are a demigod, man, i have been looking for a resource like this. Thanks for being prompt about this.
#3
06/20/2007 (11:54 am)
awesome.. this will be very useful.