fangflecked-old

old project. ive since repurposed the name
git clone git://moonbender.net/fangflecked-old
Log | Files | Refs | README

subs.qc (1175B)


      1 void() SUB_Null = {};
      2 
      3 void() SUB_Remove = {remove(self);};
      4 
      5 void() SUB_UseTargets =
      6 {
      7 	local entity t;
      8 	local entity oSelf, oOther;
      9 
     10 
     11 	t = world;
     12 	
     13 	if (self.target)
     14 	do
     15 	{
     16 		//find all entities with
     17 		//targetname that matches
     18 		//this ent's target
     19 		t = find(t, targetname, self.target);
     20 		if(!t)
     21 			return;
     22 		
     23 		//need to temporarily set self to the target,
     24 		//otherwise the target's use function will effect
     25 		//THIS entity
     26 		oSelf = self;
     27 		oOther = other;
     28 
     29 		self = t;
     30 		other = oSelf;
     31 
     32 		if(t.use)
     33 			t.use();
     34 
     35 		self = oSelf;
     36 		other = oOther;
     37 	}while(1);
     38 }
     39 
     40 void() SUB_CalcMoveDone =
     41 {
     42 	//TODO: Make sure this does what I want it to...
     43 	setorigin(self, self.origin);
     44 	self.velocity = '0 0 0';
     45 	self.nextthink = -1;
     46 }
     47 
     48 void(vector tdest) SUB_CalcMove =
     49 {
     50 	local vector delta_v;
     51 	local float traveltime;
     52 	self.think = SUB_CalcMoveDone;
     53 	
     54 	if (tdest == self.origin)
     55 	{
     56 		self.velocity = '0 0 0';
     57 	}
     58 
     59 	delta_v = tdest - self.origin;
     60 
     61 	//travel speed is hardcoded to 300 for now
     62 	traveltime = vlen(delta_v) / 300;
     63 
     64 	self.nextthink = self.ltime + traveltime;
     65 
     66 	self.velocity = delta_v / traveltime;
     67 }
     68