RDE Modifier Tutorial


By AllenSam
Last Updated: July 12, 2007



Start Tutorial

 

Jump To:
Using Variables
List of Variables
Basic If Statements
Nested If Statements
Multiple Conditions
If Else Statements
Using Actual Conditions
Basic Modifier Templates
Using Functions
Location/Region Modifiers
Creating Monsters!

 

! = New material was added to this section in the last update.

 


Throughout this tutorial, I will use // comments which are used in PHP to put comments in the coding without affecting the evaluation.

We'll start off with basic variables. As in basic algebra, a variable is any letter or letters that represent a number. All PHP variables start with a '$' and end with a ';'. So, if you want x to equal 2, you put:

$x = 2;

You MUST have the $ and ; or the entire coding will result in an error and not function. Then you will have to go searching for the missing $ or ;.

After you put that, x will equal 2 throughout the rest of the coding unless you specify otherwise.

You can change the value x by adding to, subtracting from, multiplying, or dividing it. Here is a rundown of the symbols:

+ (add)
- (subtract)
* (multiply)
/ (divide)

You can add to x by entering something like this:

$x = $x + 2;

That makes x equal 4 and it will remain 4 until you make another change.

As a shorter, alternative way to add to x, you can also do this:

$x += 2;

The same can be used to subtract, multiply, and divide.

if $x=2
$x = $x - 1; //results in x equaling 1
$x -= 1; //same as above
$x = $x * 2; //results in 4
$x *= 2; //same as above
$x = $x / 2; //results in 1
$x /= 2; //same as above

You can use any letter or letters as variables such as $a or $abc, but the RDE also has special embedded variables to represent different things. The next page shows a list of those variables.

 

Menu | Next

 

This is a list of the RDE's embedded variables that are used for causing damage, healing, etc.

The following are "stat" variables. They are usually used in if statements to "ask" for a certain stat. You may want to say "if my character's HP is 200; do this" for example. 'Char' variables are from your character, while 'enemy' variables are from the enemy character.

'char' variables
'enemy' variables
 
$charinfo['charid'] $enemyinfo['charid'] //the character's ID number
$charinfo['name'] $enemyinfo['name'] //the character's name
$charinfo['level'] $enemyinfo['level'] //the character's level
$charinfo['experience'] $enemyinfo['experience'] //the character's experience
$charinfo['next'] $enemyinfo['next'] //the amount of experience needed to next level up
$charinfo['attpoints'] $enemyinfo['attpoints'] //the character's AP points
$charinfo['race'] $enemyinfo['race'] //the character's race ID
$charinfo['clas'] $enemyinfo['clas'] //thecharacter's class ID
$charinfo['gender'] $enemyinfo['gender'] //the character's gender ID
$charinfo['hp'] $enemyinfo['hp'] //the character's HP
$charinfo['mp'] $enemyinfo['mp'] //the character's MP
$charinfo['hpmax'] $enemyinfo['hpmax'] //the character's max HP
$charinfo['basehp'] $enemyinfo['basehp'] //the characters Max HP excluding bonuses from race, class, and equipment
$charinfo['mpmax'] $enemyinfo['mpmax'] //the character's max MP
$charinfo['basemp'] $enemyinfo['basemp'] //the characters Max MP excluding bonuses from race, class, and equipment
$charinfo['atk'] $enemyinfo['atk'] //the character's ATK
$charinfo['baseatk'] $enemyinfo['baseatk'] //the characters ATK excluding bonuses from race, class, and equipment
$charinfo['def'] $enemyinfo['def'] //the character's DEF
$charinfo['basedef'] $enemyinfo['basedef'] //the characters DEF excluding bonuses from race, class, and equipment
$charinfo['mo'] $enemyinfo['mo'] //the character's MO
$charinfo['basemo'] $enemyinfo['basemo'] //the characters MO excluding bonuses from race, class, and equipment
$charinfo['md'] $enemyinfo['md'] //the character's MD
$charinfo['basemd'] $enemyinfo['basemd'] //the characters MD excluding bonuses from race, class, and equipment
$charinfo['mlvl'] $enemyinfo['mlvl'] //the character's Magic Level
$charinfo['basemlvl'] $enemyinfo['basemlvl'] //the characters Magic level excluding bonuses from race, class, and equipment
$charinfo['agil'] $enemyinfo['agil'] //the character's Agility (Agility is currently not used in the RDE)
$charinfo['baseagil'] $enemyinfo['baseagil'] //the characters Agility excluding bonuses from race, class, and equipment (Agility is currently not used in the RDE)
$charinfo['statusid'] $enemyinfo['statusid'] //an array of the characters current statuses excluding auto-statuses. They are listed as status id => duration.
$charinfo['autostatus'] $enemyinfo['autostatus'] //an array of the characters current auto-statuses.
$charinfo['rhand'] $enemyinfo['rhand'] //the ID# of the item equipped on the character's right hand equip slot
$charinfo['lhand'] $enemyinfo['lhand'] //the ID# of the item equipped on the character's left hand equip slot
$charinfo['head'] $enemyinfo['head'] //the ID# of the item equipped on the character's head equip slot
$charinfo['body'] $enemyinfo['body'] //the ID# of the item equipped on the character's body equip slot
$charinfo['accessory'] $enemyinfo['accessory'] //the ID# of the item equipped on the character's accessory equip slot
$charinfo['i1'] $enemyinfo['i1'] //the ID# of the item equipped on the character's item slot #1 equip slot
$charinfo['i2'] $enemyinfo['i2'] //the ID# of the item equipped on the character's item slot #2 equip slot
$charinfo['i3'] $enemyinfo['i3'] //the ID# of the item equipped on the character's item slot #3 equip slot
$charinfo['i4'] $enemyinfo['i4'] //the ID# of the item equipped on the character's item slot #4 equip slot
$charinfo['i5'] $enemyinfo['i5'] //the ID# of the item equipped on the character's item slot #5 equip slot
$charinfo['commands'] $enemyinfo['commands'] //a list of the character's available commands
$charinfo['limitbreak'] $enemyinfo['limitbreak'] //the characters limit amount (0-100)
$charinfo['blockstatus'] $enemyinfo['blockstatus'] //the statuses that the character blocks; usually an array (arrays will be covered later)
$charinfo['atkstatus'] $enemyinfo['atkstatus'] //the statuses that the character's weapon add when attacking; usually an array (arrays will be covered later)
$charinfo['atkelements'] $enemyinfo['atkelements'] //the elements that the character's weapon has; usually an array (arrays will be covered later)

 

The following are "action" variables. They are used to determine damage, healing, etc.'Self' variables affect your character, while 'enemy' variables affect the enemy character.

'self' variables
'enemy' variables
 
$act['selfdamage'] $act['enemydamage'] //cause damage to the character
$act['selfmpdamage'] $act['enemympdamage'] //cause damage to the character's MP
$act['selfhpheal'] $act['enemyhpheal'] //restores the character's HP
$act['selfmpheal'] $act['enemympheal'] //restores the character's MP
$act['setselfstatus'][1]=5; $act['setenemystatus'][1]=5; //sets status with ID#1 on the character for 5 turns
$act['healselfstatus'][]=1; $act['healenemystatus'][]=1; //removes status with ID#1 from the character
$act['setselfstatus'] = array(); $act['setenemystatus'] = array(); //cancels any status that was to be set on the character
$act['selfatkelements'] = array(1,2); $act['enemyatkelements'] = array(1,2); //adds elements with ID# 1 and 2 to the action performed.
$act['selflife3']=1; $act['enemylife3']=1; //sets Life3 on the character
$act['target']==TARGET_SELF $act['target']==TARGET_ENEMY //The character you target. There is also $act['target']==TARGET_ALL which means you targetted both characters.
$act['effectmsg']="message"; $act['effectmsg']="message"; //Puts a message in the battle that says "message." You can use variables such as $charinfo[name] in these messages.
$act['cmdid']==1 $act['cmdid']==1 //The command ID used. 1 is attack, 2 is defend, 3 is skill,etc.
$act['mpuse'] $act['mpuse'] //the amount of MP used

 

Others:

MOD_AREA=='pvpbattle' //This is used at the top of all modifiers for PvP battles. More on this will be covered later in this tutorial.
$isturn==1 //Who's turn it is. 1 is your turn, 2 is the enemy's turn.
$useitem=1; //removes an item from your item list after using it. Leaving this out of an item modifier or setting it to 0 would make the item infinite use.

 

Functions:

These are embedded functions that can be used.

