Casting An Entity Origin To The Client/Player Origin?
#3478 posted by
rsrsceo on 2024/09/14 00:27:55
I'm working on the stealth mod detailed in my previous posts, and I've run into a conundrum that I'm not sure how to solve.
I want to get the players origin whenever they are visible and assign it to an entity that tracks their last visible position. Whenever I try doing this, the entity just gets assigned to [world.origin].
I'm new to QuakeC but am making steady progress, any and all help is appreciated, thanks!
Three Options
#3479 posted by
Preach on 2024/09/14 11:20:20
In your design are you planning:
1. To have a global record of the last place any of the players were seen by any of the monsters
2. To have a record on each player of the last place they were seen by any monster
3. To have a record on each monster of the last place they saw their current enemy
Option 1 is different to option 2 when you think about co-op. To be more blunt, option 1 doesn't work very well in co-op.
Game Crashes When Attacking Unaware Monster
#3480 posted by
rsrsceo on 2024/09/16 07:46:36
A [self.think] statement seems to be missing from the ai.qc script (or another related script). Whenever I attack an unaware/passive enemy, the level will crash and boot me to the command menu. Does anyone know where the missing [self.think] statement should go for aggro-ing an enemy?
For context, I'm using StealthQuake by RenegadeC as a base for this mod and I've changed up quite a bit of stuff because the base mod pretty much entirely changes up how Quake plays.
Speculation
#3481 posted by
Preach on 2024/09/17 08:23:14
Never seen the source code for StealthQuake, but I can explain how a similar crash can happen in vanilla Quake and that might point you in the right direction. Take a look at HuntTarget
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
};
This function runs when a monster spots a player, and the dangerous line is self.think = self.th_run. The idea is th_run contains a think function bottled up for future use, and HuntTarget finally uncorks it. But if th_run is empty, then you've just scheduled an empty function to run in 0.1 seconds, and a crash is imminent.
Have a look at your code to see if the same transfer from th_run to think is happening when a monster wakes up, or if a similar transfer is happening from a different field. Then make sure that when you create your monster you populate that field with the correct ai function.