Skemech Posted March 6, 2024 So it's possible to have something be activated via the player pressing "E", the player hitting something, or even the player walking over a linedef... but can you have something get activated via the player looking at something? 1 Quote Share this post Link to post
1 Dark Pulse Posted March 6, 2024 56 minutes ago, Skemech said: So it's possible to have something be activated via the player pressing "E", the player hitting something, or even the player walking over a linedef... but can you have something get activated via the player looking at something? Generally no, given that in the original engine you had no way to control your vertical look. I'm not even sure if it'd be doable via DECORATE or ZScript stuff - "line of sight" calculations in Doom terms are generally done on a 2D basis. In other words, even if you're hundreds of feet above a monster, it will still "see" you. 1 Quote Share this post Link to post
1 rouge_means_red Posted March 6, 2024 In ZScript you can detect an object that the player is looking at, if it helps static actor GetClosestToCursor(actor self, string type, int closestDistFromCenter) { if (!self) return null; // Get the world position (x,y,z) of the owner's eyes. Vector3 viewpoint = self.Pos; if (self.Player) viewpoint.Z = self.Player.viewz; else viewpoint.Z += self.GetCameraHeight(); // Find the owner's view angles (yaw and pitch). Vector2 viewAngles = (self.Angle, self.Pitch); Actor closest = null; double minimumDistFromCenter = closestDistFromCenter; double closestDistFromCamera = 768; for (let i = BlockThingsIterator.Create(self, 768); i.Next();) { Actor other = i.thing; // The owner can't aim at itself, of course. if (other == self) continue; if (!(other is type)) continue; // Get the world position of the middle of the other actor. Actor.Pos is normally at the very bottom of the actor, so we'll take other.Pos and add half of its height. Vector3 otherCenter = other.Pos; otherCenter.Z += other.Height * .5; // Compute how close the other actor is to the player's crosshairs. Vector3 sphericalCoords = LevelLocals.SphericalCoords(viewpoint, otherCenter, viewAngles); double distanceFromCenter = sphericalCoords.XY.Length(); double distanceFromCamera = sphericalCoords.Z; // Is it closer? if (distanceFromCenter <= minimumDistFromCenter && distanceFromCamera < closestDistFromCamera) { closest = other; closestDistFromCenter = distanceFromCenter; closestDistFromCamera = distanceFromCamera; } } // Now, decide on what message to log, if any. String msg = ""; if (!closest && self.Target) // Was aiming at something, but no longer is. msg = "Not aiming at anything"; else if (closest != self.Target) // Was aiming at something else (or nothing). msg = String.Format("Now aiming at %s", closest.GetTag(closest.GetClassName())); // Log the message, if any. if (msg) self.A_Log(msg); // Update the Target pointer to whatever was chosen. Next tic, we'll check again whether the owner is still aiming at the same thing. self.Target = closest; return closest; } } (This code isn't mine and I don't remember where I got it) 1 Quote Share this post Link to post
0 Skemech Posted March 6, 2024 honestly, regardless. even if it's only applied via x and y cords, is it still possible? To, for example, activate an acs script just from the player gazing upon a linedef? 0 Quote Share this post Link to post
0 Stabbey Posted March 6, 2024 Select a linedef in an ACS-enabled map and click properties. Look in the box marked "Activation." Does "when player looks at linedef" or anything like it appear anywhere in that box? No, it does not. 0 Quote Share this post Link to post
0 Kan3 Posted March 6, 2024 I did something similar in ACS using PickActor. Of course, you will need an actor (any) to do this, but you can place it wherever you want and make it invisible if you want to (for example to give the impression to activate the script when the player looks at a wall/whatever). 1 Quote Share this post Link to post
0 zokum Posted March 8, 2024 On 3/6/2024 at 3:31 AM, Dark Pulse said: Generally no, given that in the original engine you had no way to control your vertical look. I'm not even sure if it'd be doable via DECORATE or ZScript stuff - "line of sight" calculations in Doom terms are generally done on a 2D basis. In other words, even if you're hundreds of feet above a monster, it will still "see" you. No, in Doom I think the z axis is taken into account. Monsters do however have quite wide fields of view, both sideways and up/down. A monster below a high ledge will not see you until you are quite close to the edge. 0 Quote Share this post Link to post
0 Dark Pulse Posted March 8, 2024 (edited) 12 hours ago, zokum said: No, in Doom I think the z axis is taken into account. Monsters do however have quite wide fields of view, both sideways and up/down. A monster below a high ledge will not see you until you are quite close to the edge. It's taken into account, but there's no way to control where you're vertically looking. Suppose that even if this were possible, the linedef were above or below your line of sight. Vanilla Doom had literally no way to allow you to see that, so it'd be down to if it were "in vision" at the fixed vertical angle you have. It took until Heretic for Y-shearing to give this sort of effect, and even that was limited due to the limitations of Y-shearing itself. Edited March 8, 2024 by Dark Pulse 0 Quote Share this post Link to post
Question
Skemech
So it's possible to have something be activated via the player pressing "E", the player hitting something, or even the player walking over a linedef...
but can you have something get activated via the player looking at something?
Share this post
Link to post
7 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.