Difference between revisions of "HPL2/HPL2 Helper Scripts"

From Frictional Wiki
Jump to navigation Jump to search
m
m
Line 14: Line 14:
  
 
=Contents=
 
=Contents=
The documentation and help is organised by file. '''The majority of help, and full details of the new classes and functions, can be found on the following pages:'''
+
The documentation and help is organised by file. '''''The majority of help, and full details of the new classes and functions, can be found on the following pages:'''''
 
{|
 
{|
 
|-
 
|-

Revision as of 15:11, 24 December 2023

Introduction

HPL2 Helper Scripts by Aetheric Games is a package of .hps files containing script classes and functions that may be useful to HPL2 modders and custom story creators. It is compatible with ATDD version 1.5 and later.

Would you like to...

...make 500 candles blow out in a big wave? ...make haunted objects hover in the air? ...spawn dozens of random debris objects throughout an area? ...make a particle system move along a spline? ...manage a list of quest objectives? ...compare the distances between entities? ...make puzzles based on position and rotation? ...store an array in a global game variable? ...seamlessly teleport the player into an almost identical room? ...make a statue that twitches when the player has low sanity?

Well, this script package isn't going to magically do those things for you, but it gives you a lot of tools to help you do them yourself.

The scripts are divided into two categories: utilities and features. The utilities scripts include tools for general scripting, like new maths functions, or linked lists and vector classes. The features scripts are more specific solutions that make use of the utilities, such as a way to spawn entities at specific locations, script a large chain of events or to make entities twitch and flicker. Some modders might prefer to just adopt the utilities scripts. It's up to you!

See below for download and set-up instructions.

Contents

The documentation and help is organised by file. The majority of help, and full details of the new classes and functions, can be found on the following pages:

Utilities

Provides more control and options for debug messages and logging.
Extends the functionality of the saved game global and local variable wrappers.
Adds support for linked list classes.
Provides an "OnLoad()" global function.
Provides extended maths functionality.
Provides extended string functionality.
Adds support for vector classes.
          

Features

Implements a class for floating or hovering entities, without physics.
Implements a class for managing global ambient sounds.
Implements a class for managing entities that appear to glitch or flicker.
Implements a class for managing large sequences of entity actions.
Implements a class for spawning entities at specific map locations.
 
 
Bits and pieces that don't fit anywhere else.

Set-up


Alert icon.png Requires version 1.5

First, download HPL2 Helper Scripts from the Steam Workshop page or ModDb page and unzip it.

If you get it on Steam Workshop, you'll find the actual folder in your Steam Workshop downloads.

Once you have zipped the folder, there are three options for how you add it into your mod. If you are unsure, just go with option A.

Option A: The full feature-set package

If you want to be able to use all the new functions and classes, go with option A.
  1. Copy the folder HPL2HelperScripts into your maps folder.
  2. Include HelperScripts_FullPackage.hps in your level's .hps script file using the #include directive.
  3. Add HelperScriptsUpdate(afStep) to your main OnUpdate() function in your level's .hps script file.
For example, in myLevel.hps:
#include "HelperScripts_FullPackage.hps"

void OnUpdate(float afStep)
{
    HelperScriptsUpdate(afStep);
}

Option B: The utilities-only package

Choose option B if you want to have access to the functions and classes in the utilities category, but don't need the stuff in the features category.
  1. Copy the folder HPL2HelperScripts into your maps folder.
  2. Include HelperScripts_UtilitiesOnly.hps in your level's .hps script file using the #include directive.
  3. Add HelperScriptsUpdate(afStep) to your main OnUpdate() function in your level's .hps script file.
For example, in myLevel.hps:
#include "HelperScripts_UtilitiesOnly.hps"

void OnUpdate(float afStep)
{
    HelperScriptsUpdate(afStep);
}

Option C: Pick-n-mix

Advanced modders might prefer to only adopt the specific script files they need. Go nuts! But also be aware of the #include dependencies in each script file, as many of them are interdependent. You might find it easiest to start with option A or B and then remove scripts later that you definitely haven't used. You're also fully allowed and encouraged to just use HPL2HelperScripts as a learning resource or even to just copy snippets here and there.

Licence and Credits

You are free to use HPL2 Helper Scripts in whatever way you see fit, no rights reserved by Aetheric Games. (As long as you're not going against any licence terms between you and Frictional Games, of course!) Aetheric Games is mostly just one person, mrbehemo, me (hello), and this has been a stupid amount of work, so if you find it helpful then it would be very cool of you to give me a credit in your mod or custom story. You can list it as "HPL2 Helper Scripts by Aetheric Games".

This script package would not have been possible without the work of the tireless and patient Luis Rodero of Frictional Games, and the ever present pillar of the community, Mudbill.

Support

HPL2 Helper Scripts is made by mrbehemo of Aetheric Games. If you need support, here's what to do:

  1. First be sure that you're familar with the official HPL2 scripting reference and the community scripting guide.
  2. And second, be sure that you've read the relevant parts of this documentation, including the FAQ.
  3. And then if you're still stuck I'll be happy to hear from you and will help if I can. Come and find me on the Frictional Discord server.

FAQ

Fervently Anticipated Questions. Nobody's asked anything yet...

  • I've added one or more scripts to my project separately, but I'm getting errors. What should I check?
    • The script files are very interdependent. Check the .hps files you've added - they will have #include directives near the top for every other script they rely on. Either make sure you've also added those into your project.
  • What's "#include"? What's "OnUpdate()"?
    • Those are new features added with the ATDD 1.5 update.
  • I want to make something weird happen, like make 100 flying naked guys do a loop-de-loop around the player. How?
  • Can I get the player's camera direction yet?
    • No, sorry. I investigated multiple ways of doing that, as have many people over the years. There's just no reliable way of doing it in HPL2 without branching the source code.
  • What's a uint and why have you used them everywhere?
    • A "U-int" is an unsigned integer, that is, an integer that can only be positive. I think it's best to use uint in scenarios where negative numbers are nonsensical. Behind the scenes it minimises the the chance of conversion issues, and also minimises warnings in the error output.
  • Why are all your function arguments passed by reference, and why is that not reflected in the docs?
    • In Angelscript there's a tiny, tiny performance saving gained from passing arguments by reference (and by using const where possible). It's not enough of a saving for modders and gameplay scripters to bother with, but since I was writing hundreds of them, it was an easy thing to do. It's not reflected in the docs because most non-advanced modders don't know what "pass by reference" means, or need to know.
  • I looked at your code and you did it all weird. Why did you do it weird?
    • It's probably because of the version of Angelscript that is integrated into HPL2. It has some surprising versatility but also some surprising limitations.
  • Why did you do any of this?
    • I know, I know - HPL2 is old now, I should have done this for The Bunker or whatever. Actually, I was just tidying up The Trapdoor (ATDD mod) for a Steam release, and I got carried away with refactoring it... and then, half a million characters of script later, this had happened. Hope it's useful. If not, it was a good exercise for me. Maybe you would like to port these scripts to HPL3 as and where needed! Go ahead, just be sure to credit and it'd be cool to let me know.