Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

one gun

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
franqutrass Joined: 30 Dec 2009 Posts: 22 Location: peru |

Posted: Tue Jan 19, 2010 12:54 am Post subject: one gun |

hello I wanted to ask how can I make in "quake 1" can only carry a weapon (apart from axe and the first shotgun). I want that code because I already got a code to power the gun vote, good I want is to be like "Counter Strike" in which only one can carry a weapon other than your knife and your gun.
thanks
_________________
hello

Back to top |

Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Tue Jan 19, 2010 7:42 pm Post subject: |

I suppose you could remove the other guns on the pickup of a new gun, if you want to do it the quick and dirty way: I'm no QuakeC genius but here goes my attempt: You have weapon_touch which is the function which is triggered when a weapon item is picked up:

Code:
/* ============= weapon_touch ============= */
float() W_BestWeapon;
void() weapon_touch =
{
local float hadammo, best, new, old;
local entity stemp;
local float leave;
if (!(other.flags & FL_CLIENT))
return;
// if the player was using his best weapon, change up to the new one if better
stemp = self;
self = other;
best = W_BestWeapon();
self = stemp;
if (deathmatch == 2 || coop)
leave = 1;
else
leave = 0;
if (self.classname == "weapon_nailgun")
{
if (leave && (other.items & IT_NAILGUN) )
return;
hadammo = other.ammo_nails;
new = IT_NAILGUN;
other.ammo_nails = other.ammo_nails + 30;
}
else if (self.classname == "weapon_supernailgun")
{
if (leave && (other.items & IT_SUPER_NAILGUN) )
return;
hadammo = other.ammo_rockets;
new = IT_SUPER_NAILGUN;
other.ammo_nails = other.ammo_nails + 30;
}
else if (self.classname == "weapon_supershotgun")
{
if (leave && (other.items & IT_SUPER_SHOTGUN) )
return;
hadammo = other.ammo_rockets;
new = IT_SUPER_SHOTGUN;
other.ammo_shells = other.ammo_shells + 5;
}
else if (self.classname == "weapon_rocketlauncher")
{
if (leave && (other.items & IT_ROCKET_LAUNCHER) )
return;
hadammo = other.ammo_rockets;
new = IT_ROCKET_LAUNCHER;
other.ammo_rockets = other.ammo_rockets + 5;
}
else if (self.classname == "weapon_grenadelauncher")
{
if (leave && (other.items & IT_GRENADE_LAUNCHER) )
return;
hadammo = other.ammo_rockets;
new = IT_GRENADE_LAUNCHER;
other.ammo_rockets = other.ammo_rockets + 5;
}
else if (self.classname == "weapon_lightning")
{
if (leave && (other.items & IT_LIGHTNING) )
return;
hadammo = other.ammo_rockets;
new = IT_LIGHTNING;
other.ammo_cells = other.ammo_cells + 15;
}
else
objerror ("weapon_touch: unknown classname");
sprint (other, "You got the ");
sprint (other, self.netname);
sprint (other, "\n");
// weapon touch sound
sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
stuffcmd (other, "bf\n");
bound_other_ammo ();
// change to the weapon
old = other.items;
other.items = other.items | new;
stemp = self;
self = other;
if (!deathmatch)
self.weapon = new;
else
Deathmatch_Weapon (old, new);
W_SetCurrentAmmo();
self = stemp;
if (leave)
return;
// remove it in single player, or setup for respawning in deathmatch
self.model = string_null;
self.solid = SOLID_NOT;
if (deathmatch == 1)
self.nextthink = time + 30;
self.think = SUB_regen;
activator = other;
SUB_UseTargets(); // fire all targets / killtargets
};

So in the weapon touch function, make it only give you axe plus the new weapon by making the following modification:

Quote:
// change to the weapon // old = other.items; // Baker: comment this line out, they are losing old weapons // other.items = other.items | new; // Baker: Nope, lose this too other.items = IT_AXE | IT_SHOTGUN | new; // Baker: you get the axe/shotgun plus what you picked up, losing other weapons
stemp = self;
self = other;
if (!deathmatch) // Baker: comment me out
self.weapon = new;
else // Baker: comment me out
Deathmatch_Weapon (old, new); // Baker: comment me out
W_SetCurrentAmmo();

