Skip to content

Commit 9cd9cdc

Browse files
authored
Add entry 002: Item States
1 parent 8b7b278 commit 9cd9cdc

1 file changed

Lines changed: 152 additions & 0 deletions

File tree

points/002-item-states.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Item States
2+
3+
Currently, separate states of items – like on vs. off flashlight – have to be defined and treated as separate items, with the `transform` action used to surreptitiously switch one item for another. This leads to bloat, and creates a larger surface area for errors: for example, making changes to the item's dimensions in one case but not the rest of them.
4+
5+
Using *states* allows avoiding the these problems by managing their properties within the frame of the same item. A state would be part of the item definition, under the `state_data` key.
6+
7+
Each state defines a set of properties that differentiate it from the item's default state, which is defined in the item object's root.
8+
9+
10+
## Exclusive and Complementary States
11+
12+
States could be structurally defined as exclusive or complementary in `state_data`.
13+
14+
Only one state from each exclusive group can be on at any given time. Switching to a different state in an exclusive group turns the previous state off automatically. Examples include flashlights with multiple brightness settings, firearms with fire mode switches, and mechanical tools which may operate from different configurations.
15+
16+
Complementary states may operate independently of other state groups. Smartphones may act as music players and flashlights at the same time, and control panels for security systems may be used to toggle any number of switches on the panel at any given moment.
17+
18+
`state_data` of an item must be able to define both kinds of states, and switching between the states cannot be a one-at-a-time action – where players are required to activate the item multiple times to toggle multiple states, the repetitiveness of which quickly becomes unpleasant – unless there's only one other state to switch to.
19+
20+
21+
### Example `state_data` Definition
22+
23+
```
24+
{
25+
"name": "SUPERSHOCK self-defence flashlight",
26+
"//": "...the rest of the item definition...",
27+
"state_data": [
28+
{
29+
"category_name": "Flashlight",
30+
"states": [
31+
{
32+
"name": "off",
33+
"default": true,
34+
35+
"luminance": 0,
36+
"power_draw": 0
37+
},
38+
{
39+
"name": "on, regular",
40+
"description_suffix": "The flashlight is on.",
41+
42+
"luminance": 400,
43+
"power_draw": "10.7 Wh",
44+
"power_min": "5 J"
45+
},
46+
{
47+
"name": "on, bright",
48+
"description_suffix": "The flashlight is on, operating at increased brightness.",
49+
50+
"luminance": 1200,
51+
"power_draw": "32.1 Wh",
52+
"power_min": "15 J"
53+
}
54+
]
55+
},
56+
{
57+
"category_name": "Shocker",
58+
"states": [
59+
{
60+
"name": "active",
61+
"description_suffix": "The flashlight's self-defense module is currently on. Any attack made using the flashlight will inflict electrical damage on the target, potentially stunning them. Each attack drains a bit of power from the embedded battery.",
62+
"extend": {
63+
"damage": {
64+
"damage_type": "electric",
65+
"amount": 45,
66+
"range": 1
67+
},
68+
69+
"power_draw_per_attack": "10 W",
70+
"power_min": "50 J"
71+
}
72+
}
73+
]
74+
}
75+
]
76+
}
77+
```
78+
79+
*Note*: values are given for the purposes of demonstration and are not necessarily correct.
80+
81+
*Note*: in the example above, `"luminance"` is the scaling parameter for the perceived power of light, in lumens. `"power_draw_per_attack"` is an *ad hoc* parameter meant to indicate power draw similar to `"ups_per_charge"`, but in a more generic power-supply framework.
82+
83+
`state_data` is given in the form of array, itself containing any number of objects. Each object represents a set of complementary states. Each object must have at least the `"name"` and `"states"` keys, and may have any number of other permitted keys.
84+
85+
One example of such keys is `"description_suffix"`, which adds a separate (double returns) line at the end of the item's description in order to clarify the item's current state. Multiple "suffixes" from complementary states combine, each starting on a separate line. The order of the suffixed lines is determined by the order of the state groups in the item's JSON definition.
86+
87+
In this example, the item is a flashlight with a shocker self-defense function. According to `state_data`, it has two complementary states: the "Flashlight" function and the "Shocker" function.
88+
89+
90+
#### Exclusive States
91+
92+
"Flashlight" has several states, with a defined "off" state because there are multiple states available.
93+
94+
The "off" state may not be required, with the game potentially assuming there is one where no states-based changes apply unless stated otherwise. However, this may cause issues defining objects where there is no real "off" state.
95+
96+
A good example of this are tools which may be extended or compressed, with no default state obvious to the game. In this case, the item itself is an abstract, where some of its key qualities – such as tool qualities, volume, and length – would be defined in each given state.
97+
98+
If an exclusive state requires power to function and there isn't enough power for that in the item, it would revert to the default state (see below).
99+
100+
101+
#### Complementary States
102+
103+
"Shocker" has one state, which implies that the category is togglable between positions "on" and "off", where "on" is the explicitly defined state.
104+
105+
"Shocker" and "Flashlight" state groups may be active at the same time, as long as both satisfy their own requirements. In this case, the item would be emitting light *and* producing electical damage on each attack.
106+
107+
108+
#### Conditional States
109+
110+
It must be possible to define states which would be activated only if conditions are met.
111+
112+
For example, radiation badges would have states of "green" and "red", the latter activating if the square the badge is in emits radiation.
113+
114+
Another example would be a tracking device, which lights a different color – green, yellow, or red – depending on the distance between it and the target. This may be useful in tracking bounties as a bounty hunter, or tracking a horde by attaching a tracking device onto one of the zombies surreptitiously.
115+
116+
The changes in conditional states may be reflected via log entries: "Your radiation badge turns red", or "The tracking device light is now yellow".
117+
118+
119+
#### Default States
120+
121+
States may be marked as `"default"`, with the value being either `true` or `false`. There may be no more than one default state in an exclusive group.
122+
123+
Items with states spawn with each complementary state set to its default value.
124+
125+
For single-state entries, the default state is assumed to be "off". Adding `"default": true` to the single state indicates that the item must be "on" be default, whatever "on" means in each specific case.
126+
127+
States, the conditions for which are no longer met, automatically revert to the default sibling state instead, notifying the player about the change.
128+
129+
130+
#### State Inheritance
131+
132+
`state_data` may be inherited from item to item. This would enable creating classes of items with similar functionality, such as different types of flashlights.
133+
134+
`state_data` must be affected by the `"extend"` property where such is indicated. This would allow using inheritance to create distinct individual states: for example, adding a "disorienting" mode which causes confusion in intelligent enemies.
135+
136+
137+
### Naming via States
138+
139+
Items with non-default states active gain parentheses-marked suffixes. Suffixes follow one another in the same set of brackets, their order defined by the order of the state groups in the item's JSON definition: e.g. `flashlight (on, regular, shocker on)`.
140+
141+
Options to directly change the name of the item itself should be considered for more abstract entities which may alter their very nature, such as artifacts or magical / sci-fi items.
142+
143+
144+
## Examples of Use
145+
146+
**Apparel**. Manipulating scarves between "tight", "loose" (default), and "hanging" states, which affects the degree to which they help you retain heat. Changing the degree to which the clothes you wear are open, allowing you to manually control heat exchange between you and the environment. For advanced apparel and armor, changing operating modes:
147+
148+
**Equipment**. Bags, backpacks etc. may be folded to save room or unfolded to make them useful as containers. Cords may be tied loosely, making them useful in crafting and as improvised slings, or tightly to save space or even as improvised armor. Glasses may be moved away from your eyes, but not off your head, to enable a different visual processing – for example, moving shades enables one to see clearer.
149+
150+
**Devices**. Switching between available FM stations on a radio to find the right automated music for the atmosphere. Changing intensity of an emitter in order to attract a larger group of enemies to the source, thus distracting them without putting yourself at risk. Switching the signal on your radio device to control a different target, enabling manipulation of multiple personal mobile devices, such as drones. Explosive charges may be set to a timer or turned off.
151+
152+
**Environment**. Room heaters may be controlled as to their temperature output, in situations where you have to manage your available electrical power against your needs. Ovens may be turned on for preheating towards baking. Power stations and UPS may be disabled, to prevent them from sharing charge with relevant devices automatically upon contact.

0 commit comments

Comments
 (0)