djcev.com

//

Git Repos / fte_dogmode / qc / misc / infight.qc

Last update to this file was on 2024-04-12 at 18:56.

Show infight.qc

//==============================================================================
// misc_infight
//==============================================================================

//======================================================================
// misc_infight
//
// target = monster that gets mad
// target2 = who target1 will be angry at
//
// spawnflag 1 = mutual hate, both targets get angry at each other instantly
// spawnflag 2 = maintain activator, makes it so the player that triggers
// the infighting sees centerprints triggered by it
//======================================================================

//======================================================================
// constants
//======================================================================

const float INFIGHT_MUTUAL = 1;
const float INFIGHT_PLAYER_ACTIVATION = 2;

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

// misc_infight
void(entity t1, entity t2) misc_infight_make_angry_at;
void() misc_infight_use;
void(entity e) misc_infight_init;
void() misc_infight;

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

//----------------------------------------------------------------------
// class misc_infight: base_mapentity
// {
//--------------------------------------------------------------
void(entity t1, entity t2) misc_infight_make_angry_at =
{
// checks if targets are alive
if (t2.health > 0 && t1.health > 0)
{
if (t1.enemy.classtype == CT_PLAYER)
t1.oldenemy = t1.enemy;
t1.enemy = t2;

// was FoundTargetForEntity (t1) -- CEV
if (t1.classgroup & CG_MONSTER)
{
sub_runfloatas (t1, ai_findtarget);
}
else
{
objerror (sprintf("misc_infight_make_angry_at"
": tried to make a %s fight a %s!",
t1.classname, t2.classname));
}
}
};

//--------------------------------------------------------------
void() misc_infight_use =
{
local entity t1, t2;

for (t1 = world; (t1 = find (t1, targetname, self.target)); )
{
for (t2 = world;
(t2 = find (t2, targetname, self.target2)); )
{
// t1 = find(world, targetname, self.target);
// t2 = find(world, targetname, self.target2);
if (!t1)
{
dprint ("misc_infight_use: Cannot find "
"target, trying targetname2\n");
t1 = find (world, targetname2,
self.target);
}
if (!t1)
{
dprint ("misc_infight_use: Cannot find "
"target, trying targetname3\n");
t1 = find (world, targetname3,
self.target);
}
if (!t1)
{
dprint ("misc_infight_use: Cannot find "
"target, trying targetname4\n");
t1 = find (world, targetname4,
self.target);
}
if (!t1)
{
dprint ("misc_infight_use: Cannot find "
"target, out of targetnames\n");
return;
}
if (!t2)
{
dprint ("misc_infight_use: Cannot find "
"target2 trying targetname2\n");
t2 = find (world, targetname2,
self.target2);
}
if (!t2)
{
dprint ("misc_infight_use: Cannot find "
"target2 trying targetname3\n");
t2 = find (world, targetname3,
self.target2);
}
if (!t2)
{
dprint ("misc_infight_use: Cannot find "
"target2 trying targetname4\n");
t2 = find (world, targetname4,
self.target2);
}
if (!t2)
{
dprint ("misc_infight_use: Cannot find "
"target2 out of targetnames\n");
return;
}

misc_infight_make_angry_at (t1, t2);

if (self.spawnflags & INFIGHT_PLAYER_ACTIVATION)
{
t1.infight_activator = activator;
t2.infight_activator = activator;
}

if (self.spawnflags & INFIGHT_MUTUAL)
misc_infight_make_angry_at (t2, t1);
}
}
};

//--------------------------------------------------------------
void(entity e) misc_infight_init =
{
e.classname = "misc_infight";
e.classtype = CT_MISC_INFIGHT;

base_mapentity_init (e);

e.use = misc_infight_use;
};

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

misc_infight_init (self);
};
// };

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

Log infight.qc

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