MCPcopy Create free account
hub / github.com/EasyRPG/Player / CommandControlVariables

Method CommandControlVariables

src/game_interpreter.cpp:1076–1474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1074}
1075
1076bool Game_Interpreter::CommandControlVariables(lcf::rpg::EventCommand const& com) { // code 10220
1077 int value = 0;
1078 int operand = com.parameters[4];
1079
1080 if (EP_UNLIKELY(operand >= 9 && !Player::IsPatchManiac())) {
1081 Output::Warning("ControlVariables: Unsupported operand {}", operand);
1082 return true;
1083 }
1084
1085 switch (operand) {
1086 case 0:
1087 // Constant
1088 value = com.parameters[5];
1089 break;
1090 case 1:
1091 // Var A ops B
1092 value = Main_Data::game_variables->Get(com.parameters[5]);
1093 break;
1094 case 2:
1095 // Number of var A ops B
1096 value = Main_Data::game_variables->GetIndirect(com.parameters[5]);
1097 break;
1098 case 3: {
1099 // Random between range
1100 int32_t arg1 = com.parameters[5];
1101 int32_t arg2 = com.parameters[6];
1102 if (Player::IsPatchManiac() && com.parameters.size() >= 8) {
1103 arg1 = ValueOrVariableBitfield(com.parameters[7], 0, arg1);
1104 arg2 = ValueOrVariableBitfield(com.parameters[7], 1, arg2);
1105 }
1106
1107 value = ControlVariables::Random(arg1, arg2);
1108 break;
1109 }
1110 case 4: {
1111 // Items
1112 int item = com.parameters[5];
1113 if (Player::IsPatchManiac() && com.parameters.size() >= 8) {
1114 item = ValueOrVariable(com.parameters[7], item);
1115 }
1116
1117 value = ControlVariables::Item(com.parameters[6], item);
1118 break;
1119 }
1120 case 5: { // Hero
1121 int actor_id = com.parameters[5];
1122 if (Player::IsPatchManiac() && com.parameters.size() >= 8) {
1123 actor_id = ValueOrVariable(com.parameters[7], actor_id);
1124 }
1125 value = ControlVariables::Actor(com.parameters[6], actor_id);
1126 break;
1127 }
1128 case 6: {
1129 // Characters
1130 int event_id = com.parameters[5];
1131 if (Player::IsPatchManiac() && com.parameters.size() >= 8) {
1132 event_id = ValueOrVariable(com.parameters[7], event_id);
1133 }

Callers

nothing calls this directly

Calls 15

ItemClass · 0.85
maxFunction · 0.85
minFunction · 0.85
GetIntMethod · 0.80
SubMethod · 0.80
MultMethod · 0.80
DivMethod · 0.80
ModMethod · 0.80
BitOrMethod · 0.80
BitAndMethod · 0.80
BitXorMethod · 0.80
BitShiftLeftMethod · 0.80

Tested by

no test coverage detected