vector@Posted: Tue Nov 12, 2002 11:19 pm :
I slapped together a quick superweapon as a test. All you have to do to try it out is add some text to three script files. These changes will add a new weapon to the game, not modify an existing weapon. To be safe, you may want to back up your script files beforehand.

First, create a new projectile definition by adding the following code to projectiles.def:

entityDef projectile_hellfireball {
   "spawnclass"            "idProjectile"
   "mins"                  "-3.5 -3.5 -3.5"
   "maxs"                  "3.5 3.5 3.5"
   //"model"                "models/weapons/impfireball/impfireball.lwo"

   "model"                  "models/weapons/impfireball/anims/tumble.md5mesh"
   "anim idle"               "models/weapons/impfireball/anims/flight.md5anim"
   "anim growth"            "models/weapons/impfireball/anims/growth.md5anim"
   "anim flight"            "models/weapons/impfireball/anims/tumble.md5anim"
   "s_shader"               "player_rocket"
   "damage"               "damage_missileDirect"
   "splash_damage"               "damage_missileSplash"
   "health"               "5"               // amount of damage projectile can take if damaged (0 means it can't be destroyed)
   "velocity"               "1500 0 0"         // how fast the projectile leaves the gun (or distance if fuse is 0)
   "angular_velocity"         "0 0 0"            // how the projectile is rotating when it leaves the gun
   "thrust"               "5"               // the rate of acceleration (always in the direction of the projectiles model)
   "thrust_start"            "0"               // when to start accelerating
   "thrust_end"            "0"               // when to stop accelerating
   "linear_friction"         "0"               // "air" friction
   "angular_friction"         "0"
   "contact_friction"         "0"
   "bounce"               "1"               // how much speed a projectile retains when it bounces off of objects (coefficient of restitution).  0 means no bounce.
   "mass"                  "5"
   "gravity"               "5"            // how much gravity affects the trajectory.  gravity direction is same as the entity that fired it.
   "fuse"                  "30"            // how long before the projectile is removed or self-detonates.  Use 0 for beam weapons (velocity == distance).
   "detonate_on_fuse"         "1"               // whether projectile should detonate when it's fuse runs out
   "detonate_on_death"         "1"               // whether projectile should detonate when it's "killed" (health runs out)
   "detonate_on_world"         "1"               // whether projectile should detonate when it hits an obstacle
   "detonate_on_actor"         "1"               // whether projectile should detonate when it hits a character in the game
   "impact_blood"            "0"               // whether projectile causes blood splats from characters that bleed
   "impact_gib"            "1"               // whether projectile can gib a character or not (for example: bullets don't gib, but rockets do)
   "decal_bounce"            ""               // decal to leave on world when bounces
   "decal_detonate"         "textures/decals/ballburn01"
   "decal_size"            "75"

   "fx_fly"               "particles/firetrail.particle"               // particle effect while in the air
   "fx_fly2"               "particles/fireballsmoke.particle"            // particle effect while in the air
   "fx_fly3"               "particles/firetrailembers.particle"         // particle effect while in the air
   "fx_detonate"            "particles/fireballexplosion.particle"         // particle effect when detonates
   "fx_detonate2"            "particles/fireballsmoke2.particle"            // particle effect when detonates
   "fx_residue"            "particles/firetrailembers2.particle"         // particle effect while in the air
   "fx_bounce"               ""               // particle effect when bounces
   "fx_fuse"               "particles/bigsparks.particle"               // particle effect when removed from fuse expiring
   "light_shader"            "lights/impflash"
   "light_color"            "1 .8 .6"
   "light_radius"            "300"
//   "light_offset"            "-8 0 -20"
   "light_offset"            "0 0 0"

   "detonate_light_shader"      "lights/impflash"
   "detonate_light_color"      "1 .8 .6"
   "detonate_light_radius"      "500"
   "detonate_light_removetime"   "1.0"

   "snd_explode"            "monster_demon_imp_fireball_explode"
   "snd_fly"               "monster_demon_imp_fireball_flight"               // particle effect while in the air

Then create a new weapon definition (to use the particle definition) by adding the following code to weapons.def:

entityDef weapon_hellfirecannon {
   "editor_color"         ".3 .3 1"
   "editor_mins"         "-16 -16 0"
   "editor_maxs"         "16 16 32"

   "editor_usage"         ""

   "spawnclass"         "idItem"
   "size"               "32 32 32"
   "model"             "models/weapons/pistol/pistol_world.ase"
   "viewmodel"          "models/weapons/pistol/fred/cycles/idle.md5mesh"
   "anim idle"          "models/weapons/pistol/fred/cycles/idle.md5anim"
   "anim fire1"          "models/weapons/pistol/fred/cycles/fire1.md5anim"
   "anim fire2"          "models/weapons/pistol/fred/cycles/fire2.md5anim"
   "anim fire3"          "models/weapons/pistol/fred/cycles/fire3.md5anim"
   "anim fire4"         "models/weapons/pistol/fred/cycles/fire4.md5anim"

   "anim putaway"         "models/weapons/pistol/fred/cycles/put_away.md5anim"
   "anim raise"         "models/weapons/pistol/fred/cycles/raise2.md5anim"
   "anim reload"         "models/weapons/pistol/fred/cycles/reload_empty.md5anim"
   "anim noammo"         "models/weapons/pistol/fred/cycles/empty_reload_start.md5anim"
   "action"            "sound/electronics/1shot_beep_02.wav"
   "inv_message"         "Picked up a Hellfire Cannon"
   "inv_weapon"         "weapon_hellfirecannon"
   "inv_ammo_bullets"      "200"
   "icon"               "guis/assets/hud/wpn_1"

   "weaponname"         "Hellfire Cannon"
   "projectile"         "projectile_hellfireball"
   "numProjectiles"      "1"
   "spread"            "0" // "1"
   "ammoType"            "ammo_bullets"
   "ammoRequired"         "1"
   "clipSize"            "200"
   "fireRate"            "0.00"
   "continuousFire"      "0"
   "dryFireReload"       "1"
   "switchWhenEmpty"      "0"
   "flashShader"         "muzzleflash"
   "flashColor"         "1 0.8 0.6"
   "flashRadius"         "500"

   //"recoilTime"         "125"
   //"recoilAngles"      "-1 -1 0"

   "recoilTime"         "125"
   "recoilAngles"         "-1 0 0"

   "ejectParticles"      "particles/smokepuff.particle"
   "ejectParticleBone"      "barrel"
   "barrelParticles"      "particles/smoketrail.particle"
   "barrelParticleBone"      "barrel"
   "barrelSmokeDelay"      "150"
   "barrelSmokeLength"      "0"
   "barrelPressure"      "300"
   //"frame idle:1"      "sound snd_idle"
   "frame raise:1"         "sound snd_raise"
   "frame fire1:1"         "sound snd_fire"
   "frame fire2:1"         "sound snd_fire"
   "frame fire3:1"         "sound snd_fire"
   "frame fire4:1"         "sound snd_fire"
   "frame noammo:1"      "sound snd_empty"
   "frame reload:1"      "sound snd_reload"
   "frame putaway:1"      "sound snd_putaway"

   "snd_raise"            "player_pistol_raise"
   //snd_raise"            "nosound"
   "snd_fire"            "player_pistol_fire"
   "snd_reload"         "player_pistol_reload"
   "snd_empty"            "player_pistol_empty"
   "snd_putaway"         "player_pistol_putaway"
   //"snd_putaway"         "nosound"

   "snd_idle"            ""
   "snd_explode"         ""
   "snd_bounce"         ""
   "snd_windown"         ""
   "snd_windup"         ""

Finally, register the weapon in player.def by adding the new weapon to the 12th weapon slot:

"weapon12"      "weapon_hellfirecannon"

This illustrates the basics of creating a new doom weapon. Most of the settings are pretty self-explanetory. This weapon is a very powerful rocket-like projectile and uses the Imp fireball shader effects. To use the weapon in game, simply call the following from the console:

give weapon_hellfirecannon

And to reload the entity definitions in game, simply call:


Please note that you will have to reload the entities, switch weapons, and then switch back to your modified weapon to see changes made to the configuration.

Have fun!

BNA!@Posted: Wed Nov 13, 2002 9:57 pm :
Just to add to vectors mini tutorial:

It's enough to store all the values in one single .def file, in this case just name it "wpn_hellfire.def", drop it in the def dir and that's it (+ adding the weapon into a slot in the player.def.
Alternertively you can zip it including the directory structure, rename it to .pk4 and drop it into your base dir.

Ghost@Posted: Sun Dec 01, 2002 7:58 pm :
dont worx for me

there is not : "models/weapons/impfireball/impfireball.lwo"

BNA!@Posted: Sun Dec 01, 2002 8:26 pm :
In this case edit the file contents to match up your paths or def names.

Ghost@Posted: Sun Dec 01, 2002 8:33 pm :
i cant match a path to an non-existent file
ive checked my folders and i dont have this files

BNA!@Posted: Sun Dec 01, 2002 8:45 pm :
Ghost wrote:
i cant match a path to an non-existent file
ive checked my folders and i dont have this files

If you can see an imp throwing fireballs at you in e3_3, you have the files.

BNA!@Posted: Tue Dec 10, 2002 2:40 am :
testing & restoring

Eggy@Posted: Tue Jul 20, 2004 9:45 pm :
Just a quick tip. Instead of copying over the whole entity you wish to replicate you can use the "inherit" tag to take all the information from the stated entity and then only change what you want.

Heres an example for the projectile_hellfirecannon
entityDef projectile_hellfireball {
   "inherit"                    "projectile_impfireball"
   "damage"                     "damage_missileDirect"
   "splash_damage"              "damage_missileSplash"
   "velocity"                   "1500 0 0"
   "thrust"                     "5"
   "bounce"                     "1"
   "gravity"                    "5"
   "fuse"                       "30"
   "light_color"                "1 .8 .6"
   "light_radius"               "300"
   "detonate_light_color"       "1 .8 .6"
   "detonate_light_radius"      "500"
   "detonate_light_removetime"  "1.0"

Comments were removed to preserve formatting.

Hope this is helpful to someone. Once you start to get a basic set of weapons made you will find you can inherit those into most other weapons. This has helped me to cut development time. Nice tut tho vector, this is what got me started :D

davey1971@Posted: Tue Aug 17, 2004 8:21 pm :
Can't get this to work.

Error message is "Error: Unknown weapon 'weapon_hellFirecannon'

I created one file called "weapon_hellfirecannon.def"

I placed the projectiles.def code and the weapons.def code into this file.

I saved the file and added the file to the pak000.pk4 file.

I modified the player.def file in the pak000.pk4 file, to include:

"weapon12" "weapon_hellfirecannon"

However, when I did this I received an error related to "weapon_pda". EDIT: when I ran Doom3.

So, I made the following entry in the player.def file

"def_weapon16" "weapon_hellfirecannon"
"weapon10_best" "0"
"weapon10_cycle" "1"
"weapon10_toggle" "0"
"weapon10_allowempty" "1"

right after the def_weapon15 entry.

I loaded a map and typed "give weapon_hellfirecannon" (with out the quotes) and that is when I get the Unknown weapon error

What am I doing wrong?

I looked in the pk4 file, and there seems to be scripts for each weapon.

Do you not have to make a script file for the new weapon?

Thanks for any help.

waterboy4800@Posted: Tue Aug 17, 2004 8:35 pm :
Had the same problem

Weapon 12 is the PDA, thats the error you get, you'd have to remove PDA to stick it in the 12th spot

no such thing as a 16th weapon set it between 13th and 15th spot, here was my modified player def that didnt give me the error

   "def_weapon13"                  "weapon_grenadelauncher"
   "weapon13_best"                  "0"
   "weapon13_cycle"               "1"
   "weapon13_toggle"               "0"
   "weapon13_allowempty"                    "1"

Daaave@Posted: Fri Aug 20, 2004 8:56 pm :
I've just extracted the whole of the def folder, and there's no weapons.def or projectiles.def :S

Is it somewhere else I put this code? Or have I got missing files in my Doom 3??

Daaave@Posted: Fri Aug 20, 2004 9:06 pm :
I think I'll try the way BNA! suggested, I can't find those files anywhere :S

Daaave@Posted: Fri Aug 20, 2004 9:33 pm :
ERROR: No 'weapon_scriptobject' set on 'weapon_hellfirecannon'.

Is what I get... very strange... I tried taking weapon_pistol.script and making a copy called weapon_hellfirecannon.script, but no luck, I get the same error message.

Can anyone let me know what I'm doing wrong??

I basically took the two sets of code from the original post, stuck them into weapon_hellfirecannon.def, changed the code in player.def for weapon 13 so that def_weapon13 had "weapon_hellfirecannon" there, and then loaded the game and typed "give weapon weapon_hellfirecannon" into console.

FireHawk@Posted: Sat Aug 21, 2004 1:24 am :
I had the same problem took me hours to work out why

the reason is

its not being loaded, so when the game looks for it it cant find it even thou it exisits...

it has to be refrenced in the doom_main.script to be loaded when doom loads.

doom_main.script is pretty straightforward just refrence your new weapon in the weaponsection.

Daaave@Posted: Sat Aug 21, 2004 9:58 am :
Ah excellent. Cheers a bunch.

Actually, I managed to get a weapon working by just downloading someone's weapon mod from fileplanet and having a look in the code.

It seems a bunch of entitydefs that were supposed to be in the weapon_hellfirecannon.def weren't in there either.

But I'll have a look at that file for the weapons section, when I get around to making weapons of my own they'll come in very handy.

Twiglet@Posted: Sun Aug 22, 2004 3:25 pm :
Ugh.. Sorry for bumping the topic again but I just can't get it to work...

So I did exactly what Daaave had done, and got the same error message, so what exactly do I need to add to the Doom.Main.Script file?

I would figure that i'd just add a line like:
#include "script/weapon_hellfirecannon.script"

But when I do that it obviously comes up with an error saying about how that file doesnt exist. If i just copy and paste another weapon script file and rename it, i get all sorts of errors that prevent me from even starting up the game, and I don't think i'm quite advanced enough to be altering the script files themselves...

Thanks a lot guys, I wouldnt have asked, but this seems to be the only tutorial of it's kind, and i'd really like to get the issue cleared up for me or anyone else in a similar situation.

Daaave@Posted: Sun Aug 22, 2004 3:43 pm :
Basically what I did was make a copy of weapon_pistol.script and named it weapon_hellfirecannon.script, then I changed each of the functions in the script (for instance weapon_pistol::fire()) to the hellfirecannon equivalent (for instance weapon_hellfirecannon::fire()).

I then added the line:

#include "script/weapon_hellfirecannon.script"

to the doom_main.script file.

I think your problem might have been renaming the functions.

Oh and I think in the end I gave up on the tutorial and created a copy of the weapon_pistol.def file, changed the name to weapon_hellfirecannon.def and changed the values for that instead.

It wasn't a hellfirecannon or whatever, but at least it was creating a new gun in the game.

I dunno. I guess I could probably make a tutorial of my own tying up all the loose ends from the other tutorial, but that might upset Vector :(.

Plus I'm not really an experience enough modder to answer any specific questions.

Daaave@Posted: Sun Aug 22, 2004 3:47 pm :
And don't worry about being experienced enough to change any of the script files, that's the beauty of it all being packed into pk4 files. If you manage to completely mess up the game, just delete the files that you extracted and changed in your base folder and the game will refer back to the default ones. :D

Twiglet@Posted: Sun Aug 22, 2004 9:49 pm :
I doubt he'd mind.. I mean, it seems he did write it in 2002, so some of it probably doesnt apply now anyways.

But I still can't get it to work, and I tried modifying the original tut and making a modified copy of one weapon, thanks for trying anyway tho.

Daaave@Posted: Sun Aug 22, 2004 10:13 pm :
Well the way I found out was by downloading this mod:

and seeing what this guy did, taking into account what had been said in the tutorial on this thread.

It might be worth checking it out in case there's anything I forgot to add.