prozac-qfcc/monsters.qc

774 lines
15 KiB
C++
Raw Normal View History

2001-07-17 05:58:10 +00:00
/* ALL MONSTERS SHOULD BE 1 0 0 IN COLOR */
#include "defs.qh"
#include "monsters.qh"
2001-07-17 05:58:10 +00:00
// name =[framenum, nexttime, nextthink] {code}
// expands to:
// name ()
// {
// self.frame=framenum;
// self.nextthink = time + nexttime;
// self.think = nextthink
// <code>
// };
//- OfN -
entity (vector location, float life, float type) CreateWaypoint;
void (entity player) kill_his_demon;
string(entity themonster) GetMonsterName;
/*
=============
visible
returns 1 if the entity is visible to self, even if not infront ()
=============
*/
float (entity targ) visible =
{
local vector spot1, spot2;
spot1 = self.origin + self.view_ofs;
spot2 = targ.origin + targ.view_ofs;
traceline (spot1, spot2, TRUE, self); // see through other monsters
2001-07-17 05:58:10 +00:00
if (trace_inopen && trace_inwater)
return FALSE; // sight line crossed contents
2001-07-17 05:58:10 +00:00
if (trace_fraction == 1)
return TRUE;
return FALSE;
2001-07-17 05:58:10 +00:00
};
//CH so you can check other then self
float (entity targ, entity check) visible2 =
{
local vector spot1, spot2;
spot1 = check.origin + check.view_ofs;
spot2 = targ.origin + targ.view_ofs;
traceline (spot1, spot2, TRUE, check); // see through other monsters
2001-07-17 05:58:10 +00:00
if (trace_inopen && trace_inwater)
return FALSE; // sight line crossed contents
2001-07-17 05:58:10 +00:00
if (trace_fraction == 1 && trace_endpos == spot2) //CH just extra check
return TRUE;
return FALSE;
2001-07-17 05:58:10 +00:00
};
//- OfN - Used for haxxx and sentrygun targetting
float (entity targ, entity check) visible2x =
{
local vector spot1, spot2;
spot1 = check.origin + check.view_ofs;
spot2 = targ.origin + targ.view_ofs;
if (check.classname == "building_sentrygun" && (check.tf_items & NIT_TURRET))
2001-07-17 05:58:10 +00:00
spot1 = check.origin + check.view_ofs - '0 0 20';
if (check.classname == "building_sentrygun" && !(check.tf_items & NIT_TURRET))
2001-07-17 05:58:10 +00:00
spot1 = check.origin + check.view_ofs + '0 0 20';
traceline (spot1, spot2, TRUE, check); // see through other monsters
2001-07-17 05:58:10 +00:00
if (trace_inopen && trace_inwater)
return FALSE; // sight line crossed contents
2001-07-17 05:58:10 +00:00
if (trace_fraction == 1)
return TRUE;
return FALSE;
2001-07-17 05:58:10 +00:00
};
//#ifndef COOP_MODE
#ifdef NEVER_DEFINED
/*
void() monster_ogre =
{
dremove(self);
};
void() monster_knight =
{
dremove(self);
};
void() monster_shambler =
{
dremove(self);
};
void() monster_demon1 =
{
dremove(self);
};
void() monster_wizard =
{
dremove(self);
};
void() monster_zombie =
{
dremove(self);
};
void() monster_dog =
{
dremove(self);
};
void() monster_hell_knight =
{
dremove(self);
};
void() monster_tarbaby =
{
dremove(self);
};
void() monster_vomit =
{
dremove(self);
};
void() monster_enforcer =
{
dremove(self);
};
void() monster_shalrath =
{
dremove(self);
};
void() monster_dragon =
{
dremove(self);
};
void() monster_army =
{
dremove(self);
};
*/
/*
==============================================================================
MOVETARGET CODE
The angle of the movetarget effects standing and bowing direction, but has no effect on movement, which allways heads to the next target.
targetname
must be present. The name of this movetarget.
target
the next spot to move to. If not present, stop here for good.
pausetime
The number of seconds to spend standing or bowing for path_stand or path_bow
==============================================================================
*/
/*
void() t_movetarget;
void() movetarget_f =
{
if (!self.targetname)
objerror ("monster_movetarget: no targetname");
self.solid = SOLID_TRIGGER;
2001-07-17 05:58:10 +00:00
self.touch = t_movetarget;
setsize (self, '-8 -8 -8', '8 8 8');
};
*/
/*QUAKED path_corner (0.5 0.3 0) (-8 -8 -8) (8 8 8)
Monsters will continue walking towards the next target corner.
*/
/*
void() path_corner =
{
if (CheckExistence() == FALSE)
2001-07-17 05:58:10 +00:00
{
dremove(self);
return;
}
movetarget_f ();
};
*/
/*
=============
t_movetarget
Something has bumped into a movetarget. If it is a monster
moving towards it, change the next destination and continue.
==============
*/
/*
void() t_movetarget =
{
local entity temp;
if (other.movetarget != self)
return;
if (other.enemy)
return; // fighting, not following a path
temp = self;
self = other;
other = temp;
*/
/*
if (self.classname == "monster_ogre")
sound (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE);// play chainsaw drag sound
2001-07-17 05:58:10 +00:00
*/
/*
//RPrint ("t_movetarget\n");
self.goalentity = self.movetarget = find (NIL, targetname, other.target);
2001-07-17 05:58:10 +00:00
self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
if (!self.movetarget)
{
self.pausetime = time + 999999;
self.th_stand ();
return;
}
};
float(float v) anglemod =
{
while (v >= 360)
v = v - 360;
while (v < 0)
v = v + 360;
return v;
};
float(entity targ) range =
{
local vector spot1, spot2;
local float r;
spot1 = self.origin + self.view_ofs;
spot2 = targ.origin + targ.view_ofs;
r = vlen (spot1 - spot2);
if (r < 120)
return RANGE_MELEE;
2001-07-17 05:58:10 +00:00
if (r < 500)
return RANGE_NEAR;
2001-07-17 05:58:10 +00:00
if (r < 1000)
return RANGE_MID;
return RANGE_FAR;
2001-07-17 05:58:10 +00:00
};
*/
/*
=============
infront
returns 1 if the entity is in front (in sight) of self
=============
*/
/*
float(entity targ) infront =
{
local vector vec;
local float dot;
makevectors (self.angles);
vec = normalize (targ.origin - self.origin);
dot = vec * v_forward;
if ( dot > 0.3)
{
return TRUE;
2001-07-17 05:58:10 +00:00
}
return FALSE;
2001-07-17 05:58:10 +00:00
};
//============================================================================
void() HuntTarget =
{
self.goalentity = self.enemy;
self.think = self.th_run;
self.ideal_yaw = vectoyaw(self.enemy.origin - self.origin);
self.nextthink = time + 0.1;
SUB_AttackFinished (1); // wait a while before first attack
};
/*
===========
FindTarget
Self is currently not attacking anything, so try to find a target
Returns TRUE if an enemy was sighted
2001-07-17 05:58:10 +00:00
When a player fires a missile, the point of impact becomes a fakeplayer so
that monsters that see the impact will respond as if they had seen the
player.
To avoid spending too much time, only a single client (or fakeclient) is
checked each frame. This means multi player games will have slightly
slower noticing monsters.
============
*/
/*
float() FindTarget =
{
//WK THIS CODE IS DEF-ed out!!
2001-07-17 05:58:10 +00:00
/* WK Replace this with the code from sentry
local entity client;
client = checkclient ();
if (!client)
return FALSE; // current check entity isn't in PVS
2001-07-17 05:58:10 +00:00
if (client.flags & FL_NOTARGET)
return FALSE;
if (client.items & IT_INVISIBILITY)
return FALSE;
2001-07-17 05:58:10 +00:00
if (!visible (client))
return FALSE;
2001-07-17 05:58:10 +00:00
if (client.classname != "player")
return FALSE;
2001-07-17 05:58:10 +00:00
self.enemy = client;
HuntTarget ();
return TRUE;
2001-07-17 05:58:10 +00:00
*/
/*
local entity client;
local float r, gotone, loopc;
//WK Hack to get floating sentry working
if (self.tf_items & NIT_FLOATING_SENTRY) {
2001-07-17 05:58:10 +00:00
self.origin_z = self.origin_z - 40;
}
// Try a few checks to make it react faster
r = 0;
loopc = 0;
gotone = FALSE;
while (loopc < 5 && gotone == FALSE) //WK 3
2001-07-17 05:58:10 +00:00
{
client = checkclient();
gotone = TRUE;
2001-07-17 05:58:10 +00:00
if (!client)
gotone = FALSE;
2001-07-17 05:58:10 +00:00
/*
if (teamplay)
{
// Only attack enemies
if (client.team_no == self.team_no && self.team_no != 0)
gotone = FALSE;
2001-07-17 05:58:10 +00:00
// Cant see Undercover spies
if (client.undercover_team == self.team_no && self.team_no != 0)
gotone = FALSE;
2001-07-17 05:58:10 +00:00
}
// if (client == self.real_owner)
// gotone = FALSE;
2001-07-17 05:58:10 +00:00
*/
/*
if (client.is_feigning)
gotone = FALSE;
2001-07-17 05:58:10 +00:00
if (client.flags & FL_NOTARGET)
gotone = FALSE;
if (client.items & IT_INVISIBILITY)
gotone = FALSE;
2001-07-17 05:58:10 +00:00
if (!visible (client))
gotone = FALSE;
2001-07-17 05:58:10 +00:00
r = range (client);
if (r == RANGE_FAR)
gotone = FALSE;
2001-07-17 05:58:10 +00:00
if (r == RANGE_NEAR)
2001-07-17 05:58:10 +00:00
{
if (client.show_hostile < time && !infront (client))
gotone = FALSE;
2001-07-17 05:58:10 +00:00
}
else if (r == RANGE_MID)
2001-07-17 05:58:10 +00:00
{
if ( /* client.show_hostile < time || */ !infront (client))
/* gotone = FALSE;
2001-07-17 05:58:10 +00:00
}
loopc = loopc + 1;
if (gotone) loopc = 1000;
}
if (!gotone)
return FALSE;
2001-07-17 05:58:10 +00:00
// Found a Target
self.enemy = client;
if (self.enemy.classname != "player")
{
self.enemy = self.enemy.enemy;
if (self.enemy.classname != "player")
{
self.enemy = NIL;
return FALSE;
2001-07-17 05:58:10 +00:00
}
}
HuntTarget ();
return TRUE;
2001-07-17 05:58:10 +00:00
};*/
#endif
void() FoundTarget;
/*
================
monster_use
Using a monster makes it angry at the current activator
================
*/
void() monster_use =
{
if (self.enemy)
return;
if (self.health <= 0)
return;
if (activator.items & IT_INVISIBILITY)
2001-07-17 05:58:10 +00:00
return;
if (activator.flags & FL_NOTARGET)
2001-07-17 05:58:10 +00:00
return;
if (activator.classname != "player")
return;
// delay reaction so if the monster is teleported, its sound is still
// heard
self.enemy = activator;
self.nextthink = time + 0.1;
self.think = FoundTarget;
};
/*===========================
set_monster_health
Increases the monsters health
for skill levels above 3
doesnt work
===========================*/
void() set_monster_health =
{
skill = cvar("skill");
if (skill > 2)
{
self.lives = ((skill - 2) * 10) - 1;
skill = 3;
}
};
/*
================
monster_death_use
When a mosnter dies, it fires all of its targets with the current
enemy as activator.
================
*/
#ifdef COOP_MODE
//WK This is doubly declared in combat.qc
void() monster_death_use =
{
local entity ent, otemp;
// fall to ground
if (self.flags & FL_FLY)
self.flags = self.flags - FL_FLY;
if (self.flags & FL_SWIM)
self.flags = self.flags - FL_SWIM;
2001-07-17 05:58:10 +00:00
if (!self.target)
return;
activator = self.enemy;
SUB_UseTargets ();
};
#endif
//============================================================================
void() walkmonster_start_go =
{
// local float failure;
// local vector test;
<Grievre> lemme see... fixes: stuck shamblers, cheat teslas, camming and sensing <Grievre> give mirvs the right death message, make them a little weaker and more spread out <Grievre> increased damage done by exp body... fixes not being able to use airfist if you have daedalus or lg with no cells <Grievre> made it so missing judo = you can't fire for 1.5 seconds, also judo doesn't always work, less chance of it working a) if they're facing you b) if they have knife, judo, or close combat <Grievre> you lose speed the more armor you have (so upgraded people can buy cougar and cheetah now) <Grievre> attempted to fix the respawn guard not telefragging bug (if it was still there) <Grievre> made it so you can tell a shambler to come, stop, or patrol even if it is fighting someone, doesn't really work most of the time but can "wake up" your shambler if it's being screwy <Grievre> (works for all demons) <Grievre> made it so a monster goes back to what it was doing before (following you, patrolling etc) once it's done with its enemy <Grievre> made the sniper rifle less cheap (or tried to), charging now = more accuracy, rather than more damage. OTR now does slightly less damage than regular, but isn't blocked by armor as much. <Grievre> autorifle now has half the rate of fire but does same damage as sniper rifle, but less accurate <Grievre> headshots always ignore armor if target has green armor, legshots always ignore armor except for red <Grievre> added bshams and shambler kings (can be disabled with infokeys) <Grievre> increased max knife blood to 32 <Grievre> made it so airfist bounces gymnasts twice as much, and bounces everyone a little more (I think), may cause stuck bugs but I think it won't. airfist does half damage to gymnasts and slightly more to hwguys <Grievre> made shamblers a little smarter and more powerful in general <Grievre> they now attack buildings (only bshams/kings) if they are attacked by them first <Grievre> bsham/king fireball now sets things on fire <Grievre> shamblers will generally attack the person who last hit them <Grievre> shortened judoka range (they have the old range if they get close combat <Grievre> shamblers will cycle the left-right slash or fireball longer than they did (but they won't keep doing it if their enemy is not visible) <Grievre> fixed shambler fireball so it doesn't miss and hurt itself so much <Grievre> #define OLD_AUTORIFLE <Grievre> will go to the old behavior of the auto rifle <Grievre> I think that's it <Grievre> oh, I changed the intro message and version string a little, you might want to change that
2003-11-12 04:58:19 +00:00
self.movetype = MOVETYPE_STEP;
self.solid = SOLID_SLIDEBOX;
2001-07-17 05:58:10 +00:00
self.origin_z = self.origin_z + 1; // raise off floor a bit
droptofloor();
1) Attempted to give players positive frags whenever possible. You now should get frags for blowing people up with others' dispensers/mines/expbody, airfisting rockets, etc. 2) Redid Give_Frags_Out 3) Changed many uses of pointcontents and ugly hacks to use hullpointcontents and checkmove, now a lot cleaner and less buggy 4) You can grapple builds again. This caused really odd bugs. 5) You can now damage your own buildings again (gasp). Any time a tesla or sentry is damaged it turns on its attacker, friendly or otherwise. This is both a counter-TK and counter-spy mechanism. 6) Teslas are now entirely inside their bounding box 7) Now check every frame for players startsolid and for outside of the map cube. 8) #define WALL_HURT to make it hurt when you hit a wall 9) Used some cool ideas (aka laws of physics) to make the airfist a little less annoying 10) You now only get 1 mirv per slot without bandolier. Demoman and hwguy gain bandolier. demoman loses his extra mirv but gains an extra grenade and pair of detpacks. Hwguy gets extra grenade. 11) New and improved EMP grenade now does damage based on range. no longer blows up shells. Doesn't directly damage sentries anymore, but does significant damage to dispensers. EMP someone who's setting a det and it blows up in their face. 12) Players now do radius damage from getting EMPed (again) 13) EMPs now go through walls (again) 14) EMP number lowered by one (3 without, 4 with bandolier) and cost raised by $100 15) You can only have 2 frag grens, 3 with bandolier now. 16) Hover boots will now eat cells if they get low on charge. In addition, the silly bug where their charge wasn't restored when you die is fixed now. 17) EMPing a detpack now sets its timer to anywhere between 1 and 121 seconds from current time, with a logarithmic probability of it being lower. (random() * random() * 120 + 1). Also, probably more time the closer it is to the EMP. 18) Judo can now be blocked by people with close combat, knife or judo. Blocked judo means that the attacker loses 3 seconds of attack. 19) Judo missing now makes them unable to fire. 20) Shortened judo range (back to normal if w/ close combat) 21) Attempted to rework the railgun. Seems to be okay now. Probably still a lot of bugs in here, but since this is the devel version I thought I would commit all my changes so people could start testing it. I'll commit fixes as soon as I find the bugs.
2003-11-26 08:53:44 +00:00
if (entpointcontents(self) == CONTENTS_SOLID)
2001-07-17 05:58:10 +00:00
{
//- OfN - if (self.classname == "monster_demon1" || self.classname == "monster_army" || self.classname == "monster_shambler")
if (IsMonster(self))
if (self.real_owner.classname == "player")
{
//self.real_owner.job = self.real_owner.job - (self.real_owner.job & JOB_DEMON_OUT);
2001-07-17 05:58:10 +00:00
local string MName;
MName=GetMonsterName(self);
sprint(self.real_owner,PRINT_HIGH,"Your ");
sprint(self.real_owner,PRINT_HIGH,MName);
sprint(self.real_owner,PRINT_HIGH," was beamed into a wall and died.\n");
2001-07-17 05:58:10 +00:00
if (self.classname == "monster_shambler") //- ofn
{
self.real_owner.demon_blood = self.real_owner.demon_blood + 4;
if (self.real_owner.demon_blood > MAX_KNIFE_BLOOD)
self.real_owner.demon_blood = MAX_KNIFE_BLOOD;
2001-07-17 05:58:10 +00:00
}
else if (self.classname == "monster_demon1") //- ofn
{
self.real_owner.demon_blood = self.real_owner.demon_blood + 2;
if (self.real_owner.demon_blood > MAX_KNIFE_BLOOD)
self.real_owner.demon_blood = MAX_KNIFE_BLOOD;
2001-07-17 05:58:10 +00:00
}
/*else if (self.classname == "monster_wizard") //- ofn
{
self.real_owner.demon_blood = self.real_owner.demon_blood + ? ;
if (self.real_owner.demon_blood > MAX_KNIFE_BLOOD)
self.real_owner.demon_blood = MAX_KNIFE_BLOOD;
2001-07-17 05:58:10 +00:00
}*/
kill_his_demon(self.real_owner);
return;
}
dremove(self);
return;
}
self.takedamage = DAMAGE_AIM;
2001-07-17 05:58:10 +00:00
self.ideal_yaw = self.angles * '0 1 0';
if (!self.yaw_speed)
self.yaw_speed = 20;
self.view_ofs = '0 0 25';
self.use = monster_use;
self.flags = self.flags | FL_MONSTER;
2001-07-17 05:58:10 +00:00
if (self.target)
{
self.goalentity = self.movetarget = find(NIL, targetname, self.target);
2001-07-17 05:58:10 +00:00
self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
if (!self.movetarget)
{
RPrint ("Monster can't find target at ");
RPrint (vtos(self.origin));
RPrint ("\n");
}
// this used to be an objerror
if (self.movetarget.classname == "path_corner")
self.th_walk ();
else
self.pausetime = 99999999;
self.th_stand ();
}
else
{
self.pausetime = 99999999;
self.th_stand ();
}
if (self.classname == "monster_army")
{
self.martyr_enemy = CreateWaypoint(self.origin,WAYPOINT_LIFE,WAYPOINT_TYPE_PRIMARY);
self.martyr_enemy.goalentity = NIL;
2001-07-17 05:58:10 +00:00
// OFTEN
self.demon_two=NIL;
self.demon_one=NIL;
2001-07-17 05:58:10 +00:00
// OFTEN
self.goalentity = NIL;
2001-07-17 05:58:10 +00:00
}
// spread think times so they don't all happen at same time
self.nextthink = self.nextthink + random()*0.5;
};
void() walkmonster_start =
{
// delay drop to floor to make sure all doors have been spawned
// spread think times so they don't all happen at same time
self.nextthink = self.nextthink + 1; //WK Give time to run from demons
//WK self.nextthink = self.nextthink + random()*0.5;
self.think = walkmonster_start_go;
total_monsters = total_monsters + 1;
set_monster_health();
};
void() flymonster_start_go =
{
self.takedamage = DAMAGE_AIM;
2001-07-17 05:58:10 +00:00
self.ideal_yaw = self.angles * '0 1 0';
if (!self.yaw_speed)
self.yaw_speed = 10;
self.view_ofs = '0 0 25';
self.use = monster_use;
self.flags = self.flags | FL_FLY;
self.flags = self.flags | FL_MONSTER;
2001-07-17 05:58:10 +00:00
if (!walkmove(0,0))
{
RPrint ("flymonster in wall at: ");
RPrint (vtos(self.origin));
RPrint ("\n");
}
if (self.target)
{
self.goalentity = self.movetarget = find(NIL, targetname, self.target);
2001-07-17 05:58:10 +00:00
if (!self.movetarget)
{
RPrint ("Monster can't find target at ");
RPrint (vtos(self.origin));
RPrint ("\n");
}
// this used to be an objerror
if (self.movetarget.classname == "path_corner")
self.th_walk ();
else
self.pausetime = 99999999;
self.th_stand ();
}
else
{
self.pausetime = 99999999;
self.th_stand ();
}
};
void() flymonster_start =
{
// spread think times so they don't all happen at same time
self.nextthink = self.nextthink + random()*0.5;
self.think = flymonster_start_go;
total_monsters = total_monsters + 1;
set_monster_health();
};
void() swimmonster_start_go =
{
if (deathmatch)
{
dremove(self);
return;
}
self.takedamage = DAMAGE_AIM;
2001-07-17 05:58:10 +00:00
total_monsters = total_monsters + 1;
self.ideal_yaw = self.angles * '0 1 0';
if (!self.yaw_speed)
self.yaw_speed = 10;
self.view_ofs = '0 0 10';
self.use = monster_use;
self.flags = self.flags | FL_SWIM;
self.flags = self.flags | FL_MONSTER;
2001-07-17 05:58:10 +00:00
if (self.target)
{
self.goalentity = self.movetarget = find(NIL, targetname, self.target);
2001-07-17 05:58:10 +00:00
if (!self.movetarget)
{
RPrint ("Monster can't find target at ");
RPrint (vtos(self.origin));
RPrint ("\n");
}
// this used to be an objerror
self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
self.th_walk ();
}
else
{
self.pausetime = 99999999;
self.th_stand ();
}
// spread think times so they don't all happen at same time
self.nextthink = self.nextthink + random()*0.5;
};
void() swimmonster_start =
{
// spread think times so they don't all happen at same time
self.nextthink = self.nextthink + random()*0.5;
self.think = swimmonster_start_go;
total_monsters = total_monsters + 1;
set_monster_health();
};
// WK #endif
/* WK We are already including these
ai.qc
fight.qc
demon.qc
*/
#ifdef COOP_MODE
// include all the monsters
// WK In normal QW we only need demons
// SB and soldiers, and shamblers
#include "dog.qc"
#include "enforcer.qc"
#include "fish.qc"
#include "hknight.qc"
#include "knight.qc"
#include "ogre.qc"
#include "oldone.qc"
#include "shalrath.qc"
#include "tarbaby.qc"
#include "wizard.qc"
#include "zombie.qc"
#endif