Adding/replacing weapons; how to force them into maps

Locked
eepberries
Posts: 1975
Joined: Mon Jan 24, 2005 10:14 pm

Adding/replacing weapons; how to force them into maps

Post by eepberries »

I've been working on a small mod lately that: removes the plasmagun and railgun and replaces them with a "super nailgun" and "super shotgun". I've already coded both of these weapons into both game and cgame so that they function and can be received with the give command. The problem that I'm facing now is how to get them into currently existing maps, specifically the id maps, without having to re-distribute them (obviously because that's illegal and also because it's dumb). How can I do this? Is there some way that I can tell the game that when it finds say "wp_plasmagun" when loading the map to replace it with another weapon?

edit: I noticed one more thing. Once the rocket launcher is picked up, using the nextweapon command will allow the player to select an "invisible weapon." What I mean is that the hud selection box that shows which weapon is currently selected while you're switching through weapons, it moves to a nonexisting weapon past the last visible icon so that it's hovering over nothing, though both visually and in terms of gameplay you will still have the last valid weapon. Example: if the rocket launcher if the last valid weapon, once the non existant weapon is selected, the rocket launcher model is still displayed, rockets are still fired, rocket ammo is still subtracted, etc. Anyone know what's causing this and what I should do to fix it?

in case it helps, the current weapon list (in order):

gauntlet
nailgun (renamed machinegun)
super nailgun (variant of machinegun)
shotgun
super shotgun (variant of shotgun)
grenade launcher
rocket launcher
lightning gun
bfg
Wudan07
Posts: 9
Joined: Fri Sep 09, 2005 9:32 am

Post by Wudan07 »

Look at Pickup_Weapon in g_items.c, you can change what weapon is given to the player when they touch a weapon. That's server side, client side it looks like there's more to be done, but that should get you started.
eepberries
Posts: 1975
Joined: Mon Jan 24, 2005 10:14 pm

Post by eepberries »

How do I do that? Also, isn't that a problem in the first place due to the fact that the map is trying to call up weapons that no longer exist?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Alter the appropriate entries in the bg_itemlist[] array in game/bg_misc.c.
eepberries
Posts: 1975
Joined: Mon Jan 24, 2005 10:14 pm

Post by eepberries »

Alright, sorry but I really don't get what exactly I'm supposed to do. I tried a few things and they didn't work. Also, I had another thought. Wouldn't it be a problem that the player is supposed to start off with the shotgun? Because of this, I will want to replace the shotgun pickups in maps with something else, but I can't just replace the shotgun entry in bg_itemlist...
corncobman
Posts: 304
Joined: Fri Aug 08, 2003 7:00 am

Post by corncobman »

If you want existing maps to work with your new weapons, you need to keep the same classname and just change the other things like the pickup name, icon and sounds, or check for the old weapons in g_spawn.c and replace the classname strings with your new weapons.
-It is not the fall that kills you. It's the sudden stop at the end. (Douglas Adams)-

[url=http://www.violationentertainment.com/misc/ccm]-An eyeful a day is bloody fantastic!-[/url]
AnthonyJa
Posts: 47
Joined: Sun Nov 26, 2000 8:00 am

Post by AnthonyJa »

FWIW, you can also do it at runtime in G_CallSpawn() (g_spawn.c), by simply changing item for the appropriate one and setting ent->classname based upon it, before it spawns it. eg, something like this:

if (!strcmp(ent->classname, "some_classname"))
{
item = BG_FindItemForWeapon(WP_MACHINEGUN);
ent->classname = item->classname;
}
:
G_SpawnItem( ent, item );
Locked