Vlatitude: Scripting Tutorial Part 1 - Overview Last edited 1 year ago2022-09-29 07:56:29 UTC

Shortcuts to other parts of this tutorial:
Actually, this tutorial goes beyond just enemies. As you will soon see, the scripting system can be interconnected with any entity you wish. The Half-Life scripts I'm going to explain define what NPCs (non player characters) do, and how they do it.

The entities we will be working with are I have attempted to draw a diagram of trigger and reaction hierarchy:
User posted image
OK, that's probably confusing as hell, so let me explain it from left to right. First, you have a trigger. This trigger can come from many places. It can be a trigger_once or trigger_multiple entity which a player walks over, or uses something to activate. It can also come from a trigger condition of a monster. For example, the trigger condition of a zombie can be 50% health. When the zombie's health reaches 50% or below, the specified target is triggered. Therefore, the monster in our flowchart can also be the trigger. When a func_breakable brush is broken, that can also be a trigger. Other entities can also be triggers. Generally, almost any entity with a "target" attribute can be a trigger for that target.

When the condition of a trigger is met, the trigger activates its target: the aiscripted_sequence entity. It's important to understand what an aiscripted_sequence (which I'll now refer to as AI_S) is. AI_S is the shape and size of its assigned NPC because in a way, it IS the NPC. Think of AI_S as a point in space at which your NPC will do what it's assigned. A circle of AI_S entities can be a path for a pondering NPC who paces in circles. an AI_S entity facing a wall can be a point at which your NPC will stop and examine this wall, and then move on. So let's go back to the flowchart. When a trigger condition is met, the AI_S is triggered. The NPC walks (or runs, or faces, you define!) to the AI_S, faces the direction the AI_S is pointing, and performs the action defined by the AI_S. The completion of this action can now trigger another target (AI_S for example) if you so desire. The animations that an AI_S can force a monster to do can be found in your Worldcraft Entity Guide help file under Scripted Sequences. The AI_S has two target fields. One is for the monster that it will affect, and the other is for an object that will be affected (most commonly a button or a func_door or a func_breakable).

Now, we get to our NPC. The NPC does the least work of these three entities. It's pretty much our bitch, or skank if you will: we tell it what to do, but it has no say in it. The only thing important to our little hoe is to have a name. If your NPC is your trigger, it also needs a trigger condition and a target.
This article was originally published on 69th Vlatitude.
The original URL of the article was http://www.vlatitude.com/tutorials.php?tutID=9.
The archived page is available here.
TWHL only publishes archived articles from defunct websites, or with permission. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.

Comments

You must log in to post a comment. You can login or register a new account.