|
{
"weapon_shotgun",
Pickup_Weapon,
Use_Weapon,
Drop_Weapon,
Weapon_Shotgun,
"misc/w_pkup.wav",
"models/weapons/g_shotg/tris.md2", EF_ROTATE,
"models/weapons/v_shotg/tris.md2",
/* icon */ "w_shotgun",
/* pickup */ "Shotgun",
0,
1,
"Shells",
IT_WEAPON,
NULL,
0,
/* precache */ "weapons/v_shotg/flash2/tris.md2 weapons/shotgf1b.wav
weapons/shotgr1b.wav"
},
Now start changing things. Modifying the 10th, 12th, and 13th fields of
the weapon, make it look like:
{
"weapon_shotgun",
Pickup_Weapon,
Use_Weapon,
Drop_Weapon,
Weapon_Shotgun,
"misc/w_pkup.wav",
"models/weapons/g_shotg/tris.md2", EF_ROTATE,
"models/weapons/v_shotg/tris.md2",
/* icon */ "w_shotgun",
/* pickup */ "Cute little gun",
0,
5,
"Cells",
IT_WEAPON,
NULL,
0,
/* precache */ "weapons/v_shotg/flash2/tris.md2 weapons/shotgf1b.wav
weapons/shotgr1b.wav"
},
Now compile the source with the modified g_items.c and put the
resulting gamex86.dll (If you use lcc-win32 remember to use the dllhack
program, availible somewhere-or-other) in a subdirectory of quake2
called mygame or something. Then run quake2 with the command line quake2
+set game "mygame". Get the shotgun, (or just use give all or give cute
little gun) and you'll find that it now shows up in your inventory
(press tab to view) as "Cute little gun" and takes 5 cells to use.
How this works: the 10th field (with /* pickup */ in front of it) which
we changed from Shotgun to Cute little gun controls the name of the
item. The 12th field whcih we changed from 1 to 5 controls how much ammo
the item uses. The 13th field which we changed from Shells to Cells
controls what type of ammo the item
Let's take a closer look at the structure of a gitem_t (anyone of the items in itemlist)
{
"weapon_rocketlauncher", -This appears to be the entity in the map
that creates this object, or maybe just a classname
Pickup_Weapon, -the function that is called when it's picked up
Use_Weapon, -ditto
Drop_Weapon, -ditto
Weapon_RocketLauncher, -Perhaps this is the entity name and above is
the classname, or vice-veraa
"misc/w_pkup.wav", -sound when being picked up?
"models/weapons/g_rocket/tris.md2", EF_ROTATE, -the rotating image of
the rocket launcher that you pick up, i guess.
"models/weapons/v_rocket/tris.md2", -?
/* icon */ "w_rlauncher", -the little icon at the bottom of the screen?
/* pickup */ "Rocket Launcher", -what is displayed when you pick it up,
and also, and this is a useful thing to know, what is displayed in the
inventory window
0, - I have no idea
1, -This is how much Ammo the thing uses. We can confirm this by
checking BFG and seeing that it's 50
"Rockets", - The ype of ammo it uses
IT_WEAPON, -It's a weapon, i guess
NULL, -no idea
0, -haven't a clue
/* precache */ "models/objects/rocket/tris.md2 weapons/rockfly.wav
weapons/rocklf1a.wav weapons/rocklr1b.wav
models/objects/debris2/tris.md2" - the sound and model to prechache, i
suppose
},
Updated Info:
I humbly apologize for putting some not-quite-accurate info in the description of the gitem_t structure at the end of my tutorial. I was oging to change this section, but forgot. Sorry again, and please thank mrcool and crowdpleazr in the tutorialfor pointing this out to me. { "weapon_rocketlauncher", -the classname of the object. Pickup_Weapon, -the function that is called when it's picked up Use_Weapon, -ditto Drop_Weapon, -ditto Weapon_RocketLauncher, -The function that is called when the weapon is fired. "misc/w_pkup.wav", -sound when being picked up? "models/weapons/g_rocket/tris.md2", EF_ROTATE, -the rotating image of the rocket launcher that you pick up, i guess. "models/weapons/v_rocket/tris.md2", the image of the rocket launcher you see when you're holding it. /* icon */ "w_rlauncher", -the little icon at the bottom of the screen? /* pickup */ "Rocket Launcher", -what is displayed when you pick it up, and also, and this is a useful thing to know, what is displayed in the inventory window 0, - I have no idea 1, -This is how much Ammo the thing uses. We can confirm this by checking BFG and seeing that it's 50 "Rockets", - The type of ammo it uses IT_WEAPON, -It's a weapon, i guess NULL, -for armor 0, -for armor shards /* precache */ "models/objects/rocket/tris.md2 weapons/rockfly.wav weapons/rocklf1a.wav weapons/rocklr1b.wav models/objects/debris2/tris.md2" - the sound and model to prechache, i suppose },