djcev.com

//

Git Repos / fte_dogmode / qc / triggers / monsterface.qc

Last update to this file was on 2024-06-15 at 19:50.

Show monsterface.qc

//==============================================================================
// trigger_monsterface
//==============================================================================

//======================================================================
// forward declarations
//======================================================================

#ifdef SSQC
// trigger_monsterface
float(entity targ, entity o) ai_visible_to_other;
void() trigger_monsterface_touch;
void(entity e) trigger_monsterface_init;
void() trigger_monsterface;
#endif

//------------------------------------------------------------------------------

#ifdef SSQC
/*QUAKED trigger_monsterface (.5 .0 .5)
Running monsters that do not see their target and touch this will face in the direction of the trigger's angle instead of the unseen target.
Use this trigger to make monsters leave their sniping spot and execute complex maneuvers.

Keys:
"angle" absolute angle in which the monster should face
"targetname" entity name
"wait" time to wait between retriggers
*/
//----------------------------------------------------------------------
// class trigger_monsterface: base_trigger
// {
//--------------------------------------------------------------
// visibleToOther - returns 1 if the entity is visible to other,
// even if not infront ()
//--------------------------------------------------------------
float(entity targ, entity o) ai_visible_to_other =
{
local vector spot1, spot2;

spot1 = o.origin + o.view_ofs;
spot2 = targ.origin + targ.view_ofs;
// see through other monsters
traceline (spot1, spot2, TRUE, o);

if (trace_inopen && trace_inwater)
// sight line crossed contents
return FALSE;

if (trace_fraction == 1)
return TRUE;

return FALSE;
};

//--------------------------------------------------------------
void() trigger_monsterface_touch =
{
// only affect ground monsters
if (other.flags &
(FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER)
return;

if (!ai_visible_to_other(other.enemy, other))
{
// enemy is hidden
// don't dodge around, just go straight
other.t_length = time + self.wait + 0.2;
// face where I want
other.ideal_yaw = self.angles_y;
}
};

//--------------------------------------------------------------
void(entity e) trigger_monsterface_init =
{
e.classname = "trigger_monsterface";
e.classtype = CT_TRIGGER_MONSTERFACE;
e.touch = trigger_monsterface_touch;

if (e.angles == '0 0 0')
e.angles = '0 360 0';

// trigger_init will alter angles, so save & restore them
local vector saveangles = e.angles;
base_trigger_init (e);
e.angles = saveangles;
};

//--------------------------------------------------------------
void() trigger_monsterface =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

trigger_monsterface_init (self);
};
// };
#endif

Return to the top of this page or return to the overview of this repo.

Log monsterface.qc

Return to the top of this page or return to the overview of this repo.