randomize_dmg() // randomizes the amount put in the parentheses so that it is not the same number every time. This can be used to make the damage done randomize by small amounts. For example, if you do 50 damage, it may sometimes do 48, 49, 51, or 52.
mt_rand() //This is used to pull up a random number. More on this will be explained later in this tutorial
battle_log("Message", LOG_REF) //this is the same as $act['effectmsg'] only it can be used to make more than one message.
status_set() //checks for a status set. It is used as 'status_set($charinfo['charid'], 1, 0)' where 1 is the status ID and 0 is whether or not it is an auto status (0 for no, 1 for yes)
in_array(), array(), and array_keys() //used for an array of multiple numbers in a variable. This will be explained later in this tutorial.
defined() //this can be used to ask if something is defined, such as limit use. defined('LIMIT_USED") would mean the character's limit has been used.
strlen() //counts the number of numbers in a certain number. For example, 123 would come out as 3, 2782 would come out as 4.
countchar() //counts the number of a certain character in a number. For example you could use this to count the number of 7's in your HP. 217 would come out as 1, 747 would come as 2, etc.
errorsend("message") //takes you to a page with the message "message". This cancels any action and the user will have to go back and choose another one.
floor() //rounds off the number in the parentheses so that it doesn't have continuous decimal places.
sqrt() //evaluates the square root of the number in the parentheses.

 

Now that you know what you can use, I'll show you how to use it. The next page shows how to do basic if statements.

 

Previous | Menu | Next

 

All modifiers in the RDE use basic if statements. If you know PHP, this should be easy for you. If not, here is how if statements work:

If statements are used to perform certain actions under certain conditions. If statements start with "if" of course. Then you put the condition in parentheses () then the action in brackets {} like this:

if(condition){action}

However, that's not the propper layout that programmers should use. Here is how it should look:

if(condition){   //break after the opening bracket
     action         //tab or space, enter the action, then break again
}                     //close the statement with the closing bracket

This makes it easier to read and doesn't cram everything together when there are multiple lines in the coding.

When putting more than one if statement the code should look like this:

if(condition1){
     action1
}
if(condition2){
     action2
}


Also, you will most likely need to put if statements within if statements, which are known as nested if statements. The next page explains nested if statements.

 

Previous | Menu | Next

 

A nested if statement is an if statement within an if statement. Here is what one should look like:

if(condition1){
     action1
     if(condition2){  //break and tab again for the nested 'if'
          action2       //break and tab twice
     }                     //break and tab, close nested statement
}                          //close original statement

 

With that example, action2 will only be evaluated if both condition1 and condition2 are true. However, action1 will be evaluated if condition1 is true no matter what condition2 is.

Another example:

if(condition1){
     if(condition2){
          action
     }
}

 

With this example, action will only evaluated if conditions 1 and 2 are both true.

An alternative way to this is to use 'and' or '&&'. "and" and "or" can be used to make multiple conditions. Multiple conditions are explained on the next page.

 

Previous | Menu | Next

 

 

Multiple conditions can be used in the same if statement by using 'and' or 'or'.

Example using 'and':

if(condition1 and condition2){
     action
}

or

if(condition1 && condition2){
     action
}

action will be evaluated if condition 1 and 2 are both true.

 

Example using 'or':

if(condition1 or condition2){
     action
}

or

if(condition1 || condition2){
     action
}

With this example, action will be evaluated if condition1 OR condition2 are true. Only one of them has to be true for it to be evaluated.

 

Another useful symbol is '!' which means 'not'.

if(!condition){
     action
}

This will evaluate if the condition is NOT true (false).

You may also want to specify what happens if the condition is false. This can be done with an 'if else statement'. 'If else' statemtents are explained on the next page.

 

Previous | Menu | Next

 

When you use a condition to specify what happens when it is true, you may also want to specify what happens when the condition is false.

The hard way to do it would be like this:

if(condition){
     action1
}
if(!condition){  //remember, '!' means 'not true'
     action2
}

If else statements make it easier. Here is the same example using if else.

if(condition){
     action1
}else{
     action2
}

This does the same as the previous example. The 'else' tells it to evaluate action2 if the condition is false.

You can also use 'else if' and add another condition to work with if the first condition is false.

Example:

if(condition1){
     action1
}else if(condition2){
     action2
}

action2 will only evaluate if condition2 is TRUE and condition1 is FALSE.

 

Now, let's put some actual conditions and actions in so it makes more sense. The next page shows examples using actual conditions and actions.

 

Previous | Menu | Next

 

Here are a few examples using actual conditions and actions.

In this example, we're going to make the modifier do 500 damage to the enemy if your character has 500 HP.

if($charinfo['hp'] == 500){
     $act['enemydamage'] = 500;
}

Notice the '==' in the condition. This says 'is equal to'. You must put two equal signs to say this. One equal sign only says 'equals' and is used in variables (as you can see in the action). You may think 'is equal to' and 'equals' mean the same thing, but they don't.

You can also use:
<
less than
>
greater than
<=
less than or equal to
>=
greater than or equal to
!=
is not equal to

 

Here's another example where the modifier will do double damage if your HP is greater than 500:

$act['enemydamage'] = 500;
if($charinfo['hp'] > 500){
     $act['enemydamage'] *= 2;
}

Remember, '$act['enemydamage']*=2;' is the same as '$act['enemydamage']=$act['enemydamage']*2;'.

That example will result in 1000 damage if your HP is greater than 500, but only 500 damage if your HP is less than or equal to 500.

 

Here's an example using a nested if statement:

$act['enemydamage'] = 500;
if($charinfo['hp'] > 500){
     $act['enemydamage'] *= 2;
     if($charinfo['mp'] == 500){
          $act['selfhpheal'] = 500;
     }
}

That example will do the same as the above example but will also restore 500 HP if your MP is 500 and your HP is greater than 500. Remember, they must both be true for the nested action to evaluate.

 

Here's an example using 'or':

$act['enemydamage'] = 500;
if($charinfo['hp'] > 500 or $charinfo['mp'] == 500){
     $act['enemydamage'] *= 2;
}

That example will result in 1000 damage if your HP is greater than 500 OR your MP is equal to 500. They do not both have to be true. It will evaluate if either one is true. If both are false, it will default to 500 damage as the first line specifies.

 

You can also put 'and' and 'or' together in one statement like this:

$act['enemydamage'] = 500;
if(($charinfo['hp'] > 500 and $charinfo['mp'] > 500) or ($charinfo['atk'] == 500 and $charinfo['mo' ] == 500)){
     $act['enemydamage'] *= 2;
}

This doubles the 500 damage if your hp and mp are both greater than 500 OR your ATK and MO are both equal to 500. Notice how the two 'and' sections are grouped together with parentheses. Parentheses can be used, just like in algebra, to group certain things together.

 

Previous | Menu | Next


 

Here are some basic templates for RDE modifiers.

 

Skill, weapon, limit, item modifier template:
if(MOD_AREA=='pvpbattle'){
     $edmg=($charinfo['atk']*2)-$enemyinfo['def'];
     $sdmg=($charinfo['atk']*2)-$charinfo['def'];

     if($act['target']==TARGET_ENEMY){
          $act['enemydamage']=randomize_dmg($edmg);
     }
     if($act['target']==TARGET_SELF){
          $act['selfdamage']=randomize_dmg($sdmg);
     }
     if($act['target']==TARGET_ALL){
          $act['enemydamage']=randomize_dmg($edmg);
          $act['selfdamage']=randomize_dmg($sdmg);
     }
}

The first line (MOD_AREA=='pvpbattle') MUST always be in the modifiers for PvP battes. This tells it to evaluate in battle.

$edmg and $sdmg are custom variables I made up to represent enemy damage and self damage. You can change these to anything you want ($edamage and $sdamage or $e and $s, for example, would work the same way).

'if($act['target']==TARGET_ENEMY)' tells it what to do if you target the enemy. TARGET_SELF is if you target yourself and TARGET_ALL is if you target both yourself and the enemy.

This is a basic damage modifier, so the actions use $act['enemydamage'] and $act['selfdamage'].

randomize_dmg() randomizes the damage a little so it isn't exactly the same every time.

 

Here is a modifier template that shows other things you can do besides damage:

