How do I start a battle automatically?
The reason this article has been marked is: Many things in this article are confusing and/or untrue. See How do I make a battle start after talking to an NPC? and How do I make a battle start when you bump into an NPC? instead.
Making start a battle automatically may have several meanings. You may speak about specific battles that the hero MUST win to go on, or you may want to speak about the way ALL the battle starts, which is called "random battle". In the first case there are 2 main ways to do thing and in the second case, you have to use custom internal battle system.
Use a speaking Npc[edit]
Launch custom.exe and edit the battle formation menu. There, create a battle formation. (Let's say it's battle formation 12) . Then go back to the main menu and edit the text box. Put some text "Prepare yourself, I'll take my revenge!" (or any text that makes us suppose a battle is going to start) and edit the conditional. For the example let's say it's text box 21. Get down and make "always do the following" fight enemy formation 12 (see above for more details)
Now go on the map on which you want the battle to happen. Pick up a free Npc and edit. Give the npc (whatever it is, a he or a her) the apperance of the enemy and make it display text box 21. You can now save changes and go back under Windows. Please note that this method is especially useful for a enemy that you'll see all along the game. If you want the enemy in question to appear again on this map, you can use the same npc. You just have to create it and alter it. (Npc alteration will change the text box and therefor the battle formation.)
Use a step on invisible Npc[edit]
Launch custom.exe and edit the battle formation menu. There, edit a battle formation and create a formation set. (Let's say it's battle formation 14). Now you can go on the map on which you want the battle to happen and edit the npcs. Pick up a free one and give him (or her) the appearance of the villain (which is indeed in the battle formation). Let's say that it's npc 4. Now go back to the main menu and save the changes. Once you are back under windows (or linux, or the O.S you currectly use), edit your hss file and include the following script in your code.
#------------------------------------ plotscript, automatic battle, begin create NPC (4, hero X(me)--2, hero Y (me)+3), east) # adapt the x, y coordonates to the one of your map walk npc to X (4, 45) #enemy gets close to the hero wait for npc(4) walk npc to Y (4, 54) wait for npc (4) # feel free to add walk hero to X and set hero direction here fight formation (14) end #end of the script #------------------------------------
Save the new hss file and compiles it. Now you can go under custom.exe. Edit the script management menu and import your new hss file. Then, go on the map on which you want the battle to happen and edit the npc. Make its activation "step on" and its usability "only once". Go down a little more and put the run script line to "run script: automatic battle" (see above for more details) Place the npc on the map where you want the hero to be attacked. Save your game and you are ready to test the whole thing. Isn't that easy-peazy? ^_^
Note that all this is especially useful when you want the heroes to fall in a trap and/ or beeing attacked by surprise.
Use Custom battle system[edit]
As I explained in the head on the article, this option is called "random battle". If you choose the battle system that comes with custom.exe, you have to be sure, that battle frequency is not too important. Note also that with this kind of battle system, it is not current to have battles on towns or village except when the towns and villages in question are under attack.
Ok let's start. Go under custom and edit battle formations. Pick up the enemy graphics and the battle background. (Be sure that the background is adapted. Don't put a forest, if the battle formation will be placed on a map with a abandoned city on it ^_^|) Then go on the sub-menu "construct formation sets". Look at the line "battle frequency". Above you can see "battle frequency : 10". This setting is where you change how frequent battles are fought.
Battle frequency is not actually measured in steps like one would think, so it is not advisable to use a high number even for areas with crowded enemies. In the newest stable of the OHRRPGCE, there is now an indicator of how many steps one can expect for certain frequencies.
So what if you want the village to stay safe most of the time and to be attacked just one time? Well, that's simple, you'll use plotscripting.
Here is a bunch of scripts that you could use to do that :
# village map autorun map plotscript, autorun map 12, begin suspend random enemies end #end of the plotscript
And when the village is attacked, you'll use a tag. Your autorun map will now look like this:
# village map autorun map plotscript, autorun map 12, begin if (check tag (tag: pirates attack)==OFF) then, begin suspend random enemies end, else, begin resume random enemies end #end of the plotscript end #end for the tag end #end of the script
And when the thieves arrive, run the following script:
# village map autorun map plotscript, village under attack, begin set tag (tag: pirates attack, on)# set on random battle show text box (15) wait for text box show text box (17) #suddenly... wait for text box fade screen out (255, 255, 153) #bright flash COMPULOSRY if you can't enter houses or if you don't reload the map other ways wait (1) fade screen in pan camera (east,10) # if you want to show the player the thieves attacking everywhere in the village pan camera (east,9) pan camera (east,8) camera follows hero end #end of the plotscript
Please note that the bright flash here may be very important because it makes loads the map. From now on, we need the thieves to stay on the map and they will stay thanks to tag which is turned off.
If you have any doubts, feel free to read again the HOW TO chapter about battles, and if you have question ask for help on the forum. Good luck!