It's been a long time since I last posted something in this thread! but here's my question: How can I program an NPC that can be used like the enemys in Earthbound. like if you touch them a battle starts. But the main thing is, that I want just one NPC for one battle formation, so I don't have to make thousands of NPCs just to fill a map with the same Enemy. I hope you get the problem. Also, is it possible to recreate that thing that if an enemy approaches you from behind it attacks first? (and the same thing reaversed too?)
This can all be done, but requires scripting, that varies from the easy to the advanced, depending on what you want to do.
Here is a script that triggers a battle with an enemy when you touch an NPC with "touch" activation. The battle formation number needs to be put in the NPC's "script argument"
This script assumes that you want the NPCs to vanish after victory, but to re-appear if you leave the map and then come back later.
As for letting the enemies attack first when it approaches from behind, that gets a lot more complicated. Detecting which direction the enemy approached you from isn't so hard, all you need to do is use the "hero direction" command, and check the hero and NPC x/y values accordingy, but the hard part is changing the battle so the enemy attacks first. You might need two versions of every enemy, or you might have to use commands to alter the enemy stats before the battle begins.
Here is a script that triggers a battle with an enemy when you touch an NPC with "touch" activation. The battle formation number needs to be put in the NPC's "script argument"
Code:
plotscript, wandering enemy npc action, formation, ref, begin
if(fight formation(formation)) then(
# Battle ended in victory
destroy npc(ref)
)else(
# Player ran away from battle
)
end
plotscript, wandering enemy npc action, formation, ref, begin
if(fight formation(formation)) then(
# Battle ended in victory
destroy npc(ref)
)else(
# Player ran away from battle
)
end
This script assumes that you want the NPCs to vanish after victory, but to re-appear if you leave the map and then come back later.
As for letting the enemies attack first when it approaches from behind, that gets a lot more complicated. Detecting which direction the enemy approached you from isn't so hard, all you need to do is use the "hero direction" command, and check the hero and NPC x/y values accordingy, but the hard part is changing the battle so the enemy attacks first. You might need two versions of every enemy, or you might have to use commands to alter the enemy stats before the battle begins.
Another possibility:
Use a tag to decide if the enemy is supposed to attack first or not. Then have every formation include a special invisible enemy with huge speed, with an attack that chains to mimic a 'first round' of attacks from the enemies in that formation, then kills itself. But the chain only occurs if the tag is on. Otherwise, the invisible enemy can just kill itself right away.
Or maybe the invisible enemy can just hit all the other enemies with a spread attack using a special element designed to force a counter attack simulating their 'first round' of attacks?
I am Srime
Use a tag to decide if the enemy is supposed to attack first or not. Then have every formation include a special invisible enemy with huge speed, with an attack that chains to mimic a 'first round' of attacks from the enemies in that formation, then kills itself. But the chain only occurs if the tag is on. Otherwise, the invisible enemy can just kill itself right away.
Or maybe the invisible enemy can just hit all the other enemies with a spread attack using a special element designed to force a counter attack simulating their 'first round' of attacks?
I am Srime
Froginator wrote:
Ok! Thanks. And what about a little animation before the battle begins? Like in Pokemon or something. Also, Can I change the graphics of the Health bars inside the battles?
It has been so long since I played Pokemon, I don't remember how the battles start. Maybe?
Your options for customizing the battles are pretty limited. You can change the color of the health bar, but that is about it.
I have a plan for making battle layout more customizable, but it will probably be a long time before it is ready.



