Skip to content

Commit

Permalink
Allow more dialog use of arithmetic, small portal storm rebalance. (C…
Browse files Browse the repository at this point in the history
…leverRaven#57983)

* nested rithmetic

* Move over existing json

* Update portal_storm_effect_on_condition.json

* fix

* linker?

* Fix

* Update condition.cpp

* Update condition.cpp

* stupid linker making this code worse

* Update condition.cpp

* Update condition.cpp

* Update condition.cpp

* Update condition.cpp

* Update condition.h
  • Loading branch information
Ramza13 authored and bombasticSlacks committed Jun 10, 2022
1 parent 3f1ba17 commit 7754b2f
Show file tree
Hide file tree
Showing 16 changed files with 1,323 additions and 1,148 deletions.
22 changes: 6 additions & 16 deletions data/json/monster_special_attacks/spells.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,28 +386,18 @@
"effect": [
{
"arithmetic": [
{ "global_val": "var", "var_name": "ps_shifting_mass_fatigue" },
"=",
{ "global_val": "var", "var_name": "ps_str" },
"+",
{ "const": 20 }
{ "u_val": "fatigue" },
"+=",
{ "arithmetic": [ { "global_val": "var", "var_name": "ps_str" }, "+", { "const": 20 } ] }
]
},
{
"arithmetic": [
{ "global_val": "var", "var_name": "ps_shifting_mass_stamina" },
"=",
{ "global_val": "var", "var_name": "ps_str" },
"+",
{ "const": 50 }
{ "u_val": "stamina" },
"+=",
{ "arithmetic": [ { "global_val": "var", "var_name": "ps_str" }, "+", { "const": 50 } ] }
]
},
{
"arithmetic": [ { "u_val": "fatigue" }, "+=", { "global_val": "var", "var_name": "ps_shifting_mass_fatigue" } ]
},
{
"arithmetic": [ { "u_val": "stamina" }, "+=", { "global_val": "var", "var_name": "ps_shifting_mass_stamina" } ]
},
{ "arithmetic": [ { "u_val": "sleep_deprivation" }, "+=", { "time": "1 minutes" } ] }
]
},
Expand Down
54 changes: 19 additions & 35 deletions data/json/portal_storm_effect_on_condition.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"type": "effect_on_condition",
"id": "EOC_PORTAL_STORM_WARN_OR_CAUSE_RECURRING",
"recurrence": [ { "global_val": "ps_min_woc", "default": "5 days" }, { "global_val": "ps_max_woc", "default": "9 days" } ],
"recurrence": [ { "global_val": "ps_min_woc", "default": "5 days" }, { "global_val": "ps_max_woc", "default": "18 days" } ],
"global": true,
"effect": { "run_eocs": "EOC_CAUSE_EARLY_PORTAL_STORM" }
},
Expand Down Expand Up @@ -192,7 +192,10 @@
},
{
"queue_eocs": "EOC_CANCEL_PORTAL_STORM",
"time_in_future": [ { "global_val": "ps_min_length", "default": "2 hours" }, { "global_val": "ps_max_length", "default": "4 hours" } ]
"time_in_future": [
{ "global_val": "ps_min_length", "default": "15 minutes" },
{ "global_val": "ps_max_length", "default": "30 minutes" }
]
},
{ "u_message": "Reality is breaking!", "type": "bad" }
]
Expand Down Expand Up @@ -390,20 +393,10 @@
"type": "effect_on_condition",
"id": "EOC_PORTAL_SHIFTING_MASS",
"effect": [
{
"arithmetic": [
{ "global_val": "var", "var_name": "ps_shifting_mass_count" },
"=",
{ "global_val": "var", "var_name": "ps_str" },
"/",
{ "const": 2 }
],
"min": 1
},
{
"u_spawn_monster": "mon_shifting_mass",
"real_count": { "global_val": "ps_shifting_mass_count", "default": 1 },
"hallucination_count": { "global_val": "ps_shifting_mass_count", "default": 1 },
"real_count": { "arithmetic": [ { "global_val": "var", "var_name": "ps_str" }, "/", { "const": 2 } ], "min": 1 },
"hallucination_count": { "arithmetic": [ { "global_val": "var", "var_name": "ps_str" }, "/", { "const": 2 } ], "min": 1 },
"outdoor_only": true,
"min_radius": 3,
"max_radius": 20,
Expand Down Expand Up @@ -534,22 +527,19 @@
"id": "EOC_PORTAL_LIGHT",
"//": "If its night make it bright, if its day make it dark.",
"effect": [
{
"arithmetic": [
{ "global_val": "var", "var_name": "ps_light_str" },
"=",
{ "global_val": "var", "var_name": "ps_str" },
"*",
{ "time": "1 minutes" }
]
},
{
"run_eocs": [
{
"id": "portal_storm_dark_light",
"condition": "is_day",
"effect": { "custom_light_level": 0, "length": [ "1 minutes", { "global_val": "ps_light_str", "default": "1 minutes" } ] },
"false_effect": { "custom_light_level": 125, "length": [ "1 minutes", { "global_val": "ps_light_str", "default": "1 minutes" } ] }
"effect": {
"custom_light_level": 0,
"length": [ "1 minutes", { "arithmetic": [ { "global_val": "var", "var_name": "ps_str" }, "*", { "time": "1 minutes" } ] } ]
},
"false_effect": {
"custom_light_level": 125,
"length": [ "1 minutes", { "arithmetic": [ { "global_val": "var", "var_name": "ps_str" }, "*", { "time": "1 minutes" } ] } ]
}
},
{
"id": "portal_storm_outside_message",
Expand All @@ -572,21 +562,15 @@
"id": "EOC_PORTAL_INCORPOREAL",
"condition": { "and": [ { "not": { "u_has_worn_with_flag": "PORTAL_PROOF" } }, { "not": "u_driving" } ] },
"effect": [
{
"arithmetic": [
{ "global_val": "var", "var_name": "ps_incorporeal_str" },
"=",
{ "global_val": "var", "var_name": "ps_str" },
"*",
{ "time": "1 seconds" }
]
},
{
"u_message": "You feel stretched, as if part of you was elsewhere. You are not solid enough to affect matter, and your equipment falls through you.",
"type": "bad",
"popup": true
},
{ "u_add_effect": "incorporeal", "duration": { "global_val": "ps_incorporeal_str", "default": "1 seconds" } }
{
"u_add_effect": "incorporeal",
"duration": { "arithmetic": [ { "global_val": "var", "var_name": "ps_str" }, "*", { "time": "1 seconds" } ] }
}
]
},
{
Expand Down
10 changes: 8 additions & 2 deletions doc/NPCs.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,18 @@ One of `"for_item"` or `"for_category"`, and each can either be a single string
## Dialogue Effects
The `effect` field of `speaker_effect` or a `response` can be any of the following effects. Multiple effects should be arranged in a list and are processed in the order listed.

`variable_object`: This is either an object or array describing a variable name. It can either describe an int or a time duration. If it is an array it must have 2 values the first of which will be a minimum and the second will be a maximum and the value will be randomly between the two. If it is an int `default` is a required int which will be the value returned if the variable is not defined. If is it a duration then `default` can be either an int or a string describing a time span. `u_val`, `npc_val`, or `global_val` can be the used for the variable name element. If `u_val` is used it describes a variable on player u, if `npc_val` is used it describes a variable on player npc, if `global_val` is used it describes a global variable.
`variable_object`: This is either an object, an `arithmetic` expression(see arithmetic below) or array describing a variable name. It can either describe an int or a time duration. If it is an array it must have 2 values the first of which will be a minimum and the second will be a maximum and the value will be randomly between the two. If it is an int `default` is a required int which will be the value returned if the variable is not defined. If is it a duration then `default` can be either an int or a string describing a time span. `u_val`, `npc_val`, or `global_val` can be the used for the variable name element. If `u_val` is used it describes a variable on player u, if `npc_val` is used it describes a variable on player npc, if `global_val` is used it describes a global variable.

example json:
```
"effect": [ { "u_mod_focus": { "u_val":"test", "default": 1 } },
{ "u_mod_focus": [ 0, { "u_val":"test", "default": 1 } ] }
{ "u_add_morale": "morale_honey","bonus": -20,"max_bonus": -60, "decay_start": 1,
"duration": { "global_val": "test2", "type": "debug", "context": "testing", "default": "2 minutes" } ]
"duration": { "global_val": "test2", "type": "debug", "context": "testing", "default": "2 minutes" },
{
"u_spawn_monster": "mon_absence",
"real_count": { "arithmetic": [ { "arithmetic": [ { "const":1 }, "+", { "const": 1 } ] }, "+", { "const": 1 } ] }
} ]
```

Expand Down Expand Up @@ -1020,8 +1024,10 @@ Example | Description
`"distance": []` | Distance between two targets. Valid targets are: "u","npc" and an object with a variable name.
`"hour"` | Hours since midnight.
`"moon"` | Phase of the moon. MOON_NEW =0, WAXING_CRESCENT =1, HALF_MOON_WAXING =2, WAXING_GIBBOUS =3, FULL =4, WANING_GIBBOUS =5, HALF_MOON_WANING =6, WANING_CRESCENT =7
`"arithmetic"` | An arithmetic expression with no result.
```
"condition": { "compare_int": [ { "distance": [ "u",{ "u_val": "stuck", "type": "ps", "context": "teleport" } ] }, ">", { "const": 5 } ] }
"real_count": { "arithmetic": [ { "arithmetic": [ { "const":1 }, "+", { "const": 1 } ] }, "+", { "const": 1 } ] },
```

#### Sample responses with conditions and effects
Expand Down
Loading

0 comments on commit 7754b2f

Please sign in to comment.