if(MOD_AREA=='pvpbattle'){
     $edmg=($charinfo['atk']*2)-$enemyinfo['def'];
     $sdmg=($charinfo['atk']*2)-$charinfo['def'];
     $heal=$charinfo['mo']*2;                                               //custom variable for healing
     if($act['target']==TARGET_ENEMY){
          $act['enemympdamage']=randomize_dmg($edmg);  //damages MP instead of HP
          $act['enemyhpheal']=randomize_dmg($heal);           //heals enemy based on $heal variable specified above
          $act['enemympheal']=randomize_dmg($heal);          //heals enemy's MP based on $heal variable specified above
          $act['setenemystatus'][1]=5;                                    //sets status with ID#1 on the enemy for 5 turns
          $act['healenemystatus'][]=2;                                    //removes status with ID#2 from the enemy (leave the [] empty)
          $act['enemyatkelements']=array(1,2,3);                    //Adds elements with the ID# 1, 2, and 3 to the attack or skill.
          $act['enemylife3']=1;                                               //sets Life 3 (Auto Revive) on the enemy
          $useitem=1;                                                            //removes an item from your item list after using it. Leaving this out or setting it to 0 would make the item infinite use.
          $act['effectmsg']="message";                                    //Leaves message that says "message"
          battle_log("message2!", LOG_REF);                       //leaves another message that says "message2". Using $act['effectmsg'] again would overwrite the original $act['effectmsg']
     }
     if($act['target']==TARGET_SELF){
          $act['selfmpdamage']=randomize_dmg($sdmg);
          $act['selfhpheal']=randomize_dmg($heal);
          $act['selfmpheal']=randomize_dmg($heal);
          $act['setselfstatus'][1]=5;
          $act['healselfstatus'][]=2;
          $act['selfatkelements']=array(1,2,3);
          $act['selflife3']=1;
          $useitem=1;
          $act['effectmsg']="message";
          battle_log("message2!", LOG_REF);
     }
     if($act['target']==TARGET_ALL){
          $act['enemympdamage']=randomize_dmg($edmg);
          $act['enemyhpheal']=randomize_dmg($heal);
          $act['enemympheal']=randomize_dmg($heal);
          $act['setenemystatus'][1]=5;
          $act['healenemystatus'][]=2;
          $act['enemyatkelements']=array(1,2,3);
          $act['enemylife3']=1;
          $act['selfmpdamage']=randomize_dmg($sdmg);
          $act['selfhpheal']=randomize_dmg($heal);
          $act['selfmpheal']=randomize_dmg($heal);
          $act['setselfstatus'][1]=5;
          $act['healselfstatus'][]=2;
          $act['selfatkelements']=array(1,2,3);
          $act['selflife3']=1;
          $useitem=1;
          $act['effectmsg']="message";
          battle_log("message2!", LOG_REF);
     }
}

 

 

Status/armor type modifier template:
if(MOD_AREA=='pvpbattle'){
     $regen=$charinfo['hpmax']*.1;
     if($isturn==1){
          $act['selfhpheal']=$regen;

     }
     if($isturn==2){
          $act['enemydamage']/=2;

     }
}

That is how status modifiers are done. In this example, as long as the status is set, you will recover 10% HP every time it is your turn and if it is the enemy's turn, they will do half damage. You can do pretty much everything you can with a skill modifier, such as damage, healing, effect messages etc. Status modifiers cannot set other statuses or Life3, however. You can still use the $act['target'] variable, but most status' effects will be based on who's turn it is so you will only need $isturn.

 

Inventory Item modifier template:
if($modpage==""){
     $pagetext = "Choose the character you want to use this item on.";
     $charlist=charchooserpage($modinfo[modid],0,0);
} else if($modpage=="process" && $charid !=""){
     $update['hp'] = $charinfo['hpmax'] - $charinfo['hp'];
     $update['mp'] = $charinfo['mpmax'] - $charinfo['mp'];
     $useitem = 1;
}else{
     errorsend("An error has occured. Click back in your browser, and try again.");
}

Use this template for inventory modifiers. The only thing you need to worry about changing is the $update[] variables. They can be changed to any stat such as $update['hpmax'], $update['atk'], $update['mlvl'] etc. $update[] variables only add to the stat, so if you want to lower it, use a negative number.

$useitem removes the item from your inventory after using it. Leaving it out or setting it to 0 would make the item infinite use.

You may need to change the 0's in '$charlist=charchooserpage($modinfo[modid],0,0);'.

0,0 means you can use the item on any character that is not in battle or dead.
1,0 means you can use it on any dead character (a revive item, for example).
0,1 means you can use it on any character that is not dead (including characters in battle.)
2,0 means you can use it on any character that is dead or alive, but not on characters in battle.
2,1 means you can use it on any character.

 

 

Previous | Menu | Next

 

randomize_dmg() and battle_log(), which I have already explained, will be the most common functions you will use.

floor() and sqrt() are self explanatory, just use them like randomize_dmg(). Just put the number or variable in the parentheses.

Examples:

floor(6.45782); //evaluates as 6.
floor(13/3); //evaluates as 4 since 13 divided into 3 is 4.333333333....
floor($dmg); //rounds off the value of $dmg if it would normally leave decimal places
sqrt(49); //evaluates as 7
sqrt($charinfo['hp']); //evaluates the square root of your HP.

Note: You do not need to use floor() everytime you make a damage modifier. The RDE automatically rounds off all damage. It also automatically prevents negative damage.

 

Here is an explanation of the other functions:

 

mt_rand()
mt_rand() is probably the next most common function you will use. It can be used to trigger random events in battle.

Let's say you want to make a weapon that has a 50/50 chance of causing double damage. Here is how you would set it up.

if(MOD_AREA=='pvpbattle'){
     $doublechance=mt_rand(1,2);
     if($act['target']==TARGET_ENEMY and $doublechance==1){
          $act['enemydamage']*=2;
     }
     if($act['target']==TARGET_SELF and $doublechance==1){
          $act['selfdamage']*=2;
     }
     if($act['target']==TARGET_ALL and $doublechance==1){
          $act['enemydamage']*=2;
          $act['selfdamage']*=2;
     }
}

First, I gave the mt_rand() function a variable, $doublechance. Again, you can use almost anything for a variable.

Notice the '1,2' in the parentheses. This means it will pull a random number between 1 and 2 (so it will pull either a 1 or a 2). You can use any number, (0,10) for example, will pull a random number between 0 and 10, including 0. The first number must always be less than the second number.

Lastly, I just add $doublechance==1 in the condition which means it will only double the damage if 1 is pulled up. This gives it a 50/50 or 50% chance of doubling the damage. You can also use multiple numbers like this:


if(MOD_AREA=='pvpbattle'){
     $doublechance=mt_rand(1,10);
     if($act['target']==TARGET_ENEMY and $doublechance<=5){
          $act['enemydamage']*=2;
     }
     if($act['target']==TARGET_SELF and $doublechance<=5){
          $act['selfdamage']*=2;
     }
     if($act['target']==TARGET_ALL and $doublechance<=5){
          $act['enemydamage']*=2;
          $act['selfdamage']*=2;
     }
}

That one doubles the damage if 1, 2, 3, 4, or 5 is pulled out of a random number between 1 and 10. 6, 7, 8, 9, and 10 would result in normal damage. This is also 50/50. If you want to make the chance lower change it to $doublechance<=3 or 2 or 1. To make the chance higher make it 6, 7, or 8 etc.

 

status_set()
status_set() asks for a certain status set on you or the enemy. You must use this format:

status_set($charinfo['charid'], 10, 0)

10 is the status ID# so it will depend on the status you are looking for. The 0 is whether or not it is an auto status set by an armor or accessory. 0 means no, 1 means yes.

So here is how you would use it in a modifier:

if(MOD_AREA=='pvpbattle'){
     if($act['target']==TARGET_ENEMY and status_set($enemyinfo['charid'], 10, 1)){
          $act['enemydamage']*=2;
     }
     if($act['target']==TARGET_SELF and status_set($charinfo['charid'], 10, 1)){
          $act['selfdamage']*=2;
     }
     if($act['target']==TARGET_ALL){
          if(status_set($enemyinfo['charid'], 10, 1)){
               $act['enemydamage']*=2;
          }
          if(status_set($charinfo['charid'], 10, 1)){
               $act['selfdamage']*=2;

          }
     }
}

Let's say status ID# 10 is Magic Shield, which cuts damage in half. This modifier would make the weapon or skill double the damage if the Magic Shield status is set. It also works if the status is auto-set by an armor or accessory. If the 1 were a 0, the damage would not double if it was auto-set.

Notice how I nested the status set conditions for TARGET_ALL. This is because the status may sometimes be set on your character only, or the enemy only, or both.

 

in_array(), array(), and array_keys()
in_array() and array() can be used to call for an array of numbers in a certain variable.

For example, if you wanted to do double damage, but only to certain classes you would normally do this:

