Code Monkey home page Code Monkey logo

func_payload's Introduction

Func_Payload

Version 1.0

Installing

  • Clone the repo into your svencoop_addon/scripts/maps/{your_map}/ directory.

  • Include func_payload.

  • Call the FuncPayload::Register method on MapInit.

    Example:

    #include "func_payload/func_payload"
    
    void MapInit() {
      FuncPayload::Register();
    }
    
  • Add the func_payload.fgd to the list of game configurations in Hammer or your preferred editor.

  • Create a brush entity (with an origin brush) of type func_payload.

  • Add some path_track entities, as if the func_payload was a func_tracktrain.

  • Keep in mind that the payload will determine what is friendly or not by checking classifications. If you want a "friendly" payload, I'd suggest using the human passive option.

  • Have fun!

Property Descriptions (Customization)

  • Detection Radius
    • The radius of the circle around the payload's origin which is used to detect entities.
  • Friendly glow color
    • When entities friendly to the payload are in range, they will glow this color.
  • Enemy glow color
    • Same as the friendly glow color, except for enemies.
  • Speed multiplier per friendly
    • Each friendly entity in range beyond the first will increase the payload's speed by this much, converted to a percentage (e.g. 0.2 is 20%).
  • Max number of multiplies
    • Limit for how many times to increase the payload's speed by the multiplier, beyond the first. If set to 0, the payload won't increase speed.
  • Max speed
    • Limit the speed of the payload to this amount. The speed multiplier properties above will only raise the speed up to this maximum if they reach it.
  • Amount to heal or hurt friendlies in range
    • Positive values will heal the friendly entities, negative will hurt them. This value will apply each second the entity is in range.
  • Amount to heal or hurt enemies in range
    • Functionally the same as the friendly version, but applied to enemies in range.
  • Spawnflags
    • Disable friendly glow
      • The payload won't apply the glow affect to friendly units in range.
    • Disable enemy glow
      • the payload won't apply the glow affect to enemy units in range.

trigger_payload_mode

This is a point entity which allows you to change the movement state of the payload. Movement states change how the payload decides to move.

  • Normal
    • This mode will advance forward only when assisted by friendly units and when no enemy units are in range.
  • Force move
    • This mode will advance forward, not stopping regardless of what entities are within range. It will still heal / hurt and apply glowing effects.
  • Force stop
    • The payload will remain stationary, and will not start moving until its movement state has been changed to Normal or Force Move. It will still heal / hurt and apply glowing effects.

Technical Details

This entity was written with pretty heavy use of AngelScript's mixin classes. In order to keep things sane, the mixin classes all have a single, isolated purpose; for example, the Sound Manager mixin class is only responsible for anything sound-related. Code outside of the Sound Manager can interact with it through the methods it "exposes" (the ones not marked with private).

The mixin classes are tied together by the main CFuncPayload class, which calls out to the other mixins when appropriate.

I tried to break things out as cleanly as I could, so that others (and myself!) could reference this work if they want to make a similar entity. Perhaps a mixin class could even be brought into another entity and used without much configuration.

Thanks

Thanks to GeckonCZ, Nero, H2Whoa, and others for helping answer a bunch of questions. This code draws a lot of inspiration from GeckonCZ's vehicles code in th_hunger, as well as Valve's func_tracktrain code.

Usage

I put this code under an MIT license, but if you do happen to use the code for something else, I'd like to hear about it!

func_payload's People

Contributors

turnqujo avatar

Watchers

James Cloos avatar  avatar

func_payload's Issues

Payload can't be disabled

The payload needs to be updated so that it listens to the "disable train" keyvalue on path_tracks

Payload rotates wildly when on a vertical path

If the payload is traveling along a vertical path, right before it reaches the lowest path_node, it will rotate 180 degrees and then back again.

I'm 99% sure this is because the payload overshot the top-most path, and flips around to move towards the destination path. Moving the bottom node forward by a few units "fixes" the issue, but this isn't a clean solution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.