Skip to content

Commit

Permalink
Fixing several issues: encoding on docs, poison/detox flows (again), …
Browse files Browse the repository at this point in the history
…Combat Expertise maneuvers not registering to base monsters, monsters receiving more HP than correct, Rapid Shot not updating,
  • Loading branch information
tukkek committed Oct 19, 2017
1 parent fe5541e commit e6e7cc8
Show file tree
Hide file tree
Showing 30 changed files with 142 additions and 130 deletions.
14 changes: 7 additions & 7 deletions doc/upgrades.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ Deceitful: +3 to disguise skill checks (+4 if 10 or more ranks in disguise).
Darkvision: greatly improved vision when dark.
Energy resistance/immunity: reduces or ignores damage from non-physical attacks.
Fast healing: heals a certain number of hit points per turn (1AP).
Fear damage: adds the fear effect to mêlée attacks.
Fear damage: adds the fear effect to melee attacks.
Flying: allows character to fly over terrain and water.
Great fortitude: +2 fortitude.
Improved initiative: +4 initiative.
Iron will: +2 will.
Lightning reflexes: +2 reflexes.
Low-light vision: improved vision when dark.
Mêlée damage: raises damage of all mêlée attacks.
Mêlée focus: +1 to all mêlee attack bonuses (requires +1 Base Attack Bonus).
melee damage: raises damage of all melee attacks.
melee focus: +1 to all mêlee attack bonuses (requires +1 Base Attack Bonus).
Natural armor: raises armor class.
Paralysis damage: adds the paralysis effect to mêlée attacks.
Poison damage: adds the poison effect to mêlée attacks.
Paralysis damage: adds the paralysis effect to melee attacks.
Poison damage: adds the poison effect to melee attacks.
Raise constitution: raises fortitude, hit points and breath weapon saving throw difficulty.
Raise dexterity: raises armor class, reflexes, ranged attack bonuses and initiative.
Raise strength: raises mêlée attack bonuses and damage.
Raise strength: raises melee attack bonuses and damage.
Raise wisdom: raises will saving throw bonus.
Ranged damage: raises damage of all ranged attacks.
Ranged focus: +1 to all ranged attack bonuses (requires +1 BAB).
Expand Down Expand Up @@ -53,7 +53,7 @@ Point blank shot: you get a +1 bonus on attack and damage rolls with ranged weap
Improved precise shot: ignores the -4 penalty for cover (dexterity 19, BAB +11).
Rapid shot: you can make an extra ranged attack but have a -2 penalty to all attacks for a turn (dexterity 13).

Power attack: you may subtract up to your base attack bonus from mêlée attack rolls and add it as damage (requires strength 13, BAB +1).
Power attack: you may subtract up to your base attack bonus from melee attack rolls and add it as damage (requires strength 13, BAB +1).
Bull rush: push opponent back on a successful charge.
Cleave: acts faster right after downing an opponent.
Great cleave: grants a bonus attack after downing an opponent (BAB +4).
4 changes: 0 additions & 4 deletions javelin/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javelin.model.Realm;
import javelin.model.item.Item;
import javelin.model.unit.Squad;
import javelin.model.unit.abilities.spell.necromancy.Poison;
import javelin.model.unit.attack.Combatant;
import javelin.model.world.Actor;
import javelin.model.world.Incursion;
Expand Down Expand Up @@ -91,9 +90,6 @@ static void generateincursion(Location l, Realm r,
}

public static String onbattlehelp() {
for (Combatant c : Fight.state.blueTeam) {
new Poison().cast(c, c, Fight.state, false);
}
return "";
}

