Friday, March 19, 2010

Fooling around with Ioquake3 game engine

I am a big fan of the Quake 3 Arena (Q3A) game. I stumbled upon the Ioquake3 opensource Q3A game engine. I thought it would be fun to play with the code and see what happened in the game. I decided to mod the Plasma gun effect to use BFG style "bullets". That should increase the level of fun. Well, it turns out I only need to change one line of code. A quick look at code/game/g_weapon.c in the source code is enough to make the change.
This is how the BFG firing function code:

void BFG_Fire ( gentity_t *ent ) {
gentity_t *m;

m = fire_bfg (ent, muzzle, forward);
m->damage *= s_quadFactor;
m->splashDamage *= s_quadFactor;
}

And this is how the Plasma gun firing function code:

void Weapon_Plasmagun_Fire (gentity_t *ent) {
gentity_t *m;

m = fire_plasma (ent, muzzle, forward);
m->damage *= s_quadFactor;
m->splashDamage *= s_quadFactor;

}

Replacing the call to fire_plasma() with a call to fire_bfg() changes the "bullet" coming out from a plasma gun.
However, this is only a quick hack and it only works correctly on arenas which has a real BFG gun. Otherwise the rendering output of the "hacked" plasma gun is incorrect because it only shows swirling black rectangle toward the enemy.
All-in-all it's a nice experience for me :).
Post a Comment

No comments: