Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing tanktrain_ai to be Functional #2579

Closed
epicplayer40 opened this issue Jan 6, 2025 · 3 comments
Closed

Fixing tanktrain_ai to be Functional #2579

epicplayer40 opened this issue Jan 6, 2025 · 3 comments

Comments

@epicplayer40
Copy link

Details

By default, tanktrain_ai is a broken entity that does not function in the way it's supposed to. It's intended to make a func_tanktrain follow a series of path_tracks to reach another entity (such as a player), being able to drive forwards, reverse, or stop to reach it's destination (or as close as it can get).

Recently I took it upon myself to go in and fix it to make it work again. Here's a video showcasing the fixed tanktrain_ai in action as it tries to move to the player:
https://github.com/user-attachments/assets/12c4ffc3-1a6a-4a53-a292-7acef4b8d395

And here's the fixed version of game\server\tanktrain.cpp I made to get the result seen in the video:
tanktrain.txt

@teamclown
Copy link

Something else to clarify about tanktrain_ai is that it doesn't currently have a way to assign a 'subject' or 'target' entity for it to reach, which is a key feature that most entities includes.

For example, in other entities:
Image

You can see that there’s an explicit field for assigning a target. Unfortunately, tanktrain_ai lacks this functionality:
Image

To make the entity work and follow an NPC or player, you have to rely on inputs instead:
Image

It accepts a targetentity input via Hammer, even though this functionality isn’t officially included in the FGD. While this workaround technically works, it’s not very intuitive or convenient—especially if this entity ever gets properly fixed in the future.

@robotboy655
Copy link
Contributor

robotboy655 commented Jan 7, 2025

I have made several fixes;

  • Fixed sound playback and updated default sounds to existing files
  • Added "Chase Target" key value
  • Added missing input to the FGD
  • Fixed movement (This one is based on the OPs proposed changes)
  • !player target will update to the closest player before every move
  • Changed update rate while moving to 0.1s (from 0.5) so it doesnt overshoot its target as much

@teamclown
Copy link

Thank you for your work; the entity is functioning correctly. It would be nice to also include an option in the flags to force the func_tracktrain to rotate automatically when It's on backwards or on forwards
For example:
Image

(As you can see in this GIF, even if the Tracktrain is moving backwards, the entity doesn’t rotate to align its angle with the direction of movement.)
Image

It would also be very helpful to add Inputs like StopThinking (disables the AI) and ResumeThinking (enables the AI). This would allow disabling or reactivating the AI of the tanktrain_ai entity using buttons or logic entities.
Image

Finally, for the Outputs, it would nice to add Outputs such as OnForward and OnBackward. If the entity detects that the func_tracktrain is moving forward or backward, it could trigger Inputs to activate or toggle other entities accordingly.
Image

Even though I am incredibly grateful that you’ve fixed this entity, I’ve been waiting a long time for it to finally work properly—and I’m sure many other mappers feel the same way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants