Making a Re-Patch

'''I would like to start this page off by saying if you plan to make a short side story I do not recommend reading this page and instead would wish to re-direct you to this page for [http://monstergirlquest.wikia.com/wiki/Making_a_Side_Story making side-stories. ]'''

I tried my best making this guide as user-friendly as possible for those who have no knowledge at all on how to program.

Is this the best option best for you?
Before you delve deeper into this page it is best if you ask yourself these questions, with the first one being one having a different answer from the rest. If you can then you may want to try to make your mod as a side story instead unless there you feel one of the conditions below is also true. If you answered yes to any of these 3 questions you may indeed want to look at this page so continue reading.
 * Is my story something I can finish under 10 thousand lines and if not is it something I can finish in a second installment?
 * Is my story going to be a long one that would require saving and loading in between plays like the normal game or is it something you can play and finish in 1 or 2 sittings?
 * Do I plan to add stuff that might be too hard or even impossible in a side story?
 * Am I willing to look at how the game works or at least learn through trial and error?

The tools for the job
Note some of these that you download you do not exactly install so read on before you believe you have encountered a problem.

Before you can start working on your re-patch mod you will need to download the following programs : Alright now I will explain each tool with screenshots (or a video later on....)
 * The tools for onscripter (Onscripter is the language in which the game runs.)
 * Click here for the Onscripter Tools
 * The tools to unpackage the NSA files (optional but it lets you see the character, background, and voice files used by the game)
 * Here is Crass / Crage. Use this to open the NSA files.
 * Optional -- A good programmer-oriented text editor (unless you are fine with working on wordpad or notepad...)
 * Microsoft Visual Studio works fine also Notepad++ if you do not happen to have MVS (or prefer NP++)

the Onscripter tools will be a bunch of executable files that must be opened via the command line if you plan to use them. You can read the readme file for more instructions in how to handle them but I will tell you how to use the two main ones you will need (unpackaging the script [mainly for the first time] into a text-file and re-packaging the script [for actual game usage] )

I would first suggest moving all those executable and everything included to a folder and move it to your desktop (or wherever you feel comfortable.)In my case I have a folder called Onscripter and inside are all those files.

Now then, open up the command prompt. You can do this by hitting the windows key or going to Start then on the search bar type in (without quotes) "cmd" then hit enter. This will give you a black box.

You may see the windows version and what not (I cleared it out of mine before showing the screenshot with "cls")

Next you are most likely gonna need to change the directory (where the command prompt is looking). So type in "cd" and type in the entire directory of where you have your folder with all those executables. In my case I said I have it in my desktop under a folder called Onscripter so I will type that in....



When you hit enter (and you did it correctly), you will notice that the command prompt is now looking inside that place you specified. Make sure you have a copy of the script you are going to unpackage inside the same folder with those executable and type in (without quotes again) "nscdec nscript.dat" this will create a text file called "result" where the script is now readable as a text file. Open it with whatever program you want (like I said I suggest something more orientated for programming like Notepad++) and congratulation now you can see the script in all its Rated R glory. You are free to jump to the next section if you already have opened (or don't care to get) the NSA files.

Good now you can see what the script file says but now you have to be able to see all the files. Inside the arc files as well no?

Extract the Crass download somewhere (I made a folder for this copy since I changed mine a little bit). After extracting it go inside and look for and open the CrageGUI executable.

Click the check-mark on Source Path (this way it grabs all the NSA files) then go browse and look for the folder that has all the NSA files (obviously I suggest going to the folder for Chapter 2 of the game since it has the files of both Chapter 1 and 2) Click OK then Execute

Let the program run as it works on extracting  all the files which will be quite alot of resources.



Once its done with all the files unless you went to advanced and change the destination you should find folder inside called output_dir and all the goodies will be inside and you can browse them for reference when you are programming.

Programming Vocabulary
Now I understand not everyone that wishes to make a re-patch has programming knowledge so I will give a quick breakdown on some of the common terms and commands used by the game.

However for a full list of everything that is possible please look at the Reference book found here. Before you go asking around as to what does print mean cause you won't get an answer from me...

Please not all these screenshots are done while using Notepad++ so I cannot help you if you are using anything else.

Ok when you first open up the script you will see some code and will probably be lost already unless you know how to swim already (err...program. I can't swim either...)



first let me explain the simple some of the little nits and bits.

; -- whenever you see this that means everything to the right of it on that line is a comment. A comment is simply that. A comment the program (the game in this case) will not read it and is simply there for the programmer to be able to read it while he is working here. Most comments won't make sense considering they were originally written in Japanese and thus when the character encoding was switched they turned to weird jibberish. If you wish to know check the screenshot below.

Then you are free to either read it yourself if you got the knowledge of use any translator you know. Just be sure to set the character encoding back to "Encode in ANSI" before packaging it back as a script data file.

* - A * is a label. Almost like a flag or a landmark it lets the game know where to go when a certain commands tells it to be.

mov - mov is a command that loads a number or string into a variable.

string - a string is a set of characters (letters, numbers, symbols,etc.) usually an entire string is in between quotations. "This is a string. " this is not a string. "All of this no matter how long or if it has 30 numbers of different #s is a string from quotation to quotation. "

variable - If you have taken Algebra you should know what a variable is. basically a variable (can be a letter or a word) holds a number or a string depending on the type of variable it is.

goto *xxxx - does as it says. It makes the program go to a certain section of the code marked by the label (*)

gosub *xxxx - subroutine works in a similar way to goto but it is like a detour. If will go to where the label marks but it has to have a return at one point of time or another when it hits the return it will go to the last gosub that it took and continue from there ('''it must not have any subroutines left to run when it is don't working otherwise you can be prone to a crash due to a stacking amount of in-returned subroutines.

Most of this will be self explanatory so I'll move onward. You start the game through new-game and it takes you to game_start

and you see the following: *sean0000a mov %manuoff,1 bg black,1 wait 500 lsp 700,":s/24,24,1;#FFFFFFDifficulty? (Changeable On@Loss) ",172,143 csel "Normal",*sean0000b,"Hard",*sean0000b csel"",*sean0000b you goto label *sean000a

and you are moving a number variable (if you see a % then a word it is a number variable. If you see a $ then a word it is a character variable) and we are storing a 1 into that variable.

we are getting our background to black and we are doing it instantly

we then wait 500 milliseconds (half a second)

lsp is loading a sprite (a text sprite at that) I'll ignore the first section of it and jump to the #FFFFFF

those 7 characters is a hexadecimal code color for white meaning the text after it will be white) and they are placing it at the X and Y coordinates of 172, 143 from the upper left corner.

then you are given an option between choosing hard or normal and they both take you to sean000b

so we'll jump to that next *sean0000b if %sentaku=1 mov %nanido,1 if %sentaku=2 mov %nanido,2 cspl 700,701:print 10,500 wait 500 lsp 700,":s/24,24,1;#FFFFFFVore@ScenesH (Changeable in@Special Config) ",172,143 csel "Watch.",*sean0001,"Skip",*sean0001 if you went with the first option (normal) it is going to set a variable called nanido (which basically means difficulty level) to 1

otherwise it will be #2

then it will clear up the sprites and do basically the same thing it did earlier but ask a different thing and go to the next sean simple choices and serves as a simple tutorial if you ask me

Lets jump a few lines now and so we get some more examples

bg "bg\bg001.bmp",99,5000,"system\lngtwave.dll/vwi" wait 1000 >Where am I...? \ >A soft light fills the area, giving the atmosphere a solemn feel. \ >...Is this a dream? \ name "??? " >Luka...@ >Oh brave Luka...\ name "" >I hear a beautiful voice begin to call out to me. @ bgm"bgm\irias.ogg" lsp 700,":a;chara\iriasu_st01.bmp",0,0:print 10,3000 >The goddess Ilias suddenly appears before me! \

now instead of a simple background (black) we are using a string to specify the background.

The game automatically knows to search all the NSA files as you see and thus doesn't need to be told which BG folder to check (whether it be arc or arc1) and then checking all the BG folders does it check for "bg001.bmp" it then uses a special effect (special effects are marked as 99), the effect lasts for 5000 milliseconds (5 seconds) and the special effect is the lngtwave.dll/vwi inside the system folder.

wait causes a pause for 1 second

> - > basically is a line of text.

These lines of text are either cut off by a " \ " or an " @ ". So whats the difference? If you are playing the game on the side while looking at the code (or you aren't looking carefully enough) they do similar but different things.

\ cuts off the line of text and thus forces you to click (or the space-bar or however else you progress through text) before continuing the rest of the text and it also clears all the text.

@ on the other hand also cuts off the line of text and forces you to click to continue BUT it does not clear the text.

There are times you might wish to continue the text of one line to show up while you are displaying another and thus the @ is available however beware if your lines of text are longer the text box the game will crash so be sure to clear out your text often with \

name - name is actually a command that loads (or removes) a sprite that goes in the name-box for dialogue

if you have "" with no space in between you don't have a name nor a sprite which is very different from " " where you do have a sprite but obviously no name. while they may not seem very important with dialogue be aware of this when using it with skillname which works in the same form of way since leaving the a space between the quotation marks will leaves a black bar that normally displays a skill name but all it is displaying is a space.

Single word names do not require a space and thus putting for example

name "Ilias"

while it MAY not give you an error (a graphic character error not a fatal crash) out of good practice I suggest leaving a space after names and skillnames whether they are only a word long or several.

further down the line you see bgm"bgm\irias.ogg" it is going to loop endlessly (thus act as a background music) the sound file called irias.ogg that is inside the bgm folder. This sound file will not stop until you quit the game. use bgmstop or have it play a new sound file as the bgm

Adding your own resources
So you got a good grasp of the program and how to run files in the game. Now you want your own resources (images, sound effects/music, videos, etc.) to your mod. Great! for the sake of organization I suggest you create a folder call it whatever you want (so others have an idea time knowing what they installed call it something related to your mod ) and drop that folder to where all the other game folders (same place where the script is, where the executable is, where system,bgm,save,etc.etc. is)

all you need to do now is change where the directory points to

so if you are loading an image from  your folder

lsp 700 ":a;\your_game_folder\your_image.bmp"

sound?

dwave 1,"your_game_folder\your_sound_file.ogg"

bgm"your_game_folder\your_backgroundmusic.ogg"

of course you can also do this folder within folder (note I never done this but covar has and I haven't looked at his script but I'm safely assuming it should be like this...)

lsp 700 ":a;\your_main_folder\your_character_folder\your_image.bmp"

Adding your own images for fights however is trickier and I will go through my example in the Advanced section

Battles
 '''This section will start covering as soon as you hit the label that says goto *...._start with .... being the name of the enemy that starts that fight'''

Battles and the functions/labels,etc. that go behind them take about 82.5% (well that and other small stuff like the encyclopedia but yeah about 70-75% of it would be more accurate...) of the script text file if you are looking at Chapter 2's script (since it encompasses both Chapter 1 and 2's dialogue and battles)

Due to that fact I highly suggest you look all the paths it takes all the subroutines it takes before continuing where it was earlier and everything and try to grasp as much as you can. But since I do not believe the average reader is going to bother the first time I suggest you simply come here and refer to my walk-through (or actually study the code yourself ) when you run into problems.If anything go ahead and skim-read it when you encounter a problem either look at the code and the paths it takes and try to see what is causing it to not do what you were intending or look at the main section here...

Due to the fact you will jump a lot I suggest keeping a second copy of the script to jump around with or in Notepad++ right click the tab and click "Clone to other view" now you have the same file (if you edit 1 side it will affect the other) but you can see 2 sections of the file.

Battle Start


'''For the sake of covering as much material in 1 run I will use the Granberia 4 fight since it covers almost (but definitely not) everything you can do in fights. A simple fight example would be the first fight (slime girl). An example of tag team fights would be mummy girl. An example of multiple enemies would be Zombie Girls. '''

Immediately from the start you are given a bunch of variables that correspond to granberia her name will be marked as Granberia in both cases (the reason you have 2 name variables is for the name changes in the middle of a fight like an enemy disguised or against multiple enemies) her 4 poses are marked by each tatie (Granberia hardly ever dropping her guard or pose stays the same with _st41 but I will give a quick explanation of the 4 taties near the end)

Take careful note of $lavel (label) this is what you will use to move around alot and it is important that your lavel (label) name matches both the one on _start and all the important labels in the fight.

Haikei is the background. Your two monster variables are the X and Y for when loading the sprite (in correspondence to LSP not LSP2 so from the upper left not from the center)

The difficulty aka nanido (Normal = 1, Hard = 2, Hell = 3) will correspond (not always sometimes these will be flat no matter the difficulty) as to how much HP the enemy

henkahp1 (and henkahp2) is a very useful HP variable for when you want an event to happen after the enemy's HP has dropped to a certain point. You do not need to set this variable up if you do not plan on using it

damage_keigen is how much damage YOU do to the enemy (in this case you do 70% damage to granberia)

Kaihi is your chance to hit the enemy (in this case you got an 80% chance to hit granberia with your normal attack [skills have a 100% chance unless you specify but I will cover that later] )

Earth_keigen is how much damage resistance you will have from enemy attacks (in this case damage is cut in half [50%] that you receive from Granberia UNLESS this is hell difficulty in that case you take 3/4ths damage (you are only protected by a quarter (25%) )

we are going to play the 4th song on the list (you will find out which one is #4 soon)

Next we will take our first detour of the many detours (subroutines) we will take. so let's see what maxmp does.

Note anything that says gosub instead of goto means that as soon as it hits a "return" it will go back to past the last gosub it hit and continue from there so if you got 4 gosubs in a row and it hit 1 return it will go back to the 3rd gosub not all the way to the beginning.

'''Again I suggest you have a 2nd copy of the script or clone view since you will be jumping through the code alot. '''

Maxmp will check that your skill is greater than 0 (since at the start of the game your skill is 0 and you have 0 MP) if your skill is greater than 0 it will then check what LV you are (remember just like math with number-lines it does not include the number listed unless it says >= or <= ) then it tells sets up what your max MP count will be then it will return. Immediately it will then set our current MP (%mp)  to be that of whatever your maximum MP is.

Syutugen2


I like to think of Syutugen as the battle preparations, and you will learn why after finishing this section.

Then it will go into another subroutine called syutugen2 (do not worry too much on the definition of the words its basically how the battle will start in the case of the 2nd syutugen you won't get the whole "A xxxx has appeared! with the whole battle start sound effect)

Syutugen2 will turn off your save option (so you can't save in the middle of a fight) and then take a subroutine (yes while it is still in its own subroutine) called musicplay so now lets jump to that one...

musicplay then checks what music we are going to play (remember we were going to play the 4th song) so our background music for the battle against granberia 4 will be sitenno.ogg it will then return so go back to syutugen (not the battle_start)

it will then check if this is from the main game or if this is a side story (if this is from teh game itself the variable by default will equal to 0 if you are in a side story by default it will equal 1) for now we are assuming you are only doing fights with resources from the nsa files [not to mention I'm using granberia4 as the example] so all mon_labo_on variables will equal 0 for this example.  since we equal 0 our hero's name is Luka and we are player 0 then we will skip 3 lines (to count it correctly you should land on the empty space in between the 2 written lines)

we will now go into another subroutine called setwindow_02 (Beware when using Find in notepad [Ctrl+F] make sure you are looking at setwindow_02 and not setwindow_02p. )

Here it will check what player you are (player 0 is Luka, 1 is Alice, 99 is the black anon common in side stories) AND what window type you have chosen (covered in the special config[?] settings) it will then set the correct window for you and return back to syutugen so continue onward!

Now we will hide sprites 592 thru 595 then we will load into sprite #700 the sprite marked in tatie1 (what we had at the start before jumping in here) and setup its coordinates (see why we had those variables now?) afterwards it will setup the background.

After setting the background it will then setup the max HP bars for both you (gager (gage r R for Ruka / Luka) and gagee (gage e E for Enemy) and its gonna be the gage 100 (100% hp)

Then since we are player 0 we will load the sprite with Luka's face as the avatar

then it will move your LV into a variable called %mylv_sin.

Why make a copy of your Lv? For fights like the succubi that drain levels (refer to those fights as to how this variable is used exactly)

again since we are player 0 we will go into another subroutine that will grab our max HP (I'm not gonna go over this one but it works EXACTLY like the maxMP subroutine [checks your level then tells you what your max is)

after returning from that variable it will then move your maximum HP into your current HP so they both match at max.

then it will take another 2 subroutines simply called hp and sp I will only cover subroutine HP *hp itoa2 $mylifeh,%mylife itoa2 $max_mylifeh,%max_mylife mov $hp_hyouzi,$mylifeh+"^"+$max_mylifeh len %name_count,$hp_hyouzi lsp 559,":s/12,12,0;#FFFFFF"+$hp_hyouzi,264-%name_count*3,557 return itoa is a command that changes numbers into characters for strings. In other words the #2 can now be read as "2"

So it grabs what you have as your current hp (%mylife) and it makes it into a text number as well as with your max hp

then it puts both of those strings together into a string variable called hyouzi, checks the character length and then displays it over your HP bar before returning

If it wasn't for this simple subroutine you would not have an exact clue as to how much damage you were taking and thus you would have to guide yourself blindly by using only the HP bar.

it then returns and goes to the subroutine for SP (does something similar but figures out how many SP sprites [the yellow dots] it will load)

returns and then it makes sure that the enemy's current HP is that of their max HP

then we go to subroutine syokika

I highly suggest you check this first so you know where exactly you need to put this subroutine (no point in adding a variable then calling syokika and thus erasing that variable you just changed)

Syokika is a very subroutine here it cleans out anything and everything from a previous fight and sets it at zero

after returning from syokika you finally exit syutugen2 (quite a lot wasn't it?)

and return to battle start.

the next 3 variables end_n, exp minus and zmonster_x, I will leave those to you to figure them out since they do not hold too much important with my mods but you may find them more important (in my case I leave end_n at 2 but you may need it at a different number )

tukix (and tukiy) will determine the X and  Y of some skill's animations

finally after all of that you have your dialogue but right before the end of the dialogue we see a variable being loaded called sinkou (shinkou means progression in Japanese). sinkou (as well as the many hanyo variables) can be used to mark certain events in the middle of a fight.

So we set sinkou to the 1 (you can say the start of the fight is the first event but its not necessary) then we go to simply what is says. The common main shared by all fights so let us jump there next

Common Main (1st trip)


We will set battle to 1 (I can't recall purpose to be honest...but whatever its in the main so don't mess with it. Only mess with things in these important sections if you know what you are doing or affecting)

We will then increase the turn by 0 (by default its 0 so we have now jumped to the 1st turn)

all the owaza counts are like the "cool downs" to your enemy's big moves as you can see in the code you can tell right away why Hell difficulty is well...hell lol your enemy's big moves are always ready. Every.Single.Turn.

Afterwards it will look at tuika owaza (another thing I got no honest clue...)

bougyo is your guard so its being set back to 0 (meaning you are no longer guarding in case you were, your previous turn)

skill_sub will cause your skill to take a subroutine in where you miss or do no damage (depending if you made it equal to 1 or 2)

skill_num ...no idea leave it alone XD

ignoring the nodamage line... it then checks to see if your life is less than 1/5th of your maximum life (as well if you are not bound [and done its kiki. Kiki is the tease the enemy will tell luka the first time Luka's HP drops to such a point] ) if the conditions are true then it will go to the subroutine if face2 (I'm not gonna take you through it but basically it will change the sprite to whatever tatie2 is)

kousoku is basically binding so if you are bound (thus greater than 0) it will skip the next 5 lines meaning it will not cause your earth or wind durations to drop down. If you are not bound, their duration turns will tick down as usual

As you can see by how the game normally operates bound or not water can be lost while bound while earth and wind (as well as fire on the upcoming check) will not lose turn durations while bound. Whether this is intentional or a bug is something I personally do not know.... but just a curious thing to note (and you are free to change on your mod or not...)

Anyways before we continue lets imagine you do got a spirit (lets say Sylph) and your turn duration does run out this time so we will take the subroutine element_sel.

Here it will check which spirit is active (above 0) and their duration is out (under 0 [-1 really] ) it will then turn off that spirit (set their element to 0) and then move a string character saying that element is out

it will go into another subroutine called elm_print (element or emblem is up to you as to what it means but the 4 icons for your spirits) where it will check if the spirit is greater than 0 it will make sure their emblem is present if it is at 0 it will cause it to disappear, print and then return to element_sel.

it will then take a small function command called eng (english) which I MAY be wrong but I believe Rouge himself created which basically it checks the length of the string (the string $sel1) and checks that its length is proper enough to display otherwise it takes care of what it has to do to make sure it won't crash the game.

it will then print the prepared string clear it out and then send you back to where you were in the common main...

it will then check your status (not your binding) if you have none ( 0 ) it will skip all that section if you do got one it will check which one and find out how it will continue. I'll leave that for you to explore....

%kadora and %kadora_damage revolve solely on your one and only skill that requires a charge (Quadruple Giga)

making this work outside of pre-scripted scenes (like granberia 4 or tamamo2) is quite tricky so I suggest you look at these pre-scripted fights first and make changes where you feel are necessary (in my case I added their variables to the syokika label )

the last thing common_main will do will check if you are bound or not.

If you are it will jump straight to the enemy's attack $lavel_a remember for this example $lavel = granberia4 so we are jumping to *granberia4_a if we were bound (or if she had any in the first place)

since we are not bound we will instead go to their main so jump back to *granberia4_main

Your move
 Straight after getting here in what you would expect to be the enemy's action we are actually going to go to another main called command main (cmd_main) so again we shall jump~ some sprites are removed, saving is kept off if for whatever reason it was on and we clear any button values we had. We change the window type again this time by taking the subroutine *setwindow_04 (I'll spare you the trip you can do that yourself) Then it checks if we stopped (by force) any commands from being useable. Why would you want to stop commands? Well they might not be written (example - Alice doesn't have a normal attack or a struggle in any label function and thus were forced disabled when using her in the Chimera Plant in Chapter 1) Or you might want to forcefully lead a player down a certain path (My mod Chapter 2 when first learning Passionate Wrath). In Granberia4 we are not forcing any command to not be useable so if the conditions are correct we can use them simple as that. As you can see options that are available are marked by 2 hexadecimal colors #FFFFFF#FF4444 (White then red) followed by the name of the action. Why two colors? Think for a second.... ... Nothing? When you first see the option it is white, when you hover your mouse of the option it turns red. if the action is marked as #bbbbbb it is dark grey and thus unable. Of course those are just color aids what actually determines if they are clickable (and thus useable) is if they are actually buttons (and thus clickable) or not. spbtn as I'm hoping you can guess for yourself from all the clues I'm giving out...means sprite button. So it turns our text sprite into a button and it works in a simple way. I'll use the attack line for this example. The sprite number is 601 correct? Spbtn on that line is written as Spbtn 601,11 (Attack) meaning sprite #601 has a value of 11 while (Skill) Spbtn 607,17 means sprite #607 has a value of 17

now that we have all our buttons given numbers we need something to "listen" and record the button we pressed (the text sprite we clicked on) so after saying what is available and what isn't we go to *cmd2_main and wait... we continue waiting until we get a button press. When we receive a click it gets stored into %cmd1 Once it does get a button click it runs that number (which is now in %cmd1) and checks it with the "what ifs" lets imagine we clicked two buttons at once (attack and skill) since we passed all the what ifs we can return so we go back to granberia4_main and check (first attack so #11 then skill #17)

Since we don't got Undine on at the moment we end up going to *granbera4_miss so jump there (its right below it) Luka attempts to attack but it misses then we go off to her attack (granberia4_a) but lets cut it off there the enemy attacks will be a section below. Lets go to skill now both the regular path *common_skill and Granberia4_skill take you to the same subroutine so we shall do that this time instead of command main we go to skill command (cmd_skill) so lets go there!

Skill Moves


The skill list is almost the same as the command main but it checks for different things. It looks to see what your skill level is (if you are too low the skill either doesn't exist or only shows the weaker version if it is higher the old skill is over-written by the new skill not to mention the new skill has a different number value than the old.) and obviously it also checks how much MP you have to see if you can even pull off the skill.

It then goes from cmd_skill to cmd_skill3 no matter what button you pressed. There it checks what button you pressed. If you pressed either directional in either end of the bottom corners it then jumps to cmd_skill2 before coming back to cmd_skill3 after checking you have an acceptable number it returns to the label (whether it *common_skill in most cases or *granberia4_skill in this case) When it gets a number that matches it goes to that label and so on and so forth. For the sake of advancing through this fast lets imagine your choice was Undine (#33) since our hanyo3 by default is 0 (unless we changed it) we will then go to *granberia4_skill7

You can read that by yourself I don't have to explain it. In the mist of all the code you see that %hanyo3 is changed to 1. Thankfully the game is merciful (or simply the fact that Granberia attacked at the same time you used your skill [perspective I guess...] you don't go to granberia4_a this time) This time it took you back to common_main so I'll save you the walk-through and do the same path we just did up to calling undine this time however hanyo3 does equal 1 so it will instead take you to your regular skill10b at the end of this we take the regular attack path so onto granberia4_a. Lets assume we don't meet the conditions for the first 5 what ifs so we go to your normal attack pattern then. rnd2 %ransu,1,9 this line basically means that %ransu will receive a number between 1 and 9 afterwards it will take a subroutine of its attack before returning to the main. Thus completing our circle, of-course the battle must have a victor and a loser so lets first look at the path Luka takes upon losing so lets go to any of Granberia's attacks right after taking damage you will see a line in for all offensive attacks that says

if %mylife=0 return *granberia4_h1

which simply means; if Luka is out of HP its off to the H scenes ignoring (or getting distracted however you wish lol) most of the H-content you will spot 2 variables you want to note for loses the two $bad variables. ($bad1, and $bad2) at the end of the H-content there is a label that reads goto *badend this will take you to the game over scene what is said about you will depend on the two bad variables. But you can go over those yourself.

Now for victory Granberia4 is a bad example since its a scripted victory by Quadruple Giga instead of actually bringing their HP down. for any victory you are to look for $lavel with _v (in this case granberia4_v) and this leads you to the event of the victory before continuing with the story.

So instead for the victory we will go a few battles back and look at Yao's fight (lavel is hatibi) but we don't have to go to her for the example Lets imagine she is just 1 hit away from going down so lets go to a random attack say Demon Serene Sword (*skill13) since its a simple one

Since I have neglected Skill explanation I'll use this one. So I'll break it down

%before_action is a unique number for every action (attack, critical attack, guard, wait, each individual skill,etc. )

you then randomize between 3 numbers and that will be the dialogue

%aqua_end variable will be moved to 1 (it affects Serene mind lv 1 [aqua 2] ) and thus is not important if you are not dealing with a level 2 water (but you can still study the mechanism for other uses however)

it then takes away 2 MP from your current total and displays the new total it then prepares a few things for the skill name, fires off the sound effect and then checks if player is either 99 or you don't got undine on at the moment (if either is true it skips that section but lets assume you are player 0 and you got aqua lv 3) it then loads both of the water sprites (water luka and undine) into LSP2 ( this one works differently from LSP where X and Y measure from the center of the image instead of the upper left corner )and takes a subroutine called skill_cutin to do the movement animations for them [you can explore that yourself if interested I also ranted a bit in a blog about them. ] then you have some effects blah blah blah and near the bottom you have your damage modifiers so I'll jump to that....

mov %abairitu,300+%mylv*3 if %aqua>0 mov %abairitu,%abairitu*2 if %fire>1 mov %abairitu,%abairitu*3/2 gosub *enemylife skillname "" if %skill_sub>1 return goto *common_attack_end

the base damage will be measure by 300 plus 3 times your current level. So lets say Luka is lv 70 when he is fighting Yao (I don't remember the exact level) so his total damage multiplier is is 510 Lets also assume Luka has salamander so our multiplier is then multiplied by 1.5 for a total multiplier of 765 This number is then taken to the subroutine that will subract HP (along with the simple vanish / re-appear animation for the enemy taking damage )

The multiplier (765) is then multiplied by 70 (his level we are assuming right now ) times the damage resistance of yao (in this case 100 ) and then we divide by 2000 That gives us 2678 [rounded up?] as the flat damage. (Note my math might be wrong but I THINK it goes by order of operations... ) The flat damage isn't what actually is dealt however. Instead we get a range between the damage * (9/10) and the damage *(11/10) meaning the actual damage dealt will be a random number between 2410 and 2946 )

Whatever we get out of the randomizer then is what is subtracted from Yao's HP we are going to stick with our earlier assumption that Yao was 1 hit away from reaching 0 HP so after returning from the enemylife subroutine (and making sure our skill_sub is at 0) we go to the common_attack_end

the first line is true for Yao so we then jump to her victory scene (Hatibi_v) if she were still alive though we would check first if she had a counter (and if so we would take that path) otherwise we would continue by going to her attack (Hatibi_a)

and thus that should cover all the paths with battles.