ew-engine/hq engine src/pr_delegates.c
2006-10-08 00:00:00 +00:00

1265 lines
32 KiB
C

/*
Made by tei from scrach for quake
*/
#include "quakedef.h"
#define DELEGATE -120
#define DTYPE(what) {ent->v.touch = DELEGATE;ent->v.weapon = what;}
#define TTYPE(what) {ent->v.think = DELEGATE;ent->v.weapon = what;ent->v.nextthink= pr_global_struct->time + 3;}
#define SetModelIndex(ent, model) ent->v.modelindex = SV_ModelIndex(model);
#define NEXTTHINK(what,timeadd) {ent->v.think = DELEGATE;ent->v.weapon = what;ent->v.nextthink=pr_global_struct->time+timeadd;}
void SetNextthink(edict_t *ent, int id, float delay)
{
ent->v.think = DELEGATE;
ent->v.weapon = id;
ent->v.nextthink = pr_global_struct->time + delay;
}
//FUNC_SUPPORTED
#define FUNC_LADDER 0 //work
#define FUNC_HEALER 1 //work, need sound
#define FUNC_AMMO 2 //work, need sound
#define FUNC_ROTATE 3 //not work
#define FUNC_FORCEFIELD 4 //need fix
#define FUNC_PUSHABLE 5 //need tweak
#define FUNC_WEAKWALL 6 //crap
#define FUNC_FLOORMIRROR 7 //crap
#define FUNC_FLOOR 8 //crap
#define DECOR_LASERTOPLAYER 9
#define LIGHT_GLARE 10 //work
#define DECOR_FAN 11 //work
#define MISC_SPARK 12 //not work
#define SUBREMOVE 13 //work?
#define FUNC_CONVEYOR 14
#define FUNC_VEHICLE1 15
#define FUNC_FLOATHING 16
#define FUNC_VEHICLE2 17
#define TRAFFIC_GENERATOR1 18
#define FUNC_GLASS 19
extern cvar_t mod_showlight;
extern cvar_t mod_cityofangels;
extern cvar_t temp1;
extern cvar_t mod_handicap;
void PF_precache_model (void);
void StaticBuild (edict_t *ent, char * model);
float TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal);
void SetMinMaxSize (edict_t *e, float *min, float *max, qboolean rotate);
void StaticBuild2 (edict_t *ent, char * model, float alfa);
void setmodel (edict_t * ent,int im);
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
void PrecacheModel( char * model );
void PrecacheSound( char * sound );
void AddNextThink(edict_t *self, float time);
float VectorLength( const vec3_t v );
vec3_t * GetVectorValue(char *name, edict_t * ed);
void R_SuperZing (vec3_t start, vec3_t end);
int SV_ModelIndex (char *name);
void setorigin (edict_t *e, vec3_t org);
//
// Entity Run By Engine Call This Function.
//
int CallFunction(char *fname)
{
dfunction_t *func;
//TODO: optimize (static fname copy with static func?)
func = ED_FindFunction ( fname );
if (func)
{
PR_ExecuteProgram(func - pr_functions);
return true;
}
else
return false;
}
extern progs_t fx_progs;
extern progs_t con_prog;
int CallFunctionGame(char *fname, progs_t *game_pr)
{
dfunction_t *func;
//TODO: optimize (static fname copy with static func?)
if (!game_pr || !game_pr->progs)
return false;
if (active_pr!= game_pr)
PR_SetProgset(game_pr);
//TODO: optimize this with hask key, or something...
func = ED_FindFunction ( fname );
if (func)
{
if (game_pr == &con_prog)
pr_global_struct->time = cl.time;//needed?
//pr_global_struct->time = sv.time;//what?
PR_ExecuteProgram(func - pr_functions);
PR_SetProgset(&sv_progs);//TODO remove this??
return true;
}
PR_SetProgset(&sv_progs);//TODO remove this??
return false;
}
//Tei decal
void R_Decal2 (vec3_t origin) ;
int BspFree(edict_t *ed, vec3_t forward)
{
vec3_t vtemp, vtemp2, center;
int empty,f;
VectorAdd(forward,ed->v.absmax,vtemp);
f = SV_PointContents(vtemp);
empty = (f==CONTENTS_EMPTY);
// Con_Printf("absmax: %d\n",f);
VectorAdd(forward,ed->v.absmin,vtemp);
f = SV_PointContents(vtemp);
empty = empty && (f==CONTENTS_EMPTY);
//Con_Printf("absmin: %d\n",f);
VectorCopy(ed->v.absmin,vtemp);
vtemp[0]=ed->v.absmax[0];
f = SV_PointContents(vtemp);
//Con_Printf("absmin_amax_x: %d\n",f);
empty = empty && (f==CONTENTS_EMPTY);
VectorCopy(ed->v.absmin,vtemp);
vtemp[1]=ed->v.absmax[1];
f = SV_PointContents(vtemp);
//Con_Printf("absmin_amax_y: %d\n",f);
empty = empty && (f==CONTENTS_EMPTY);
VectorCopy(ed->v.absmax,vtemp);
vtemp[1]=ed->v.absmin[1];
f = SV_PointContents(vtemp);
//Con_Printf("absmax_amin_y: %d\n",f);
empty = empty && (f==CONTENTS_EMPTY);
VectorCopy(ed->v.absmax,vtemp);
vtemp[0]=ed->v.absmin[0];
f = SV_PointContents(vtemp);
//Con_Printf("absmax_amin_x: %d\n",f);
empty = empty && (f==CONTENTS_EMPTY);
VectorAdd(ed->v.absmin,ed->v.absmax,vtemp);
VectorScale(vtemp,0.5,center);
VectorCopy(center,vtemp);
vtemp[2] = ed->v.absmin[2];
f = SV_PointContents(vtemp);
//Con_Printf("center low: %d\n",f);
empty = empty && (f==CONTENTS_EMPTY);
VectorCopy(center,vtemp);
vtemp[1] = ed->v.absmax[1];
f = SV_PointContents(vtemp);
//Con_Printf("center front: %d\n",f);
empty = empty && (f==CONTENTS_EMPTY);
vtemp[2] = ed->v.absmin[2];
f = SV_PointContents(vtemp);
//Con_Printf("center front low: %d\n",f);
empty = empty && (f==CONTENTS_EMPTY);
VectorCopy(ed->v.absmax,vtemp);
vtemp[2] = ed->v.absmin[2];
f = SV_PointContents(vtemp);
//Con_Printf("absmax_amin_z: %d\n",f);
empty = empty && (f==CONTENTS_EMPTY);
return empty;
}
float changeyaw (float ideal, float speed, float current);
void PR_SelfCall(void )
{
edict_t * n;
vec3_t vtemp, vfor,vrig, vup, vx, vy, vz, forward,right, up;
int iself, iother, itime;
float f;
int empty;
edict_t * ed = PROG_TO_EDICT(pr_global_struct->self);
edict_t * ot = PROG_TO_EDICT(pr_global_struct->other);
//entvars_t *k = &ed->v;
// dfunction_t *func;
iother = pr_global_struct->other;
iself = pr_global_struct->self;
itime = pr_global_struct->time;
if ( active_pr != &cl_progs) PR_SetProgset(&cl_progs);
pr_global_struct->self = iself;
pr_global_struct->other = iother;
pr_global_struct->time = itime;//sv.time;
pr_global_struct->time = sv.time;
//Con_Printf("Other is %d", pr_global_struct->other);
switch((int)ed->v.weapon)
{
case FUNC_FLOATHING:
//Con_Printf("nz: %f\n",ed->v.nextthink);
AddNextThink(ed,0.05);
//Con_Printf("nz2: %f\n",ed->v.nextthink);
ed->v.origin[2] = ed->v.movedir[2] + sin(sv.time*0.2)*temp1.value;
//SetNextthink(ed,FUNC_FLOATHING,0.1);
setorigin(ed,ed->v.origin);
Con_Printf("zis :%f\n",ed->v.origin[2]);
//ed->v.angles[0]++;
//ed->v.nextthink = pr_global_struct->time + 0.1;
//Con_Printf("nz: %f\n",ed->v.nextthink);
//AddNextThink(ed,0.5);
//Con_Printf("nz2: %f\n",ed->v.nextthink);
//*/
break;
case FUNC_CONVEYOR:
if (!ot->v.button2)
if ((int)ot->v.flags & FL_ONGROUND)
{
ot->v.flags = (int)ot->v.flags & ~FL_ONGROUND;
VectorAdd(ot->v.velocity,ed->v.movedir,ot->v.velocity);
ot->v.origin[2]+=0.1;
}
break;
case FUNC_VEHICLE2:
if ((int)ot->v.flags & FL_ONGROUND)
{
if (!BspFree(ed,vec3_origin))
{
//The movil is stuff initially.
VectorCopy(ed->v.oldorigin,ed->v.origin);
setorigin(ed,ed->v.origin);
break;
}
//ed->v.armorvalue++;
// Generate moving vector
//AngleVectors(ot->v.v_angle,forward,right,up);
f = anglemod(ot->v.v_angle[1]);
ed->v.angles[1] = changeyaw(f,1,ed->v.angles[1]);
AngleVectors(ed->v.angles,forward,right,up);
forward[2]=0;
// Check if new location is invalid
empty = BspFree(ed,forward);
// Efective move
if (empty)
{
// ed->v.angles[2] += 1;
VectorScale(forward,ed->v.frags,forward);//Speed!!
VectorAdd(ed->v.origin,forward,ed->v.origin);
//ed->v.origin[2] = ed->v.movedir[2] + abs(sin(sv.time*300)*5);
setorigin(ed,ed->v.origin);
VectorAdd(ot->v.origin,forward,ot->v.origin);
setorigin(ot,ot->v.origin);
if (!BspFree(ed,vec3_origin))
{
setorigin(ot,ot->v.oldorigin);
/*
if (ed->v.armorvalue>100)
{
ed->v.velocity[2] = 600;
ed->v.flags = (int)ed->v.flags & ~FL_ONGROUND;
VectorScale(forward,ed->v.armorvalue,forward);
VectorSubtract(ed->v.velocity,forward,ed->v.velocity);
Con_Printf("Crsh!!\n");
VectorAdd(ed->v.velocity,ot->v.velocity,ot->v.velocity);
ot->v.flags = (int)ot->v.flags & ~FL_ONGROUND;
ot->v.origin[2] += 0.1;
ed->v.avelocity[0] = lhrandom(-10,10);
ed->v.avelocity[1] = lhrandom(-10,10);
ed->v.avelocity[2] = lhrandom(-10,10);
}
ed->v.armorvalue = 0;
*/
}
else
VectorCopy(ed->v.origin,ed->v.oldorigin);
}
//ed->v.origin[2]+=0.1;
}
//Con_Printf("Hello Conveyor!\n");
break;
case FUNC_VEHICLE1:
if ((int)ot->v.flags & FL_ONGROUND)
{
if (!BspFree(ed,vec3_origin))
{
//The movil is stuff initially.
VectorCopy(ed->v.oldorigin,ed->v.origin);
setorigin(ed,ed->v.origin);
break;
}
// Generate moving vector
AngleVectors(ot->v.v_angle,forward,right,up);
forward[2]=0;
// Check if new location is invalid
empty = BspFree(ed,forward);
// Efective move
if (empty)
{
// ed->v.angles[2] += 1;
VectorScale(forward,ed->v.frags,forward);//Speed!!
VectorAdd(ed->v.origin,forward,ed->v.origin);
//ed->v.origin[2] = ed->v.movedir[2] + abs(sin(sv.time*300)*5);
setorigin(ed,ed->v.origin);
SV_LinkEdict (ed, false);
VectorAdd(ot->v.origin,forward,ot->v.origin);
setorigin(ot,ot->v.origin);
if (!BspFree(ed,vec3_origin))
{
setorigin(ot,ot->v.oldorigin);
SV_LinkEdict (ot, false);
}
else
VectorCopy(ed->v.origin,ed->v.oldorigin);
}
//ed->v.origin[2]+=0.1;
}
//Con_Printf("Hello Conveyor!\n");
break;
case SUBREMOVE:
//TODO. make safe against remove world
SparksHere(ed->v.origin);
ED_Free (ed);
break;
case MISC_SPARK:
n = ED_Alloc();
VectorCopy(ed->v.origin,n->v.origin);
n->v.modelindex = SV_ModelIndex("progs/fx_glare.mdl");
//n->v.model = SV_ModelString("progs/fx_glare.mdl");
n->v.model = ed->v.model;
n->v.movetype = MOVETYPE_BOUNCE;
n->v.solid = SOLID_BBOX;
f = ed->v.angles[0]*0.5;n->v.velocity[0] = lhrandom(-f,f);
f = ed->v.angles[1]*0.5;n->v.velocity[1] = lhrandom(-f,f);
f = ed->v.angles[2]*0.5;n->v.velocity[2] = lhrandom(-f,f);
VectorNormalize(n->v.velocity);
n->forcefx3 = EF3_ALIENBLOOD;
//f = VectorLength(*GetVectorValue("speed",ed));
SV_LinkEdict (n, false);
R_Beam(ed->v.origin, n->v.origin);
Con_Printf("hello! %d\n", n->v.modelindex);
//n->ishud = true;
// SparksHere(n->v.origin);
//VectorMA(vec3_origin,f,n->v.velocity,n->v.velocity);
SetNextthink(n,SUBREMOVE,2.5);
AddNextThink(ed,lhrandom(1,2));
break;
case DECOR_FAN:
ed->v.angles[1] = anglemod(ed->v.angles[1]+ed->v.avelocity[1]/100);
//ed->v.nextthink = pr_global_struct->time + 0.1;
AddNextThink(ed,0.1);
break;
case DECOR_LASERTOPLAYER:
ed->v.nextthink = pr_global_struct->time + 0.1;
vtemp[0] = lhrandom(ed->v.origin[0]-300,ed->v.origin[0]+300);
vtemp[1] = lhrandom(ed->v.origin[1]-300,ed->v.origin[1]+300);
vtemp[2] = lhrandom(ed->v.origin[2]-300,ed->v.origin[2]+300);
R_SuperZing(ed->v.origin, vtemp);
break;
case FUNC_FLOOR:
ot->v.flags = (int)(ot->v.flags) | FL_ONGROUND;
if( ot->v.origin[2] < ed->v.absmax[2])
{
ot->v.origin[2] = ed->v.absmax[2];
if (ot->v.velocity[2]<0)
ot->v.velocity[2]= 0;
}
break;
case FUNC_FLOORMIRROR:
if(!CallFunction("touch_func_floormirror"))
{
ed->v.movetype = MOVETYPE_NONE;
ed->v.solid = SOLID_NOT;
ed->v.modelindex = ot->v.modelindex;
VectorCopy(ot->v.origin, ed->v.origin);
ed->v.angles[2] = 180;
ed->v.origin[2] = ot->v.origin[2] - ( ot->v.absmax[2]-ot->v.absmin[2]);
//Con_Printf("Hello!\n");
}
break;
case FUNC_WEAKWALL:
if (ed->v.health >0)
{
ed->v.health = ed->v.health - 1;
Con_Printf("touch!\n");
}
else
{
ed->v.movetype = MOVETYPE_BOUNCE;
ed->v.solid = SOLID_SLIDEBOX;
ed->v.touch = DELEGATE;
ed->v.weapon = FUNC_PUSHABLE;
}
break;
case FUNC_PUSHABLE:
VectorAdd(sv.models[ (int)ed->v.modelindex]->mins,sv.models[ (int)ed->v.modelindex]->maxs,ed->v.v_angle);
ed->v.v_angle[2] = ot->v.origin[2];
//VectorMA(vec3_origin,0.5,ed->v.v_angle,ed->v.v_angle);
VectorScale2(0.5,ed->v.v_angle,ed->v.v_angle);
VectorSubtract(ed->v.v_angle,ot->v.origin, , vtemp);
//VectorCopy(ot->v.oldorigin, ot->v.origin);
VectorAdd(ed->v.velocity,vtemp,ed->v.velocity);
//VectorNormalize(ed->v.velocity);
if (ed->v.velocity[2]>5)
ed->v.velocity[2] = 5;
if (ed->v.velocity[1]>100)
ed->v.velocity[1] = 100;
if (ed->v.velocity[0]>100)
ed->v.velocity[0] = 100;
if ((int)(ed->v.flags) & FL_ONGROUND)
{
ed->v.origin[2]+=0.1;
ed->v.flags = ((int)(ed->v.flags))&(0xFFFF-FL_ONGROUND);
}
break;
case FUNC_HEALER: //Health Other
if(!CallFunction("touch_func_healer"))
{
if (ot->v.health < ed->v.health)
ot->v.health += 1;
}
break;
case FUNC_AMMO: //Give munition
if (ot->v.ammo_nails < ed->v.ammo_nails)
ot->v.ammo_nails += 1;
else
if (ot->v.ammo_rockets < ed->v.ammo_rockets)
ot->v.ammo_rockets += 1;
else
if (ot->v.ammo_cells < ed->v.ammo_cells)
ot->v.ammo_cells += 1;
else
if (ot->v.ammo_shells < ed->v.ammo_shells)
ot->v.ammo_shells += 1;
break;
case FUNC_ROTATE: //Dont work.
ed->v.angles[1]++;
//void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
AngleVectors(ed->v.angles, vfor,vrig, vup);
/*
org = ent.oldorigin;
vx = ( v_forward * org_x );
vy = ( v_right * org_y );
vy = vy * -1;
vz = ( v_up * org_z );
ent.neworigin = vx + vy + vz;
setorigin( ent, ent.neworigin + self.origin );*/
/* ?????????????????????
VectorAdd(sv.models[ (int)ed->v.modelindex]->mins,sv.models[ (int)ed->v.modelindex]->maxs,ed->v.v_angle);
VectorMA(vec3_origin,0.5,ed->v.v_angle,ed->v.v_angle);*/
VectorCopy(ed->v.v_angle,vtemp);
VectorMA(vec3_origin, vtemp[0],vfor, vx);
VectorMA(vec3_origin, vtemp[1],vrig, vy);
VectorNegate(vy,vy);
VectorMA(vec3_origin, vtemp[2],vup, vz);
VectorAdd(vx,vy,vy);
VectorAdd(vy,vz,vz);
VectorAdd(vz,ed->v.origin, ed->v.origin);
//VectorCopy(vz,ed->v.v_angle);
//Con_Printf("hola!\n");
//ed->v.nextthink = host_frametime+1;
break;
case FUNC_FORCEFIELD://Dont work. Need a better approach
VectorAdd(sv.models[ (int)ed->v.modelindex]->mins,sv.models[ (int)ed->v.modelindex]->maxs,ed->v.v_angle);
ed->v.v_angle[2] = ot->v.origin[2];
VectorMA(vec3_origin,0.5,ed->v.v_angle,ed->v.v_angle);
VectorSubtract(ot->v.origin, ed->v.v_angle, vtemp);
//VectorCopy(ot->v.oldorigin, ot->v.origin);
VectorAdd(ot->v.velocity,vtemp,ot->v.velocity);
ot->v.origin[2]+=0.1;
ot->v.flags = ((int)(ot->v.flags))&(0xFFFF-FL_ONGROUND);
Con_Printf("hola!\n");
break;
case FUNC_LADDER:
default: //Default is ladder
ot->v.movetype = MOVETYPE_LADDER;
break;
}
if ( active_pr != &sv_progs) PR_SetProgset(&sv_progs);
};
void AmbientSound (vec3_t pos, char * samp, float vol, float attenuation);
extern cvar_t mod_tenebrae;
void ED_LoadFromFile (char *data)
{
// vec3_t vtemp;
int i;//, k;
edict_t *ent;
int inhibit;//, oldmodelindex;
// float oldmdl;
dfunction_t *func;
ent = NULL;
inhibit = 0;
pr_global_struct->time = sv.time;
// parse ents
while (1)
{
// parse the opening brace
data = COM_Parse (data);
if (!data)
break;
if (com_token[0] != '{')
Sys_Error ("ED_LoadFromFile: found %s when expecting {",com_token);
if (!ent)
ent = EDICT_NUM(0);
else
ent = ED_Alloc ();
data = ED_ParseEdict (data, ent);
// remove things from different skill levels or deathmatch
if (deathmatch.value)
{
if (((int)ent->v.spawnflags & SPAWNFLAG_NOT_DEATHMATCH))
{
ED_Free (ent);
inhibit++;
continue;
}
}
else if ((current_skill == 0 && ((int)ent->v.spawnflags & SPAWNFLAG_NOT_EASY))
|| (current_skill == 1 && ((int)ent->v.spawnflags & SPAWNFLAG_NOT_MEDIUM))
|| (current_skill >= 2 && ((int)ent->v.spawnflags & SPAWNFLAG_NOT_HARD)) )
{
ED_Free (ent);
inhibit++;
continue;
}
//
// immediately call spawn function
//
if (!ent->v.classname)
{
Con_DPrintf ("No classname for:\n");
ED_Print (ent);
ED_Free (ent);
continue;
}
// look for the spawn function
func = ED_FindFunction ( pr_strings + ent->v.classname );
//Tei staticlight
if ((mod_showlight.value || mod_tenebrae.value)&& !strcmp("light",pr_strings + ent->v.classname))
{
StaticBuild(ent, "progs/fx_lux.mdl");
}
if (mod_showlight.value == 2 && !strcmp("path_corner",pr_strings + ent->v.classname))
{
StaticBuild(ent, "progs/fx_sparkshower.mdl");
}
//Tei staticlight
//Tei mod city of angels
if (mod_cityofangels.value && !strcmp("light",pr_strings + ent->v.classname))
{
i = mod_cityofangels.value;
if (i==666)
i = lhrandom(1,8);
switch(i)
{
case 1:
func = ED_FindFunction ("monster_wizard");
break;
case 2:
func = ED_FindFunction ("monster_demon1");
break;
case 3:
func = ED_FindFunction ("monster_army");
break;
case 4:
func = ED_FindFunction ("monster_hell_knight");
break;
case 5:
func = ED_FindFunction ("monster_enforcer");
break;
case 6:
func = ED_FindFunction ("monster_shambler");
break;
case 7:
func = ED_FindFunction ("monster_dog");
break;
case 8:
func = ED_FindFunction (temp1.string);
break;
default:
func = ED_FindFunction ("monster_wizard");
break;
}
if (func)
{
pr_global_struct->self = EDICT_TO_PROG(ent);
PR_ExecuteProgram (func - pr_functions);
}
}
//Tei mod city of angels
//Tei lightfluor
if ( !strcmp("light_fluoro",pr_strings + ent->v.classname))
{
//Model codified model
StaticBuild(ent, "progs/fx_lux.mdl");
}
if ( !strcmp("light_fluorospark",pr_strings + ent->v.classname))
{
//Model codified model
StaticBuild(ent, "progs/fx_xlux.mdl");
//Con_Printf("Fluorospark detected!\n");
}
//Tei lightfluor
/*
if ( !strcmp("ambient_comp_hum",pr_strings + ent->v.classname))
{
//Model codified model
//Con_Printf("Light here\n");
StaticBuild(ent, "progs/fx_fm.mdl");
}
*/
if (!func)
{
//Tei mapmodels builtins support
if (!strcmp("misc_model",pr_strings + ent->v.classname) ||!strcmp("static_brush",pr_strings + ent->v.classname))
//if (!strcmp("misc_model",pr_strings + ent->v.classname) )
{
//Model codified model
StaticBuild(ent, ent->v.model + pr_strings);
ED_Free (ent);
continue;
}
else
if (!strcmp("misc_staticsmoke",pr_strings + ent->v.classname))
{
//Model codified model
StaticBuild(ent, "progs/fx_fm.mdl");
ED_Free (ent);
continue;
}
else
if (!strcmp("play_ambient",pr_strings + ent->v.classname))
{
//Noise codifies ambient
PrecacheSound(ent->v.noise + pr_strings);
AmbientSound (ent->v.origin,ent->v.noise + pr_strings,1,3 );//3=ATTN_STATIC
ED_Free (ent);
continue;
}
else
if (!strcmp("item_mdl",pr_strings + ent->v.classname))
{
//Message codified model
StaticBuild(ent, ent->v.message + pr_strings);
ED_Free (ent);
continue;
}
else
if (!strcmp("light_environment",pr_strings + ent->v.classname))
{
//Message codified model
StaticBuild(ent, "progs/fx_lux.mdl");
ED_Free (ent);
continue;
}
else
if (!strcmp("env_glow",pr_strings + ent->v.classname))
{
//Message codified model
StaticBuild(ent, "progs/fx_glow.mdl");
ED_Free (ent);
continue;
}
else
if (!strcmp("func_illusionary",pr_strings + ent->v.classname))
{
//Message codified model
StaticBuild2(ent, pr_strings + ent->v.model, 1);
ED_Free (ent);
continue;
}
else
if (!strcmp("func_wall",pr_strings + ent->v.classname))
{
//Message codified model
StaticBuild2(ent, pr_strings + ent->v.model, 1);
ED_Free (ent);
continue;
}
else
/*
if (!strcmp("misc_fan2",pr_strings + ent->v.classname))
{
//Message codified model
StaticBuild(ent, pr_strings + ent->v.model);
ED_Free (ent);
continue;
}
else*/
if (!strcmp("light_glare",pr_strings + ent->v.classname))
{
//Message codified model
StaticBuild(ent,"progs/fx_glare.mdl");
ED_Free (ent);
continue;
}
if (!strcmp("light_drama",pr_strings + ent->v.classname))
{
//Message codified model
func = ED_FindFunction ("misc_teleporttrain");
if (func)
{
PrecacheModel("progs/fx_glare.mdl");
pr_global_struct->self = EDICT_TO_PROG(ent);
PR_ExecuteProgram (func - pr_functions);
ent->v.modelindex = SV_ModelIndex("progs/fx_glare.mdl");
}
else
{
StaticBuild(ent,"progs/fx_glare.mdl");
ED_Free (ent);
}
continue;
}
else
if (!strcmp("hostage_entity",pr_strings + ent->v.classname))
{
//Message codified model
if (rand()&1)
func = ED_FindFunction ("monster_army");
else
func = ED_FindFunction ("monster_enforcer");
}
else
if (!strcmp("func_water",pr_strings + ent->v.classname))
{
//Message codified model
StaticBuild(ent, pr_strings + ent->v.model);
ED_Free (ent);
continue;
}
else
if (!strcmp("env_sound",pr_strings + ent->v.classname))
{
//Message codified model
//StaticBuild(ent, "progs/fx_fmlit.mdl");
//TODO adjust "ambient" to "roomtype"
func = ED_FindFunction ("light_fluoro");
//ED_Free (ent);
//continue;
}
else
if (!strcmp("func_ladder",pr_strings + ent->v.classname))
{
ent->v.movetype = MOVETYPE_PUSH;
ent->v.solid = SOLID_TRIGGER;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
ent->v.modelindex = SV_ModelIndex("");;
DTYPE(FUNC_LADDER);
continue;
}
else
if (!strcmp("func_healer",pr_strings + ent->v.classname))
{
ent->v.movetype = MOVETYPE_PUSH;
ent->v.solid = SOLID_TRIGGER;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
ent->v.modelindex = SV_ModelIndex("");;
DTYPE(FUNC_HEALER);
continue;
}
else
if (!strcmp("func_ammo",pr_strings + ent->v.classname))
{
ent->v.movetype = MOVETYPE_PUSH;
ent->v.solid = SOLID_TRIGGER;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
ent->v.modelindex = SV_ModelIndex("");;
DTYPE(FUNC_AMMO);
continue;
}
else
if (!strcmp("func_rotate",pr_strings + ent->v.classname))
{
ent->v.movetype = MOVETYPE_PUSH;
ent->v.solid = SOLID_BSP;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
/*ent.rotate_type = OBJECT_MOVEWALL;
tempvec = ( ent.absmin + ent.absmax ) * 0.5;
ent.oldorigin = tempvec - self.oldorigin;
ent.neworigin = ent.oldorigin;
ent.owner = self;*/
ent->v.modelindex = SV_ModelIndex("");;
TTYPE(FUNC_ROTATE);
DTYPE(FUNC_ROTATE);
continue;
}
else
if (!strcmp("func_forcefield",pr_strings + ent->v.classname))
{
ent->v.movetype = MOVETYPE_PUSH;
ent->v.solid = SOLID_TRIGGER;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
ent->v.modelindex = SV_ModelIndex("");
DTYPE(FUNC_FORCEFIELD);
continue;
}
else
if (!strcmp("func_pushable",pr_strings + ent->v.classname))
{
ent->v.movetype = MOVETYPE_BOUNCE;
ent->v.solid = SOLID_SLIDEBOX;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
//ent->v.modelindex = SV_ModelIndex("");
DTYPE(FUNC_PUSHABLE);
continue;
}
else
if (!strcmp("func_weakwall",pr_strings + ent->v.classname))
{
ent->v.movetype = MOVETYPE_PUSH;
ent->v.solid = SOLID_BSP;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
PrecacheModel("progs/fx_glare.mdl");
DTYPE(FUNC_WEAKWALL);
continue;
}
else
if (!strcmp("func_floormirror",pr_strings + ent->v.classname))
{
ent->v.movetype = MOVETYPE_NONE;
ent->v.solid = SOLID_TRIGGER;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
ent->v.modelindex = 0;
DTYPE(FUNC_FLOORMIRROR);
continue;
}
else
if (!strcmp("func_floor",pr_strings + ent->v.classname))
{
ent->v.movetype = MOVETYPE_NONE;
ent->v.solid = SOLID_TRIGGER;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
ent->v.modelindex = 0;
DTYPE(FUNC_FLOOR);
continue;
}
else
if (!strcmp("misc_fan",pr_strings + ent->v.classname))
{
PrecacheModel(pr_strings + ent->v.model);
ent->v.movetype = MOVETYPE_NONE;
ent->v.solid = SOLID_BBOX;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
//ent->v.avelocity[2] = 90;
//Con_Printf(" fan avel %f\n", ent->v.avelocity[1]);
TTYPE(DECOR_FAN);
continue;
}
else
if (!strcmp("decor_lasertoplayer",pr_strings + ent->v.classname))
{
PrecacheModel("progs/fx_laserbeam.mdl");
//ent->v.modelindex = SV_ModelIndex("progs/fx_laserbeam.mdl");
SetModelIndex(ent,"progs/fx_laserbeam.mdl");
TTYPE(DECOR_LASERTOPLAYER);
continue;
}
else
if (!strcmp("misc_spark",pr_strings + ent->v.classname))
{
PrecacheModel("progs/fx_glare.mdl");
StaticBuild(ent,"progs/fx_glare.mdl");
NEXTTHINK(MISC_SPARK,3);
continue;
}
else
if (!strcmp("func_conveyor",pr_strings + ent->v.classname))
{
ent->v.movetype = MOVETYPE_NONE;
ent->v.solid = SOLID_TRIGGER;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
ent->v.modelindex = 0;
DTYPE(FUNC_CONVEYOR);
continue;
}
else
if (!strcmp("func_vehicle1",pr_strings + ent->v.classname))
{
//ent->v.movetype = MOVETYPE_BOUNCE;
//ent->v.solid = SOLID_SLIDEBOX;
ent->v.movetype = MOVETYPE_PUSH;
ent->v.solid = SOLID_BSP;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
VectorCopy(ent->v.origin,ent->v.movedir);
//ent->v.effects3 = EF3_ROTATEZ;
DTYPE(FUNC_VEHICLE1);
ent->forcefx3 = EF3_ROTATEZDESINCRO;
continue;
}
else
if (!strcmp("func_floathing",pr_strings + ent->v.classname))
{
//ent->v.movetype = MOVETYPE_BOUNCE;
//ent->v.solid = SOLID_SLIDEBOX;
ent->v.movetype = MOVETYPE_PUSH;
ent->v.solid = SOLID_BSP;
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
//VectorCopy(ent->v.origin,ent->v.movedir);
ent->forcefx3 = EF3_ROTATEZDESINCRO;
//TTYPE(FUNC_FLOATHING);
//NEXTTHINK(FUNC_FLOATHING,lhrandom(1,3));
continue;
}
else
if (!strcmp("decor_zumacar",pr_strings + ent->v.classname))
{
//ent->v.movetype = MOVETYPE_BOUNCE;
//ent->v.solid = SOLID_SLIDEBOX;
ent->v.movetype = MOVETYPE_BOUNCE;
ent->v.solid = SOLID_BBOX;
PrecacheModel(pr_strings + ent->v.model);
SetModelIndex(ent,pr_strings + ent->v.model);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
//VectorCopy(ent->v.origin,ent->v.movedir);
//ent->v.effects3 = EF3_ROTATEZ;
DTYPE(FUNC_VEHICLE2);
//ent->forcefx3 = EF3_ROTATEZDESINCRO;
//ent->v.weapon = F
//ent->v.th_die = DELEGATE;
continue;
}
else
if (!strcmp("traffic_gen1",pr_strings + ent->v.classname))
{
//ent->v.movetype = MOVETYPE_BOUNCE;
//ent->v.solid = SOLID_SLIDEBOX;
ent->v.movetype = MOVETYPE_FLY;
ent->v.solid = SOLID_BBOX;
PrecacheModel(pr_strings + ent->v.model);
SetModelIndex(ent,pr_strings + ent->v.model);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
//DTYPE(TRAFFIC_GENERATOR1);
NEXTTHINK(TRAFFIC_GENERATOR1,3);
continue;
}
else
if (!strcmp("func_glass",pr_strings + ent->v.classname))
{
//ent->v.movetype = MOVETYPE_BOUNCE;
//ent->v.solid = SOLID_SLIDEBOX;
ent->v.movetype = MOVETYPE_PUSH;
ent->v.solid = SOLID_BSP;
//ent->v.damage = DAMAGE_YES;
//
ent->v.modelindex = SV_ModelIndex(ent->v.model + pr_strings);
SetMinMaxSize (ent,sv.models[ (int)ent->v.modelindex]->mins, sv.models[ (int)ent->v.modelindex]->maxs, true);
//VectorCopy(ent->v.origin,ent->v.movedir);
ent->forcefx3 = EF3_GLASS;
//ent->forcefx3 = EF3_ROTATEZDESINCRO;
//TTYPE(FUNC_FLOATHING);
//NEXTTHINK(FUNC_FLOATHING,lhrandom(1,3));
continue;
}
//Tei mapmodels builtins support
//Tei renaming entitys
if (!func)
{
if (CallFunctionGame(pr_strings + ent->v.classname,&cl_progs))
continue;
}
if (func)
{
ent->v.skin = 0;//Hack for unkwnow new skins...
pr_global_struct->self = EDICT_TO_PROG(ent);
PR_ExecuteProgram (func - pr_functions);
continue;
}
//Tei renaming entitys
else
if (developer.value || temp1.value == 666) // don't confuse non-developers with errors
{
Con_Printf ("No spawn function for:\n");
ED_Print (ent);
}
ED_Free (ent);
continue;
}
pr_global_struct->self = EDICT_TO_PROG(ent);
//Call spawn function
PR_ExecuteProgram (func - pr_functions);
//Adjust handicap for this entity
if (mod_handicap.value)
ent->v.health = ent->v.health * mod_handicap.value;
}
Con_DPrintf ("%i entities inhibited\n", inhibit);
}