diff --git a/AndorsTrail/gen/com/gpl/rpg/AndorsTrail/R.java b/AndorsTrail/gen/com/gpl/rpg/AndorsTrail/R.java index f82dbe862..001cc3f64 100644 --- a/AndorsTrail/gen/com/gpl/rpg/AndorsTrail/R.java +++ b/AndorsTrail/gen/com/gpl/rpg/AndorsTrail/R.java @@ -170,13 +170,13 @@ public final class R { public static final int bulkselection_summary_totalgold=0x7f09001b; public static final int combatview_actionbar=0x7f09001e; public static final int combatview_endturn=0x7f090021; - public static final int combatview_flee=0x7f090020; + public static final int combatview_flee=0x7f090022; public static final int combatview_monsterbar=0x7f090024; public static final int combatview_monsterhealth=0x7f090026; public static final int combatview_monsterinfo=0x7f090025; public static final int combatview_monsterismoving=0x7f090023; public static final int combatview_moveattack=0x7f09001f; - public static final int combatview_status=0x7f090022; + public static final int combatview_status=0x7f090020; public static final int conversation_image=0x7f09002a; public static final int conversation_leave=0x7f090029; public static final int conversation_next=0x7f090028; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java index b81d3210f..edf1c062e 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java @@ -19,7 +19,7 @@ public final class AndorsTrailApplication extends Application { public static final boolean DEVELOPMENT_DEBUGBUTTONS = true; public static final boolean DEVELOPMENT_VALIDATEDATA = true; public static final boolean DEVELOPMENT_DEBUGMESSAGES = true; - public static final int CURRENT_VERSION = 20; + public static final int CURRENT_VERSION = 21; public static final String CURRENT_VERSION_DISPLAY = "0.6.10dev"; public final WorldContext world = new WorldContext(); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LevelUpActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LevelUpActivity.java index b25450ecb..dd7ccf227 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LevelUpActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LevelUpActivity.java @@ -16,6 +16,7 @@ import com.gpl.rpg.AndorsTrail.context.WorldContext; import com.gpl.rpg.AndorsTrail.controller.ActorStatsController; import com.gpl.rpg.AndorsTrail.controller.Constants; import com.gpl.rpg.AndorsTrail.model.actor.Player; +import com.gpl.rpg.AndorsTrail.model.actor.Skills; public final class LevelUpActivity extends Activity { private WorldContext world; @@ -89,11 +90,10 @@ public final class LevelUpActivity extends Activity { } private static void addLevelupEffect(Player player, int selectionID) { + int hpIncrease = 0; switch (selectionID) { case SELECT_HEALTH: - player.health.max += Constants.LEVELUP_EFFECT_HEALTH; - player.traits.maxHP += Constants.LEVELUP_EFFECT_HEALTH; - player.health.current += Constants.LEVELUP_EFFECT_HEALTH; + hpIncrease = Constants.LEVELUP_EFFECT_HEALTH; break; case SELECT_ATK_CH: player.traits.baseCombatTraits.attackChance += Constants.LEVELUP_EFFECT_ATK_CH; @@ -107,6 +107,12 @@ public final class LevelUpActivity extends Activity { break; } player.level++; + + hpIncrease += player.getSkillLevel(Skills.SKILL_FORTITUDE) * Skills.PER_SKILLPOINT_INCREASE_FORTITUDE_HEALTH; + player.health.max += hpIncrease; + player.traits.maxHP += hpIncrease; + player.health.current += hpIncrease; + player.recalculateLevelExperience(); ActorStatsController.recalculatePlayerCombatTraits(player); } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java index c48393e0a..6d6a7ed8a 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java @@ -13,8 +13,6 @@ import com.gpl.rpg.AndorsTrail.controller.CombatController; import com.gpl.rpg.AndorsTrail.model.actor.Monster; import com.gpl.rpg.AndorsTrail.model.actor.Player; import com.gpl.rpg.AndorsTrail.model.item.ItemContainer.ItemEntry; -import com.gpl.rpg.AndorsTrail.model.map.MapObject; -import com.gpl.rpg.AndorsTrail.model.quest.QuestProgress; import com.gpl.rpg.AndorsTrail.util.Coord; import com.gpl.rpg.AndorsTrail.util.L; import com.gpl.rpg.AndorsTrail.view.CombatView; @@ -149,6 +147,20 @@ public final class MainActivity extends Activity { Toast.makeText(MainActivity.this, "DEBUG: added items", Toast.LENGTH_SHORT).show(); } })*/ + /*,new DebugButton("skills+=20", new OnClickListener() { + @Override + public void onClick(View arg0) { + int N = 1; + for(int j = 0; j < N; ++j) { + for(int i = 0; i < Skills.NUM_SKILLS; ++i) { + world.model.player.addSkillLevel(i); + } + } + ActorStatsController.recalculatePlayerCombatTraits(world.model.player); + updateStatus(); + Toast.makeText(MainActivity.this, "DEBUG: all skills raised " + N + " levels", Toast.LENGTH_SHORT).show(); + } + })*/ /*,new DebugButton("bwm", new OnClickListener() { @Override public void onClick(View arg0) { @@ -172,7 +184,7 @@ public final class MainActivity extends Activity { view.movementController.placePlayerAt(MapObject.MAPEVENT_NEWMAP, "blackwater_mountain29", "south", 0, 0); } })*/ - ,new DebugButton("kazaul", new OnClickListener() { + /*,new DebugButton("kazaul", new OnClickListener() { @Override public void onClick(View arg0) { Player player = world.model.player; @@ -188,7 +200,7 @@ public final class MainActivity extends Activity { view.movementController.placePlayerAt(MapObject.MAPEVENT_NEWMAP, "blackwater_mountain50", "exit", 0, 0); } - }) + })*/ /*,new DebugButton("wyrms", new OnClickListener() { @Override public void onClick(View arg0) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ShopActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ShopActivity.java index 58645623e..0549ede69 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ShopActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ShopActivity.java @@ -73,7 +73,7 @@ public final class ShopActivity extends TabActivity implements OnContainerItemCl shoplist_sell = (ListView) h.findViewById(R.id.shop_sell_list); Loot merchantLoot = new Loot(); - npcType.dropList.createRandomLoot(merchantLoot); + npcType.dropList.createRandomLoot(merchantLoot, player); container_buy = merchantLoot.items; shoplist_buy.setAdapter(new ShopItemContainerAdapter( diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java index 723c82d92..1ac3ae875 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java @@ -118,6 +118,7 @@ public class ActorStatsController { private static void recalculateActorCombatTraits(Actor actor) { actor.resetStatsToBaseTraits(); if (actor.isPlayer) ItemController.applyInventoryEffects((Player) actor); + if (actor.isPlayer) SkillController.applySkillEffects((Player) actor); applyEffectsFromCurrentConditions(actor); if (actor.isPlayer) ItemController.recalculateHitEffectsFromWornItems((Player) actor); } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java index 65e3456c8..c0196efbe 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java @@ -19,6 +19,8 @@ import com.gpl.rpg.AndorsTrail.model.actor.Actor; import com.gpl.rpg.AndorsTrail.model.actor.ActorTraits; import com.gpl.rpg.AndorsTrail.model.actor.Monster; import com.gpl.rpg.AndorsTrail.model.actor.MonsterType; +import com.gpl.rpg.AndorsTrail.model.actor.Player; +import com.gpl.rpg.AndorsTrail.model.actor.Skills; import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnUse; import com.gpl.rpg.AndorsTrail.model.item.Loot; import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap; @@ -205,17 +207,22 @@ public final class CombatController { } public void playerKilledMonster(Monster killedMonster) { + final Player player = model.player; + Loot loot = model.currentMap.getBagOrCreateAt(killedMonster.position); - killedMonster.createLoot(loot); + killedMonster.createLoot(loot, player); model.currentMap.remove(killedMonster); context.mainActivity.redrawAll(MainView.REDRAW_ALL_MONSTER_KILLED); + if (player.getSkillLevel(Skills.SKILL_CLEAVE) > 0) player.ap.setMax(); + player.health.add(player.getSkillLevel(Skills.SKILL_EATER) * Skills.PER_SKILLPOINT_INCREASE_EATER_HEALTH, false); + model.statistics.addMonsterKill(killedMonster.monsterType); model.player.addExperience(loot.exp); totalExpThisFight += loot.exp; loot.exp = 0; - context.actorStatsController.applyKillEffectsToPlayer(model.player); + context.actorStatsController.applyKillEffectsToPlayer(player); context.mainActivity.updateStatus(); @@ -240,7 +247,8 @@ public final class CombatController { if (dest == null) return; if (!useAPs(model.player.traits.moveCost)) return; - if (Constants.roll100(Constants.FLEE_FAIL_CHANCE_PERCENT)) { + int fleeChanceBias = model.player.getSkillLevel(Skills.SKILL_EVASION) * Skills.PER_SKILLPOINT_INCREASE_EVASION_FLEE_CHANCE_PERCENTAGE; + if (Constants.roll100(Constants.FLEE_FAIL_CHANCE_PERCENT - fleeChanceBias)) { fleeingFailed(); return; } @@ -249,7 +257,9 @@ public final class CombatController { context.movementController.moveToNextIfPossible(false); if (canExitCombat()) exitCombat(true); - else maybeAutoEndTurn(); + + context.mainActivity.updateStatus(); + maybeAutoEndTurn(); } private void fleeingFailed() { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java index e2f76ae66..19f25d716 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java @@ -37,15 +37,16 @@ public final class Constants { public static final Random rnd = new Random(); - public static boolean roll100(final int chance) { return rnd.nextInt(100) < chance; } - public static int rollValue(final ConstRange r) { - if (r.isMax()) return r.max; - else return rnd.nextInt(r.max - r.current) + r.current; + public static int rollValue(final ConstRange r) { return rollValue(r.max, r.current); } + public static int rollValue(final ConstRange r, int bias) { return rollValue(r.max, r.current + bias); } + public static int rollValue(final Range r) { return rollValue(r.max, r.current); } + private static int rollValue(final int max, final int min) { + if (max <= min) return max; + else return rnd.nextInt(max - min + 1) + min; } - public static int rollValue(final Range r) { - if (r.isMax()) return r.max; - else return rnd.nextInt(r.max - r.current + 1) + r.current; - } - public static boolean rollResult(final ConstRange r) { return rnd.nextInt(r.max) < r.current; } - public static boolean rollResult(final Range r) { return rnd.nextInt(r.max) < r.current; } + public static boolean roll100(final int chance) { return rollResult(100, chance); } + public static boolean rollResult(final ConstRange r) { return rollResult(r.max, r.current); } + public static boolean rollResult(final ConstRange r, int bias) { return rollResult(r.max, r.current + bias); } + public static boolean rollResult(final Range r) { return rollResult(r.max, r.current); } + private static boolean rollResult(final int probabilityMax, final int probabilityValue) { return rnd.nextInt(probabilityMax) < probabilityValue; } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Controller.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Controller.java index 3f12c2025..f03b713d0 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Controller.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Controller.java @@ -10,6 +10,7 @@ import com.gpl.rpg.AndorsTrail.context.WorldContext; import com.gpl.rpg.AndorsTrail.model.ModelContainer; import com.gpl.rpg.AndorsTrail.model.actor.Monster; import com.gpl.rpg.AndorsTrail.model.actor.Player; +import com.gpl.rpg.AndorsTrail.model.actor.Skills; import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap; import com.gpl.rpg.AndorsTrail.model.map.MapObject; import com.gpl.rpg.AndorsTrail.util.Coord; @@ -62,8 +63,10 @@ public final class Controller { view.combatController.exitCombat(false); view.effectController.waitForCurrentEffect(); final Player player = model.player; - int lostExp = player.levelExperience.current / (100 / Constants.PERCENT_EXP_LOST_WHEN_DIED); - if (lostExp < 0) lostExp = 0; // Shouldn't happen, but just to be sure. + int lostExp = player.levelExperience.current * Constants.PERCENT_EXP_LOST_WHEN_DIED / 100; + lostExp -= lostExp * player.getSkillLevel(Skills.SKILL_LOWER_EXPLOSS) * Skills.PER_SKILLPOINT_INCREASE_EXPLOSS_PERCENT / 100; + + if (lostExp < 0) lostExp = 0; player.addExperience(-lostExp); model.statistics.addPlayerDeath(lostExp); playerRested(world, null); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java index 6d1028402..c1f5f3098 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java @@ -16,7 +16,7 @@ public final class ConversationController { final Loot loot = new Loot(); if (phrase.rewardDropList != null) { - phrase.rewardDropList.createRandomLoot(loot); + phrase.rewardDropList.createRandomLoot(loot, player); player.inventory.add(loot); } if (phrase.progressQuest != null) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/GameRoundController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/GameRoundController.java index 76b8ecfa4..34e51ecde 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/GameRoundController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/GameRoundController.java @@ -3,6 +3,7 @@ package com.gpl.rpg.AndorsTrail.controller; import com.gpl.rpg.AndorsTrail.context.ViewContext; import com.gpl.rpg.AndorsTrail.context.WorldContext; import com.gpl.rpg.AndorsTrail.model.ModelContainer; +import com.gpl.rpg.AndorsTrail.model.actor.Skills; import com.gpl.rpg.AndorsTrail.util.TimedMessageTask; public final class GameRoundController implements TimedMessageTask.Callback { @@ -65,6 +66,8 @@ public final class GameRoundController implements TimedMessageTask.Callback { private void onNewRound() { view.actorStatsController.applyConditionsToMonsters(model.currentMap, false); view.actorStatsController.applyConditionsToPlayer(model.player, false); + + model.player.health.add(model.player.getSkillLevel(Skills.SKILL_REGENERATION) * Skills.PER_SKILLPOINT_INCREASE_REGENERATION, false); } private void onNewTick() { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java index 3814e955f..fc0c64740 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java @@ -10,6 +10,7 @@ import com.gpl.rpg.AndorsTrail.context.WorldContext; import com.gpl.rpg.AndorsTrail.model.CombatTraits; import com.gpl.rpg.AndorsTrail.model.ModelContainer; import com.gpl.rpg.AndorsTrail.model.actor.Player; +import com.gpl.rpg.AndorsTrail.model.actor.Skills; import com.gpl.rpg.AndorsTrail.model.item.Inventory; import com.gpl.rpg.AndorsTrail.model.item.ItemContainer; import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnUse; @@ -190,11 +191,15 @@ public final class ItemController { return isBagRemoved; } + private static int getMarketPriceFactor(Player player) { + return Constants.MARKET_PRICEFACTOR_PERCENT + - player.getSkillLevel(Skills.SKILL_BARTER) * Skills.PER_SKILLPOINT_INCREASE_BARTER_PRICEFACTOR_PERCENTAGE; + } public static int getBuyingPrice(Player player, ItemType itemType) { - return itemType.baseMarketCost * (100 + Constants.MARKET_PRICEFACTOR_PERCENT) / 100; + return itemType.baseMarketCost + itemType.baseMarketCost * getMarketPriceFactor(player) / 100; } public static int getSellingPrice(Player player, ItemType itemType) { - return itemType.baseMarketCost * (100 - Constants.MARKET_PRICEFACTOR_PERCENT) / 100; + return itemType.baseMarketCost - itemType.baseMarketCost * getMarketPriceFactor(player) / 100; } public static boolean canAfford(Player player, ItemType itemType) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java index 76b94e6cd..7ed77f392 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java @@ -4,6 +4,7 @@ import com.gpl.rpg.AndorsTrail.context.ViewContext; import com.gpl.rpg.AndorsTrail.context.WorldContext; import com.gpl.rpg.AndorsTrail.model.ModelContainer; import com.gpl.rpg.AndorsTrail.model.actor.Monster; +import com.gpl.rpg.AndorsTrail.model.actor.Skills; import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea; import com.gpl.rpg.AndorsTrail.util.Coord; @@ -38,7 +39,9 @@ public final class MonsterMovementController { for (Monster m : a.monsters) { if (!m.isAgressive()) continue; if (!m.rectPosition.isAdjacentTo(model.player.position)) continue; - if (Constants.roll100(Constants.MONSTER_AGGRESSION_CHANCE_PERCENT)) { + + int aggressionChanceBias = model.player.getSkillLevel(Skills.SKILL_EVASION) * Skills.PER_SKILLPOINT_INCREASE_EVASION_MONSTER_ATTACK_CHANCE_PERCENTAGE; + if (Constants.roll100(Constants.MONSTER_AGGRESSION_CHANCE_PERCENT - aggressionChanceBias)) { view.combatController.monsterSteppedOnPlayer(m); return; } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java new file mode 100644 index 000000000..c0c166343 --- /dev/null +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java @@ -0,0 +1,58 @@ +package com.gpl.rpg.AndorsTrail.controller; + +import com.gpl.rpg.AndorsTrail.model.actor.Player; +import com.gpl.rpg.AndorsTrail.model.actor.Skills; +import com.gpl.rpg.AndorsTrail.model.item.ItemTypeCollection; +import com.gpl.rpg.AndorsTrail.model.item.DropList.DropItem; + +public final class SkillController { + public static void applySkillEffects(Player player) { + player.traits.attackChance += Skills.PER_SKILLPOINT_INCREASE_WEAPON_CHANCE * player.getSkillLevel(Skills.SKILL_WEAPON_CHANCE); + player.traits.damagePotential.addToMax(Skills.PER_SKILLPOINT_INCREASE_WEAPON_DAMAGE_MAX * player.getSkillLevel(Skills.SKILL_WEAPON_DMG)); + player.traits.damagePotential.add(Skills.PER_SKILLPOINT_INCREASE_WEAPON_DAMAGE_MIN * player.getSkillLevel(Skills.SKILL_WEAPON_DMG), false); + player.traits.blockChance += Skills.PER_SKILLPOINT_INCREASE_DODGE * player.getSkillLevel(Skills.SKILL_DODGE); + player.traits.damageResistance += Skills.PER_SKILLPOINT_INCREASE_BARKSKIN * player.getSkillLevel(Skills.SKILL_BARKSKIN); + if (player.traits.hasCriticalChanceEffect()) { + player.traits.criticalChance += player.traits.criticalChance * Skills.PER_SKILLPOINT_INCREASE_MORE_CRITICALS_PERCENT * player.getSkillLevel(Skills.SKILL_MORE_CRITICALS) / 100; + } + if (player.traits.hasCriticalMultiplierEffect()) { + player.traits.criticalMultiplier += player.traits.criticalMultiplier * Skills.PER_SKILLPOINT_INCREASE_BETTER_CRITICALS_PERCENT * player.getSkillLevel(Skills.SKILL_BETTER_CRITICALS) / 100; + } + player.ap.addToMax(Skills.PER_SKILLPOINT_INCREASE_SPEED * player.getSkillLevel(Skills.SKILL_SPEED)); + /*final int berserkLevel = player.getSkillLevel(Skills.SKILL_BERSERKER); + if (berserkLevel > 0) { + final int berserkHealth = player.health.max * Skills.BERSERKER_STARTS_AT_HEALTH_PERCENT / 100; + if (player.health.current <= berserkHealth) { + player.traits.attackChance += Skills.PER_SKILLPOINT_INCREASE_BERSERKER_WEAPON_CHANCE * berserkLevel; + player.traits.damagePotential.addToMax(Skills.PER_SKILLPOINT_INCREASE_BERSERKER_WEAPON_DAMAGE_MAX * berserkLevel); + player.traits.damagePotential.add(Skills.PER_SKILLPOINT_INCREASE_BERSERKER_WEAPON_DAMAGE_MIN * berserkLevel, false); + player.traits.blockChance += Skills.PER_SKILLPOINT_INCREASE_BERSERKER_DODGE * berserkLevel; + } + }*/ + } + + public static int getChanceRollBias(DropItem item, Player player) { + if (player == null) return 0; + + if (item.itemType.id == ItemTypeCollection.ITEMTYPE_GOLD) { + return getRollBias(item, player, Skills.SKILL_COINFINDER, Skills.PER_SKILLPOINT_INCREASE_COINFINDER_CHANCE_PERCENT); + } else if (!item.itemType.isOrdinaryItem()) { + return getRollBias(item, player, Skills.SKILL_MAGICFINDER, Skills.PER_SKILLPOINT_INCREASE_MAGICFINDER_CHANCE_PERCENT); + } else { + return 0; + } + } + + public static int getQuantityRollBias(DropItem item, Player player) { + if (player == null) return 0; + if (item.itemType.id != ItemTypeCollection.ITEMTYPE_GOLD) return 0; + + return getRollBias(item, player, Skills.SKILL_COINFINDER, Skills.PER_SKILLPOINT_INCREASE_COINFINDER_QUANTITY_PERCENT); + } + + private static int getRollBias(DropItem item, Player player, int skill, int perSkillpointIncrease) { + int skillLevel = player.getSkillLevel(skill); + if (skillLevel <= 0) return 0; + return item.chance.current * skillLevel * perSkillpointIncrease / 100; + } +} diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/CombatTraits.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/CombatTraits.java index c8cfeba5d..de5bfa19b 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/CombatTraits.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/CombatTraits.java @@ -11,7 +11,7 @@ public class CombatTraits { public int attackChance; public int criticalChance; - public int criticalMultiplier; + public float criticalMultiplier; public final Range damagePotential; public int blockChance; @@ -51,7 +51,11 @@ public class CombatTraits { this.attackCost = src.readInt(); this.attackChance = src.readInt(); this.criticalChance = src.readInt(); - this.criticalMultiplier = src.readInt(); + if (fileversion <= 20) { + this.criticalMultiplier = src.readInt(); + } else { + this.criticalMultiplier = src.readFloat(); + } this.damagePotential = new Range(src, fileversion); this.blockChance = src.readInt(); this.damageResistance = src.readInt(); @@ -61,7 +65,7 @@ public class CombatTraits { dest.writeInt(attackCost); dest.writeInt(attackChance); dest.writeInt(criticalChance); - dest.writeInt(criticalMultiplier); + dest.writeFloat(criticalMultiplier); damagePotential.writeToParcel(dest, flags); dest.writeInt(blockChance); dest.writeInt(damageResistance); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java index ea428fdd7..8099bf35a 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java @@ -27,10 +27,12 @@ public final class Monster extends Actor { this.nextPosition = new CoordRect(new Coord(), traits.tileSize); } - public void createLoot(Loot container) { - container.exp += monsterType.exp; + public void createLoot(Loot container, Player player) { + int exp = monsterType.exp; + exp += exp * player.getSkillLevel(Skills.SKILL_MORE_EXP) * Skills.PER_SKILLPOINT_INCREASE_MORE_EXP_PERCENT / 100; + container.exp += exp; if (monsterType.dropList == null) return; - monsterType.dropList.createRandomLoot(container); + monsterType.dropList.createRandomLoot(container, player); } public boolean isAgressive() { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java index 76e24c279..caec5ac68 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java @@ -32,7 +32,7 @@ public final class Player extends Actor { private final HashMap > questProgress = new HashMap >(); public int useItemCost; public int reequipCost; - public final int[] skillLevels = new int[Skills.NUM_SKILLS]; + private final int[] skillLevels = new int[Skills.NUM_SKILLS]; public String spawnMap; public String spawnPlace; @@ -69,7 +69,7 @@ public final class Player extends Actor { recalculateLevelExperience(); Loot startItems = new Loot(); - dropLists.getDropList(DropListCollection.DROPLIST_STARTITEMS).createRandomLoot(startItems); + dropLists.getDropList(DropListCollection.DROPLIST_STARTITEMS).createRandomLoot(startItems, this); inventory.add(startItems); if (AndorsTrailApplication.DEVELOPMENT_DEBUGRESOURCES) { @@ -127,6 +127,17 @@ public final class Player extends Actor { return levelExperience.isMax(); } + public int getSkillLevel(int skill) { + return skillLevels[skill]; + } + public boolean hasSkill(int skill) { + return skillLevels[skill] > 0; + } + public void addSkillLevel(int skill) { + skillLevels[skill] += 1; + } + + // ====== PARCELABLE =================================================================== diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Skills.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Skills.java index fc918f8cb..3287acdfb 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Skills.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Skills.java @@ -1,20 +1,50 @@ package com.gpl.rpg.AndorsTrail.model.actor; -public class Skills { +public final class Skills { public static final int SKILL_WEAPON_CHANCE = 0; public static final int SKILL_WEAPON_DMG = 1; public static final int SKILL_BARTER = 2; - public static final int SKILL_DODGE = 3; - public static final int SKILL_BARKSKIN = 4; + public static final int SKILL_DODGE = 3; // + BC + public static final int SKILL_BARKSKIN = 4; // Dmg resist public static final int SKILL_MORE_CRITICALS = 5; public static final int SKILL_BETTER_CRITICALS = 6; - public static final int SKILL_SPEED = 7; + public static final int SKILL_SPEED = 7; // Raises max ap public static final int SKILL_COINFINDER = 8; public static final int SKILL_MORE_EXP = 9; - public static final int SKILL_CLEAVE = 10; - public static final int SKILL_EATER = 11; // +1hp per kill - public static final int SKILL_BERSERKER = 12; // <=20%hp - public static final int SKILL_FORTITUDE = 13; // +2hp /level + public static final int SKILL_CLEAVE = 10; // +10ap on kill + public static final int SKILL_EATER = 11; // +1hp per kill + //public static final int SKILL_BERSERKER = 12; // <=20%hp increases AC and DMG + public static final int SKILL_FORTITUDE = 13; // +N hp per levelup + public static final int SKILL_EVASION = 14; // increase successful flee chance & reduce chance of monster attack + public static final int SKILL_REGENERATION = 15; // +N hp per round + public static final int SKILL_LOWER_EXPLOSS = 16; + public static final int SKILL_MAGICFINDER = 17; - public static final int NUM_SKILLS = 14; + public static final int NUM_SKILLS = SKILL_MAGICFINDER+1; + + //public static final int BERSERKER_STARTS_AT_HEALTH_PERCENT = 20; + + public static final int PER_SKILLPOINT_INCREASE_WEAPON_CHANCE = 15; + public static final int PER_SKILLPOINT_INCREASE_WEAPON_DAMAGE_MAX = 1; + public static final int PER_SKILLPOINT_INCREASE_WEAPON_DAMAGE_MIN = 1; + public static final int PER_SKILLPOINT_INCREASE_DODGE = 9; + public static final int PER_SKILLPOINT_INCREASE_BARKSKIN = 1; + public static final int PER_SKILLPOINT_INCREASE_MORE_CRITICALS_PERCENT = 20; + public static final int PER_SKILLPOINT_INCREASE_BETTER_CRITICALS_PERCENT = 50; + public static final int PER_SKILLPOINT_INCREASE_SPEED = 1; + /*public static final int PER_SKILLPOINT_INCREASE_BERSERKER_WEAPON_CHANCE = 15; + public static final int PER_SKILLPOINT_INCREASE_BERSERKER_WEAPON_DAMAGE_MAX = 1; + public static final int PER_SKILLPOINT_INCREASE_BERSERKER_WEAPON_DAMAGE_MIN = 1; + public static final int PER_SKILLPOINT_INCREASE_BERSERKER_DODGE = 9;*/ + public static final int PER_SKILLPOINT_INCREASE_BARTER_PRICEFACTOR_PERCENTAGE = 5; + public static final int PER_SKILLPOINT_INCREASE_COINFINDER_CHANCE_PERCENT = 50; + public static final int PER_SKILLPOINT_INCREASE_MAGICFINDER_CHANCE_PERCENT = 100; + public static final int PER_SKILLPOINT_INCREASE_COINFINDER_QUANTITY_PERCENT = 100; + public static final int PER_SKILLPOINT_INCREASE_MORE_EXP_PERCENT = 10; + public static final int PER_SKILLPOINT_INCREASE_EATER_HEALTH = 1; + public static final int PER_SKILLPOINT_INCREASE_FORTITUDE_HEALTH = 2; + public static final int PER_SKILLPOINT_INCREASE_EVASION_FLEE_CHANCE_PERCENTAGE = 5; + public static final int PER_SKILLPOINT_INCREASE_EVASION_MONSTER_ATTACK_CHANCE_PERCENTAGE = 5; + public static final int PER_SKILLPOINT_INCREASE_REGENERATION = 1; + public static final int PER_SKILLPOINT_INCREASE_EXPLOSS_PERCENT = 30; } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/DropList.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/DropList.java index 46dfbe4f8..06f4214fc 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/DropList.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/DropList.java @@ -3,6 +3,8 @@ package com.gpl.rpg.AndorsTrail.model.item; import java.util.Collection; import com.gpl.rpg.AndorsTrail.controller.Constants; +import com.gpl.rpg.AndorsTrail.controller.SkillController; +import com.gpl.rpg.AndorsTrail.model.actor.Player; import com.gpl.rpg.AndorsTrail.util.ConstRange; public final class DropList { @@ -17,10 +19,15 @@ public final class DropList { this.items = items.toArray(new DropItem[items.size()]); this.DEBUG_items = this.items; } - public void createRandomLoot(Loot loot) { + public void createRandomLoot(Loot loot, Player player) { for (DropItem item : items) { - if (Constants.rollResult(item.chance)) { - int quantity = Constants.rollValue(item.quantity); + + final int chanceRollBias = SkillController.getChanceRollBias(item, player); + if (Constants.rollResult(item.chance, chanceRollBias)) { + + final int quantityRollBias = SkillController.getQuantityRollBias(item, player); + int quantity = Constants.rollValue(item.quantity, quantityRollBias); + if (quantity != 0) { if (item.itemType.id == ItemTypeCollection.ITEMTYPE_GOLD) { loot.gold += quantity; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemType.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemType.java index 8aa3d31f3..f59c56d28 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemType.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemType.java @@ -68,6 +68,7 @@ public final class ItemType { public boolean isEquippable() { return actionType == ACTIONTYPE_EQUIP; } public boolean isUsable() { return actionType == ACTIONTYPE_USE; } public boolean isQuestItem() { return baseMarketCost == 0; } + public boolean isOrdinaryItem() { return displayType == DISPLAYTYPE_ORDINARY; } public String describeWearEffect(int quantity) { StringBuilder sb = new StringBuilder(name); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java index b770d7656..599df6bc5 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java @@ -232,7 +232,7 @@ public final class PredefinedMap { for (MapObject o : eventObjects) { if (o.type == MapObject.MAPEVENT_CONTAINER) { Loot bag = getBagOrCreateAt(o.position.topLeft); - o.dropList.createRandomLoot(bag); + o.dropList.createRandomLoot(bag, null); } } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceFileParser.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceFileParser.java index d421eab38..baff01359 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceFileParser.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceFileParser.java @@ -78,7 +78,7 @@ public class ResourceFileParser { result.attackCost = parseInt(attackCost, 0); result.attackChance = parseInt(attackChance, 0); result.criticalChance = parseInt(criticalChance, 0); - result.criticalMultiplier = parseInt(criticalMultiplier, 0); + result.criticalMultiplier = parseFloat(criticalMultiplier, 0); if (attackDamage != null) result.damagePotential.set(attackDamage); result.blockChance = parseInt(blockChance, 0); result.damageResistance = parseInt(damageResistance, 0); @@ -89,6 +89,10 @@ public class ResourceFileParser { if (s == null || s.length() <= 0) return defaultValue; return Integer.parseInt(s); } + public static float parseFloat(String s, int defaultValue) { + if (s == null || s.length() <= 0) return defaultValue; + return Float.parseFloat(s); + } public static boolean parseBoolean(String s, boolean defaultValue) { if (s == null || s.length() <= 0) return defaultValue; if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/TraitsInfoView.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/TraitsInfoView.java index 4d952a90d..7a84ee0cb 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/TraitsInfoView.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/TraitsInfoView.java @@ -74,7 +74,7 @@ public final class TraitsInfoView extends TableLayout { } if (traits != null && traits.hasCriticalMultiplierEffect()) { traitsinfo_critical_row2.setVisibility(View.VISIBLE); - traitsinfo_criticalhit_multiplier.setText(Integer.toString(traits.criticalMultiplier)); + traitsinfo_criticalhit_multiplier.setText(Float.toString(traits.criticalMultiplier)); } else { traitsinfo_critical_row2.setVisibility(View.GONE); }