Forum

Action/Use Button

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Action/Use Button

Postby Ghost_Fang » Wed Jul 21, 2010 3:21 am

I had a similar post a long time ago, but I've actually made some progress on my own. I made an action/use button, and it only seems to work on enemies. (I tested to see if it even worked by making a knight have th_use = knight_die;) And i click use on the knights and they die.

Ok, wait, i did a little more testing before submitting this post and i found out if i made the button a shootable button (obviously giving it health) it works, so which makes me believe that is it linked to the:

Code: Select all
if (trace_ent.takedamage)
   {      
      use_ent();
   }


portion of my code, so my new question, what do i need to replace takedamage with for it to be able to work on pickups and buttons and doors etc, without giving them health?

EDIT:

Here is my whole action/use code if you need it.

Code: Select all
void() use_ent =
{

local entity oldself;

   if (trace_ent.th_use)
   {
   oldself = self;
   other = self;
   self = trace_ent;
   self.th_use();
   self = oldself;
   }
};


void() use_cmd =
{

   local   vector   source;
   local   vector   org;

   makevectors (self.v_angle);
   source = self.origin + '0 0 16';
   traceline (source, source + v_forward*64, FALSE, self);
   if (trace_fraction == 1.0)
      return;
   
   org = trace_endpos - v_forward*4;

   if (trace_ent.takedamage)
   {      
      use_ent();
   }
};
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Postby Sajt » Wed Jul 21, 2010 5:28 am

You can just get rid of the takedamage if entirely, since use_ent is checking for trace_ent.th_use.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby Ghost_Fang » Wed Jul 21, 2010 5:36 am

yea, i ended up find that on my own messing with it, but i waited for comments to see if there is a better way, thanks though :)
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest