move common functions with no home to common.qc
This commit is contained in:
		
							parent
							
								
									a2b4ae8a15
								
							
						
					
					
						commit
						d7ef811865
					
				| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
progs.dat
 | 
					progs.dat
 | 
				
			||||||
 | 
					
 | 
				
			||||||
source/defs.qc
 | 
					source/defs.qc
 | 
				
			||||||
 | 
					source/common.qc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
source/fight.qc
 | 
					source/fight.qc
 | 
				
			||||||
source/subs.qc
 | 
					source/subs.qc
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										77
									
								
								source/ai.qc
									
									
									
									
									
								
							
							
						
						
									
										77
									
								
								source/ai.qc
									
									
									
									
									
								
							| 
						 | 
					@ -90,83 +90,6 @@ void() t_movetarget = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//============================================================================
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
=============
 | 
					 | 
				
			||||||
range
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
returns the range catagorization of an entity reletive to self
 | 
					 | 
				
			||||||
0 melee range, will become hostile even if back is turned
 | 
					 | 
				
			||||||
1 visibility and infront, or visibility and show hostile
 | 
					 | 
				
			||||||
2 infront and show hostile
 | 
					 | 
				
			||||||
3 only triggered by damage
 | 
					 | 
				
			||||||
=============
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
float(entity targ) range = {
 | 
					 | 
				
			||||||
	vector spot1, spot2;
 | 
					 | 
				
			||||||
	float r;
 | 
					 | 
				
			||||||
	spot1 = self.origin + self.view_ofs;
 | 
					 | 
				
			||||||
	spot2 = targ.origin + targ.view_ofs;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	r = vlen(spot1 - spot2);
 | 
					 | 
				
			||||||
	if(r < 120) {
 | 
					 | 
				
			||||||
		return RANGE_MELEE;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(r < 500) {
 | 
					 | 
				
			||||||
		return RANGE_NEAR;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(r < 1000) {
 | 
					 | 
				
			||||||
		return RANGE_MID;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return RANGE_FAR;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
=============
 | 
					 | 
				
			||||||
visible
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
returns 1 if the entity is visible to self, even if not infront()
 | 
					 | 
				
			||||||
=============
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
float(entity targ) visible = {
 | 
					 | 
				
			||||||
	vector spot1, spot2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	spot1 = self.origin + self.view_ofs;
 | 
					 | 
				
			||||||
	spot2 = targ.origin + targ.view_ofs;
 | 
					 | 
				
			||||||
	traceline(spot1, spot2, TRUE, self); // see through other monsters
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(trace_inopen && trace_inwater) {
 | 
					 | 
				
			||||||
		return FALSE; // sight line crossed contents
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(trace_fraction == 1) {
 | 
					 | 
				
			||||||
		return TRUE;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return FALSE;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
=============
 | 
					 | 
				
			||||||
infront
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
returns 1 if the entity is in front(in sight) of self
 | 
					 | 
				
			||||||
=============
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
float(entity targ) infront = {
 | 
					 | 
				
			||||||
	vector vec;
 | 
					 | 
				
			||||||
	float dot;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	makevectors(self.angles);
 | 
					 | 
				
			||||||
	vec = normalize(targ.origin - self.origin);
 | 
					 | 
				
			||||||
	dot = vec * v_forward;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(dot > 0.3) {
 | 
					 | 
				
			||||||
		return TRUE;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return FALSE;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//============================================================================
 | 
					//============================================================================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void() HuntTarget = {
 | 
					void() HuntTarget = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										82
									
								
								source/common.qc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								source/common.qc
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,82 @@
 | 
				
			||||||
 | 
					// common.qc: common functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					float() crandom = {
 | 
				
			||||||
 | 
						return 2 * (random() - 0.5);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					=============
 | 
				
			||||||
 | 
					range
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					returns the range catagorization of an entity reletive to self
 | 
				
			||||||
 | 
					0 melee range, will become hostile even if back is turned
 | 
				
			||||||
 | 
					1 visibility and infront, or visibility and show hostile
 | 
				
			||||||
 | 
					2 infront and show hostile
 | 
				
			||||||
 | 
					3 only triggered by damage
 | 
				
			||||||
 | 
					=============
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					float(entity targ) range = {
 | 
				
			||||||
 | 
						vector spot1, spot2;
 | 
				
			||||||
 | 
						float r;
 | 
				
			||||||
 | 
						spot1 = self.origin + self.view_ofs;
 | 
				
			||||||
 | 
						spot2 = targ.origin + targ.view_ofs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						r = vlen(spot1 - spot2);
 | 
				
			||||||
 | 
						if(r < 120) {
 | 
				
			||||||
 | 
							return RANGE_MELEE;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(r < 500) {
 | 
				
			||||||
 | 
							return RANGE_NEAR;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(r < 1000) {
 | 
				
			||||||
 | 
							return RANGE_MID;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return RANGE_FAR;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					=============
 | 
				
			||||||
 | 
					visible
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					returns 1 if the entity is visible to self, even if not infront()
 | 
				
			||||||
 | 
					=============
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					float(entity targ) visible = {
 | 
				
			||||||
 | 
						vector spot1, spot2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spot1 = self.origin + self.view_ofs;
 | 
				
			||||||
 | 
						spot2 = targ.origin + targ.view_ofs;
 | 
				
			||||||
 | 
						traceline(spot1, spot2, TRUE, self); // see through other monsters
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(trace_inopen && trace_inwater) {
 | 
				
			||||||
 | 
							return FALSE; // sight line crossed contents
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(trace_fraction == 1) {
 | 
				
			||||||
 | 
							return TRUE;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return FALSE;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					=============
 | 
				
			||||||
 | 
					infront
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					returns 1 if the entity is in front(in sight) of self
 | 
				
			||||||
 | 
					=============
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					float(entity targ) infront = {
 | 
				
			||||||
 | 
						vector vec;
 | 
				
			||||||
 | 
						float dot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						makevectors(self.angles);
 | 
				
			||||||
 | 
						vec = normalize(targ.origin - self.origin);
 | 
				
			||||||
 | 
						dot = vec * v_forward;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(dot > 0.3) {
 | 
				
			||||||
 | 
							return TRUE;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return FALSE;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// EOF
 | 
				
			||||||
| 
						 | 
					@ -676,12 +676,7 @@ void() ShalHome;
 | 
				
			||||||
void() ShalMissile;
 | 
					void() ShalMissile;
 | 
				
			||||||
void() ShalMissileTouch;
 | 
					void() ShalMissileTouch;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
float() crandom;
 | 
					 | 
				
			||||||
float(entity targ) infront;
 | 
					 | 
				
			||||||
float(entity targ) range;
 | 
					 | 
				
			||||||
float(entity targ) visible;
 | 
					 | 
				
			||||||
float(entity targ, entity attacker) SameTeam;
 | 
					float(entity targ, entity attacker) SameTeam;
 | 
				
			||||||
float(float v) anglemod;
 | 
					 | 
				
			||||||
void() DecodeLevelParms;
 | 
					void() DecodeLevelParms;
 | 
				
			||||||
void(entity ent) CopyToBodyQue;
 | 
					void(entity ent) CopyToBodyQue;
 | 
				
			||||||
void() InitBodyQue;
 | 
					void() InitBodyQue;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,10 +16,6 @@ void() W_Precache = {
 | 
				
			||||||
	precache_sound("weapons/shotgn2.wav"); // super shotgun
 | 
						precache_sound("weapons/shotgn2.wav"); // super shotgun
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
float() crandom = {
 | 
					 | 
				
			||||||
	return 2 * (random() - 0.5);
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
================
 | 
					================
 | 
				
			||||||
W_FireAxe
 | 
					W_FireAxe
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user