if(MOD_AREA=='pvpbattle'){
     if($act['target']==TARGET_ENEMY and ($enemyinfo['clas']==1 or $enemyinfo['clas']==2 or $enemyinfo['clas']==3 or $enemyinfo['clas']==4 or $enemyinfo['clas']=5 or $enemyinfo['clas']==6 or $enemyinfo['clas']==7 or $enemyinfo['clas']==8 or $enemyinfo['clas']==9 or $enemyinfo['clas']==10 or $enemyinfo['clas']==11)){
          $act['enemydamage']*=2;
     }
     if($act['target']==TARGET_SELF and ($charinfo['clas']==1 or $charinfo['clas']==2 or $charinfo['clas']==3 or $charinfo['clas']==4 or $charinfo['clas']=5 or $charinfo['clas']==6 or $charinfo['clas']==7 or $charinfo['clas']==8 or $charinfo['clas']==9 or $charinfo['clas']==10 or $charinfo['clas']==11)){
          $act['selfdamage']*=2;
     }
     if($act['target']==TARGET_ALL){
          if($enemyinfo['clas']==1 or $enemyinfo['clas']==2 or $enemyinfo['clas']==3 or $enemyinfo['clas']==4 or $enemyinfo['clas']=5 or $enemyinfo['clas']==6 or $enemyinfo['clas']==7 or $enemyinfo['clas']==8 or $enemyinfo['clas']==9 or $enemyinfo['clas']==10 or $enemyinfo['clas']==11){
               $act['enemydamage']*=2;
          }
          if($charinfo['clas']==1 or $charinfo['clas']==2 or $charinfo['clas']==3 or $charinfo['clas']==4 or $charinfo['clas']=5 or $charinfo['clas']==6 or $charinfo['clas']==7 or $charinfo['clas']==8 or $charinfo['clas']==9 or $charinfo['clas']==10 or $charinfo['clas']==11){
               $act['selfdamage']*=2;
          }
     }
}

As you can see, that gets kind of messy. With in_array() you can make it look cleaner by searching for the class ID's in one array.

Example:


if(MOD_AREA=='pvpbattle'){
     if($act['target']==TARGET_ENEMY and in_array($enemyinfo['clas'],array(1,2,3,4,5,6,7,8,9,10,11))){
           $act['enemydamage']*=2;
     }
     if($act['target']==TARGET_SELF and in_array($charinfo['clas'],array(1,2,3,4,5,6,7,8,9,10,11))){
           $act['selfdamage']*=2;
     }
     if($act['target']==TARGET_ALL){
           if(in_array($enemyinfo['clas'],array(1,2,3,4,5,6,7,8,9,10,11))){
                 $act['enemydamage']*=2;
           }
           if(in_array($charinfo['clas'],array(1,2,3,4,5,6,7,8,9,10,11))){
                 $act['selfdamage']*=2;
           }
     }
}

Simply put the variable, a comma, then array() with the numbers you want to search for seperated by commas in the parentheses, in the parentheses of in_array(). In this example, the numbers in the array are class ID's, so this modifier will do double damage only to characters with those classes.

array_keys() is used for statuses.

