Space Engineers

Space Engineers

Not enough ratings
Auto-loading NPC Behaviour
   
Award
Favorite
Favorited
Unfavorite
Type: Mod
Mod category: NPC
File Size
Posted
Updated
49.126 KB
28 Mar, 2020 @ 6:22am
3 May, 2020 @ 8:08pm
21 Change Notes ( view )

Subscribe to download
Auto-loading NPC Behaviour

Description
Just a couple of scripts to make SPRTs a little more challenging, and add a tiny bit of flair.

Firstly, NPC ships will have a particle effect when they spawn, to give the impression they've jumped in. You can make this "flash" jump in, or "warp" jump out, happen on command on any NPC with a PB with the following commands:
var didItWork = Me.GetValue<bool>("JumpIn");
var didItWork = Me.GetValue<bool>("JumpOut");
The didItWork variable is just there because adding commands requires a <T>ype, it only returns false if the block isn't owned by an NPC. Thanks very much to Meridius X/Lucas for this functionality in the NPC Programming Extender as I've really just updated that code a little.

I also added the ability for NPC grids to teleport using their PB. Have the PB write the desired coordinate into the CustomData field then call the function. Doesn't work for non-SPRTs sorry :) Here's an example script:
Vector3D destination = new Vector3D(1000, 2000. 3000);
Me.CustomData = destination.ToString();
var didItWork = Me.GetValue<bool>("JumpTo");

The main thing you'll notice with this mod, though, is the way NPC ships behave. On spawn the mod will look at any grid with one or more programmable blocks which don't have some custom script already loaded, and if it sees a camera and remote control it'll load a script into the first PB it finds on the grid, and compile it. The script makes the ships seem a little more intelligent; they'll head away from you and weave when you start nearing weapons range, and then engage you if you get closer again. There a a few behaviours based on what size the ship is and how its weapons, if any, are deployed.

Oh and SPRT grids get a custom name and a bit of a random paint touch-up, just for fun.

I'll leave the details up to discovery by trial and error :) Have fun!
3 Comments
Annastasya 19 Mar, 2021 @ 5:51pm 
@jonn19

Okies, thank you for the quick reply. =-)
jonn19  [author] 19 Mar, 2021 @ 4:47pm 
Sadly no Anna, it's designed for ships that don't get any other "behaviour" code added to PBs, so it can coexist with MES. It's easy enough to mod in a flash when ships jump in (i.e. spawn) but timing the jump out effect 5s or so before a despawn is tricky :)
Annastasya 19 Mar, 2021 @ 11:38am 
@jonn19

Does this work with Modular Encounters Spawner so that all the MES NPCs will use the jump effect?