luminol_data/rmxp/
state.rs

1// Copyright (C) 2024 Melody Madeline Lyons
2//
3// This file is part of Luminol.
4//
5// Luminol is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Luminol is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Luminol.  If not, see <http://www.gnu.org/licenses/>.
17use crate::{id_alox, id_serde, id_vec_alox, id_vec_serde, optional_id_alox, optional_id_serde};
18
19#[derive(Default, Debug, serde::Deserialize, serde::Serialize)]
20#[derive(alox_48::Deserialize, alox_48::Serialize)]
21#[marshal(class = "RPG::State")]
22pub struct State {
23    #[serde(with = "id_serde")]
24    #[marshal(with = "id_alox")]
25    pub id: usize,
26    pub name: String,
27    #[serde(with = "optional_id_serde")]
28    #[marshal(with = "optional_id_alox")]
29    pub animation_id: Option<usize>,
30    pub restriction: Restriction,
31    pub nonresistance: bool,
32    pub zero_hp: bool,
33    pub cant_get_exp: bool,
34    pub cant_evade: bool,
35    pub slip_damage: bool,
36    pub rating: i32,
37    pub hit_rate: i32,
38    pub maxhp_rate: i32,
39    pub maxsp_rate: i32,
40    pub str_rate: i32,
41    pub dex_rate: i32,
42    pub agi_rate: i32,
43    pub int_rate: i32,
44    pub atk_rate: i32,
45    pub pdef_rate: i32,
46    pub mdef_rate: i32,
47    pub eva: i32,
48    pub battle_only: bool,
49    pub hold_turn: i32,
50    pub auto_release_prob: i32,
51    pub shock_release_prob: i32,
52    #[serde(with = "id_vec_serde")]
53    #[marshal(with = "id_vec_alox")]
54    pub guard_element_set: Vec<usize>,
55    #[serde(with = "id_vec_serde")]
56    #[marshal(with = "id_vec_alox")]
57    pub plus_state_set: Vec<usize>,
58    #[serde(with = "id_vec_serde")]
59    #[marshal(with = "id_vec_alox")]
60    pub minus_state_set: Vec<usize>,
61}
62
63#[derive(Clone, Copy, Debug, Eq, PartialEq, Default)]
64#[derive(
65    num_enum::TryFromPrimitive,
66    num_enum::IntoPrimitive,
67    strum::Display,
68    strum::EnumIter
69)]
70#[derive(serde::Deserialize, serde::Serialize)]
71#[derive(alox_48::Deserialize, alox_48::Serialize)]
72#[repr(u8)]
73#[serde(into = "u8")]
74#[serde(try_from = "u8")]
75#[marshal(into = "u8")]
76#[marshal(try_from = "u8")]
77pub enum Restriction {
78    #[default]
79    None = 0,
80    #[strum(to_string = "Can't use magic")]
81    NoMagic = 1,
82    #[strum(to_string = "Always attack enemies")]
83    AttackEnemies = 2,
84    #[strum(to_string = "Always attack allies")]
85    AttackAllies = 3,
86    #[strum(to_string = "Can't move")]
87    NoMove = 4,
88}