In $act['setenemystatus][1]=5; the 1 in the []'s is known as an array key. array_keys() is used to search for numbers in that area.

Here is an example:

if(MOD_AREA=='pvpbattle'){
     if($isturn==2 and in_array(array_keys($act['setenemystatus']), array(1,2))){
          battle_log("$enemyinfo[name] is immune to this status!", LOG_EFFECT);
     }
     if($isturn==1 and in_array(array_keys($act['setselfstatus']), array(1,2))){
          battle_log("$charinfo[name] is immune to this status!", LOG_EFFECT);
     }
}

This modifier would make an armor or accessory type equipment show the message "Name is immune to this status!" if the enemy tried to set a status that the armor or accessory blocks. The 1 and the 2 are status ID's, they will be determined by the status you are looking for.

 

defined()
This function can be used in an if statement to ask if something is defined.

For example, you may want your weapon to double damage, but not if the limit break is used.

Here is how you would do that:

if(MOD_AREA=='pvpbattle'){
     $doublechance=mt_rand(1,2);
     if($act['target']==TARGET_ENEMY and $doublechance==1 and !defined('LIMIT_USED')){
          $act['enemydamage']*=2;
     }
     if($act['target']==TARGET_SELF and $doublechance==1 and !defined('LIMIT_USED')){
          $act['selfdamage']*=2;
     }
     if($act['target']==TARGET_ALL and $doublechance==1 and !defined('LIMIT_USED')){
          $act['enemydamage']*=2;
          $act['selfdamage']*=2;
     }
}

All I did was add '!defined('LIMIT_USED')' to the condition. Remember, '!' means 'not' or 'false'. Thus, this will result in double damage ONLY if the random number is 1 and the limit has not been used. You could also remove the '!' to make this weapon cause double damage only when the limit is used. It will still have a 50/50 chance however.

 

strlen()
strlen() can be used to find the length of a certain number. For example if you want to use the amount of numbers in your HP you could put something like this:

if(MOD_AREA=='pvpbattle'){
     $hplength=strlen($charinfo['hp']);
     if($act['target']==TARGET_ENEMY and !defined('LIMIT_USED')){
          $act['enemydamage']*=$hplength;
     }
     if($act['target']==TARGET_SELF and !defined('LIMIT_USED')){
          $act['selfdamage']*=$hplength;
     }
     if($act['target']==TARGET_ALL and !defined('LIMIT_USED')){
          $act['enemydamage']*=$hplength;
          $act['selfdamage']*=$hplength;
     }
}

This will make the weapon multiply the damage by the amount of numbers in your HP. So if you have high HP of say, 2433, it will quadruple the damage. Once you get down to 3 digit HP such as, 234 it will only triple it, then at 2 digit HP it will double it and 1 digit will result in normal damage.

 

countchar()
countchar() counts the number of a certain character in a variable specified.

Example:

if(MOD_AREA=='pvpbattle'){
     $hpsevens=countchar($charinfo['hp'],"7");
     if($act['target']==TARGET_ENEMY and !defined('LIMIT_USED')){
          $act['enemydamage']*=$hpsevens;
     }
     if($act['target']==TARGET_SELF and !defined('LIMIT_USED')){
          $act['selfdamage']*=$hpsevens;
     }
     if($act['target']==TARGET_ALL and !defined('LIMIT_USED')){
          $act['enemydamage']*=$hpsevens;
          $act['selfdamage']*=$hpsevens;
     }
}

This one will multiply the amount of damage done by the amount of 7's in your HP. So, if your HP was 147, it would result in normal damage, 1797 would double the damage, 2777 would triple the damage.

You must put the variable you are targetting, a comma, then the character you want to count in quotes within the parentheses.

countchar($charinfo['hp'],"7");

 

foreach()
foreach() loops through each value in an array and assigns it to a variable.

Example:

if(MOD_AREA=='pvpbattle'){
     if($act['target']==TARGET_ENEMY){
          foreach($enemyinfo['statusid'] as $statusid => $duration){
               $act['setselfstatus'][$statusid]=$duration;
               $act['healenemystatus'][] = $statusid;
          }
     }
}

This one will check each status set on the enemy and set the status id as $statusid and the status duration as $duration then set each of those statuses on your character and remove each of the statuses from the enemy.

You must put the array you are targetting, the word 'as', then the variable you want to use for the key (remember, the key is the [1] in $act['setenemystatus'][1]=5;), then '=>', then the variable you want to use for the value. The variables can be anything. For example, I could've used $id instead of $statusid or $turns instead of $duration.


If you are using an array with no key, just leave out the key and put it as 'foreach($array as $value){'

 

 

Previous | Menu | Next

 

The following guide for Location/Region Modifiers was originally posted by "Storm" at RPG Palace. However, I have added a few new things to further explain certain features.

$hideshops -- Hides the shops if this is set to 1 or true, shows shops if omitted (works for $modA == 'enter' only)
$hidenpcs -- Hides NPC's if set to 1 or true, shows otherwise (works for $modA == 'enter' only)

triggerswitch('triggername'); -- will TOGGLE the status of the trigger, triggername. With this you can keep track if a user has entered a location or picked up an item already. To check if a user has been to a location and set the trigger if they haven't, you would do something like:

if(!$bbuserinfo['triggername']){
     $triggerswitch('triggername');
}

AllenSam's further explanation:

$bbuserinfo[] is a vBulleting variable that checks the user's vBulletin information.

triggername is the name of the trigger you are checking for. You can name the trigger whatever you want as long as it doesn't contain spaces or symbols and doesn't start with a number. For example, you could make a trigger called "treasurechest" and use it in place of "triggername" in the modifier.

The trigger's name must first be created in the RDE control panel. Simply click "Add" under "Triggers" and type in the name you want for the trigger and submit it. After that you can use it in any location/region modifier.

$triggerswitch() is a function that will switch the trigger on or off. If the trigger is on it is considered "true." If it is off, it is considered "false". This allows you to check for it in an if condition as you see in the example above. (Remember "!" means false, so the above example says to trigger the switch to "on/true" if it is "off/false"

This allows you to check if a certain event has been triggered by each user who enters the location. In the above example, it will switch the trigger to "on" the first time they enter the location (since it is off (!) by default). After that, each time they enter the location, the event will no longer happen because the trigger is set to "on" which makes the if condition false.

To add an event, simply put it in the action statement along with $triggerswitch like this:

if(!$bbuserinfo['triggername']){
     $actionhere;
     $triggerswitch('triggername');
}

This will cause the action to evaluate the first time the user enters the location, but it will never evaluate again unless the trigger is switched back to "off/false" by another modifier. This can be used to create treasure chests or other one time events.

(End of AllenSam's explanation)

You will need to use the if conditional to check if it has been set already because each time you call triggerswitch() it will toggle the value of it. Refer to the sample modifier below for more:

// $modA == 'enter' -- evaluated when user enters location
// $modA == 'exit' -- evaluated when user leaves location
// $modA == 'notravel' -- evaluated when user refreshes or reloads the current location*
if ($modA == 'enter'){
/* =========================================================================
To check if a particular item exists in a user inventory:
     if ($inventory->check(item id, mode)){
          event to evaluate if the user has this item
     }
     Using mode:
          1 = checks inventory only
          2 = checks the equipped items only
          3 = checks inventory and equipped items
     item id is an integer representing the itemid of the item you wish to check.
     Numbers only, you will need to look this up in the RDE control panel.

     To add extra quantity to an item the user has:
          $inventory->add(item id, quantity);
          (if the user does not have this item in their inventory it will be created when this is called)

     To subtract quantity from an item the user has:
          $inventory->remove(item id, quantity);

     To completely remove an item from user inventory:
          $inventory->delete(item id);

     You can also isolate events to a particular user, or usergroup if you wish by using conditionals:
     if ($bbuserinfo['usergroupid'] == 6){
          event to evaluate for administrators only
     }
     if ($bbuserinfo['userid'] == 1){
          event isolated to user id 1 only
     }
     if (in_array($bbuserinfo['userid'], array(1, 2, 3, 4))){
          event isolated to user ids 1, 2, 3, 4 only
     }

// This will add 100 gil to the user's money:
$bbuserinfo['rpgmoney'] += 100;

// This will take away 50 gil from the user's money:
$bbuserinfo['rpgmoney'] -= 50;

// This will take away all of the user's money:
$bbuserinfo['rpgmoney'] = 0;

// If you make changes to the user's money, you must call this function at the end of your modifier:
save_gil();

// To warp the user to a different location, you can use the following :
$overideaddy = '4-2-5'; // where the new location is regionid-x-y

     The modifier below will add one elixir to your inventory upon entering the location if you are an administrator.
========================================================================= */

     if ($bbuserinfo['usergroupid'] == 6){
          $inventory->add(12);
          echo '<script>alert("You\'re an admin, here is an Elixir for you!");</script>';
     }
}

*UPDATE!!!: $modA=='notravel' was newly added (2-19-2007) after a bug was found with $hideshops and $hidenpcs. If you are using $hideshops or $hidenpcs you MUST put it in both $modA=='enter' AND $modA=='notravel' otherwise the user can refresh the page or click "Map" again and the shops/npcs will no longer be hidden! However, DO NOT use $modA=='notravel' when the location gives or takes items or money, otherwise the user will be able to repeatedly refresh the page and gain or lose large amounts of items or money. You can seperate the two by doing something like this:

if($modA == 'notravel'){
     $hidenpcs=1;
     $hideshops=1;
}
if($modA == 'enter'){
     $hidenpcs=1;
     $hideshops=1;
     code to give money or items
}

Region and Location modifiers are the same thing, only difference is that region modifiers are evaluated on every location in the region.

More examples by AllenSam:

if($modA == 'enter' or $modA == 'notravel'){ //evaluates the modifier when the user enters the location or refreshes the location.
                                                                                   //Replace 'enter' with 'exit' to evaluate on exit. It is not recommended to use 'exit' and 'notravel' together.
     if(!$bbuserinfo['warptreasure']){       //Checks to see if the user has not triggered "warptreasure." If they have, the actions below will not be evaluated.
          if($inventory->check(123, 1)>=3){            //checks the user's inventory for the item with ID# 123, ">=3" makes it check for 3 or more of the item.
                                                                                //You can leave ">=3" off if you are only checking for one.
               $inventory->add(456, 1);                     //Adds 1 item with ID# 456 to the user's inventory.
               $inventory->remove(123, 3);               //Removes 3 items with ID# 123 from the user's inventory.
               $inventory->delete(789);                     //Removes ALL items with ID# 789 from the user's inventory.
               $bbuserinfo['rpgmoney'] += 1000;      //Gives the user 1000 money.
               $bbuserinfo['rpgmoney'] -= 10;           //Subtracts 10 money from the user.
               $bbuserinfo['rpgmoney'] = 0;              //Deletes all of the user's money.
               savegil();                                            //Saves the user's gil. This function must ALWAYS be used in order to make changes to the user's money.
               $hideshop=array(12,34);              //Hides shops with ID# 12 and 34. This is used to hide only some shops but not all.
               $hidenpc=array(56,78);              //Hides NPCs with ID# 56 and 78. This is used to hide only some NPCs but not all.
                                                                                              //You can use an array to specify multiple ID's seperated by commas.
               $hideshops=1;              //Hides ALL shops in the location.
               $hidenpcs=1;              //Hides ALL NPC's in the location.
               $overideaddy = '4-20-12';                //Overides the user's destination and sends them to the location at (20x,12y) in the region with ID# 4. (A warp.)
               echo '<script>alert("This is a pop up message!");</script>';                //Pops up a message saying "This is a pop up message!"
               triggerswitch('warptreasure');              //Switches the trigger "warptreasure" to on/true for the user.
                                                                                                       //This prevents this mod from being evaluated next time they enter this location.
          }
     }
}

 

 

Previous | Menu | Next

 

Step 1: Add the Monster
-Add the monster just like you would a character.
-All monsters go in the Monsters account.
-The Race should be Monster, Class should be (Monster) Monster Type.
-If you have to create a new monster type, create it like a normal class, but make all stats 0. If it is an evil or good based type, add it to all Angel/Demon Killer type mods. Same for Dragon Killer, etc.
-Give the monster 1 max MP, the rest of the stats are up to you. I recommend making the HP higher than normal since the monster won't heal or use potions like a player will.

Step 2: Add the Monster's Accessory
-The Monster must have an accessory to determine auto-status, status immunities, and elemental properties.
-All monsters must have the "Monster" status as an auto-status. This gives them the 9999 damage cap as well as other necassary effects.
-Name the accessory (Monster) Monster Name. If the accessory has the same properties as a monster accessory that is already added, change the name to (Monster) Name1/Name2/Name3.
-DO NOT leave the accessory as ungrouped, make sure it is an accessory type.

Step 3: Making the Bot
-Create a new skill modifier and call it (Bot) Monster Name.
-Use the following template to code your bot:

if(MOD_AREA=='pvpbattle'){

     $price=9000;

     foreach($charinfo['statusid'] as $sid => $sturns){
          if($sid==17){
               $bers=1;
          }
          if($sid==25){
               $fear=1;
          }
          if($sid==4){
               $slnc=1;
          }
     }


     if($enemyinfo['level']>=15 or $enemygil['rpgmoney']<$price){
          $skillused=0;
     }else if($bers==1){
          $skillused=1;
     }else if($fear==1){
          $skillused=99;
     }else{
          $skillused=mt_rand(1,12);
     }


     if($enemyinfo['mlvl']==1){
          $emlvl=1.75;
     }else{
          $emlvl=$enemyinfo['mlvl'];
     }

     $charinfo['limitbreak']=0;

     $elementstatus=mt_rand(1,15);

     $atk=($charinfo['atk']*2)-$enemyinfo['def'];
     $phy=(($charinfo['atk']*2.5)-($enemyinfo['def']));
     $mag=(($charinfo['mo']*$charinfo['mlvl'])-($enemyinfo['md']*sqrt($emlvl)));
     $mid=(($charinfo['mo']*($charinfo['mlvl']+.5))-($enemyinfo['md']*sqrt($emlvl)));


     if($skillused==0){
          if($enemygil['rpgmoney']<$price){
               battle_log("You don't have enough gil to battle this monster!", LOG_REF);
          }else{
               battle_log("$charinfo[name] sees $enemyinfo[name]'s level and runs away!", LOG_REF);
          }
          $act['enemydamage']=0;
          define('RUN_SUCCESSFUL', true);

     //Defend
     }else if(in_array($skillused, array(99))){
          $noreflect=1;
          battle_log("$charinfo[name] defends.", LOG_REF);
          $act['setselfstatus'][9]=1;
          $act['cmdid']=2;

     //Limit
     }else if($charinfo['limitbreak']>=100){
          battle_log("$charinfo[name] unleashes limit Limit Name!", LOG_REF);
          $act['enemydamage']=randomize_dmg($edmg);
          $charinfo['limitbreak'] = 0;
          define('LIMIT_USED', 1);

     //Shadow
     }else if(!$slnc and in_array($skillused, array(4,5,6))){
          battle_log("$charinfo[name] casts Shadow.", LOG_REF);
          $magic=1;
          $act['enemydamage']=randomize_dmg($mag);
          $act['enemyatkelements']=array(7);
          if($elementstatus==1){
               $act['setenemystatus'][62]=5;
          }

     //Black Stare
     }else if(!$slnc and in_array($skillused, array(7,8))){
          battle_log("$charinfo[name] casts Black Stare.", LOG_REF);
          $act['enemydamage']=0;
          $act['setenemystatus'][62]=5;

     //Rasp
     }else if(!$slnc and in_array($skillused, array(9))){
          battle_log("$charinfo[name] casts Rasp.", LOG_REF);
          $magic=1;
          $act['enemydamage']=0;
          $act['enemympdamage']=randomize_dmg($mag/3);

     //Shadowa
     }else if(!$slnc and in_array($skillused, array(10))){
          battle_log("$charinfo[name] casts Shadowa.", LOG_REF);
          $magic=1;
          $act['enemydamage']=randomize_dmg($mid);
          $act['enemyatkelements']=array(7);
          if($elementstatus==1){
               $act['setenemystatus'][62]=5;
          }
          if($elementstatus==10){
               $act['setenemystatus'][34]=3;
          }

     //Shockwave
     }else if(in_array($skillused, array(11))){
          $physical=1;
          $noreflect=1;
          battle_log("$charinfo[name] strikes with Shockwave.", LOG_REF);
          $confuchance=mt_rand(1,3);
          $blindchance=mt_rand(1,2);
          $act['enemydamage']=randomize_dmg($phy);
          if($confuchance==1){
               $act['setenemystatus'][20]=5;
          }
          if($blindchance==1){
               $act['setenemystatus'][18]=5;
          }

     //Stone Gaze
     }else if(!$slnc and in_array($skillused, array(12))){
          battle_log("$charinfo[name] casts Stone Gaze.", LOG_REF);
          $act['enemydamage']=0;
          $hitchance=mt_rand(1,4);
          if($hitchance==1){
               $act['setenemystatus'][3]=3;
          }else{
               battle_log("Missed!", LOG_REF);
          }

     //Attack
     }else{
          $noreflect=1;
          $physical=1;
          battle_log("$charinfo[name] attacks.", LOG_REF);
          $act['enemydamage']=randomize_dmg($atk);
     }


     foreach($charinfo['blockstatus'] as $sblock){
          if($sblock==15){
               $sblkatkd=1;
          }
          if($sblock==22){
               $sblkdefd=1;
          }
          if($sblock==27){
               $sblkmdd=1;
          }
          if($sblock==47){
               $sblkmod=1;
          }
     }

     foreach($enemyinfo['blockstatus'] as $eblock){
          if($eblock==15){
               $eblkatkd=1;
          }
          if($eblock==22){
               $eblkdefd=1;
          }
          if($eblock==27){
               $eblkmdd=1;
          }
          if($eblock==47){
               $eblkmod=1;
          }
     }

     foreach($act['setenemystatus'] as $eid => $eturns){
          foreach($enemyinfo['statusid'] as $stat => $dur){
               if($eid==15 and $stat==14 and !$eblkatkd){
                    $act['healenemystatus'][]=14;
                    unset($act['setenemystatus'][15]);
                    battle_log("$enemyinfo[name]'s Atk stat returned to normal.", LOG_REF);
               }
               if($eid==14 and $stat==15){
                    $act['healenemystatus'][]=15;
                    unset($act['setenemystatus'][14]);
                    battle_log("$enemyinfo[name]'s Atk stat returned to normal.", LOG_REF);
               }
               if($eid==21 and $stat==22){
                    $act['healenemystatus'][]=22;
                    unset($act['setenemystatus'][21]);
                    battle_log("$enemyinfo[name]'s Def stat returned to normal.", LOG_REF);
               }
               if($eid==22 and $stat==21 and !$eblkdefd){
                    $act['healenemystatus'][]=21;
                    unset($act['setenemystatus'][22]);
                    battle_log("$enemyinfo[name]'s Def stat returned to normal.", LOG_REF);
               }
               if($eid==27 and $stat==26 and !$eblkmdd){
                    $act['healenemystatus'][]=26;
                    unset($act['setenemystatus'][27]);
                    battle_log("$enemyinfo[name]'s MD stat returned to normal.", LOG_REF);
               }
               if($eid==26 and $stat==27){
                    $act['healenemystatus'][]=27;
                    unset($act['setenemystatus'][26]);
                    battle_log("$enemyinfo[name]'s MD stat returned to normal.", LOG_REF);
               }
               if($eid==47 and $stat==46 and !$eblkmod){
                    $act['healenemystatus'][]=46;
                    unset($act['setenemystatus'][47]);
                    battle_log("$enemyinfo[name]'s MO stat returned to normal.", LOG_REF);
               }
               if($eid==46 and $stat==47){
                    $act['healenemystatus'][]=47;
                    unset($act['setenemystatus'][46]);
                    battle_log("$enemyinfo[name]'s MO stat returned to normal.", LOG_REF);
               }
     }
     if(!in_array($eid, $enemyinfo['blockstatus'])){
                $evuln=1;
     }
     if(in_array($eid, $enemyinfo['blockstatus'])){
                $eimmune=1;
     }
     }
     if($eimmune==1 and !$evuln and $act['enemydamage']==0){
           battle_log("IMMUNE", LOG_REF);
     }

     foreach($act['setselfstatus'] as $sid => $sturns){
          foreach($charinfo['statusid'] as $sstat => $sdur){
               if($sid==15 and $sstat==14 and !$sblkatkd){
                    $act['healselfstatus'][]=14;
                    unset($act['setselfstatus'][15]);
                    battle_log("$charinfo[name]'s Atk stat returned to normal.", LOG_REF);
               }
               if($sid==14 and $sstat==15){
                    $act['healselfstatus'][]=15;
                    unset($act['setselfstatus'][14]);
                    battle_log("$charinfo[name]'s Atk stat returned to normal.", LOG_REF);
               }
               if($sid==21 and $sstat==22){
                    $act['healselfstatus'][]=22;
                    unset($act['setselfstatus'][21]);
                    battle_log("$charinfo[name]'s Def stat returned to normal.", LOG_REF);
               }
               if($sid==22 and $sstat==21 and !$sblkdefd){
                    $act['healselfstatus'][]=21;
                    unset($act['setselfstatus'][22]);
                    battle_log("$charinfo[name]'s Def stat returned to normal.", LOG_REF);
               }
               if($sid==27 and $sstat==26 and !$sblkmdd){
                    $act['healselfstatus'][]=26;
                    unset($act['setselfstatus'][27]);
                    battle_log("$charinfo[name]'s MD stat returned to normal.", LOG_REF);
               }
               if($sid==26 and $sstat==27){
                    $act['healselfstatus'][]=27;
                    unset($act['setselfstatus'][26]);
                    battle_log("$charinfo[name]'s MD stat returned to normal.", LOG_REF);
               }
               if($sid==47 and $sstat==46 and !$sblkmod){
                    $act['healselfstatus'][]=46;
                    unset($act['setselfstatus'][47]);
                    battle_log("$charinfo[name]'s MO stat returned to normal.", LOG_REF);
               }
               if($sid==46 and $sstat==47){
                    $act['healselfstatus'][]=47;
                    unset($act['setselfstatus'][46]);
                    battle_log("$charinfo[name]'s MO stat returned to normal.", LOG_REF);
               }
     }
     if(!in_array($sid, $enemyinfo['blockstatus'])){
                $svuln=1;
     }
     if(in_array($sid, $enemyinfo['blockstatus'])){
               $simmune=1;
     }
     }
     if($simmune==1 and !$svuln and $act['selfdamage']==0){
           battle_log("IMMUNE", LOG_REF);
     }
}

--The first thing in the mod is the monster's price. Just change the number after $price= to the cost of your monster. If your monster is a boss and has no cost, you can take this part out.
--The stuff in blue, you don't need to change. It just checks if the monster has Berserk, Fear, or Silence. If your monster blocks these statuses, you can leave this part out.
--The green section is very important. It determines which skill the monster uses.
---$skillused=0; tells the monster to run, so it is set only if the user is above the monster's max level or the user does't have enough gil. The only thing you will need to change is the 15 if you want to change the max level for the monster.
---$skillused=1; tells it to attack, so this is always set if the monster is berserk ($bers=1;).
---$skillused=99; tells it to defend. This is always set if the monster has Fear ($fear=1;)
---The next line is one you may have to change. $skillused=mt_rand(1,12); tells it to randomly chose a number, then each number will be assigned to a skill. You may have to change the second number (12) depending on the amount of skills your monster has.
--The purple section is the damage variables. Just like in normal skill mods, you can use anything for a variable such as $damage, $dmg, etc. Use this to set the amount of damage you want each attack to do.
---The $charinfo['limitbreak']=0; means the monster will not gain limit. If your monster has a limit, take this part out.
---$elementstatus is used for statuses caused by elemental attacks. If your monster has no elemental attacks, you can take this part out.
--The orange section is the most important and the one you will have to edit the most.
---First, start with the Run action since it will need to be top priority. The monster will run if $skillused==0; which we already set to be true if they don't have enough gil or are too high leveled.
---Next, set the monster to defend for $skillused==99; which we set to Fear before.
---Next, set the limit, if your monster has one. If not, skip this part. This will only happen if the limitbar is full ($charinfo['limitbreak']==100). Also, make sure the $charinfo['limitbreak']=0; is there to reset the limit bar and define('LIMIT_USED', 1); must be used to classify the skill as a limit.
---Now, you can set the skills. in_array($skillused, array(4,5,6)) will check which number was pulled up by the mt_rand(1,12) that we used earlier. If the number is 4, 5, or 6, it will execute this skill.
----Remember, we set attack to 1, so do not start the skills at 1. Starting them at 4 like this one will mean that it will attack if 1, 2, or 3 comes up.
----The more numbers you put in the array(), the higher the chance of this skill being used will be. So if you want the skill to be rare, only use one number like with Shockwave or Stone Gaze in this example.
----Be sure to put $noreflect=1; and $physical=1; in the physical based skills and $magic=1; in the magic based skills.
----To give the skill an element use $act['enemyatkelements']=array(7); where 7 is the element's id.
----If the skill is magic based, add !$slnc to the condition so the monster won't use the skill if it is silenced
----Always put the attack action last since it will be the default action if all other conditions are false. Do not give the attack command a condition, just use }else{, that way it will default to attack no matter what.
---The pink section will not need to be changed, but you must leave it in. It will show the immune messages and is needed for the up/dwn statuses to cancel eachother out.

Step 4: Add the bot to the bot selector
-Go into edit modifiers and look for a modifier called ((bot)) bot selector.
-Scroll all the way down to the bottom of the code and add the following piece of code between "break;" and "default:"



                    case "Monster Name":
                         $bot=999; break;

--Change Monster Name to your monster's name. Make sure it is spelled exactly the way it is on the monster.
--Change the 999 to the id of your monster's bot modifier. To find this, go in the modifiers and look for your monster's bot [should be (bot) Monster Name], then click on it and at the top it will say "Modifier: (bot) Monster Name(id: ###). The ### is the number that you put in place of 999.
-Please keep it spaced out the way the rest of them are so the code doesn't get messy.

Step 5: Set the drop/steal items and the gil or items it costs to fight the monster.
-Go into edit modifiers and look for a modifier called ((bot)) char_anihilation.
--Scroll all the way down to the bottom of the code and add the following piece of code BEFORE "$charinfo['hp']=$charinfo['hpmax'];"



if($charinfo['name']=="Monster Name"){
     $enemygil['rpgmoney']-=1200;
     if($charinfo['i1']==0){
          $inventory2->swap_equip(347,i1,$charinfo['charid'],0,0);//pupu
     }
     if($charinfo['i2']==0){
          $inventory2->swap_equip(416,i2,$charinfo['charid'],0,0);//curse scroll
     }
     if($charinfo['i3']==0){
          $inventory2->swap_equip(169,i3,$charinfo['charid'],0,0);//black ring
     }
}

---Change Monster Name to your monster's name. Make sure it is spelled exactly the way it is on the monster.
---Change the 1200 to the cost of your monster. This will subtract the cost from the user's gil.
---The $inventory2 sections are for steal items. This will equip the items back on the monster after the battle if they are stolen by the user.
----Change the numbers I have highlighted in red to the id's of the items you want to be equipped. i1 is Item Slot 1, i2 is Item slot 2, etc. Also change the item name after "//".
----You can find the item id by going to edit items and clicking on the item like you're going to edit it. At the top you will see "Edit Item (id: ###)" The ### is the item id that you replace the red number with.
----If you want to add items for Item Slots 4 and 5, copy everything from "if($charinfo['i3']==0){" down to "}" and paste it right after the "}", then change i3 to i4 in both lines. Repeat for i5.
---Please keep it spaced out the way the rest of them are so the code doesn't get messy.

-Go into edit modifiers and look for a modifier called ((bot)) enemy_anihilation.
--Scroll all the way down to the bottom of the code and add the following piece of code BEFORE "$enemyinfo['hp']=$enemyinfo['hpmax'];"


if($enemyinfo['name']=="Monster Name"){
     $bbuserinfo['rpgmoney']-=1200;
     if($enemyinfo['i1']==0){
          $inventory2->swap_equip(347,i1,$enemyinfo['charid'],0,0);//pupu
     }
     if($enemyinfo['i2']==0){
          $inventory2->swap_equip(416,i2,$enemyinfo['charid'],0,0);//curse scroll
     }
     if($enemyinfo['i3']==0){
          $inventory2->swap_equip(169,i3,$enemyinfo['charid'],0,0);//black ring
     }
}

---Change Monster Name to your monster's name. Make sure it is spelled exactly the way it is on the monster.
---Change the 1200 to the cost of your monster. This will subtract the cost from the user's gil.
---The $inventory2 sections are for steal items. This will equip the items back on the monster after the battle if they are stolen by the user.
----Change the numbers I have highlighted in red to the id's of the items you want to be equipped. i1 is Item Slot 1, i2 is Item slot 2, etc. Also change the item name after "//".
----You can find the item id by going to edit items and clicking on the item like you're going to edit it. At the top you will see "Edit Item (id: ###)" The ### is the item id that you replace the red number with.
----If you want to add items for Item Slots 4 and 5, copy everything from "if($enemyinfo['i3']==0){" down to "}" and paste it right after the "}", then change i3 to i4 in both lines. Repeat for i5.
---Please keep it spaced out the way the rest of them are so the code doesn't get messy.

-Go into edit modifiers and look for a modifier called ((bot)) char_run.
--Scroll all the way down to the bottom of the code and add the following piece of code BEFORE "$charinfo['hp']=$charinfo['hpmax'];"


if($charinfo['name']=="Monster Name"){
     if($enemygil['rpgmoney']>=1200){
          $enemygil['rpgmoney']-=1200;
     }
     if($charinfo['i1']==0){
          $inventory2->swap_equip(347,i1,$charinfo['charid'],0,0);//pupu
     }
     if($charinfo['i2']==0){
          $inventory2->swap_equip(416,i2,$charinfo['charid'],0,0);//curse scroll
     }
     if($charinfo['i3']==0){
          $inventory2->swap_equip(169,i3,$charinfo['charid'],0,0);//black ring
     }
}

---Change Monster Name to your monster's name. Make sure it is spelled exactly the way it is on the monster.
---Change the 1200 to the cost of your monster. This will subtract the cost from the user's gil.
---The $inventory2 sections are for steal items. This will equip the items back on the monster after the battle if they are stolen by the user.
----Change the numbers I have highlighted in red to the id's of the items you want to be equipped. i1 is Item Slot 1, i2 is Item slot 2, etc. Also change the item name after "//".
----You can find the item id by going to edit items and clicking on the item like you're going to edit it. At the top you will see "Edit Item (id: ###)" The ### is the item id that you replace the red number with.
----If you want to add items for Item Slots 4 and 5, copy everything from "if($charinfo['i3']==0){" down to "}" and paste it right after the "}", then change i3 to i4 in both lines. Repeat for i5.
---Please keep it spaced out the way the rest of them are so the code doesn't get messy.

-Go into edit modifiers and look for a modifier called ((bot)) enemy_run.
--Scroll all the way down to the bottom of the code and add the following piece of code BEFORE "$enemyinfo['hp']=$enemyinfo['hpmax'];"


if($enemyinfo['name']=="Monster Name"){
     if($bbuserinfo['rpgmoney']>=1200){
          $bbuserinfo['rpgmoney']-=1200;
     }
     if($enemyinfo['i1']==0){
          $inventory2->swap_equip(347,i1,$enemyinfo['charid'],0,0);//pupu
     }
     if($enemyinfo['i2']==0){
          $inventory2->swap_equip(416,i2,$enemyinfo['charid'],0,0);//curse scroll
     }
     if($enemyinfo['i3']==0){
          $inventory2->swap_equip(169,i3,$enemyinfo['charid'],0,0);//black ring
     }
}

---Change Monster Name to your monster's name. Make sure it is spelled exactly the way it is on the monster.
---Change the 1200 to the cost of your monster. This will subtract the cost from the user's gil.
---The $inventory2 sections are for steal items. This will equip the items back on the monster after the battle if they are stolen by the user.
----Change the numbers I have highlighted in red to the id's of the items you want to be equipped. i1 is Item Slot 1, i2 is Item slot 2, etc. Also change the item name after "//".
----You can find the item id by going to edit items and clicking on the item like you're going to edit it. At the top you will see "Edit Item (id: ###)" The ### is the item id that you replace the red number with.
----If you want to add items for Item Slots 4 and 5, copy everything from "if($enemyinfo['i3']==0){" down to "}" and paste it right after the "}", then change i3 to i4 in both lines. Repeat for i5.
---Please keep it spaced out the way the rest of them are so the code doesn't get messy.

-Go into edit modifiers and look for a modifier called ((bot)) char_lost bot win.
--Scroll all the way down to the bottom of the code and add the following piece of code BEFORE "$enemyinfo['hp']=$enemyinfo['hpmax'];"


if($enemyinfo['name']=="Monster Name"){
     $bbuserinfo['rpgmoney']-=1200;
     if($enemyinfo['i1']==0){
          $inventory2->swap_equip(347,i1,$enemyinfo['charid'],0,0);//pupu
     }
     if($enemyinfo['i2']==0){
          $inventory2->swap_equip(416,i2,$enemyinfo['charid'],0,0);//curse scroll
     }
     if($enemyinfo['i3']==0){
          $inventory2->swap_equip(169,i3,$enemyinfo['charid'],0,0);//black ring
     }
}

---Change Monster Name to your monster's name. Make sure it is spelled exactly the way it is on the monster.
---Change the 1200 to the cost of your monster. This will subtract the cost from the user's gil.
---The $inventory2 sections are for steal items. This will equip the items back on the monster after the battle if they are stolen by the user.
----Change the numbers I have highlighted in red to the id's of the items you want to be equipped. i1 is Item Slot 1, i2 is Item slot 2, etc. Also change the item name after "//".
----You can find the item id by going to edit items and clicking on the item like you're going to edit it. At the top you will see "Edit Item (id: ###)" The ### is the item id that you replace the red number with.
----If you want to add items for Item Slots 4 and 5, copy everything from "if($enemyinfo['i3']==0){" down to "}" and paste it right after the "}", then change i3 to i4 in both lines. Repeat for i5.
---Please keep it spaced out the way the rest of them are so the code doesn't get messy.

-Go into edit modifiers and look for a modifier called ((bot)) enemy_lost bot win.
--Scroll all the way down to the bottom of the code and add the following piece of code BEFORE "$charinfo['hp']=$charinfo['hpmax'];"


if($charinfo['name']=="Monster Name"){
     $enemygil['rpgmoney']-=1200;
     if($charinfo['i1']==0){
          $inventory2->swap_equip(347,i1,$charinfo['charid'],0,0);//pupu
     }
     if($charinfo['i2']==0){
          $inventory2->swap_equip(416,i2,$charinfo['charid'],0,0);//curse scroll
     }
     if($charinfo['i3']==0){
          $inventory2->swap_equip(169,i3,$charinfo['charid'],0,0);//black ring
     }
}

---Change Monster Name to your monster's name. Make sure it is spelled exactly the way it is on the monster.
---Change the 1200 to the cost of your monster. This will subtract the cost from the user's gil.
---The $inventory2 sections are for steal items. This will equip the items back on the monster after the battle if they are stolen by the user.
----Change the numbers I have highlighted in red to the id's of the items you want to be equipped. i1 is Item Slot 1, i2 is Item slot 2, etc. Also change the item name after "//".
----You can find the item id by going to edit items and clicking on the item like you're going to edit it. At the top you will see "Edit Item (id: ###)" The ### is the item id that you replace the red number with.
----If you want to add items for Item Slots 4 and 5, copy everything from "if($charinfo['i3']==0){" down to "}" and paste it right after the "}", then change i3 to i4 in both lines. Repeat for i5.
---Please keep it spaced out the way the rest of them are so the code doesn't get messy.

-Go into edit modifiers and look for a modifier called ((bot)) enemy_lost bot lose.
--Scroll all the way down to the bottom of the code and add the following piece of code BEFORE "$enemyinfo['hp']=$enemyinfo['hpmax'];"


     if($enemyinfo['name']=="Monster Name"){
          if(in_array($drop, array(3,4,5))){
               $botmessage = "$charinfo[name] won a Black Ring.";
               $inventory->add(169,1);
          }else
          if($drop==6){
               $botmessage = "$charinfo[name] won a PuPu Doll!";
               $inventory->add(347,1);
          }
          $bbuserinfo['rpgmoney']-=1200;
          if($enemyinfo['i1']==0){
               $inventory2->swap_equip(347,i1,$enemyinfo['charid'],0,0);//pupu
          }
          if($enemyinfo['i2']==0){
               $inventory2->swap_equip(416,i2,$enemyinfo['charid'],0,0);//curse scroll
          }
          if($enemyinfo['i3']==0){
               $inventory2->swap_equip(169,i3,$enemyinfo['charid'],0,0);//black ring
          }
     }

---Change Monster Name to your monster's name. Make sure it is spelled exactly the way it is on the monster.
---Change "Black Ring" and "PuPu Doll" to the name of the items your monster will drop. The first one (Black Ring) is the more common drop and PuPu Doll is the rare drop.
---Change the numbers I have highlighted in red to the id's of the items you want dropped.
---Change the 1200 to the cost of your monster. This will subtract the cost from the user's gil.
---The $inventory2 sections are for steal items. This will equip the items back on the monster after the battle if they are stolen by the user.
----Change the numbers I have highlighted in blue to the id's of the items you want to be equipped. i1 is Item Slot 1, i2 is Item slot 2, etc. Also change the item name after "//".
----You can find the item id by going to edit items and clicking on the item like you're going to edit it. At the top you will see "Edit Item (id: ###)" The ### is the item id that you replace the red number with.
----If you want to add items for Item Slots 4 and 5, copy everything from "if($enemyinfo['i3']==0){" down to "}" and paste it right after the "}", then change i3 to i4 in both lines. Repeat for i5.
---Please keep it spaced out the way the rest of them are so the code doesn't get messy.

-Go into edit modifiers and look for a modifier called ((bot)) char_lost bot lose.
--Scroll all the way down to the bottom of the code and add the following piece of code BEFORE "$charinfo['hp']=$charinfo['hpmax'];"


     if($charinfo['name']=="Monster Name"){
          if(in_array($drop, array(3,4,5))){
               $botmessage = "$enemyinfo[name] won a Black Ring.";
               $inventory->add(169,1);
          }else
          if($drop==6){
               $botmessage = "$enemyinfo[name] won a PuPu Doll!";
               $inventory->add(347,1);
          }
          $enemygil['rpgmoney']-=1200;
          if($charinfo['i1']==0){
               $inventory2->swap_equip(347,i1,$charinfo['charid'],0,0);//pupu
          }
          if($charinfo['i2']==0){
               $inventory2->swap_equip(416,i2,$charinfo['charid'],0,0);//curse scroll
          }
          if($charinfo['i3']==0){
               $inventory2->swap_equip(169,i3,$charinfo['charid'],0,0);//black ring
          }
     }

---Change Monster Name to your monster's name. Make sure it is spelled exactly the way it is on the monster.
---Change "Black Ring" and "PuPu Doll" to the name of the items your monster will drop. The first one (Black Ring) is the more common drop and PuPu Doll is the rare drop.
---Change the numbers I have highlighted in red to the id's of the items you want dropped.
---Change the 1200 to the cost of your monster. This will subtract the cost from the user's gil.
---The $inventory2 sections are for steal items. This will equip the items back on the monster after the battle if they are stolen by the user.
----Change the numbers I have highlighted in blue to the id's of the items you want to be equipped. i1 is Item Slot 1, i2 is Item slot 2, etc. Also change the item name after "//".
----You can find the item id by going to edit items and clicking on the item like you're going to edit it. At the top you will see "Edit Item (id: ###)" The ### is the item id that you replace the red number with.
----If you want to add items for Item Slots 4 and 5, copy everything from "if($charinfo['i3']==0){" down to "}" and paste it right after the "}", then change i3 to i4 in both lines. Repeat for i5.
---Please keep it spaced out the way the rest of them are so the code doesn't get messy.

Step 6: Assign a background to the monster (optional)
-You can set a certain background image to be used when battling your monster. This is optional. If you do not do this, the user will be able to choose the background like normal.
-Go into edit modifiers and look for a modifier called ((bot)) battle BGs.
-Scroll all the way down to the bottom of the code and add the following piece of code ABOVE "default:"



     case 581: //Monster Name
          $shopid=175; break; //Shop Name

-Change Monster Name to your monster's name and Shop Name to the name of the arena shop that your background is on.
-Change the red number to the id of your monster. This can be found by going to edit your monster in the character edit section. At the top it will say "Edit Character: Monster Name (ID: ###)". The ### is the number you will put in place of the red number.
-Change the blue number to the id of the arena shop that your background is on. This can be found by going to edit the shop in the shop edit section. At the top it will say "Add / Edit Shop (id: ###)". The ### is the number you will put in place of the blue number.

 

 

Previous | Menu