Skip to content

Commit

Permalink
WIP ranged combat
Browse files Browse the repository at this point in the history
Janiczek committed Oct 5, 2024
1 parent 66cac50 commit 986c396
Showing 12 changed files with 5,170 additions and 2,026 deletions.
2 changes: 2 additions & 0 deletions .ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test: elm-test --compiler lamdera
watch: elm-test --compiler lamdera --watch
3 changes: 3 additions & 0 deletions src/Backend.elm
Original file line number Diff line number Diff line change
@@ -1895,6 +1895,9 @@ oneTimePerkEffects currentTime =

Perk.NightVision ->
Nothing

Perk.BonusRangedDamage ->
Nothing
in
Perk.all
|> List.filterMap (\perk -> oneTimeEffect perk |> Maybe.map (Tuple.pair perk))
77 changes: 65 additions & 12 deletions src/Data/Enemy.elm
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ module Data.Enemy exposing
, actionPoints
, addedSkillPercentages
, aimedShotName
, allTypes
, all
, criticalSpec
, damageResistanceNormal
, damageThresholdNormal
@@ -17,6 +17,7 @@ module Data.Enemy exposing
, forSmallChunk
, hp
, humanAimedShotName
, isLivingCreature
, manCriticalSpec
, meleeDamageBonus
, name
@@ -114,24 +115,24 @@ type Type
| Radscorpion


allTypes : List Type
allTypes =
[ Brahmin
all : List Type
all =
[ SilverGecko
, ToughSilverGecko
, GoldenGecko
, ToughGoldenGecko
, FireGecko
, ToughFireGecko
, Brahmin
, AngryBrahmin
, WeakBrahmin
, WildBrahmin
, GiantAnt
, ToughGiantAnt
, BlackRadscorpion
, LesserBlackRadscorpion
, LesserRadscorpion
, Radscorpion
, LesserBlackRadscorpion
, BlackRadscorpion
, SilverGecko
, ToughSilverGecko
, GoldenGecko
, ToughGoldenGecko
, FireGecko
, ToughFireGecko
]


@@ -3740,3 +3741,55 @@ dropItemsGenerator { items } =
)
|> Random.sequence
|> Random.map Maybe.values


isLivingCreature : Type -> Bool
isLivingCreature type_ =
case type_ of
SilverGecko ->
True

ToughSilverGecko ->
True

GoldenGecko ->
True

ToughGoldenGecko ->
True

FireGecko ->
True

ToughFireGecko ->
True

Brahmin ->
True

AngryBrahmin ->
True

WeakBrahmin ->
True

WildBrahmin ->
True

GiantAnt ->
True

ToughGiantAnt ->
True

BlackRadscorpion ->
True

LesserBlackRadscorpion ->
True

LesserRadscorpion ->
True

Radscorpion ->
True
11 changes: 11 additions & 0 deletions src/Data/Fight.elm
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ module Data.Fight exposing
, isCriticalAttack
, isMiss
, isNPC
, isOpponentLivingCreature
, isPlayer
, opponentName
, opponentXp
@@ -604,3 +605,13 @@ isMiss action =

_ ->
False


isOpponentLivingCreature : Opponent -> Bool
isOpponentLivingCreature opponent =
case opponent.type_ of
Npc enemy ->
Enemy.isLivingCreature enemy

Player _ ->
True
11 changes: 11 additions & 0 deletions src/Data/Fight/DamageType.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Data.Fight.DamageType exposing (DamageType(..))


type DamageType
= NormalDamage
| Fire
| Explosion
| Laser
| Plasma
| Electrical
| EMP
429 changes: 304 additions & 125 deletions src/Data/Fight/Generator.elm

Large diffs are not rendered by default.

6,538 changes: 4,693 additions & 1,845 deletions src/Data/Item.elm

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion src/Data/Perk.elm
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ type Perk
-- lvl 6
| AdrenalineRush
-- TODO Bonus Move -- would need move-only APs and some intelligent use of movement in combat
-- TODO Bonus Ranged Damage -- would need ranged combat
| BonusRangedDamage
| Educated
-- TODO Empathy -- would need dialogues
| FortuneFinder
@@ -114,6 +114,7 @@ all =
, Awareness
, BetterCriticals
, BonusHthAttacks
, BonusRangedDamage
, BonusRateOfFire
, BonusHthDamage
, CautiousNature
@@ -291,6 +292,9 @@ name perk =
NightVision ->
"Night Vision"

BonusRangedDamage ->
"Bonus Ranged Damage"


{-| <https://fallout.fandom.com/wiki/Fallout_2_perks>
-}
@@ -429,6 +433,9 @@ maxRank perk =
GeckoSkinning ->
1

BonusRangedDamage ->
2


encode : Perk -> JE.Value
encode perk =
@@ -566,13 +573,19 @@ encode perk =
GeckoSkinning ->
"gecko-skinning"

BonusRangedDamage ->
"bonus-ranged-damage"


decoder : Decoder Perk
decoder =
JD.string
|> JD.andThen
(\perk ->
case perk of
"bonus-ranged-damage" ->
JD.succeed BonusRangedDamage

"earlier-sequence" ->
JD.succeed EarlierSequence

@@ -878,6 +891,9 @@ isApplicableForLevelup r perk =

GeckoSkinning ->
False

BonusRangedDamage ->
r.level >= 6 && s.agility >= 6 && s.luck >= 6
)


@@ -1016,3 +1032,6 @@ description perk =

GeckoSkinning ->
"You have the knowledge of how to skin geckos properly to get their hides."

BonusRangedDamage ->
"Your training in firearms and other ranged weapons has made you more deadly in ranged combat. For each level of this Perk, you do +2 points of damage with ranged weapons."
6 changes: 5 additions & 1 deletion src/Frontend/News.elm
Original file line number Diff line number Diff line change
@@ -28,12 +28,16 @@ items =
- more "normal" unarmed+melee weapons, and make them part of shops
- Fast Shot trait -> can't use aimed shots
- Are we adding bonus to Critical Chance based on AimedShot?
- Add upgraded unarmed attacks: https://fallout.fandom.com/wiki/Unarmed_(Fallout)
EQUIPPED AMMO
- show it in the inventory
- show which types are usable for the current weapon
- don't allow equipping incompatible ammo
- when unequipping weapon unequip the ammo too
- when it runs out during the fight, do we want to default to another compatible ammo? So should it be only preferredAmmo?
- Use it in the fight, switch to another compatible ammo (even in the SPlayer afterwards!) when it runs out and unequip when it runs out (switching back to unarmed content)
- FightStrategy: walk away
59 changes: 55 additions & 4 deletions src/Logic.elm
Original file line number Diff line number Diff line change
@@ -570,7 +570,7 @@ rangedChanceToHit r =
-- weapon long range perk is already factored into the distancePenalty
+ weaponAccuratePerk
- distancePenalty_
- ((r.targetArmorClass * (100 - ammoArmorClassModifier)) // 100)
- ((r.targetArmorClass * (100 + ammoArmorClassModifier)) // 100)
- lightingPenalty_
- strengthRequirementPenalty
- shotPenalty
@@ -1168,7 +1168,7 @@ damageThresholdNormal r =
let
armorDamageThreshold =
r.equippedArmor
|> Maybe.map Item.damageThresholdNormal
|> Maybe.map Item.armorDamageThresholdNormal
|> Maybe.withDefault 0
in
r.naturalDamageThresholdNormal + armorDamageThreshold
@@ -1184,7 +1184,7 @@ damageResistanceNormal r =
let
fromArmor =
r.equippedArmor
|> Maybe.map Item.damageResistanceNormal
|> Maybe.map Item.armorDamageResistanceNormal
|> Maybe.withDefault 0

fromToughnessPerk =
@@ -1481,6 +1481,57 @@ attackStyleAndApCost kind =
Flare ->
[ ( Throw, 1 ) ]

Ap5mm ->
[]

Mm9 ->
[]

Ball9mm ->
[]

Ap10mm ->
[]

Ap14mm ->
[]

ExplosiveRocket ->
[]

RocketAp ->
[]

Wakizashi ->
meleeAttackStyleAndApCost 3

LittleJesus ->
meleeAttackStyleAndApCost 3

Ripper ->
meleeAttackStyleAndApCost 4

Pistol223 ->
shootAttackStyleAndApCost 5

NeedlerPistol ->
shootAttackStyleAndApCost 5

MagnetoLaserPistol ->
shootAttackStyleAndApCost 5

PulsePistol ->
shootAttackStyleAndApCost 4

HolyHandGrenade ->
[ ( Throw, 4 ) ]

HnNeedlerCartridge ->
[]

HnApNeedlerCartridge ->
[]


canBurst : Item.Kind -> Bool
canBurst kind =
@@ -1496,6 +1547,6 @@ strengthRequirementChanceToHitPenalty :
strengthRequirementChanceToHitPenalty r =
let
strengthRequirement =
Item.strengthRequirement r.equippedWeapon
Item.weaponStrengthRequirement r.equippedWeapon
in
max 0 (strengthRequirement - r.strength) * 20
37 changes: 0 additions & 37 deletions tests/LogicTest.elm
Original file line number Diff line number Diff line change
@@ -86,43 +86,6 @@ test =
]


log :
{ attackerAddedSkillPercentages : SeqDict Skill Int
, attackerPerks : SeqDict Perk Int
, attackerSpecial : Special
, distanceHexes : Int
, equippedWeapon : Maybe Item.Kind
, equippedAmmo : Maybe Item.Kind
, targetArmorClass : Int
, attackStyle : AttackStyle
}
->
{ attackerAddedSkillPercentages : SeqDict Skill Int
, attackerPerks : SeqDict Perk Int
, attackerSpecial : Special
, distanceHexes : Int
, equippedWeapon : Maybe Item.Kind
, equippedAmmo : Maybe Item.Kind
, targetArmorClass : Int
, attackStyle : AttackStyle
}
log args =
let
_ =
{ attackerAddedSkillPercentages = SeqDict.toList args.attackerAddedSkillPercentages
, attackerPerks = SeqDict.toList args.attackerPerks
, attackerSpecial = args.attackerSpecial
, distanceHexes = args.distanceHexes
, equippedWeapon = args.equippedWeapon
, equippedAmmo = args.equippedAmmo
, targetArmorClass = args.targetArmorClass
, attackStyle = args.attackStyle
}
|> Debug.log "chanceToHit args"
in
args


chanceToHitArgsFuzzer :
Fuzzer
{ attackerAddedSkillPercentages : SeqDict Skill Int
2 changes: 1 addition & 1 deletion tests/TestHelpers.elm
Original file line number Diff line number Diff line change
@@ -327,7 +327,7 @@ randomSeedFuzzer =

enemyTypeFuzzer : Fuzzer Enemy.Type
enemyTypeFuzzer =
Fuzz.oneOfValues Enemy.allTypes
Fuzz.oneOfValues Enemy.all


traitsFuzzer : Fuzzer (SeqSet Trait)

0 comments on commit 986c396

Please sign in to comment.