Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wolfenstein 3D Port (In Progress)
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#7
RE: Wolfenstein 3D Port (In Progress)

Here's a fun update. The enemy attacking mechanic is now fully implemented.

Here's how it works. First, the enemy is in its default state (either standing or patrolling). When the enemy sees the player (currently just a raycast from the enemy to the camera, ignoring FOV or distance for now), it starts a timer. After two seconds have passed, if the player hasn't taken cover, the enemy will enter the Chase state. In this state, the pathing system will switch to move to the player instead. Every time the enemy enters a new node, it has a chance to stop and fire. The chance increases the closer the enemy is to the player. (If the enemy is in the next tile over, the chance is 100%.)

The firing algorithm is fairly straightforward, and I've tried my best to implement it as it is described in Wolfenstein 3D itself. The gist of it is that it rolls two dice - one to see if the enemy "hit", and another to determine how much damage was dealt. The hit chance and damage are both dependent on the distance between the enemy and the player as well as a few other factors.

The result is that the enemy now follows the player around after being aggroed and will also shoot at the player, dealing damage. The random nature of the shooting algorithm does tend to make the enemies' efficiency somewhat inconsistent, however. Sometimes they are basically stormtroopers, while other times I get two-shot from the opposite end of a long room.



Another interesting challenge I had to tackle for this is that I had to modify the pathing algorithm to make the enemies ignore tiles that had another enemy already within it. Without doing that, all the enemies will eventually converge on the same square and will afterwards never leave it, making them look like some vengeful Hindu goddess with a German accent. While amusing, it's not exactly what I'm going for.

With the changes implemented, the path generation itself is unchanged. Instead, when an enemy queries the generated path for the next tile and finds an enemy already within that tile, it will "wander" by choosing a random unoccupied tile among its immediate neighbours. The result actually makes the enemies look far more organic by having them duck and move around as if avoiding my fire.



One part of this update that I have to complain about, though, is the difficulty that I had in figuring out the player detection. As I said, the process is a raycast, but doing a raycast in HPL3 is deceptively difficult. The most basic way of doing this is the cLux_GetClosestEntity function. However, that function takes two primary parameters - a vector for a starting position, and an angle vector for the ray's direction. The angle vector in particular I was having a difficult time with because the math function for generating an angle vector, cMath_Vector3Angle, between two points seems to be bugged. (Almost no matter what they were, the returned vector between the player's position and any given entity's position was infinity.)

Fortunately, I was able to rectify the problem by using cLux_CheckLineOfSight, which fortunately does take two vector positions. However, the loss of the cMath_Vector3Angle function makes me nervous going forward. It's currently too soon to tell, but trying to implement the player's shooting mechanic without that function may prove to be quite difficult.

(This post was last modified: 09-12-2017, 03:26 AM by Abion47.)
09-12-2017, 03:26 AM
Find


Messages In This Thread
Wolfenstein 3D Port (In Progress) - by Abion47 - 08-29-2017, 09:45 AM
RE: Wolfenstein 3D Port (In Progress) - by Abion47 - 09-12-2017, 03:26 AM



Users browsing this thread: 1 Guest(s)