Skip to content

Commit 01f534c

Browse files
committed
Ranged chance to hit etc.
1 parent 3374575 commit 01f534c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+3255
-4007
lines changed

src/Backend.elm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,9 @@ oneTimePerkEffects currentTime =
18921892

18931893
Perk.GeckoSkinning ->
18941894
Nothing
1895+
1896+
Perk.NightVision ->
1897+
Nothing
18951898
in
18961899
Perk.all
18971900
|> List.filterMap (\perk -> oneTimeEffect perk |> Maybe.map (Tuple.pair perk))

src/Calculator/Meta/FightSimulation.elm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type alias SPlayerSubset =
4747
, addedSkillPercentages : SeqDict Skill Int
4848
, equippedArmor : Maybe Item
4949
, equippedWeapon : Maybe Item
50+
, equippedAmmo : Maybe Item
5051
, fightStrategy : FightStrategy
5152
, items : Dict Item.Id Item
5253
}
@@ -90,6 +91,7 @@ individualToPlayer isFirst individual =
9091
, items = Dict.empty
9192
, equippedArmor = Nothing
9293
, equippedWeapon = Nothing
94+
, equippedAmmo = Nothing
9395
, addedSkillPercentages = addedSkillPercentages
9496
, fightStrategy = individual.fightStrategy
9597
}

src/Calculator/Meta/Individual.elm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Calculator.Meta.Individual exposing (Individual, crossover, generator, mutate)
22

3+
import Data.Fight.AimedShot as AimedShot
34
import Data.Fight.AttackStyle exposing (AttackStyle(..))
4-
import Data.Fight.ShotType as ShotType
55
import Data.FightStrategy as FightStrategy exposing (FightStrategy)
66
import Data.Item as Item
77
import Data.Skill as Skill exposing (Skill)
@@ -87,12 +87,11 @@ attackStyleGenerator =
8787
Random.uniform ShootBurst
8888
(UnarmedUnaimed
8989
:: MeleeUnaimed
90-
:: ThrowUnaimed
90+
:: Throw
9191
:: ShootSingleUnaimed
92-
:: List.concatMap (\toAimed -> List.map toAimed ShotType.allAimed)
92+
:: List.concatMap (\toAimed -> List.map toAimed AimedShot.all)
9393
[ UnarmedAimed
9494
, MeleeAimed
95-
, ThrowAimed
9695
, ShootSingleAimed
9796
]
9897
)
@@ -527,7 +526,7 @@ mutateFightStrategy str =
527526
mutateCommandDetails cmd =
528527
case cmd of
529528
FightStrategy.Attack _ ->
530-
shotTypeGenerator
529+
attackStyleGenerator
531530
|> Random.map FightStrategy.Attack
532531

533532
FightStrategy.AttackRandomly ->
@@ -537,6 +536,9 @@ mutateFightStrategy str =
537536
healingItemKindGenerator
538537
|> Random.map FightStrategy.Heal
539538

539+
FightStrategy.HealWithAnything ->
540+
Random.constant FightStrategy.HealWithAnything
541+
540542
FightStrategy.MoveForward ->
541543
Random.constant FightStrategy.MoveForward
542544

src/Data/Enemy.elm

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Data.Enemy exposing
1111
, dropGenerator
1212
, dropSpec
1313
, encodeType
14+
, equippedAmmo
1415
, equippedArmor
1516
, equippedWeapon
1617
, forSmallChunk
@@ -26,8 +27,8 @@ module Data.Enemy exposing
2627
, xp
2728
)
2829

30+
import Data.Fight.AimedShot exposing (AimedShot(..))
2931
import Data.Fight.Critical as Critical exposing (Effect(..), EffectCategory(..))
30-
import Data.Fight.ShotType exposing (AimedShot(..))
3132
import Data.Item as Item exposing (Item)
3233
import Data.Map.BigChunk as BigChunk exposing (BigChunk(..))
3334
import Data.Map.SmallChunk exposing (SmallChunk)
@@ -1040,6 +1041,58 @@ equippedWeapon type_ =
10401041
Nothing
10411042

10421043

1044+
equippedAmmo : Type -> Maybe Item.Kind
1045+
equippedAmmo type_ =
1046+
case type_ of
1047+
Brahmin ->
1048+
Nothing
1049+
1050+
AngryBrahmin ->
1051+
Nothing
1052+
1053+
WeakBrahmin ->
1054+
Nothing
1055+
1056+
WildBrahmin ->
1057+
Nothing
1058+
1059+
GiantAnt ->
1060+
Nothing
1061+
1062+
ToughGiantAnt ->
1063+
Nothing
1064+
1065+
LesserRadscorpion ->
1066+
Nothing
1067+
1068+
Radscorpion ->
1069+
Nothing
1070+
1071+
LesserBlackRadscorpion ->
1072+
Nothing
1073+
1074+
BlackRadscorpion ->
1075+
Nothing
1076+
1077+
SilverGecko ->
1078+
Nothing
1079+
1080+
ToughSilverGecko ->
1081+
Nothing
1082+
1083+
GoldenGecko ->
1084+
Nothing
1085+
1086+
ToughGoldenGecko ->
1087+
Nothing
1088+
1089+
FireGecko ->
1090+
Nothing
1091+
1092+
ToughFireGecko ->
1093+
Nothing
1094+
1095+
10431096
criticalSpec : Type -> AimedShot -> Critical.EffectCategory -> Critical.Spec
10441097
criticalSpec enemyType =
10451098
-- https://falloutmods.fandom.com/wiki/Critical_hit_tables

src/Data/Fight.elm

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module Data.Fight exposing
2121
)
2222

2323
import Data.Enemy as Enemy
24-
import Data.Fight.ShotType as ShotType exposing (ShotType)
24+
import Data.Fight.AttackStyle as AttackStyle exposing (AttackStyle)
2525
import Data.FightStrategy exposing (FightStrategy)
2626
import Data.Item as Item exposing (Item)
2727
import Data.Perk exposing (Perk)
@@ -70,6 +70,7 @@ type alias Opponent =
7070
, drops : List Item
7171
, equippedArmor : Maybe Item.Kind
7272
, equippedWeapon : Maybe Item.Kind
73+
, equippedAmmo : Maybe Item.Kind
7374
, naturalArmorClass : Int
7475
, attackStats : AttackStats
7576
, addedSkillPercentages : SeqDict Skill Int
@@ -101,13 +102,13 @@ type Action
101102
}
102103
| Attack
103104
{ damage : Int
104-
, shotType : ShotType
105+
, attackStyle : AttackStyle
105106
, remainingHp : Int
106107
, isCritical : Bool -- TODO the string
107108
, apCost : Int
108109
}
109110
| Miss
110-
{ shotType : ShotType
111+
{ attackStyle : AttackStyle
111112
, apCost : Int
112113

113114
-- TODO isCritical
@@ -352,7 +353,7 @@ encodeAction action =
352353
JE.object
353354
[ ( "type", JE.string "Attack" )
354355
, ( "damage", JE.int r.damage )
355-
, ( "shotType", ShotType.encode r.shotType )
356+
, ( "attackStyle", AttackStyle.encode r.attackStyle )
356357
, ( "remainingHp", JE.int r.remainingHp )
357358
, ( "isCritical", JE.bool r.isCritical )
358359
, ( "apCost", JE.int r.apCost )
@@ -361,7 +362,7 @@ encodeAction action =
361362
Miss r ->
362363
JE.object
363364
[ ( "type", JE.string "Miss" )
364-
, ( "shotType", ShotType.encode r.shotType )
365+
, ( "attackStyle", AttackStyle.encode r.attackStyle )
365366
, ( "apCost", JE.int r.apCost )
366367
]
367368

@@ -437,13 +438,13 @@ actionDecoder =
437438

438439
"Miss" ->
439440
JD.map2
440-
(\shotType apCost ->
441+
(\attackStyle apCost ->
441442
Miss
442-
{ shotType = shotType
443+
{ attackStyle = attackStyle
443444
, apCost = apCost
444445
}
445446
)
446-
(JD.field "shotType" ShotType.decoder)
447+
(JD.field "attackStyle" AttackStyle.decoder)
447448
(JD.field "apCost" JD.int)
448449

449450
"Heal" ->
@@ -507,25 +508,18 @@ commandRejectionReasonDecoder =
507508

508509
attackActionDecoder : Decoder Action
509510
attackActionDecoder =
510-
JD.oneOf
511-
[ attackActionDecoderV1
512-
]
513-
514-
515-
attackActionDecoderV1 : Decoder Action
516-
attackActionDecoderV1 =
517511
JD.map5
518-
(\damage shotType remainingHp isCritical apCost ->
512+
(\damage attackStyle remainingHp isCritical apCost ->
519513
Attack
520514
{ damage = damage
521-
, shotType = shotType
515+
, attackStyle = attackStyle
522516
, remainingHp = remainingHp
523517
, isCritical = isCritical
524518
, apCost = apCost
525519
}
526520
)
527521
(JD.field "damage" JD.int)
528-
(JD.field "shotType" ShotType.decoder)
522+
(JD.field "attackStyle" AttackStyle.decoder)
529523
(JD.field "remainingHp" JD.int)
530524
(JD.field "isCritical" JD.bool)
531525
(JD.field "apCost" JD.int)

src/Data/Fight/AimedShot.elm

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
module Data.Fight.AimedShot exposing
2+
( AimedShot(..)
3+
, all
4+
, decoder
5+
, encode
6+
, toString
7+
)
8+
9+
import Json.Decode as JD exposing (Decoder)
10+
import Json.Encode as JE
11+
12+
13+
type AimedShot
14+
= Head
15+
| Torso
16+
| Eyes
17+
| Groin
18+
| LeftArm
19+
| RightArm
20+
| LeftLeg
21+
| RightLeg
22+
23+
24+
all : List AimedShot
25+
all =
26+
[ Head
27+
, Torso
28+
, Eyes
29+
, Groin
30+
, LeftArm
31+
, RightArm
32+
, LeftLeg
33+
, RightLeg
34+
]
35+
36+
37+
encode : AimedShot -> JE.Value
38+
encode aimed =
39+
case aimed of
40+
Head ->
41+
JE.string "Head"
42+
43+
Torso ->
44+
JE.string "Torso"
45+
46+
Eyes ->
47+
JE.string "Eyes"
48+
49+
Groin ->
50+
JE.string "Groin"
51+
52+
LeftArm ->
53+
JE.string "LeftArm"
54+
55+
RightArm ->
56+
JE.string "RightArm"
57+
58+
LeftLeg ->
59+
JE.string "LeftLeg"
60+
61+
RightLeg ->
62+
JE.string "RightLeg"
63+
64+
65+
decoder : Decoder AimedShot
66+
decoder =
67+
JD.string
68+
|> JD.andThen
69+
(\type_ ->
70+
case type_ of
71+
"Head" ->
72+
JD.succeed Head
73+
74+
"Torso" ->
75+
JD.succeed Torso
76+
77+
"Eyes" ->
78+
JD.succeed Eyes
79+
80+
"Groin" ->
81+
JD.succeed Groin
82+
83+
"LeftArm" ->
84+
JD.succeed LeftArm
85+
86+
"RightArm" ->
87+
JD.succeed RightArm
88+
89+
"LeftLeg" ->
90+
JD.succeed LeftLeg
91+
92+
"RightLeg" ->
93+
JD.succeed RightLeg
94+
95+
_ ->
96+
JD.fail <| "Unknown AimedShot: '" ++ type_ ++ "'"
97+
)
98+
99+
100+
{-| TODO What purpose is this string for? Name the function better
101+
-}
102+
toString : AimedShot -> String
103+
toString aimedShot =
104+
case aimedShot of
105+
Head ->
106+
"head"
107+
108+
Torso ->
109+
"torso"
110+
111+
Eyes ->
112+
"eyes"
113+
114+
Groin ->
115+
"groin"
116+
117+
LeftArm ->
118+
"left arm"
119+
120+
RightArm ->
121+
"right arm"
122+
123+
LeftLeg ->
124+
"left leg"
125+
126+
RightLeg ->
127+
"right leg"

0 commit comments

Comments
 (0)