Expand Down
3 changes: 2 additions & 1 deletion javelin/controller/AbilityModification.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public void modify(int change) {
}
newscore += direction;
scorechange += direction;
if (newscore % 2 == 0) {
boolean even = newscore % 2 == 0;
if ((direction == +1 && even) || (direction == -1 && !even)) {
modifications.add(direction);
modifierchange += direction;
}
Expand Down
1 change: 1 addition & 0 deletions javelin/controller/action/maneuver/ExpertiseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public ExpertiseAction(String name, String key, Feat prerequisite,
super(name);
this.prerequisite = prerequisite;
this.featbonus = featbonus;
this.confirmkey = 'm';
}

@Override
Expand Down
6 changes: 1 addition & 5 deletions javelin/controller/db/reader/MonsterReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@
import javelin.controller.db.reader.fields.Speed;
import javelin.model.unit.Monster;
import javelin.model.unit.abilities.BreathWeapon;
import javelin.model.unit.abilities.TouchAttack;
import javelin.model.unit.abilities.BreathWeapon.BreathArea;
import javelin.model.unit.abilities.BreathWeapon.SavingThrow;
import javelin.model.unit.abilities.TouchAttack;
import javelin.model.unit.abilities.spell.Spell;
import javelin.model.unit.abilities.spell.conjuration.Summon;
import javelin.model.unit.attack.Attack;
import javelin.model.unit.attack.AttackSequence;
import javelin.model.unit.feat.Feat;

/**
* Reads the monster.xml file at startup.
Expand Down Expand Up @@ -510,9 +509,6 @@ public void endElement(final String uri, final String localName,
errorhandler.informInvalid(this);
errorhandler.setInvalid(null);
} else {
for (Feat f : monster.feats) {
f.update(monster);
}
registermonster();
if (!monster.breaths.isEmpty()) {
SpecialtiesLog.log(" Breaths: " + monster.breaths);
Expand Down
2 changes: 1 addition & 1 deletion javelin/controller/exception/battle/EndBattle.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ static void updateoriginal(List<Combatant> originalteam) {
}

static void update(final Combatant from, final Combatant to) {
from.transferconditions(to);
to.hp = from.hp;
if (to.hp > to.maxhp) {
to.hp = to.maxhp;
} else if (to.hp < 1) {
to.hp = 1;
}
copyspells(from, to);
from.transferconditions(to);
}

static void copyspells(final Combatant from, final Combatant to) {
Expand Down
2 changes: 1 addition & 1 deletion javelin/controller/upgrade/FeatUpgrade.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public FeatUpgrade(Feat featp) {

@Override
public boolean apply(final Combatant c) {
return feat.apply(c);
return feat.upgrade(c);
}

@Override
Expand Down
20 changes: 12 additions & 8 deletions javelin/controller/upgrade/classes/ClassLevelUpgrade.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,7 @@ public boolean apply(Combatant c) {
Level last = table[level - 1];
c.source.babpartial += advancebab(level);
if (c.source.babpartial >= 1) {
c.source.babpartial -= 1;
advanceattack(1, m.melee);
advanceattack(1, m.ranged);
int newattackbonusdelta = checkfornewattack(m, 1);
if (newattackbonusdelta != 0) {
upgradeattack(m.melee, newattackbonusdelta);
upgradeattack(m.ranged, newattackbonusdelta);
}
levelbabup(c, m);
}
m.fort += next.fort - last.fort;
m.ref += next.ref - last.ref;
Expand All @@ -125,6 +118,17 @@ public boolean apply(Combatant c) {
return true;
}

public void levelbabup(Combatant c, Monster m) {
c.source.babpartial -= 1;
advanceattack(1, m.melee);
advanceattack(1, m.ranged);
int newattackbonusdelta = checkfornewattack(m, 1);
if (newattackbonusdelta != 0) {
upgradeattack(m.melee, newattackbonusdelta);
upgradeattack(m.ranged, newattackbonusdelta);
}
}

public float advancebab(int level) {
return babprograssion;
}
Expand Down
6 changes: 1 addition & 5 deletions javelin/model/unit/HD.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ public int roll(Monster m) {
continue;
}
for (int i = 0; i < dice; i++) {
int roll = RPG.r(1, hd);
if (m.constitution > 0) {
roll += Monster.getbonus(m.constitution);
}
hp += Math.max(1, roll);
hp += RPG.r(1, hd);
}
}
return Math.max(1, hp);
Expand Down
11 changes: 5 additions & 6 deletions javelin/model/unit/Monster.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,10 @@ static private ArrayList<AttackSequence> copyattacks(
}

public void addfeat(final Feat feat) {
feats.add(feat);
feats.sort(FeatByNameComparator.INSTANCE);
if (feat.stack || !hasfeat(feat)) {
feats.add(feat);
feats.sort(FeatByNameComparator.INSTANCE);
}
}

public int countfeat(final Feat f) {
Expand Down Expand Up @@ -483,7 +485,7 @@ public void changeconstitutionscore(Combatant c, int scorechange) {
}
final int hds = hd.count();
int bonushp = hds * m.modifierchange;
if (c.maxhp + bonushp < hds) {
if (c.maxhp + bonushp < hds + hd.extrahp || c.hp + bonushp < 1) {
/*
* it's tricky to come back to the original state from <1hp/hd so
* just avoid it for now. maybe it'll be easier when abiblities and
Expand All @@ -496,9 +498,6 @@ public void changeconstitutionscore(Combatant c, int scorechange) {
fort += m.modifierchange;
hd.extrahp += bonushp;
c.hp += bonushp;
if (c.hp < 1) {
c.hp = 1;
}
c.maxhp += bonushp;
if (c.hp > c.maxhp) {
c.hp = c.maxhp;
Expand Down
5 changes: 4 additions & 1 deletion javelin/model/unit/attack/Combatant.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,14 @@ public class Combatant implements Serializable, Cloneable {
*/
public Combatant(final Monster sourcep, boolean generatespells) {
super();
source = sourcep;
source = sourcep.clone();
newid();
ap = 0;
hp = source.hd.roll(source);
maxhp = hp;
for (Feat f : source.feats) {
f.update(this);
}
for (Spell s : source.spells) {
spells.add(s.clone());
}
Expand Down
7 changes: 4 additions & 3 deletions javelin/model/unit/condition/Poisoned.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ public void end(Combatant c) {

@Override
public void transfer(Combatant from, Combatant to) {
to.maxhp = from.maxhp;
to.source.poison = from.source.poison;
to.source.changeconstitutionscore(to, -to.source.poison);
int poison = from.source.poison;
int original = to.source.constitution;
to.source.changeconstitutionscore(to, -poison);
to.source.poison = Math.min(poison, original - to.source.constitution);
to.maxhp = from.maxhp;
to.hp = from.hp;
}
Expand Down
4 changes: 2 additions & 2 deletions javelin/model/unit/feat/CombatCasting.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private CombatCasting() {
}

@Override
public boolean apply(Combatant c) {
return super.apply(c) && !c.spells.isEmpty();
public boolean upgrade(Combatant c) {
return super.upgrade(c) && !c.spells.isEmpty();
}
}
50 changes: 27 additions & 23 deletions javelin/model/unit/feat/Feat.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.Serializable;

import javelin.controller.challenge.factor.FeatsFactor;
import javelin.controller.db.reader.MonsterReader;
import javelin.controller.upgrade.Upgrade;
import javelin.model.unit.Monster;
import javelin.model.unit.abilities.spell.Spell;
Expand All @@ -21,7 +20,7 @@ public abstract class Feat implements Serializable, javelin.model.Cloneable {
/** Feat name as per d20 rules. */
public final String name;

boolean stack = false;
public boolean stack = false;
/**
* If a feat needs updating, every time a {@link Combatant} is upgraded
* {@link #remove(Combatant)} and {@link #add(Combatant)} will be called so
Expand Down Expand Up @@ -49,33 +48,30 @@ public int hashCode() {
return name.hashCode();
}

/**
* This is used by {@link MonsterReader} for when a monster source stat
* block needs to updated when it has a feat.
*
* Will be called multiple times if a monster has more than one feat of the
* same type.
*
* @param monster
* Original unique stat block to derive.
*/
public void update(Monster m) {
// do nothing
}

/**
* @see #update
*/
/** Called as part of the {@link #update} flow. */
public void remove(Combatant c) {
// do nothing

}

/**
* @see #update
* This will be called when a {@link Monster} is being made into a
* {@link Combatant}. It is also called after upgrades when the
* {@link #update} flag is set.
*
* Can be called multiple times if a monster has more than one feat of the
* same type as allowed by {@link #stack}.
*
* Note that many feats do not have to implement this as the stat block
* itself will have the changes pre-computated in it. For example:
* {@link Toughness} and {@link ImprovedInitiative} only need to implement
* {@link #upgrade(Combatant)}.
*
* @return <code>true</code> in case of success.
*/
public void add(Combatant c) {
public boolean add(Combatant c) {
// do nothing
return true;
}

@Override
Expand All @@ -94,8 +90,8 @@ public String inform(Combatant c) {
}
}

/** See {@link Upgrade} */
public boolean apply(Combatant c) {
/** This is called when an existing unit is being upgraded. */
public boolean upgrade(Combatant c) {
if (!stack && c.source.hasfeat(this)) {
return false;
}
Expand Down Expand Up @@ -135,4 +131,12 @@ public Feat clone() {
public int count() {
return 1;
}

public void update(Combatant c) {
if (update) {
c.source = c.source.clone();
remove(c);
add(c);
}
}
}
4 changes: 2 additions & 2 deletions javelin/model/unit/feat/ImprovedInitiative.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public String inform(final Combatant m) {
}

@Override
public boolean apply(final Combatant m) {
if (super.apply(m)) {
public boolean upgrade(final Combatant m) {
if (super.upgrade(m)) {
m.source.initiative += 4;
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions javelin/model/unit/feat/MartialTraining.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public MartialTraining(Discipline d) {
}

@Override
public boolean apply(Combatant c) {
public boolean upgrade(Combatant c) {
c.source = c.source.clone();
int i = c.source.feats.indexOf(this);
MartialTraining mt = i == -1 ? this
Expand All @@ -56,7 +56,7 @@ public boolean apply(Combatant c) {
return false;
}
if (i == -1) {
return super.apply(c);
return super.upgrade(c);
}
mt.slots += 2;
return true;
Expand Down
4 changes: 2 additions & 2 deletions javelin/model/unit/feat/Toughness.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public String inform(final Combatant m) {
}

@Override
public boolean apply(final Combatant m) {
if (!super.apply(m)) {
public boolean upgrade(final Combatant m) {
if (!super.upgrade(m)) {
return false;
}
m.maxhp += 3;
Expand Down
4 changes: 2 additions & 2 deletions javelin/model/unit/feat/attack/GreatCleave.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public String inform(Combatant c) {
}

@Override
public boolean apply(Combatant m) {
return m.source.getbaseattackbonus() >= 4 && super.apply(m);
public boolean upgrade(Combatant m) {
return m.source.getbaseattackbonus() >= 4 && super.upgrade(m);
}
}
Loading

0 comments on commit e6e7cc8

Please sign in to comment.