Scripts / Simple Tower Defence System (Possibly also works as Accompany Quest)

Author
Message
bumblepuppy
2
Years of Service
User Offline
Joined: 13th Apr 2022
Location: Another Dimension
Posted: 8th Oct 2023 21:17 Edited at: 8th Oct 2023 21:20
Using smallg's ai_attack script for the enemy AI entities from the bottom of this thread: https://forum.game-guru.com/thread/214597

It's possible to set the enemy AI entity to attack a building which can act as the 'tower' in a tower defence type game using this script on the tower itself to show its health:



Seems to work fine with multiple AI, so getting them to spawn intermittently should create a system that works like a tower defence game. Might work ok in Max too, not sure though as I haven't ventured into that quite yet. Not sure if it works with multiple 'towers' - probably needs separate scripts for each one, if not the health variable will get messed up. Someone might be able to make it display an HP bar as well, but I don't have the skills or time for that at present. Was going to try adding a couple of lines of code that make the building explode when the health gets to 0, because explosions, but that's on my 'to do' list.

This script could also possibly work as an Accompany Quest system if the code is added into a particular AI script for a neutral or friendly NPC that other enemy AI are set to attack, but I haven't tested that yet. Think it might be cool in a couple of projects I'm working on, so once I try it on that side I'll report back. Hope this is useful to some folks out there!
bumblepuppy
2
Years of Service
User Offline
Joined: 13th Apr 2022
Location: Another Dimension
Posted: 5th Feb 2024 17:26
I'm adding a new comment to this as I'd like to follow up on this for the Accompany Quest code. I've tried to write something myself, but I'm not a coder, and I can't figure out how to get the script to display the "failed" message and then kill the player.

This is what I've tried:



But it doesn't work. Can anyone see where it's going wrong and offer any solutions? I'm just stumped as to making things work in sequence with the right parsing. Would be nice to get this working, I think, as there's a lot of potential in this, but I just don't have the coding skills myself.

Login to post a reply

Server time is: 2024-12-21 16:08:26
Your offset time is: 2024-12-21 16:08:26