weapon's function help

Discuss programming in the QuakeC language.
Post Reply
franqutrass
Posts: 69
Joined: Wed Dec 30, 2009 6:29 pm
Location: peru
Contact:

weapon's function help

Post by franqutrass »

Hello everybody, me again, I wanted to know how I can change the next things in quake 1:

-3 weapons at a time (axe, shotgun, and the third weapon must be chosen by the player, as in counter strike, you can have just 3 weapons, knife, a pistol and a heavy gun)

I think, to get that I need to add a drop weapon function, and something to disable the player to have 8 weapons instead of just 3 which I think is more interesting.

-soldier vs enforcer

How can I make them fight each other?
Sorry if I'm asking too much but, as we say in spanish i just want to "kill two birds from one shoot".
If anyone could help me, it would be great. :D
hello
gnounc
Posts: 428
Joined: Mon Apr 06, 2009 6:26 am

Re: weapon's function help

Post by gnounc »

in client.qc somewhere before SetNewParms is called, you need to make a menu and ask the player which weapon they want. store that weapon ID in a float,
and add it to SetNewParms parm1.

that will give the player the weapon of his choosing in addition to the shotgun and axe which he already starts with.

You havent described the weapon weapon system you want to use well enough to answer your second question of "how can I make the player only pick up 3 weapons"
because this way they'll be starting with 3 weapons, so i dont know if you intend for any pickups at all, or switching for weapons in the ground, or switching only same category weapons, not switching the axe, etc etc.

So I'll answer the most basic straightforward way.
Add a player float field that says how many weapons the player has, you'll need to set that to 3 when they spawn.
Decriment it if they ever lose a weapon, and bump it in any weapon pickup code (weapon_touch).

lastly, for making enemies fight eachother, set their .enemy to the other enemy.
Might take more than that, someone else could tell you more.

best of luck.
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: weapon's function help

Post by Nahuel »

franqutrass wrote:
-3 weapons at a time (axe, shotgun, and the third weapon must be chosen by the player, as in counter strike, you can have just 3 weapons, knife, a pistol and a heavy gun)

I think, to get that I need to add a drop weapon function, and something to disable the player to have 8 weapons instead of just 3 which I think is more interesting.




I think in items.qc in weapon_touch function above

Code: Select all

stemp = self;

add this

Code: Select all

if ((other.items & IT_NAILGUN )|(other.items & IT_SUPER_NAILGUN )|(other.items & IT_SUPER_SHOTGUN )|(other.items & IT_GRENADE_LAUNCHER )|(other.items & IT_ROCKET_LAUNCHER )|(other.items & IT_LIGHTNING ))
return;
So you can just touch (and get) one "big weapon"
In the drop function you just need spawn a new entity (see backpack function ) and quit the item from the player

franqutrass wrote: -soldier vs enforcer

How can I make them fight each other?:D

in Hipnotic code you cansee the Horn of Conjuring code, where monsters attack another monsters, maybe can be useful for you
hi, I am nahuel, I love quake and qc.
franqutrass
Posts: 69
Joined: Wed Dec 30, 2009 6:29 pm
Location: peru
Contact:

Re: weapon's function help

Post by franqutrass »

Well bro, the piece of code you gave me worked great :D but, how do I do this?: "In the drop function you just need spawn a new entity (see backpack function ) and quit the item from the player", and just something else, would you mind to give the link from that web page which contains the "monster against monster" code?
hello
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: weapon's function help

Post by Nahuel »

mmm you need to call the "Drop_Weapon " function in impulses stuff in weapons.qc

Code: Select all

void()solid_arma =
{
self.touch = BackpackTouch;´// igual que tocar la mochila
};

