The Combat Code


Well, I never did get around to doing a lot of the technical discussion, so in case anyone is wondering how damage works... here's the entire code for the combat system.  :)

Mind you, I said that the system of "1987 accurate."  I never said once that the code was pretty.  I know just enough to be dangerous, but that usually implies that I have no ability to be efficient.  ;)


---

// ********* CONSTANTS

const user = this.subject();

const target = arguments[0];

const critical = arguments[1];

const item = this.item();

const baseValue = this.evalDamageFormula(target); // comes from damage formula in skill box

var skillid = this.item().id;

var isheal = 0;

// ********* VALUE SET

let value = 0;

$gameVariables.setValue(98, skillid);

// ********* VARIABLES

var i = 0; // counter

var temp1 = 0; // extras in case I need them

var temp2 = 0; // extras in case I need them

var damage = user.atk; // 81

var absorb = 0; // 82

if (!user.isActor()) {absorb = user.def;}

var critRate; // 83

var hitPercent; // 84

var baseEva = 48;

var evaRate; // 85

if (user.isActor()) {evaRate = target.agi;}

var hitNumber; // 87

var accuracy; // 88

var chanceToHit; // 89

var chanceToCrit; // 90

var numberNormalHits = 0; // 91

var numberCriticalHits = 0; // 92

var effect = value;

if (user.isActor())

{

var playernum = user._actorId;

var playerclass = user._classId;

var level = user.level;

if (user.isActor()) {$gameVariables.setValue(93, playernum);}

if (user.isActor()) {$gameVariables.setValue(94, playerclass);}

if (user.isActor()) {$gameVariables.setValue(95, level);}

var hitMultiplier=1;

}

var a1def = 0; var a2def = 0; var a3def = 0; var a4def = 0; // For defense rating of armors

var a1agi = 0; var a2agi = 0; var a3agi = 0; var a4agi = 0; // For agility rating of armors

var armorWeight;

var watk = 0; // Equipped Weapon's Attack Rating

var catk = user.atk; // Character's Natural Attack Power

var playerAgi;

if (user.isActor()) {playerAgi = user.agi;}

else {playerAgi = target.agi;}

// ********* SET VARIABLES IF MONSTER / ACTOR

var weapon = 0;

var armor1 = 0;

var armor2 = 0;

var armor3 = 0;

var armor4 = 0;

var armorWeight1 = 0;

var armorWeight2 = 0;

var armorWeight3 = 0;

var armorWeight4 = 0;

if (user.isActor())

{

if (user.equips()[0] != null) {weapon = user.equips()[0].id;}

}

if (target.isActor())

{

if (target.equips()[1] != null) {armor1 = target.equips()[1].id;}

if (target.equips()[2] != null) {armor2 = target.equips()[2].id;}

if (target.equips()[3] != null) {armor3 = target.equips()[3].id;}

if (target.equips()[4] != null) {armor4 = target.equips()[4].id;}

if (armor1 > 0) {a1def = $dataArmors[armor1].params[3];}

if (armor2 > 0) {a2def = $dataArmors[armor2].params[3];}

if (armor3 > 0) {a3def = $dataArmors[armor3].params[3];}

if (armor4 > 0) {a4def = $dataArmors[armor4].params[3];}

if (armor1 > 0) {a1agi = $dataArmors[armor1].params[1];}

if (armor2 > 0) {a2agi = $dataArmors[armor2].params[1];}

if (armor3 > 0) {a3agi = $dataArmors[armor3].params[1];}

if (armor4 > 0) {a4agi = $dataArmors[armor4].params[1];}

if (armor1 > 0) {armorWeight1 = $dataArmors[armor1].traits[1] * 100;}

if (armor2 > 0) {armorWeight2 = $dataArmors[armor2].traits[1] * 100;}

if (armor3 > 0) {armorWeight3 = $dataArmors[armor3].traits[1] * 100;}

if (armor4 > 0) {armorWeight4 = $dataArmors[armor4].traits[1] * 100;}

}

// *********** PHYSICAL DAMAGE

// Calculate Physical IS COMPLICATED!! MAGIC IS EASIER!

if (this.isPhysical())

