@Preach
#3503 posted by
ranger on 2024/12/22 11:58:49
is TE_EXPLOSION2 and such values, hardcoded?
got it, I see "Burst Of Particles"
is there a code number guide for palette colors? or I gotta count them manually?
--
also something is up with ATTN_STATIC and such for sounds? I tried setting the attn value for a sound to like 5 or 10 but seems no effect? the sound seems to still travel very far? but if i set it to ATTN_STATIC the range is reduced
Also This Is A Persistant Bug I'm Getting
#3504 posted by
ranger on 2024/12/22 15:58:31
(trying to spawn new items/models dynamically in maps)
host error
pf precache can only be done in spawn functions?
Palette And More
#3505 posted by
Preach on 2024/12/22 18:53:40
https://quakewiki.org/wiki/Quake_palette
Attenuation values wrap around when you hit the limit, so 1 = 5 = 9 etc. Don’t go above 4.
You can only precache at the first frame. You might need to rewrite the spawn function as multiple functions. One function to just precache things, one to actually create the entity without precache. The latter can be run at any time. But you must run the precache function on the initial frame somehow any time you might run the spawn function.
About Factions Revisted
#3506 posted by
ranger on 2024/12/22 19:56:15
my quakec code not working? seems no effect ingame - all monsters still are all teams with each other against the player. (I even added AssignFaction() to every monster and confirmed the monsters are on the correct teams ingame)
in monsters.qc
void () monster_use =
{
if (self.enemy)
return;
if (self.health <= 0)
return;
if (activator.flags & FL_NOTARGET)
return;
//if (activator.classname != "player")
// return;
if (activator.classname != "player" &&
activator.faction != self.faction &&
activator.faction != FACTION_NEUTRAL &&
self.faction != FACTION_NEUTRAL)
{
self.enemy = activator;
self.nextthink = time + 0.1;
self.think = FoundTarget;
return;
}
self.enemy = activator;
self.nextthink = time + 0.1;
self.think = FoundTarget;
};
void() AssignFaction =
{
if (self.classname == "monster_shambler" )
{
self.faction = FACTION_A; //1
}
else if (self.classname == "monster_army" )
{
self.faction = FACTION_B; //2
}
else if (self.classname == "monster_tarbaby")
{
self.faction = FACTION_C; //3
}
else if (self.classname == "monster_dragon")
{
self.faction = FACTION_D; //4
}
// Default faction if none assigned above
if (!self.faction)
self.faction = FACTION_NEUTRAL; //0
}
in ai.qc
float(entity targ) MonsterCheckEnemy =
{
// Invalid or dead targets
if (!targ || targ.health <= 0)
return FALSE;
// Always target players
if (targ.classname == "player")
return TRUE;
// Don't target same faction
if (targ.faction == self.faction)
return FALSE;
// Neutral faction doesn't fight anyone except players
if (targ.faction == FACTION_NEUTRAL || self.faction == FACTION_NEUTRAL)
return FALSE;
// Different factions will fight
return TRUE;
};
float () FindTarget =
{
local entity client;
local float r;
if ((sight_entity_time >= (time - 0.10)) && !(self.spawnflags & 3))
{
client = sight_entity;
if (client.enemy == self.enemy)
return (FALSE);
}
else
{
if ((active_probes != FALSE) && (random () < 0.50))
{
beef = find (world, classname, "hologram");
if ((beef != world) && (beef.holo_owner.flags != (beef.holo_owner.flags | FL_NOTARGET)))
client = beef;
else
client = checkclient ();
}
else
client = checkclient ();
if (!client)
return (FALSE);
}
if (client == self.enemy)
return (FALSE);
if (client.flags & FL_NOTARGET)
return (FALSE);
// Add faction check
//if (client.faction == self.faction || client.faction == FACTION_NEUTRAL || self.faction == FACTION_NEUTRAL)
// return (FALSE);
if (!MonsterCheckEnemy(client))
return FALSE;
r = range (client);
if ((r == RANGE_FAR)) //out of range
return (FALSE);
if (!visible (client))
return (FALSE);
if (r == RANGE_NEAR)
{
if ((client.show_hostile < time) && !infront (client))
return (FALSE);
}
else if (r == RANGE_MID) //combat range max
{
if (!infront (client))
return (FALSE);
}
self.enemy = client;
if ((self.enemy.classname != "player") && (self.enemy.classname != "hologram"))
{
self.enemy = self.enemy.enemy;
if (self.enemy.classname != "player")
{
self.enemy = world;
return (FALSE);
}
}
FoundTarget ();
return (TRUE);
};
#3507 posted by
ranger on 2024/12/22 19:59:56
To clarify all that code doesn't seem to work...
ingame monsters on the same side will infight if accidentally hit by teammates,
and will not automatically attack other monsters in other factions
Application
#3508 posted by
Preach on 2024/12/22 23:01:23
Your MonsterCheckEnemy needs to be running in T_Damage to have an effect on infighting. And there’s nothing in your FindTarget that ever makes “client” a monster, because checkclient only yields players. So there’s no chance of fighting breaking out spontaneously.