Profile image

AI Spawn Script Mod?

27.4k HuskyDynamics01  10 months ago

How easy would it be for someone with no experience modding SimplePlanes (read: me) to make a fairly simple script mod to automatically spawn in a selected plane every 30 seconds or so? I kind of want to be able to run some fly-till-you-die dogfights but pausing every few minutes to spawn a new batch of AI is kind of lame.

Just out of curiosity, 1. Is this even something that would be possible, and 2. What would be the best way to go about doing it?

Edit: 3. How much more difficult would it be to do this as a scenario instead of just a script (presumably) run through the console? That would be a lot more streamlined and user-friendly.

  • Log in to leave a comment
  • Profile image
    29.6k 32

    @windshifter1 yep you can check my profile for it.

    5 months ago
  • Profile image
    16.8k windshifter1

    @32 That would be helpful! Is it out yet?

    5 months ago
  • Profile image
    29.6k 32

    @HuskyDynamics01 @TheFlightGuySP I’ll get to work on it.

    10 months ago
  • Profile image

    @32 Doesn't sound like a bad idea. I'd say go for it!

    10 months ago
  • Profile image

    @32 Absolutely, yeah! That'd be very helpful.

    10 months ago
  • Profile image
    29.6k 32

    @HuskyDynamics01 @TheFlightGuySP would a modding tutorial from me be a video people would be interested in?

    It wouldn't be anything too crazy, it would just go over the basics of making a map, map plugin, or part.

    +1 10 months ago
  • Profile image
    6,961 Kwoshent

    @HuskyDynamics01 yeah, basically if it hasn't reached 0 yet, the function subtracts the time by delta (how much time has passed)

    10 months ago
  • Profile image
    15.9k SilverStar

    Anyway, you won't be able to do that with Funky trees...

    10 months ago
  • Profile image

    You can instantiate ai aircraft proxies but it will require you to have the xml files you want pre-packed into your mod
    You can also check if you can invoke AiManagerScript.SpawnSandboxAiFromXml, it has one strange argument type so i'm not counting on it

    10 months ago
  • Profile image

    @Kwoshent Thanks! If I'm reading that correctly, that would basically make a 10-second timer of sorts? (Man I really have no idea what I'm doing lol)

    10 months ago
  • Profile image

    @TheFlightGuySP

    yoooooooooooo I've been wanting to do this for almost two years

    10 months ago
  • Profile image
    6,961 Kwoshent

    This is very barebones and very general to unity and not just simpleplanes but this'll give a slight introduction to timers in C#

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class Timer : MonoBehaviour
    {
    ‎ ‎ ‎ ‎ public float timeRemaining = 10;
    ‎ ‎ ‎ ‎ void Update()
    ‎ ‎ ‎ ‎ ‎{
    ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ if (timeRemaining > 0)
    ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ {
    ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ timeRemaining -= Time.deltaTime;
    ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ }
    ‎ ‎ ‎ ‎ }
    }

    (Definitely didn't copypaste from Google)

    This probably won't help and I'm sorry

    +1 10 months ago
  • Profile image

    @HuskyDynamics01 Also, the tutorials for modding SP are extremely outdated but several of the concepts/processes used are still valid. I'd recommend watching some of them to get an idea of how to get a mod working (it's a bit of a pain).

    10 months ago
  • Profile image

    @HuskyDynamics01 Ah ok. I'd recommend toying around with some basic scripts using lights or other basic stuff, just to get a feel for the C#+Unity+SimplePlanes trio.
    As for line breaks, it's just an empty link bracket.

    []()
    
    10 months ago
  • Profile image

    @TheFlightGuySP Thanks for the info! I took an intro to programming course in high school but haven't done much since aside from some FT (duh) and some XML-related things, so I'm vaguely familiar with the syntax (I know how code syntax works but don't recall particulars for C# off the top of my head) but that's about it. I also did an online course that was an intro to 2D game-making in Unity but haven't gone any further with that either.

    I'll probably just keep using the AI menu for now haha


    (p.s. how do you do regular paragraph breaks in comments without doing the line thing, I've never been able to figure that out)

    10 months ago
  • Profile image

    I'm not a dev nor expert modder or programmer but I'll give my best input here.

    If you don't have any experience with the Unity editor, then trying to work with custom scripting and whatnot in SP is probably going to be pretty confusing and daunting (speaking from experience).
    Scripting is done in C#. If you already have experience with C or Python/Java/Lua/etc. then it'll probably be easier for ya.
    If you're entirely new (or almost) to scripting in any language, god help you. Now might be a good time to learn some basic Python.

    1. I'm almost certain it's possible.
    2. Download the version of Unity that corresponds with your current version of SP and get Microsoft Visual Studio. Visual Studio is gonna be your scripting interface.
    3. As a beginner, probably pretty difficult. C has a more complicated syntax than Python or Java (which are very easy in comparison), so if you're not already familiar with basic programming then I would recommend learning one of those first.
    As for the console thing, I don't know if that's actually possible. It might be possible to spawn AI aircraft using commands but at that point you might as well be doing it through the menu anyways. I don't think there's a way to auto-execute them without a custom script, which leads back to Unity and C#.

    That's my bit anyways. Hope this helps in some way.

    +2 10 months ago