{

// ********* DAMAGE RATE

if (user.isActor())

{

if (weapon > 0)

{watk = $dataWeapons[weapon].params[2];

catk = user.atk - watk;}

}

if (user.isActor())

{

if (weapon == 0)

{

if (playerclass == 3 || playerclass == 4) {damage = level * 2;}

else {damage = catk / 2;}

}

else // If there is a weapon, this is the formula.

{damage = watk + (catk / 2);

if (playerclass == 3 || playerclass == 4 || playerclass == 9 || playerclass == 10)

// for whatever reason, these guys get +1 to damage

{damage += 1;}

}

}

if (damage > 255) {damage = 255;}

if (user.isActor()) {$gameVariables.setValue(81, damage);}

// ********* ABSORB RATE

absorb += a1def + a2def + a3def + a4def;

if (absorb == 0)

{if (user.isActor())

{

if (playerclass == 3 || playerclass == 4)

{absorb = level;}

}

}

if (user.isActor()) {$gameVariables.setValue(82, absorb);}

// ********* CRITICAL RATE

if (weapon == 0)

{if (user.isActor())

{

if (playerclass == 3 || playerclass == 4)

{critRate = level * 2;}

else

{critRate = 0;}

}

}

else

{if (user.isActor())

{

critRate = weapon;

}

}

// ********* HIT %

if (user.isActor())

{

hitPercent = user.hitPer;

if (weapon > 0)

{

hitPercent += $dataWeapons[weapon].traits[1].value * 100;

}

}

// ********* EVASION RATE

armorWeight = armorWeight1 + armorWeight2 + armorWeight3 + armorWeight4;

// armorWeight should be a negative number when all is said and done

// which means adding it to the evaRate instead of subtracting

if (target.isActor())

{

evaRate = baseEva + playerAgi + armorWeight;

if (target == $gameParty.members()[0]) {evaRate += $gameVariables.value(130);}

if (target == $gameParty.members()[1]) {evaRate += $gameVariables.value(131);}

if (target == $gameParty.members()[2]) {evaRate += $gameVariables.value(132);}

if (target == $gameParty.members()[3]) {evaRate += $gameVariables.value(133);}

}

// *********** POSSIBLE NUMBER OF HITS

if (user.isStateAffected(48)) {hitMultiplier = 2;}

hitNumber = (1 + (hitPercent / 32)) * hitMultiplier;

if (weapon == 0)

{

if (playerclass == 3 || playerclass == 4)

{

hitNumber *= 2;

}

}

if (hitNumber == 0)

{

hitNumber = 1;

}

// *********** ACCURACY

accuracy = 168;

if (target.isActor()) {accuracy+=user.luk;}

if (target.isStateAffected(4))

{accuracy += 40;}

if (target.isStateAffected(47))

{accuracy -= 20;}

if (user.isStateAffected(4))

{accuracy -= 40;}

if (user.isStateAffected(5) || user.isStateAffected(6))

{chanceToHit = accuracy;}

else {

chanceToHit = accuracy + hitPercent;

if (chanceToHit > 255) {chanceToHit = 255;}

chanceToHit -= evaRate;

}

i = 0;

if (user.isActor())

{

while (i < hitNumber)

{

temp1 = Math.floor(Math.random() * 201);

if (temp1 == 200) {numberNormalHits = numberNormalHits;}

else if (temp1 == 0) {numberNormalHits++;}

else {

if (chanceToHit >= temp1) {numberNormalHits++;}

}

i++;

}

// *********** CRITICAL HITS

i = 0;

temp1 = 0;

temp2 = numberNormalHits;

chanceToCrit = weapon;

while (i < temp2)

{

temp1 = Math.floor(Math.random() * 201);

if (temp1 == 200) {numberCriticalHits = numberCriticalHits;}

else if (temp1 == 0) {numberCriticalHits++;

numberNormalHits--;}

else {

if (chanceToCrit > temp1)

{numberNormalHits--;

numberCriticalHits++;}

}

i++;

}

if (numberCriticalHits>0) {target.result().critical = true;}

if (numberNormalHits == 0 && numberCriticalHits == 0) {target.result().missed = true; return (null);}

}

// ************** APPLY HITS

i = 0;

var tempvalue=0;

if (user.isActor())

{

while (i < numberNormalHits)

{

temp1 = damage + (Math.floor(Math.random() * damage)) + 1;

tempvalue = temp1 - target.def;

if (tempvalue <= 0) {tempvalue=1;}

value += tempvalue;

i++;

}

if (user.isStateAffected(25))

{numberNormalHits--;}

i = 0;

while (i < numberCriticalHits)

{

temp1 = damage + (Math.floor(Math.random() * damage)) + 1;

temp1 += temp1;

tempvalue = temp1 - target.def;

if (tempvalue <= 0) {tempvalue=1;}

value += tempvalue;

i++;

}

}

i=0;

if (target.isActor())

{

hitNumber = user.mat;

numberNormalHits = 0;

i=0;

chanceToHit=accuracy-evaRate;

if (chanceToHit>255) {chanceToHit=255;}

if (user.isStateAffected(25))

{if (hitNumber <= 1) {hitNumber=1;} else {hitNumber--;}}

while (i < hitNumber)

{

temp1 = Math.floor(Math.random() * 201);

if (temp1 == 200) {numberNormalHits = numberNormalHits;}

else if (chanceToHit <= temp1) {numberNormalHits = numberNormalHits;}

else {numberNormalHits++;}

i++;

}

if (numberNormalHits == 0) {target.result().missed = true; return (null);}

i=0;

while (i < numberNormalHits)

{

damage = user.atk;

temp1 = Math.floor(Math.random() * damage);

tempvalue = damage + temp1 - target.def;

if (tempvalue <= 0) {tempvalue=1;}

value += tempvalue;

i++;

}

}

i=0;

if (!user.isActor())

{

var inflictChance=100-target.mdf;

if (user.states().includes($dataStates[38]) && (target.states().includes($dataStates[23]) || target.states().includes($dataStates[27]))) {inflictChance-=100;}

if (user.states().includes($dataStates[39]) && (target.states().includes($dataStates[24]) || target.states().includes($dataStates[27]))) {inflictChance-=100;}

if (user.states().includes($dataStates[40]) && (target.states().includes($dataStates[25]) || target.states().includes($dataStates[27]))) {inflictChance-=100;}

if (user.states().includes($dataStates[41]) && (target.states().includes($dataStates[26]) || target.states().includes($dataStates[27]))) {inflictChance-=100;}

if (user.states().includes($dataStates[43]) && (target.states().includes($dataStates[28]) || target.states().includes($dataStates[27]))) {inflictChance-=100;}

if (user.states().includes($dataStates[44]) && (target.states().includes($dataStates[45]) || target.states().includes($dataStates[27]))) {inflictChance-=100;}

while (i < numberNormalHits)

{

temp1 = Math.floor(Math.random() * 201);

if (temp1 == 200) {}

else if (temp1 <= inflictChance)

{

if (user.states().includes($dataStates[38])) {if (!target.isStateAffected(1)) {target.addState(1);}}

else if (user.states().includes($dataStates[39])) {if (!target.isStateAffected(2)) {target.addState(2);}}

else if (user.states().includes($dataStates[40])) {if (!target.isStateAffected(3)) {target.addState(3);}}

else if (user.states().includes($dataStates[41])) {if (!target.isStateAffected(6)) {target.addState(6);}}

else if (user.states().includes($dataStates[43])) {if (!target.isStateAffected(5)) {target.addState(5);}}

else if (user.states().includes($dataStates[44])) {if (!target.isStateAffected(4)) {target.addState(4);}}

}

i++;

}

}

// *********** RETURN VALUE AND ATTACK

}