Should work in theory. I'm not Mr. QuakeC.
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...
Last edited by Baker on Sat Jan 23, 2010 5:30 am; edited 3 times in total

Back to top |

ceriux Joined: 06 Sep 2008 Posts: 969 Location: Florida, USA |

Posted: Tue Jan 19, 2010 7:55 pm Post subject: |

if you have a buy menu, just comment out the pickup code, or delete everything in the function and put return; _________________ QuakeDB - Quake ModDB Group

Back to top |

Wazat Joined: 15 Oct 2004 Posts: 732 Location: Middle 'o the desert, USA |

Posted: Wed Jan 20, 2010 4:54 am Post subject: |

This can be done. I did something much more complex in Conquest (player has 5 slots that can hold any weapon), but you're looking for something much simpler. Basically, you want to make it so that if the player picks up a weapon, it removes all other weapons from his inventory other than the shotgun & axe. Perhaps it drops the removed weapon on the ground. Using an impulse/alias (bound to mouse2) to swap weapons would be a good idea (instead of doing it on touch only).
In the weapon selection and fire methods, impulse 3 and weapon #3 should check which weapon the player has besides the shotgun/nailgun. It would be handy to store this in a .float, such as .float weapon3;.
Anyway, I have a mod that is much simpler than Conquest, but that does something similar to what you want. It's still the system of being able to store any weapon in any weapon slot, but it should give you a good base to work with. The mod is called Monster Swarm, and I haven't worked on it in some time and never released it.
Basically, monsters spawn randomly throughout the map similar to UT's Invasion mode. The player can run around collecting guns and gunning down the monsters, and he chooses which 5 weapons he carries. Holding down the shift key while looking at a weapon and pressing a weapon number will swap weapons.
So I could swap my shotgun for a super nailgun by looking at the super nailgun, holding shift, and pressing #2. I should probably move the key binding to the mouse2 button or something, since shift is a little awkward.
If someone can point me to a decent upload site that won't fill my poor compy with innumerable worms & viruses, I'd be happy to upload it for your benefit. I'm not sure if it will be useful to you (you only want the 3rd weapon to be switchable), but it may help.
_________________
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.

Back to top |

Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Wed Jan 20, 2010 1:28 pm Post subject: |

Wazat wrote:
If someone can point me to a decent upload site that won't fill my poor compy with innumerable worms & viruses, I'd be happy to upload it for your benefit. I'm not sure if it will be useful to you (you only want the 3rd weapon to be switchable), but it may help.

www.quaketastic.com password = ilovetheshubhub
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...

Back to top |

lth Joined: 11 Nov 2004 Posts: 129 |

Posted: Wed Jan 20, 2010 3:23 pm Post subject: |

The tidy way to do it, IMO, would be to add a .entity field onto the player called "weapon_item", and store a reference to the currently-held weapon in that. That's how both THE HORROR and MechInf (part-finished) work. I've put the source to MechInf here:
http://www.random-productions.co.uk/quake/mechinf.zip for the curious.
_________________
randomviolence - tactical combat boardgame

Back to top |

franqutrass Joined: 30 Dec 2009 Posts: 22 Location: peru |

Posted: Wed Jan 20, 2010 6:16 pm Post subject: |

thanks _________________ hello

Back to top |

Wazat Joined: 15 Oct 2004 Posts: 732 Location: Middle 'o the desert, USA |

Posted: Thu Jan 21, 2010 5:43 am Post subject: |

The mod is uploaded: Download Monster Swarm Hopefully this is handy to someone. I lost track of it some time ago and I really should pick it up again. _________________ When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.

Back to top |

franqutrass Joined: 30 Dec 2009 Posts: 22 Location: peru |

Posted: Thu Jan 21, 2010 7:44 pm Post subject: |

oh is a good mod and have bugs _________________ hello

Back to top |

franqutrass Joined: 30 Dec 2009 Posts: 22 Location: peru |

Posted: Thu Jan 21, 2010 7:45 pm Post subject: |

but a good mod _________________ hello

Back to top |

franqutrass Joined: 30 Dec 2009 Posts: 22 Location: peru |

Posted: Thu Jan 21, 2010 7:46 pm Post subject: |

but I'll take the Baker _________________ hello

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group