From 07db857bf8841f4bc39b6a076922a728d2b6516b Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 2 Dec 2019 23:57:48 -0500 Subject: [PATCH] v0.8.0: formalized cases where attacks should always miss or always hit --- .../shatteredpixeldungeon/actors/Char.java | 20 ++++++++++++++++--- .../actors/buffs/Combo.java | 10 ++++++++++ .../actors/mobs/Monk.java | 6 +++--- .../actors/mobs/npcs/Blacksmith.java | 2 +- .../actors/mobs/npcs/Ghost.java | 2 +- .../actors/mobs/npcs/Imp.java | 2 +- .../actors/mobs/npcs/RatKing.java | 2 +- .../actors/mobs/npcs/Sheep.java | 2 +- .../actors/mobs/npcs/Wandmaker.java | 2 +- .../messages/actors/actors.properties | 8 ++++---- 10 files changed, 40 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index 040f8e590..4d794a8b9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -315,13 +315,27 @@ public abstract class Char extends Actor { } } - + + public static int INFINITE_ACCURACY = 1_000_000; + public static int INFINITE_EVASION = 1_000_000; + public static boolean hit( Char attacker, Char defender, boolean magic ) { - float acuRoll = Random.Float( attacker.attackSkill( defender ) ); + float acuStat = attacker.attackSkill( defender ); + float defStat = defender.defenseSkill( attacker ); + + //if accuracy or evasion are large enough, treat them as infinite. + //note that infinite evasion beats infinite accuracy + if (defStat >= INFINITE_EVASION){ + return false; + } else if (acuStat >= INFINITE_ACCURACY){ + return true; + } + + float acuRoll = Random.Float( acuStat ); if (attacker.buff(Bless.class) != null) acuRoll *= 1.25f; if (attacker.buff( Hex.class) != null) acuRoll *= 0.8f; - float defRoll = Random.Float( defender.defenseSkill( attacker ) ); + float defRoll = Random.Float( defStat ); if (defender.buff(Bless.class) != null) defRoll *= 1.25f; if (defender.buff( Hex.class) != null) defRoll *= 0.8f; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Combo.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Combo.java index f1558d5e4..f907bfe9b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Combo.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Combo.java @@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator; @@ -207,6 +208,15 @@ public class Combo extends Buff implements ActionIndicator.Action { AttackIndicator.target(enemy); + if (enemy.defenseSkill(target) >= Char.INFINITE_EVASION){ + enemy.sprite.showStatus( CharSprite.NEUTRAL, enemy.defenseVerb() ); + Sample.INSTANCE.play(Assets.SND_MISS); + detach(); + ActionIndicator.clearAction(Combo.this); + ((Hero)target).spendAndNext(((Hero)target).attackDelay()); + return; + } + int dmg = target.damageRoll(); //variance in damage dealt diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Monk.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Monk.java index b514f7fae..489691d39 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Monk.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Monk.java @@ -104,10 +104,10 @@ public class Monk extends Mob { @Override public int defenseSkill( Char enemy ) { - if (buff(Focus.class) != null){ - return 100_000_000; + if (buff(Focus.class) != null && paralysed == 0 && state != SLEEPING){ + return INFINITE_EVASION; } - return 0; //testing + return super.defenseSkill( enemy ); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java index 156232bfb..8a1650dda 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java @@ -243,7 +243,7 @@ public class Blacksmith extends NPC { @Override public int defenseSkill( Char enemy ) { - return 100_000_000; + return INFINITE_EVASION; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java index 610005bf0..c4b137f77 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java @@ -81,7 +81,7 @@ public class Ghost extends NPC { @Override public int defenseSkill( Char enemy ) { - return 100_000_000; + return INFINITE_EVASION; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Imp.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Imp.java index d9efde62b..49950a3fb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Imp.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Imp.java @@ -72,7 +72,7 @@ public class Imp extends NPC { @Override public int defenseSkill( Char enemy ) { - return 100_000_000; + return INFINITE_EVASION; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/RatKing.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/RatKing.java index e69be108d..6722a1197 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/RatKing.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/RatKing.java @@ -37,7 +37,7 @@ public class RatKing extends NPC { @Override public int defenseSkill( Char enemy ) { - return 100_000_000; + return INFINITE_EVASION; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Sheep.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Sheep.java index 208b0c158..47731f07e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Sheep.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Sheep.java @@ -58,7 +58,7 @@ public class Sheep extends NPC { @Override public int defenseSkill(Char enemy) { - return 100_000_000; + return INFINITE_EVASION; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java index 663b2dbdb..fb18c6fbc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java @@ -66,7 +66,7 @@ public class Wandmaker extends NPC { @Override public int defenseSkill( Char enemy ) { - return 100_000_000; + return INFINITE_EVASION; } @Override diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties index 6f3ed9636..a14ee9bd8 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties @@ -39,7 +39,7 @@ actors.blobs.waterofhealth.desc=Power of health radiates from the water of this actors.blobs.wateroftransmutation.desc=Power of change radiates from the water of this well. Throw an item into the well to turn it into something else. -actors.blobs.web.desc=A thick web is covering everything here. Anything that touches or is thrown though the web will break it, but will also be stuck in place. +actors.blobs.web.desc=A thick web is covering everything here. Anything that touches or is thrown through the web will break it, but will also be stuck in place. @@ -504,7 +504,7 @@ actors.mobs.fetidrat.name=fetid rat actors.mobs.fetidrat.desc=Something is clearly wrong with this rat. Its greasy black fur and rotting skin are very different from the healthy rats you've seen previously. Its pale green eyes make it seem especially menacing.\n\nThe rat carries a cloud of horrible stench with it, it's overpoweringly strong up close.\n\nDark ooze dribbles from the rat's mouth, it eats through the floor but seems to dissolve in water. actors.mobs.ghoul.name=dwarven ghoul -actors.mobs.ghoul.desc=As dwarven society slowly began to collapse, and the current king of the dwarves siezed absolute power, those who were weak or who resisted him were not treated well. As the king grew more adept at weilding dark magic, he bent these dwarves to his will, and now they make up the footsoldiers of his army.\n\nGhouls are not especially strong on their own, but always travel in groups, attempting to overwhelm their opponent with greater numbers. +actors.mobs.ghoul.desc=As dwarven society slowly began to collapse, and the current king of the dwarves seized absolute power, those who were weak or who resisted him were not treated well. As the king grew more adept at weilding dark magic, he bent these dwarves to his will, and now they make up the footsoldiers of his army.\n\nGhouls are not especially strong on their own, but always travel in groups, attempting to overwhelm their opponent with greater numbers. actors.mobs.gnoll.name=gnoll scout actors.mobs.gnoll.desc=Gnolls are hyena-like humanoids. They dwell in sewers and dungeons, venturing up to raid the surface from time to time. Gnoll scouts are regular members of their pack, they are not as strong as brutes and not as intelligent as shamans. @@ -592,7 +592,7 @@ actors.mobs.senior.name=senior monk actors.mobs.senior.desc=These monks are fanatics, who have devoted themselves to protecting their king through physical might. So great is their devotion that they have totally surrendered their minds to their king, and now roam the dwarvern city like mindless zombies.\n\nThis monk has mastered the art of hang-to-hand combat, and is able to gain focus while moving much more quickly than regular monks. When they become focused, monks will parry the next physical attack used against them, even if it was otherwise guaranteed to hit. Monks build focus more quickly while on the move, and more slowly when in direct combat. actors.mobs.shaman.name=gnoll shaman -actors.mobs.shaman.zap_kill=The lightning bolt killed you... +actors.mobs.shaman.bolt_kill=The magic bolt killed you... actors.mobs.shaman.desc=Gnoll shamans are intelligent gnolls who use battle spells to compensate for their lack of might. They have a very respected position in gnoll society, despite their weaker strength. actors.mobs.shaman$redshaman.spell_desc=This shaman is wearing a red mask, and will use magic that temporarily _weakens your attacking power._ actors.mobs.shaman$blueshaman.spell_desc=This shaman is wearing a blue mask, and will use magic that temporarily _increases the damage you take._ @@ -614,7 +614,7 @@ actors.mobs.snake.name=sewer snake actors.mobs.snake.desc=These oversized serpents are capable of quickly slithering around blows, making them quite hard to hit. Magical attacks or surprise attacks are capable of catching them off-guard however.\n\nYou can perform a surprise attack by attacking while out of the snake's vision. One way is to let a snake chase you through a doorway and then _strike just as it moves into the door._ actors.mobs.spinner.name=cave spinner -actors.mobs.spinner.desc=These greenish furry cave spiders try to avoid direct combat. Instead they prefer to wait in the distance while their victim struggles in their excreted cobweb, slowly dying from their poisonous bite. They are capable of shooting their webs great distances, and will try to block whatever path their prey is taking. +actors.mobs.spinner.desc=These greenish furry cave spiders try to avoid direct combat. Instead they prefer to wait in the distance while their victim struggles in their excreted cobweb, slowly dying from their venomous bite. They are capable of shooting their webs great distances, and will try to block whatever path their prey is taking. actors.mobs.statue.name=animated statue actors.mobs.statue.def_verb=blocked