i = 0;

// *********** MAGICAL DAMAGE

// Calculate Magical ... this is much easier.

if (this.isMagical()) {

accuracy = 0;

var basechance=148;

var isdeath=0;

var issleep=0;

var ispetrify=0;

var ispara=0;

var ispoison=0;

var ismute=0;

var isblind=0;

var isconf=0;

var isfear=0;

var fearresist=0;

var isevade=0;

//player magic starts at 12;

if (user.isActor()) {

skillid -= 11;

if (skillid == 1 || skillid == 108 || skillid == 174) {isheal = 1; if ($gameParty.inBattle()) {value=baseValue;} else {value = 16 + (Math.floor(Math.random()*15)); value *= -1;}} // CURE1

if (skillid == 2 || skillid == 109 || skillid == 175) {accuracy = 24; value = baseValue;} // HARM

if (skillid == 3 || skillid == 110 || skillid == 176) {} // FOG - DEFENSE UP // BROKEN

if (skillid == 4 || skillid == 111 || skillid == 177 || skillid == 70) {isevade=1; value=baseValue;} // RUSE - EVASION UP

if (skillid == 5 || skillid == 112 || skillid == 178) {} // ALIT - RESIST LIT

if (skillid == 6 || skillid == 113 || skillid == 179) {isevade=1; value=baseValue;} // INVISIBLE - EVASION UP

if (skillid == 7 || skillid == 114 || skillid == 180) {} // LAMP - REMOVE BLIND

if (skillid == 8 || skillid == 115 || skillid == 181) {ismute=1; if(target.states().includes($dataStates[22]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 64;} // MUTE - INFLICT SILENCE

if (skillid == 9 || skillid == 116 || skillid == 182) {isheal = 1; if ($gameParty.inBattle()) {value=baseValue;} else {value = 32 + (Math.floor(Math.random()*31)); value *= -1;}} // CURE2

if (skillid == 10 || skillid == 117 || skillid == 183) {} // AFIR - RESIST FIRE

if (skillid == 11 || skillid == 118 || skillid == 184 || skillid == 68 || skillid == 75) {isheal = 1; if ($gameParty.inBattle()) {value=baseValue;} else {value = 16 + (Math.floor(Math.random()*7)); value *= -1;}} // HEAL

if (skillid == 12 || skillid == 119 || skillid == 185 || skillid == 67) {accuracy = 24; value = baseValue;} // HARM 2

if (skillid == 13 || skillid == 120) {} // PURE

if (skillid == 14 || skillid == 121) {value=baseValue; accuracy = 24; if (target.states().includes($dataStates[52])) {isfear=1;}} // FEAR - MORALE DOWN

if (skillid == 15 || skillid == 122) {} // AICE - RESIST ICE

if (skillid == 16 || skillid == 123) {} // AMUTE - REMOVE MUTE

if (skillid == 17 || skillid == 124) {isheal = 1; if ($gameParty.inBattle()) {value=baseValue;} else {value = 64 + (Math.floor(Math.random()*63)); value *= -1;}} // CURE3

if (skillid == 18 || skillid == 125) {isheal = 1; if ($gameParty.inBattle()) {value=baseValue;} else {value = 32 + (Math.floor(Math.random()*15)); value *= -1;}} // HEAL 2

if (skillid == 19 || skillid == 126) {accuracy = 24; value = baseValue;} // HARM 3

if (skillid == 20 || skillid == 127) {accuracy = 255;} // LIFE

if (skillid == 21 || skillid == 128) {accuracy = 255;} // EXIT

if (skillid == 22 || skillid == 129) {} // FOG2 - DEFENSE UP

if (skillid == 23 || skillid == 130 || skillid == 77) {isevade=1; value=baseValue;} // INVS 2 - EVASION UP

if (skillid == 24 || skillid == 131) {accuracy = 255;} // SOFT - REMOVE STONE

if (skillid == 25 || skillid == 132) {} // ARUB - RESIST SLEEP/PARA/???

if (skillid == 26 || skillid == 133) {isheal = 1; if ($gameParty.inBattle()) {value=baseValue;} else {value = -9999;}} // CURE4

if (skillid == 27 || skillid == 134) {isheal = 1; if ($gameParty.inBattle()) {value=baseValue;} else {value = 64 + (Math.floor(Math.random()*34)); value *= -1;}} // HEAL 3

if (skillid == 28 || skillid == 135) {accuracy = 48; value = baseValue;} // HARM4

if (skillid == 29 || skillid == 136) {value=baseValue; accuracy = 107;} // FADE

if (skillid == 30 || skillid == 137) {accuracy = 255;} // LIFE 2

if (skillid == 31 || skillid == 138) {} // WALL - RESIST ALL ELEMENTS

if (skillid == 32 || skillid == 139) {accuracy = 107;} // XFER - REMOVE RESIST, ALSO BROKEN

if (skillid == 34 || skillid == 141 || skillid == 187) {value=baseValue;} // FIRE1

if (skillid == 35 || skillid == 142 || skillid == 188) {accuracy = 24; value = baseValue;} // LIT1

if (skillid == 36 || skillid == 143 || skillid == 189) {} // LOCK - BROKEN

if (skillid == 37 || skillid == 144 || skillid == 190) {issleep=1; if(target.states().includes($dataStates[26]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 24;} // SLEP

if (skillid == 38 || skillid == 145 || skillid == 191) {isblind=1; if(target.states().includes($dataStates[45]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 24;} // DARK

if (skillid == 39 || skillid == 146 || skillid == 192) {value=baseValue;} // ICE1

if (skillid == 40 || skillid == 147 || skillid == 193) {target.addState(47);} // SLOW

if (skillid == 41 || skillid == 148 || skillid == 194) {} // TMPR - BROKEN

if (skillid == 42 || skillid == 149 || skillid == 195 || skillid == 69) {value=baseValue;} // FIR2

if (skillid == 43 || skillid == 150 || skillid == 196 || skillid == 71 || skillid == 78) {value=baseValue;} // LIT2

if (skillid == 44 || skillid == 151 || skillid == 197) {} // LOK2 - HELPS ENEMIES

if (skillid == 45 || skillid == 152 || skillid == 198) {ispara=1; if(target.states().includes($dataStates[28]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 64;} // HOLD

if (skillid == 46 || skillid == 153 || skillid == 199 || skillid == 76) {value=baseValue;} // ICE2

if (skillid == 47 || skillid == 154 || skillid == 200) {issleep=1; if(target.states().includes($dataStates[26]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 64;} // SLP2

if (skillid == 48 || skillid == 155 || skillid == 201 || skillid == 72) {isconf=1; accuracy=64;} // CONF

if (skillid == 49 || skillid == 156 || skillid == 202) {target.addState(48);} // FAST - TOTALLY WORTH IT

if (skillid == 50 || skillid == 157) {value=baseValue;} // FIR3

if (skillid == 51 || skillid == 158) {} // SLO2

if (skillid == 52 || skillid == 159 || skillid == 73) {isdeath=1; value = baseValue; accuracy = 40; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;}} // BANE

if (skillid == 53 || skillid == 160) {} // WARP

if (skillid == 54 || skillid == 161) {value=baseValue;} // LIT3

if (skillid == 55 || skillid == 162) {isdeath=1; value=baseValue; accuracy=40; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;}} // QAKE

if (skillid == 56 || skillid == 163) {isdeath=1; value=baseValue; accuracy=24; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;}} // RUB

if (skillid == 57 || skillid == 164) {ispara=1; if(target.states().includes($dataStates[28]) || target.states().includes($dataStates[27])) {basechance=0;} if (target.hp <= 300) {accuracy = 200;} else {accuracy=0;}} // STUN

if (skillid == 58 || skillid == 165) {value=baseValue;} // ICE3

if (skillid == 59 || skillid == 166) {isblind=1; if(target.states().includes($dataStates[45]) || target.states().includes($dataStates[27])) {basechance=0;} if (target.hp <= 300) {accuracy = 200;} else {accuracy=0;}} // BLND

if (skillid == 60 || skillid == 167 || skillid == 79) {} // SABR - BROKEN

if (skillid == 61 || skillid == 168) {ispetrify=1; if(target.states().includes($dataStates[24]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy=64;} // BRAK

if (skillid == 62 || skillid == 169) {value=baseValue;} // NUKE

if (skillid == 63 || skillid == 170) {ispara=1; if(target.states().includes($dataStates[28]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 48;} // STOP

if (skillid == 64 || skillid == 171) {isdeath=1; accuracy=200; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;}} // XXXX

if (skillid == 65 || skillid == 172) {isdeath=1; accuracy=32; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;}} // ZAP!

if (skillid == 204 || skillid == 272) {value=baseValue;} // HADO

// SPELL ACCURACY

if (skillid == 29 || skillid == 136) {accuracy = 107;} // FADE

if (skillid == 2 || skillid == 109 || skillid == 175) {accuracy = 24;} // HARM

if (skillid == 12 || skillid == 119 || skillid == 185) {accuracy = 24;} // HARM2

if (skillid == 19 || skillid == 126) {accuracy = 24;} // HARM3

if (skillid == 28 || skillid == 135) {accuracy = 48;} // HARM4

if (skillid == 34 || skillid == 141 || skillid == 187) {accuracy = 24; if(target.states().includes($dataStates[31])) {basechance = 0;} if(target.states().includes($dataStates[35])) {accuracy += 40;}} // FIRE1

if (skillid == 35 || skillid == 142 || skillid == 188) {accuracy = 24; if(target.states().includes($dataStates[30])) {basechance = 0;} if(target.states().includes($dataStates[34])) {accuracy += 40;}} // LIT1

if (skillid == 39 || skillid == 146 || skillid == 192) {accuracy = 24; if(target.states().includes($dataStates[32])) {basechance = 0;} if(target.states().includes($dataStates[36])) {accuracy += 40;}} // ICE1

if (skillid == 42 || skillid == 149 || skillid == 195) {accuracy = 24; if(target.states().includes($dataStates[31])) {basechance = 0;} if(target.states().includes($dataStates[35])) {accuracy += 40;}} // FIR2

if (skillid == 43 || skillid == 150 || skillid == 196) {accuracy = 24; if(target.states().includes($dataStates[30])) {basechance = 0;} if(target.states().includes($dataStates[34])) {accuracy += 40;}} // LIT2

if (skillid == 46 || skillid == 153 || skillid == 199) {accuracy = 24; if(target.states().includes($dataStates[32])) {basechance = 0;} if(target.states().includes($dataStates[36])) {accuracy += 40;}} // ICE2

if (skillid == 50 || skillid == 157) {accuracy = 24; if(target.states().includes($dataStates[31])) {basechance = 0;} if(target.states().includes($dataStates[35])) {accuracy += 40;}} // FIR3

if (skillid == 54 || skillid == 161) {accuracy = 24; if(target.states().includes($dataStates[30])) {basechance = 0;} if(target.states().includes($dataStates[34])) {accuracy += 40;}} // LIT3

if (skillid == 58 || skillid == 165) {accuracy = 24; if(target.states().includes($dataStates[32])) {basechance = 0;} if(target.states().includes($dataStates[36])) {accuracy += 40;}} // ICE3

if (skillid == 62 || skillid == 169) {accuracy=107;} // NUKE

if (skillid == 204 || skillid == 272) {accuracy=107;} // HADO

if (isevade==1)

{

if (target == $gameParty.members()[0]) {$gameVariables.setValue(130, ($gameVariables.value(130)+value));}

if (target == $gameParty.members()[1]) {$gameVariables.setValue(131, ($gameVariables.value(131)+value));}

if (target == $gameParty.members()[2]) {$gameVariables.setValue(132, ($gameVariables.value(132)+value));}

if (target == $gameParty.members()[3]) {$gameVariables.setValue(133, ($gameVariables.value(133)+value));}

}

i = basechance+accuracy-target.mdf;

temp1 = Math.floor(Math.random() * 201);

if (temp1 == 200) {value = value;}

else if (temp1 == 0 || temp1 <= i)

{

if (isdeath ==1) {target.addState(42);}

else if (issleep ==1) {target.addState(6);}

else if (ismute ==1) {target.addState(7);}

else if (isblind ==1) {target.addState(4);}

else if (ispara ==1) {target.addState(5);}

else if (isconf ==1) {target.addState(8);}

else if (ispetrify ==1) {target.addState(2);}

else {value *= 2;}

}

}

else {

if (skillid == 92) {accuracy = 32; if(target.states().includes($dataStates[20])) {basechance = 0;}} // SCORCH - FIRE

if (skillid == 93) {accuracy = 32; if(target.states().includes($dataStates[20])) {basechance = 0;}} // HEAT - FIRE ATTACK

if (skillid == 94) {accuracy = 32; if(target.states().includes($dataStates[20])) {basechance = 0;}} // CREMATE - FIRE ATTACK

if (skillid == 95) {accuracy = 32; if(target.states().includes($dataStates[20])) {basechance = 0;}} // BLAZE - FIRE ATTACK

if (skillid == 96) {accuracy = 32; if(target.states().includes($dataStates[20])) {basechance = 0;}} // INFERNO - FIRE ATTACK

if (skillid == 97) {accuracy = 32; if(target.states().includes($dataStates[21])) {basechance = 0;}} // FROST - ICE ATTACK

if (skillid == 98) {accuracy = 32; if(target.states().includes($dataStates[21])) {basechance = 0;}} // BLIZZARD - ICE ATTACK

if (skillid == 99) {accuracy = 32; if(target.states().includes($dataStates[19])) {basechance = 0;}} // THUNDER - DAMAGE

if (skillid == 100) {accuracy = 32;} // POISON - DAMAGE

if (skillid == 101) {accuracy = 24;} // STARE - DAMAGE

if (skillid == 102) {accuracy = 32;} // SWIRL - DAMAGE

if (skillid == 103) {accuracy = 32;} // TORNADO - DAMAGE

if (skillid == 104) {accuracy = 48;} // NUCLEAR - DAMAGE

if (skillid == 105) {ispetrify=1; if(target.states().includes($dataStates[24]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 5;} // GLANCE - PETRIFY

if (skillid == 106) {ispara=1; if(target.states().includes($dataStates[28]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 200;} // GAZE - PARALYZE

if (skillid == 107) {isblind=1; if(target.states().includes($dataStates[45]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 24;} // FLASH - BLIND

if (skillid == 108) {isdeath=1; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 16;} // CRACK - DEATH

if (skillid == 109) {isdeath=1; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 200;} // SQUINT - DEATH

if (skillid == 110) {isdeath=1; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 16;} // GLARE - DEATH

if (skillid == 111) {ispetrify=1; if(target.states().includes($dataStates[24]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 5;} // POISON

if (skillid == 112) {ispara=1; if(target.states().includes($dataStates[28]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 200;} // TRANCE - PARALYZE

if (skillid == 113) {isdeath=1; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 200;} // TOXIC - DEATH

if (skillid == 114) {isblind=1; if(target.states().includes($dataStates[45]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 24;} // SNORTING - BLIND

if (skillid == 115) {ispoison=1; if(target.states().includes($dataStates[25]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 200;} // STINGER - POISON

if (skillid == 116) {isblind=1; if(target.states().includes($dataStates[45]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 24;} // INK - BLIND

if (skillid == 117) {ispara=1; if(target.states().includes($dataStates[28]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 32;} // DAZZLE - PARALYZE

if (skillid == 217) {isheal = 1; value=baseValue;} // CURE1

if (skillid == 218) {value = baseValue;} // HARM

if (skillid == 219) {} // FOG - DEFENSE UP // BROKEN

if (skillid == 220) {} // RUSE - EVASION UP

if (skillid == 221) {} // ALIT - RESIST LIT

if (skillid == 222) {} // INVISIBLE - EVASION UP

if (skillid == 223) {} // LAMP - REMOVE BLIND

if (skillid == 224) {ismute=1; if(target.states().includes($dataStates[22]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 64;} // MUTE - INFLICT SILENCE

if (skillid == 225) {isheal = 1; value=baseValue;} // CURE2

if (skillid == 226) {} // AFIR - RESIST FIRE

if (skillid == 227) {isheal = 1; value=baseValue;} // HEAL

if (skillid == 228) {accuracy = 24; value = baseValue;} // HARM 2

if (skillid == 229) {} // PURE

if (skillid == 230) {accuracy = 24;} // FEAR - MORALE DOWN <- CRAP

if (skillid == 231) {} // AICE - RESIST ICE

if (skillid == 232) {} // AMUTE - REMOVE MUTE

if (skillid == 233) {isheal = 1; value=baseValue;} // CURE3

if (skillid == 234) {isheal = 1; value=baseValue;} // HEAL 2

if (skillid == 235) {accuracy = 24; value = baseValue;} // HARM 3

if (skillid == 236) {accuracy = 255;} // LIFE

if (skillid == 237) {accuracy = 255;} // EXIT

if (skillid == 238) {} // FOG2 - DEFENSE UP

if (skillid == 239) {} // INVS 2 - EVASION UP

if (skillid == 240) {accuracy = 255;} // SOFT - REMOVE STONE

if (skillid == 241) {} // ARUB - RESIST SLEEP/PARA/???

if (skillid == 242) {isheal = 1; value=baseValue;} // CURE4

if (skillid == 243) {isheal = 1; value=baseValue;} // HEAL 3

if (skillid == 244) {accuracy = 48; value = baseValue;} // HARM4

if (skillid == 245) {accuracy = 107;} // FADE

if (skillid == 246) {accuracy = 255;} // LIFE 2

if (skillid == 247) {} // WALL - RESIST ALL ELEMENTS

if (skillid == 248) {accuracy = 107;} // XFER - REMOVE RESIST, ALSO BROKEN

if (skillid == 250) {value=baseValue;} // FIRE1

if (skillid == 251) {value = baseValue;} // LIT1

if (skillid == 252) {} // LOCK - BROKEN

if (skillid == 253) {issleep=1; if(target.states().includes($dataStates[26]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 24;} // SLEP

if (skillid == 254) {isblind=1; if(target.states().includes($dataStates[45]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 24;} // DARK

if (skillid == 255) {value=baseValue;} // ICE1

if (skillid == 256) {target.addState(47);} // SLOW

if (skillid == 257) {} // TMPR - BROKEN

if (skillid == 258) {value=baseValue;} // FIR2

if (skillid == 259) {value=baseValue;} // LIT2

if (skillid == 260) {} // LOK2 - HELPS ENEMIES

if (skillid == 261) {ispara=1; if(target.states().includes($dataStates[28]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 64;} // HOLD

if (skillid == 262) {value=baseValue;} // ICE2

if (skillid == 263) {issleep=1; if(target.states().includes($dataStates[26]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 64;} // SLP2

if (skillid == 264) {} // CONF

if (skillid == 265) {} // FAST - TOTALLY WORTH IT

if (skillid == 266) {value=baseValue;} // FIR3

if (skillid == 267) {target.addState(47);} // SLO2

if (skillid == 268) {isdeath=1; value = baseValue; accuracy = 40; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;}} // BANE

if (skillid == 269) {} // WARP

if (skillid == 270) {value=baseValue;} // LIT3

if (skillid == 271) {isdeath=1; value=baseValue; accuracy=40; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;}} // QAKE

if (skillid == 272) {isdeath=1; value=baseValue; accuracy=24; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;}} // RUB

if (skillid == 273) {ispara=1; if(target.states().includes($dataStates[28]) || target.states().includes($dataStates[27])) {basechance=0;} if (target.hp <= 300) {accuracy = 200;} else {accuracy=0;}} // STUN

if (skillid == 274) {value=baseValue;} // ICE3

if (skillid == 275) {isblind=1; if(target.states().includes($dataStates[45]) || target.states().includes($dataStates[27])) {basechance=0;} if (target.hp <= 300) {accuracy = 200;} else {accuracy=0;}} // BLND

if (skillid == 276) {} // SABR - BROKEN

if (skillid == 277) {ispetrify=1; if(target.states().includes($dataStates[24]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy=64;} // BRAK

if (skillid == 278) {value=baseValue;} // NUKE

if (skillid == 279) {ispara=1; if(target.states().includes($dataStates[28]) || target.states().includes($dataStates[27])) {basechance=0;} accuracy = 48;} // STOP

if (skillid == 280) {isdeath=1; accuracy=200; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;}} // XXXX

if (skillid == 281) {isdeath=1; accuracy=32; if(target.states().includes($dataStates[23]) || target.states().includes($dataStates[27])) {basechance=0;}} // ZAP!

if (skillid == 250) {accuracy = 24; if(target.states().includes($dataStates[20])) {basechance = 0;}} // FIRE1

if (skillid == 251) {accuracy = 24; if(target.states().includes($dataStates[19])) {basechance = 0;}} // LIT1

if (skillid == 255) {accuracy = 24; if(target.states().includes($dataStates[21])) {basechance = 0;}} // ICE1

if (skillid == 258) {accuracy = 24; if(target.states().includes($dataStates[20])) {basechance = 0;}} // FIR2

if (skillid == 259) {accuracy = 24; if(target.states().includes($dataStates[19])) {basechance = 0;}} // LIT2

if (skillid == 262) {accuracy = 24; if(target.states().includes($dataStates[21])) {basechance = 0;}} // ICE2

if (skillid == 266) {accuracy = 24; if(target.states().includes($dataStates[20])) {basechance = 0;}} // FIR3

if (skillid == 270) {accuracy = 24; if(target.states().includes($dataStates[19])) {basechance = 0;}} // LIT3

if (skillid == 274) {accuracy = 24; if(target.states().includes($dataStates[21])) {basechance = 0;}} // ICE3

if (skillid == 278) {accuracy=107;} // NUKE

if (skillid == 285) {accuracy=255;} // BDUP

value = baseValue;

i = basechance+accuracy-target.mdf;

temp1 = Math.floor(Math.random() * 201);

if (temp1 == 200) {value = value;}

else if (temp1 == 0 || temp1 <= i)

{

if (isdeath ==1) {target.addState(42);}

else if (issleep ==1) {target.addState(6);}

else if (ismute ==1) {target.addState(7);}

else if (isblind ==1) {target.addState(4);}

else if (ispara ==1) {target.addState(5);}

else if (isconf ==1) {target.addState(8);}

else if (ispetrify ==1) {target.addState(2);}

else if (ispoison ==1) {target.addState(3);}

}

i = basechance+accuracy-target.mdf;

temp1 = Math.floor(Math.random() * 201);

if (temp1 == 200) {value = value;}

else if (temp1 == 0 || temp1 <= i) {value *= 2;}

// *********** RETURN VALUE AND CAST DAMAGE

}

value *= this.calcElementRate(target);

}

if (isheal == 1) {return (value *= 1);}

else if (isheal == 0) {if (value < 0) {value = 1;}}

value = Math.round(value);

if (value <= 0) {value=1;}

if (isfear==1 || isevade==1) {return (null);}

return value;

Files

Memeal Mantasy Wun for Web Browsers Play in browser
Jun 30, 2021
Memeal Mantasy Wun for MacOS 329 MB
Jun 12, 2021
Memeal Mantasy Wun for Windows 285 MB
Jun 12, 2021

Get Memeal Mantasy Wun

Leave a comment

Log in with itch.io to leave a comment.