Scripts / Kill X Enemies to change song ?

Author
Message
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 19th Oct 2019 19:01
Hi guys,
I've been trying to get this script to work for my game , but I am having no success.

My scenario is when you start the game you have your basic song in the background playing as your creeping around your map. Then you hit the trigger to change the song to an action song as you get ambushed by multiple bad guys. When you killed all the bad guys the script changes back to the original basic song.

Its kinda like smallg's kill x enemies to open door, but with a trigger and different songs.

Here's the script that I found on the Steam forum.
It works, but with only one dead enemy entity id will change the song, and the script kicks on even when you are not near it.

Does anyone know of a script that will fit my needs ?
Thanks

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 19th Oct 2019 20:06
So the tricky bit here is how to tell the script which enemies need to be in 'dead' state before the music changes.

The answer to this depends entirely on whether your enemies are using the default ai scripts or custom scripts.
Been there, done that, got all the T-Shirts!
PM
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 19th Oct 2019 20:53
Default ai scripts
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 19th Oct 2019 21:21
Ok so there is a global Lua list called ai_bot_state which contains the current state for AI characters on your map.

You can check this list to see if any AI still survive and if not trigger your music change:



Been there, done that, got all the T-Shirts!
PM
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 19th Oct 2019 21:29
I'll give it a try.
Thanks, AmenMoses
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 20th Oct 2019 15:23
But that would check all the ai on the map no? If you want it limited to a particular group it's still going to need some extra check - depending how the map is set up a simple distance check might be ok
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 20th Oct 2019 16:01
I was wondering that too.

I'm a pretty bad scripter to say the least, and didn't have any luck last night fooling around with AmenMoses addon.

The concept is like your kill x enemies to open door script smallg. When I start the game I have a song playing and when I go to different parts of the map with bad guys, right before I see the bad guys I trigger this new script, a new song plays to all the bad guys in that area are dead then it goes back to the original song and repeat with maybe a new action song in the next area with bad guys.

Maybe The bad guys and the trigger zone are the same name ?

Here's the scripts I usually use to start and stop songs.

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 20th Oct 2019 17:10
This is what I had in mind.

Attach to an always active entity and in theory when it detects no live AI within a given distance (currently 3000 units but you can edit that to suit) it will switch the music.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 20th Oct 2019 17:18
Here is another with an included trigger to start the first sound playing, in this case when the player is within 2000 units of the entity the first sound will play then when no healthy enemies are detected within 3000 units of the entity it will switch to sound 2.

At least in theory, I haven't actually tested either script.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 20th Oct 2019 23:15
Wow !
Thank you for all your help. I'll give it a try tonight.
PM
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 20th Oct 2019 23:38
Unfortunately I'm getting this error code.

Is the best way to use the trigger by putting the start marker on it when you start the game ?

Or should I put a trigger zone in around where the bad guys are and activate the trigger when I'm in that area.

Thanks

Attachments

Login to view attachments
PM
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 21st Oct 2019 00:54
Here was the script I was using.

Attachments

Login to view attachments
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 21st Oct 2019 12:41
Try
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 21st Oct 2019 14:49
Yep it works.

Thank you AmenMoses, and smallg for all you guys do for everybody on the forum.
PM

Login to post a reply

Server time is: 2024-12-22 09:33:19
Your offset time is: 2024-12-22 09:33:19