Forum

Backpack Kills

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Backpack Kills

Postby redrum » Fri Oct 26, 2007 9:36 pm

In void() BackpackTouch =
I added code so that if a backpack contains a certain amount of ammo it will explode.
I want the owner of the backpack to get a frag if a player dies in this manner.
I tried adding:
item.classname = "backpack"; in
void() DropBackpack = and adding:
if (targ.deathtype == "backpack")
{
attacker.frags = attacker.frags + 1;
return;
}

in
void() ClientObituary =
but it didn't work?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Dr. Shadowborg » Sat Oct 27, 2007 4:20 am

Assuming you're having the backpack do the damage right, all you should need to do is put something like this:

Code: Select all
item.owner = self;


In void() DropBackpack.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Postby FrikaC » Sat Oct 27, 2007 5:06 am

that will also make the person who dropped the backpack unable to pick it up
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby redrum » Sat Oct 27, 2007 5:11 am

So how do I accomplish this?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Dr. Shadowborg » Sat Oct 27, 2007 10:34 pm

Whoops, sorry about that.

Do this instead then:

Code: Select all
item.enemy = self;


In DropBackpack()

Then in when you call T_Damage or T_RadiusDamage in your touch function, just set the attacker variable to self.enemy. For example:

Code: Select all
T_Damage(other, self, self.enemy, damage);


Or in the case of T_RadiusDamage

Code: Select all
T_RadiusDamage(self, self.enemy, damage, world);


Also, don't forget to put in some kind of delay before it can be picked up if you intend to make it so that the player can drop these while still alive and solid, because if you don't, YOU could blow up instead.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest