Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arithmetic is dead. And compare_int. And compare_num. Kinda. Long live the math! #70936

Merged
merged 27 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
27f24b8
more math
GuardianDll Jan 10, 2024
3a7c1d7
more math
GuardianDll Jan 10, 2024
3639415
Merge branch 'mathmathmath' of https://github.com/GuardianDll/Catacly…
GuardianDll Jan 10, 2024
0df6d06
a bit more
GuardianDll Jan 11, 2024
af80ac7
compare_int to be gone
GuardianDll Jan 12, 2024
db82205
compare_int to be gone
GuardianDll Jan 12, 2024
19630fc
and more
GuardianDll Jan 14, 2024
04dd66d
compare_num be gone
GuardianDll Jan 14, 2024
3e09029
arithmetic be gone
GuardianDll Jan 14, 2024
45c9d8e
Merge branch 'master' into mathmathmath
GuardianDll Jan 14, 2024
00a69af
lint
GuardianDll Jan 14, 2024
fe37336
fix stuff
GuardianDll Jan 14, 2024
70b3f85
fix stuff
GuardianDll Jan 14, 2024
3404fea
Merge branch 'mathmathmath' of https://github.com/GuardianDll/Catacly…
GuardianDll Jan 14, 2024
f793333
revert u_val('power')
GuardianDll Jan 15, 2024
d556797
jmathify and fix addictions
GuardianDll Jan 15, 2024
5c24df6
Apply suggestions from code review
GuardianDll Jan 15, 2024
11f6cef
migrate u_know_jaryi, mention talked_to_hub and know_jaryi should be …
GuardianDll Jan 15, 2024
4dee051
Merge branch 'master' into mathmathmath
GuardianDll Jan 15, 2024
e6b9737
revert item_rad RAD_DETECT
GuardianDll Jan 15, 2024
9149eea
replace the only place with spell level school; add to another place …
GuardianDll Jan 15, 2024
16da755
"=" -> "=="
GuardianDll Jan 15, 2024
315cb1b
Update data/json/npcs/TALK_TEST.json
GuardianDll Jan 16, 2024
e78e80c
Merge branch 'master' into mathmathmath
GuardianDll Jan 16, 2024
e0d4306
lint
GuardianDll Jan 16, 2024
46d98c3
replace all addiction formulas to use same jmath
GuardianDll Jan 16, 2024
5b3b284
Merge branch 'CleverRaven:master' into mathmathmath
GuardianDll Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/json/effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -4534,7 +4534,7 @@
"values": [
{
"value": "INTELLIGENCE",
"add": { "math": [ "u_val('effect_intensity','effect:VITRIFYING') * -1 * (ceil(u_val('intelligence') / 6))" ] }
"add": { "math": [ "u_effect_intensity('VITRIFYING') * -1 * (ceil(u_val('intelligence') / 6))" ] }
}
]
}
Expand Down
212 changes: 66 additions & 146 deletions data/json/effects_on_condition/addictions_eocs.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,38 @@
[
{
"type": "jmath_function",
"id": "addiction_rational",
"num_args": 3,
"//": "(val / max(1, (val - (step * intensity)))) - 1",
"//2": "_0 = val, _1 = step, _2 = intensity",
"return": "(_0 / max(1, (_0 - (_1 * _2)))) - 1"
},
{
"type": "effect_on_condition",
"id": "EOC_CAFFEINE_ADDICTION",
"condition": {
"compare_num": [
{ "rand": 2000 },
"<=",
{ "u_val": "addiction_intensity", "addiction": "caffeine", "mod": { "val": 2000, "step": 20 } }
]
},
"condition": { "math": [ "rand(2000)", "<=", "addiction_rational(2000, 20, u_addiction_intensity('caffeine'))" ] },
"effect": [
{ "u_message": "You want some caffeine.", "type": "warning" },
{ "u_add_morale": "morale_craving_caffeine", "bonus": -5, "max_bonus": -30 },
{
"run_eocs": [
{
"id": "EOC_CAFFEINE_ADDICTION_MODSTIM",
"condition": {
"and": [
{ "compare_num": [ { "u_val": "stim" }, ">", { "u_val": "addiction_intensity", "addiction": "caffeine", "mod": -10 } ] },
{
"compare_num": [ { "rand": 10 }, "<", { "u_val": "addiction_intensity", "addiction": "caffeine" } ]
}
]
},
"effect": { "arithmetic": [ { "u_val": "stim" }, "-=", { "const": 1 } ] }
},
{
"id": "EOC_CAFFEINE_ADDICTION_SHAKES",
"condition": {
"and": [
{ "compare_num": [ { "u_val": "addiction_intensity", "addiction": "caffeine" }, ">=", { "const": 8 } ] },
{
"compare_num": [ { "rand": 392 }, "<", { "u_val": "addiction_intensity", "addiction": "caffeine" } ]
}
]
},
"effect": [
{ "u_message": "Your hands start shaking… you need it bad!", "type": "bad" },
{ "u_add_effect": "shakes", "duration": "2 minutes" }
]
}
"if": {
"and": [
{ "math": [ "u_val('stim')", ">", "u_addiction_intensity('caffeine') * -10" ] },
{ "math": [ "rand(10)", "<", "u_addiction_intensity('caffeine')" ] }
]
},
"then": { "math": [ "u_val('stim')", "--" ] }
},
{
"if": {
"and": [
{ "math": [ "u_addiction_intensity('caffeine')", ">=", "8" ] },
{ "math": [ "rand(392)", "<", "u_addiction_intensity('caffeine')" ] }
]
},
"then": [
{ "u_message": "Your hands start shaking… you need it bad!", "type": "bad" },
{ "u_add_effect": "shakes", "duration": "2 minutes" }
]
}
]
Expand All @@ -49,84 +41,37 @@
"type": "effect_on_condition",
"id": "EOC_SLEEP_ADDICTION",
"//": "Actual effects processed in player::can_sleep(). Here, only prolong this addiction longer than usual.",
"condition": {
"and": [
{ "compare_num": [ { "rand": 2 }, "==", { "const": 1 } ] },
{ "compare_num": [ { "u_val": "addiction_turns", "addiction": "sleeping pill" }, "<", { "const": 0 } ] }
]
},
"effect": { "arithmetic": [ { "u_val": "addiction_turns", "addiction": "sleeping pill" }, "+=", { "const": 1 } ] }
"condition": { "and": [ { "one_in_chance": 2 }, { "math": [ "u_addiction_turns('sleeping pill')", "<", "0" ] } ] },
"effect": { "math": [ "u_addiction_turns('sleeping pill')", "++" ] }
},
{
"type": "effect_on_condition",
"id": "EOC_MARLOSS_R_ADDICTION",
"condition": {
"compare_num": [
{ "rand": 800 },
"<=",
{ "u_val": "addiction_intensity", "addiction": "marloss_r", "mod": { "val": 800, "step": 20 } }
]
},
"condition": { "math": [ "rand(800)", "<=", "addiction_rational(800, 20, u_addiction_intensity('marloss_r'))" ] },
"effect": [
{ "u_add_morale": "morale_craving_marloss", "bonus": -5, "max_bonus": -30 },
{ "u_message": "You daydream about luscious pink berries as big as your fist.", "type": "info" },
{
"run_eocs": [
{
"id": "EOC_MARLOSS_R_ADDICTION_MODFOCUS",
"condition": { "compare_num": [ { "u_val": "focus" }, ">", { "const": 40 } ] },
"effect": { "arithmetic": [ { "u_val": "focus" }, "-=", { "const": 1 } ] }
}
]
}
{ "if": { "math": [ "u_val('focus')", ">", "40" ] }, "then": { "math": [ "u_val('focus')", "--" ] } }
]
},
{
"type": "effect_on_condition",
"id": "EOC_MARLOSS_B_ADDICTION",
"condition": {
"compare_num": [
{ "rand": 800 },
"<=",
{ "u_val": "addiction_intensity", "addiction": "marloss_b", "mod": { "val": 800, "step": 20 } }
]
},
"condition": { "math": [ "rand(800)", "<=", "addiction_rational(800, 20, u_addiction_intensity('marloss_b'))" ] },
"effect": [
{ "u_add_morale": "morale_craving_marloss", "bonus": -5, "max_bonus": -30 },
{ "u_message": "You daydream about nutty cyan seeds as big as your hand.", "type": "info" },
{
"run_eocs": [
{
"id": "EOC_MARLOSS_B_ADDICTION_MODFOCUS",
"condition": { "compare_num": [ { "u_val": "focus" }, ">", { "const": 40 } ] },
"effect": { "arithmetic": [ { "u_val": "focus" }, "-=", { "const": 1 } ] }
}
]
}
{ "if": { "math": [ "u_val('focus')", ">", "40" ] }, "then": { "math": [ "u_val('focus')", "--" ] } }
]
},
{
"type": "effect_on_condition",
"id": "EOC_MARLOSS_Y_ADDICTION",
"condition": {
"compare_num": [
{ "rand": 800 },
"<=",
{ "u_val": "addiction_intensity", "addiction": "marloss_y", "mod": { "val": 800, "step": 20 } }
]
},
"condition": { "math": [ "rand(800)", "<=", "addiction_rational(800, 20, u_addiction_intensity('marloss_y'))" ] },
"effect": [
{ "u_add_morale": "morale_craving_marloss", "bonus": -5, "max_bonus": -30 },
{ "u_message": "You daydream about succulent, pale golden gel, sweet but light.", "type": "info" },
{
"run_eocs": [
{
"id": "EOC_MARLOSS_Y_ADDICTION_MODFOCUS",
"condition": { "compare_num": [ { "u_val": "focus" }, ">", { "const": 40 } ] },
"effect": { "arithmetic": [ { "u_val": "focus" }, "-=", { "const": 1 } ] }
}
]
}
{ "if": { "math": [ "u_val('focus')", ">", "40" ] }, "then": { "math": [ "u_val('focus')", "--" ] } }
]
},
{
Expand All @@ -135,69 +80,44 @@
"condition": { "u_has_trait": "MUT_JUNKIE" },
"effect": [
{
"run_eocs": [
"if": { "math": [ "rand(600)", "<=", "addiction_rational(600, 50, u_addiction_intensity('mutagen'))" ] },
"then": [
{
"id": "EOC_MUTAGEN_ADDICTION_JUNKIE_MORALE",
"condition": {
"compare_num": [ { "rand": 600 }, "<=", { "u_val": "addiction_intensity", "addiction": "mutagen", "mod": { "val": 600, "step": 50 } } ]
},
"effect": [
{
"run_eocs": [
{
"id": "EOC_MUTAGEN_ADDICTION_JUNKIE_MORALE_MSG",
"condition": { "compare_num": [ { "rand": 6 }, "<", { "u_val": "addiction_intensity", "addiction": "mutagen" } ] },
"effect": { "u_message": "You so miss the exquisite rainbow of post-humanity.", "type": "warning" },
"false_effect": { "u_message": "Your body is SOO booorrrring. Just a little sip to liven things up?", "type": "warning" }
}
]
},
{ "u_add_morale": "morale_craving_mutagen", "bonus": -20, "max_bonus": -200 }
]
"if": { "math": [ "rand(6)", "<", "u_addiction_intensity('mutagen')" ] },
"then": { "u_message": "You so miss the exquisite rainbow of post-humanity.", "type": "warning" },
"else": { "u_message": "Your body is SOO booorrrring. Just a little sip to liven things up?", "type": "warning" }
},
{ "u_add_morale": "morale_craving_mutagen", "bonus": -20, "max_bonus": -200 }
]
},
{
"if": {
"and": [
{ "math": [ "u_val('focus')", ">", "40" ] },
{ "math": [ "rand(800)", "<=", "addiction_rational(800, 20, u_addiction_intensity('mutagen'))" ] }
]
},
"then": [
{ "math": [ "u_val('focus')", "-=", "u_addiction_intensity('mutagen')" ] },
{
"id": "EOC_MUTAGEN_ADDICTION_JUNKIE_FOCUS",
"condition": {
"and": [
{ "compare_num": [ { "u_val": "focus" }, ">", { "const": 40 } ] },
{
"compare_num": [ { "rand": 800 }, "<=", { "u_val": "addiction_intensity", "addiction": "mutagen", "mod": { "val": 800, "step": 20 } } ]
}
]
},
"effect": [
{ "arithmetic": [ { "u_val": "focus" }, "-=", { "u_val": "addiction_intensity", "addiction": "mutagen" } ] },
{
"u_message": "You daydream what it'd be like if you were *different*. Different is good.",
"type": "warning"
}
]
"u_message": "You daydream what it'd be like if you were *different*. Different is good.",
"type": "warning"
}
]
}
],
"false_effect": {
"run_eocs": [
{
"id": "EOC_MUTAGEN_ADDICTION_NOJUNKIE",
"condition": {
"compare_num": [ { "rand": 500 }, "<=", { "u_val": "addiction_intensity", "addiction": "mutagen", "mod": { "val": 500, "step": 15 } } ]
"false_effect": [
{
"if": { "math": [ "rand(500)", "<=", "addiction_rational(500, 15, u_addiction_intensity('mutagen'))" ] },
"then": [
{
"if": { "math": [ "rand(6)", "<", "u_addiction_intensity('mutagen')" ] },
"then": { "u_message": "You haven't had any mutagen lately.", "type": "warning" },
"else": { "u_message": "You could use some new parts…", "type": "warning" }
},
"effect": [
{
"run_eocs": [
{
"id": "EOC_MUTAGEN_ADDICTION_NOJUNKIE_MSG",
"condition": { "compare_num": [ { "rand": 6 }, "<", { "u_val": "addiction_intensity", "addiction": "mutagen" } ] },
"effect": { "u_message": "You haven't had any mutagen lately.", "type": "warning" },
"false_effect": { "u_message": "You could use some new parts…", "type": "warning" }
}
]
},
{ "u_add_morale": "morale_craving_mutagen", "bonus": -5, "max_bonus": -50 }
]
}
]
}
{ "u_add_morale": "morale_craving_mutagen", "bonus": -5, "max_bonus": -50 }
]
}
]
GuardianDll marked this conversation as resolved.
Show resolved Hide resolved
}
]
2 changes: 1 addition & 1 deletion data/json/effects_on_condition/bionic_eocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"recurrence": [ "25 minutes", "1 hours 15 minutes" ],
"condition": { "and": [ { "u_has_bionics": "bio_sleepy" }, { "not": { "u_has_effect": "sleep" } } ] },
"deactivate_condition": { "not": { "u_has_bionics": "bio_sleepy" } },
"effect": [ { "arithmetic": [ { "u_val": "fatigue" }, "++" ] } ]
"effect": { "math": [ "u_val('fatigue')", "++" ] }
},
{
"type": "effect_on_condition",
Expand Down
6 changes: 3 additions & 3 deletions data/json/effects_on_condition/generalized_eocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"u_location_variable": { "global_val": "randenc_loc" },
"target_params": { "om_terrain": { "context_val": "omt" } }
},
{ "arithmetic": [ { "global_val": "var", "var_name": "RandEnc" }, "=", { "const": 1 } ] },
{ "math": [ "RandEnc", "=", "1" ] },
{ "set_string_var": { "context_val": "omt" }, "target_var": { "global_val": "random_encounter_omt" } },
{
"set_string_var": { "context_val": "map_removal" },
Expand All @@ -45,7 +45,7 @@
"and": [
{ "u_compare_time_since_var": "RandEnc", "type": "timer", "context": "caravan", "op": ">", "time": "1 h" },
{ "not": { "u_near_om_location": { "global_val": "random_encounter_omt" }, "range": 2 } },
{ "compare_num": [ { "global_val": "var", "var_name": "RandEnc" }, "==", { "const": 1 } ] }
{ "math": [ "RandEnc", "==", "1" ] }
]
},
"effect": [
Expand All @@ -54,7 +54,7 @@
"om_terrain": { "global_val": "random_encounter_omt" },
"target_var": { "global_val": "randenc_loc" }
},
{ "arithmetic": [ { "global_val": "var", "var_name": "RandEnc" }, "=", { "const": 0 } ] }
{ "math": [ "RandEnc", "=", "0" ] }
]
}
]
6 changes: 3 additions & 3 deletions data/json/effects_on_condition/misc_effect_on_condition.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
{
"type": "effect_on_condition",
"id": "EOC_SLEEP",
"effect": [ { "u_message": "You feel very sleepy…" }, { "arithmetic": [ { "u_val": "fatigue" }, "+=", { "const": 40 } ] } ]
"effect": [ { "u_message": "You feel very sleepy…" }, { "math": [ "u_val('fatigue')", "+=", "40" ] } ]
},
{
"type": "effect_on_condition",
"id": "EOC_MINOR_SLEEP",
"effect": [ { "u_message": "You feel sleepy…" }, { "arithmetic": [ { "u_val": "fatigue" }, "+=", { "const": 20 } ] } ]
"effect": [ { "u_message": "You feel sleepy…" }, { "math": [ "u_val('fatigue')", "+=", "20" ] } ]
},
{
"type": "effect_on_condition",
Expand Down Expand Up @@ -89,7 +89,7 @@
"u_spawn_monster": "GROUP_YOUR_FEARS",
"group": true,
"real_count": 0,
"hallucination_count": { "arithmetic": [ { "const": 1 }, "+", { "rand": 2 } ] },
"hallucination_count": { "math": [ "rand(2) + 1" ] },
"outdoor_only": false,
"min_radius": 10,
"max_radius": 40,
Expand Down
15 changes: 5 additions & 10 deletions data/json/effects_on_condition/mutation_eocs/changing_eocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
"id": "changing_initiate_check",
"//": "Give player the CHANGING trait when they have enough basic mutagen in their blood.",
"recurrence": [ "30 m", "45 m" ],
"condition": {
"and": [
{ "compare_num": [ { "u_val": "vitamin", "name": "mutagen" }, ">=", { "const": 450 } ] },
{ "not": { "u_has_flag": "CHANGING" } }
]
},
"condition": { "and": [ { "math": [ "u_vitamin('mutagen')", ">=", "450" ] }, { "not": { "u_has_flag": "CHANGING" } } ] },
"deactivate_condition": { "u_has_flag": "CHANGING" },
"effect": [
{
Expand All @@ -35,7 +30,7 @@
"effect": [
{ "u_message": "<CHANGING_ENDS>", "type": "bad" },
{ "u_lose_trait": "CHANGING" },
{ "arithmetic": [ { "u_val": "vitamin", "name": "mutagen" }, "=", { "const": 0 } ] }
{ "math": [ "u_vitamin('mutagen')", "=", "0" ] }
]
},
{
Expand All @@ -51,12 +46,12 @@
{
"id": "changing_mutate2",
"//": "Mutate!",
"condition": { "compare_num": [ { "u_val": "vitamin", "name": "mutagen" }, ">=", { "const": 300 } ] },
"condition": { "math": [ "u_vitamin('mutagen')", ">=", "300" ] },
"effect": [
{ "u_message": "You feel a deep, churning sensation fill your body.", "type": "mixed" },
{ "u_mutate": 0 },
{ "arithmetic": [ { "u_val": "vitamin", "name": "mutagen" }, "-=", { "const": 60 } ] },
{ "arithmetic": [ { "u_val": "vitamin", "name": "mutagen" }, "-=", { "rand": 80 } ] }
{ "math": [ "u_vitamin('mutagen')", "-=", "60" ] },
{ "math": [ "u_vitamin('mutagen')", "-=", "rand(80)" ] }
],
"false_effect": [ { "run_eocs": [ "changing_reqs_not_met" ] } ]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,7 @@
"type": "effect_on_condition",
"id": "EOC_insect_wings_shutoff",
"recurrence": [ "1 seconds", "1 seconds" ],
"condition": {
"and": [ { "compare_num": [ { "u_val": "stamina" }, "<", { "const": 3000 } ] }, { "u_has_trait": "WINGS_INSECT_active" } ]
},
"condition": { "and": [ { "math": [ "u_val('stamina')", "<", "3000" ] }, { "u_has_trait": "WINGS_INSECT_active" } ] },
"effect": [
{ "u_activate_trait": "WINGS_INSECT_active" },
{ "u_message": "You don't have the stamina to keep buzzing.", "type": "bad" }
Expand Down
Loading
Loading