Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Help appreciated: Enemy detected > alarm system activates

Discussion in 'General' started by SirConnery, Sep 29, 2019.

  1. SirConnery Apprentice Engineer

    Messages:
    168
    I wish to make an alarm system where the hangar doors close when enemy activity is detected close (say, 1,5km) and open when there is none.

    I tried using sensors (modded for longer range) to detect enemy grids. It works fine for closing the doors, but after the fight even small enemy ship wrecks in the radius of the sensors will keep it triggered and the "open hangar doors" state of the sensors is not triggered while the rubbish is lying around.

    IN SHORT:
    So, in short is there a way for the sensors to only trigger on sensing powered enemy grids (for example using scripting) or is there some better way to detect enemies up to 1,5km away.
     
  2. captainbladej52 Apprentice Engineer

    Messages:
    374
    I'm sure one of the others might be able to provide a more technical solution if you're looking for it but there's a simpler solution in the mean time. The simplest solution would be to fly out after said battle and disable any remaining power sources on what's left of your foes. If there is no power left on the remaining bits of the enemy grid then the sensor should just treat it as debris, thus shutting off the combat state. You could also try setting up a manual override so you can reset the doors and such manually if it screws up.
     
  3. Spaceman Spiff Senior Engineer

    Messages:
    1,410
    Or use a timer block that resets everything after a certain amount of time...
     
  4. SirConnery Apprentice Engineer

    Messages:
    168
    Are you sure that's how it works? I think the sensor just detects grids powered or not.

    That doesn't work unfortunately since the PvE enemies can sometimes circle around for half an hour or more. I am currently manually using a button to "clear state" when I think it's safe. It's allright but I would really like an automatic system.
     
    Last edited: Sep 29, 2019
  5. Spaceman Spiff Senior Engineer

    Messages:
    1,410
    I believe sensors now detect any “enemy” block, powered or not. So unless you clean up everything within the sensor’s range, you’re probably stuck with a manual reset. But, of course, I probably don’t know what I’m talking about.
     
  6. SirConnery Apprentice Engineer

    Messages:
    168
    Is there some way to do this automation with scripting? Don't turrets spot enemies like 1km away? Is it possible to somehow trigger a "Turret spotted enemy" to trigger a timer block with a script? Then trigger another timer when they don't spot anything.
     
  7. Spaceman Spiff Senior Engineer

    Messages:
    1,410
    All good questions. It’s probably simply a matter of tapping into the internal code that KSH uses for that purpose. How about having a squadron of automated cleanup grinder drones that clear the area of components and blocks for you? Just a stray thought...
     
  8. SirConnery Apprentice Engineer

    Messages:
    168
    Here's to hope. He's not the hero that we deserve, but the one that we need right now.

    [​IMG]
     
    • Funny Funny x 2
    • Like Like x 1
    • Agree Agree x 1
  9. captainbladej52 Apprentice Engineer

    Messages:
    374
    I just tested this on a testing map of mine. I threw together a basic grid with a sensor that was a basic platform, a sensor, a sound block, and a power source. I then spawned in a small grid ship of mine and turned control over to the pirates. As it should the sensor set off the sound block alarm. I then removed the current pirate ship and spawned in a fresh copy. On the second copy i deactivated all power before turning it over to the pirates and it did NOT set the sound block off. So for the moment it appears the answer is that it doesn't set off the sensor if the power is off just like the turrets won't fire on an unpowered grid.

    The way it was explained to me is part of how turrets and sensors do their thing is by detecting the power status of an enemy grid/ship, and the computers/electronics of the block. If the power is off then there is no power to detect or electronic signature for the sensor to pick up since there's no power. At that point it's basically just a chunk of metal. Think of it like a radiation sniffer trying to sniff our Radon gas from an active nuclear generator. If the generator is active the sniffer can pick up the Radon gas. If the generator isn't in operation, the sniffer won't pick it up because the gas it needs to do its thing isn't present. Not a perfect analogy I know but hope it helps. I don't use sensors that often so I won't swear 100% that there isn't a setting that could enable to detect even unpowered grids.
     
  10. KissSh0t Master Engineer

    Messages:
    3,494
    It's stuff like this that makes me wish the game had a Rader block that you could firstly use to search for things longer range, having a little in-cockpit hud that displays little dot's and a range to those dots, within the cockpit.. not having text appear in the game world saying [I AM EXACTLY RIGHT HERE DUMMY].

    And then as a radar that we could put on a rotor and have it spin to having it scanning for things, like a base of some sort and then being able to trigger things on detection of things, in this case it would be to close a hangar door and play a sound on a sound block.

    *edit*

    How cool would it be if we could have a robot npc "humanoid" walking characters and have them as a kind of sentry helper character, maybe they could follow the player around, carry things for the player or guard the base when the player is away, give them a player held weapon and then they can shoot it at any enemy, I would imagine this would be useful in multuiplayer.

    Although I can also imagine the need to limit how many a single player would be able to have because I can see people making hundreds lol.
     
    Last edited: Sep 30, 2019
    • Like Like x 1
  11. SirConnery Apprentice Engineer

    Messages:
    168
    It's nice to see someone tested it out. I actually did find out there was a powered grid in that 1km area that was still triggering my sensors. The powered ship wrecks are an annoyance.

    Is it possible to have Antenna detection trigger a timer block? Have your own Antenna set for 1km area to detect enemy beacons/antennas in range of it. By the time the Antenna is destroyed on an enemy ship is enough for me to say they are no longer a threat. I'm not sure if this is possible using scripts, but I would think so.
     
  12. Ronin1973 Master Engineer

    Messages:
    4,740
    Have the sensor trigger a timer block when the enemy is detected. From there, you can use the benefits of the timer... the timer and the 81 slots available.

    The first timer should be programmed to close whatever doors you want, turn on all your defenses (in case one or more were accidentally left off), and sound any alarms you wish. It should also TURN OFF THE SENSOR.

    The timer should also trigger a second timer block set to a few minutes that turns the sensor back on and resets anything else you want. If you get attacked, I would cue the doors to reopen because you might not be around and who knows what's still lurking.

    IF, you want to dabble in the programmable block, you can poll turrets to see if they are firing or have a target. If those conditions are true, the programmable block can change the status of almost any block or you could simply trigger a timer block or timer blocks if you want to avoid additional coding. Cameras are also able to ray-trace in front of themselves out to a ridiculous distance if they are programmed correctly with a programmable block (conditions apply).
     
  13. SirConnery Apprentice Engineer

    Messages:
    168
    That would work perfect for me. Turrets having a target and triggering a timer and then when no turrets have a target trigger a different timer. I'm not really good at the programmig stuff. I tried making a template with the visual script builder and then changing stuff.

    This is the logic part of the code, I don't think it works. Assistance is appreciated. Probably just better to scrap that one and write a simple code from start.

     
  14. Ronin1973 Master Engineer

    Messages:
    4,740
    Well... it's hard to see why it isn't working without the full code. I'm not a proficient programmer. But you may want to evaluate the "ApplyAction" it might be an outdated way to apply an action if memory serves. How frequently does the script run?
     
  15. SirConnery Apprentice Engineer

    Messages:
    168
    Here's the full code

    Basically I just made the script builder logic to poll if Gatling is on/off, then just changed that on/off line to HasTarget. Might be the logic isn't the same for both of them and that's why it's not working but they are both booleans so I thought it might work.
     
  16. Ronin1973 Master Engineer

    Messages:
    4,740

    I think you copied your code from here. The code is from the beginning of 2018. So some things may be deprecated.
    https://steamcommunity.com/app/244850/discussions/0/1700542332318320851/?l=portuguese

    You might want to start a new post in the In-Game Programming forum and possibly get some help from @Malware or someone of his level of knowledge. I would add some additional Echo statements throughout the code so you can confirm what's exactly happening in each section; especially around your IFs. I'm not at home so I can't load this into a programmable block at the moment.
     
  17. SirConnery Apprentice Engineer

    Messages:
    168
    I made the script with with the Visual Script Builder http://dco.pe/vsb/

    I thought it was up to date since it worked with some of my other more simple scripts.
     
  18. Malware Master Engineer

    Messages:
    9,549
    Ugh. Why is that site still alive.
    Please don't use the vsb or at least beg the author to generate optimized scripts because they're about as bad as they can possibly get.

    I can probably help sure, but I must be in a position to and I'm not right now. Gotta go to work :p You might want to go to Keen's discord. Lots of helpful people in the in game programming there - myself included, usually
     
  19. KissSh0t Master Engineer

    Messages:
    3,494
    Ohhh man a visual script maker, that is kind of cool... I so wish Space Engineers had a script builder like Stormworks Build and Rescue, I actually figured out how to use that and make a fully functioning V-22 Osprey, in SE the best I can do is use timer blocks to trigger things because I do not understand computer programming.
     
  20. Malware Master Engineer

    Messages:
    9,549
    @KissSh0t It would be cool if it didn't violate pretty much each and every performance recommendation given to write scripts that don't adversely affect servers...
     
  21. Roxette Senior Engineer

    Messages:
    1,379
    [​IMG]