void () Drop_Weapon =
{

if (self.weapon == IT_AXE) /// si tenes hacha o escopeta no va crear la funcin
return;
if (self.weapon == IT_SHOTGUN)
return;

local	entity arma;
arma = spawn ();
arma.owner = self;
arma.origin = self.origin;	
arma.velocity = v_up * 100 + v_forward * 200 ;
setsize (arma, '-16 -16 0', '16 16 56');
arma.origin_z = arma.origin_z + 12;
arma.solid = SOLID_TRIGGER;
arma.movetype = MOVETYPE_BOUNCE;
arma.flags = FL_ITEM;

if (self.weapon == IT_LIGHTNING)
{
arma.items = IT_LIGHTNING;
arma.ammo_cells = self.ammo_cells;
self.ammo_cells = 0;
setmodel(arma, "progs/g_light.mdl");
}
else if (self.weapon == IT_SUPER_SHOTGUN)
{
arma.items = IT_SUPER_SHOTGUN;
setmodel(arma, "progs/g_shot.mdl");
}
else if (self.weapon == IT_NAILGUN)
{
arma.items = IT_NAILGUN;
arma.ammo_nails = self.ammo_nails;
self.ammo_nails = 0;
setmodel(arma, "progs/g_nail.mdl");
}
else if (self.weapon == IT_SUPER_NAILGUN)
{
arma.items = IT_SUPER_NAILGUN;
arma.ammo_nails = self.ammo_nails;
self.ammo_nails = 0;
setmodel(arma, "progs/g_nail2.mdl");
}
else if (self.weapon == IT_GRENADE_LAUNCHER)
{
arma.items = IT_GRENADE_LAUNCHER;
arma.ammo_rockets = self.ammo_rockets;
self.ammo_rockets = 0;
arma.items = IT_GRENADE_LAUNCHER;
setmodel(arma, "progs/g_rock.mdl");
}
else if (self.weapon == IT_ROCKET_LAUNCHER)
{
arma.items = IT_ROCKET_LAUNCHER;
arma.ammo_rockets = self.ammo_rockets;
self.ammo_rockets = 0;
setmodel(arma, "progs/g_rock2.mdl");
}
self.items = self.items - arma.items;
arma.think = solid_arma;
arma.nextthink = time + 0.5;

W_SetCurrentAmmo ();

};

But also you need to replace the backpack touch function with this

Code: Select all

void() BackpackTouch =
{
	local string	s;
	local	float	best, old, new;
	local		entity	stemp;
	local	float	acount;
	


if ((other.items & IT_NAILGUN )|(other.items & IT_SUPER_NAILGUN )|(other.items & IT_SUPER_SHOTGUN )|(other.items & IT_GRENADE_LAUNCHER )|(other.items & IT_ROCKET_LAUNCHER )|(other.items & IT_LIGHTNING ))
return;


	if (other.classname != "player")
		return;
	if (other.health <= 0)
		return;

	acount = 0;
	sprint (other, "You get ");

	if (self.items)
		if ((other.items & self.items) == 0)
		{
			acount = 1;
			sprint (other, "the ");
			sprint (other, self.netname);
		}

// 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;

// change weapons
	other.ammo_shells = other.ammo_shells + self.ammo_shells;
	other.ammo_nails = other.ammo_nails + self.ammo_nails;
	other.ammo_rockets = other.ammo_rockets + self.ammo_rockets;
	other.ammo_cells = other.ammo_cells + self.ammo_cells;

	new = self.items;
	if (!new)
		new = other.weapon;
	old = other.items;
	other.items = other.items | new;
	
	bound_other_ammo ();

	if (self.ammo_shells)
	{
		if (acount)
			sprint(other, ", ");
		acount = 1;
		s = ftos(self.ammo_shells);
		sprint (other, s);
		sprint (other, " shells");
	}
	if (self.ammo_nails)
	{
		if (acount)
			sprint(other, ", ");
		acount = 1;
		s = ftos(self.ammo_nails);
		sprint (other, s);
		sprint (other, " nails");
	}
	if (self.ammo_rockets)
	{
		if (acount)
			sprint(other, ", ");
		acount = 1;
		s = ftos(self.ammo_rockets);
		sprint (other, s);
		sprint (other, " rockets");
	}
	if (self.ammo_cells)
	{
		if (acount)
			sprint(other, ", ");
		acount = 1;
		s = ftos(self.ammo_cells);
		sprint (other, s);
		sprint (other, " cells");
	}
	
	sprint (other, "\n");
// backpack touch sound
	sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
	stuffcmd (other, "bf\n");

// remove the backpack, change self to the player
	remove(self);
	self = other;

// change to the weapon
	if (!deathmatch)
		self.weapon = new;
	else
		Deathmatch_Weapon (old, new);

	W_SetCurrentAmmo ();
};
hi, I am nahuel, I love quake and qc.
Post Reply