String Question

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

String Question

Post by sheamkennedy »

For a game I'm making a custom battle system. I have NPCs which represent enemy encounters. When I touch an NPC I want a menu to be triggered which says "Enemy# Attacks" (where "Enemy#" is a string dependent on whichever NPC has touched the hero).

How can I feed in a string which is the name of whatever NPC is attacking me? As far as I understand I have to define all my enemies in my script as strings. Is there any way I can use just a single menu to do this? I obviously don't want to make menus for every single enemy. I'd rather have one menu and that runs some sort of script to check what NPC has engaged you, what that enemy's name is and what stats it has so that they can be used in a probability equation.

Even better, if someone could tell me of a way to define all my enemies using the CUSTOM engine's "Enemies" section then feed that enemies name as a string in to the menu and get it's stats to be used in the battle script.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Post by Gizmog »

Get Enemy Name can help you with a lot of that and Get Enemy Stat can help with the rest. You can use FormationSlotEnemy to streamline that even farther. All your NPC would have to do is pass on what formation to fight and the script can get what enemy it is, all the stats, and the name just like that. With some for loops it could even work for multiple enemy formations.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

NPCs have extra data, as well, if you wanted to store enemy IDs in there.
My pronouns are they/them
Ps. I love my wife
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

But you can't set the NPC extra data in the editor, which probably means it's not useful to you. However, you can set an argument to pass to a script triggered from an NPC. This is the easiest way to go: just pass the enemy ID to the script, which then reads the data from the enemy. The "Script argument" is passed as the first argument.
Also, if you aren't using the builtin formations there's not much point using them either.

I'm confused that you keep talking about menus. Why a menu rather than a textbox or text slice? I guess there will be options like running away from the enemy.
Post Reply