|
|
@ -2008,15 +2008,20 @@ int32_t *getActionTimerPointer(df::unit_action *action) {
|
|
|
|
return nullptr;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void subtractActionTimerCore(df::unit_action *action, int32_t amount)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int32_t *timer = getActionTimerPointer(action);
|
|
|
|
|
|
|
|
if (timer != nullptr && *timer != 0) {
|
|
|
|
|
|
|
|
*timer = max(*timer - amount, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Units::subtractActionTimer(df::unit *unit, int32_t amount, df::unit_action_type affectedActionType)
|
|
|
|
void Units::subtractActionTimer(df::unit *unit, int32_t amount, df::unit_action_type affectedActionType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CHECK_NULL_POINTER(unit);
|
|
|
|
CHECK_NULL_POINTER(unit);
|
|
|
|
for (auto action : unit->actions) {
|
|
|
|
for (auto action : unit->actions) {
|
|
|
|
if (affectedActionType != action->type) continue;
|
|
|
|
if (affectedActionType != action->type) continue;
|
|
|
|
int32_t *timer = getActionTimerPointer(action);
|
|
|
|
subtractActionTimerCore(action, amount);
|
|
|
|
if (timer != nullptr && *timer != 0) {
|
|
|
|
|
|
|
|
*timer = max(*timer - amount, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2027,10 +2032,7 @@ void Units::subtractCategoryActionTimers(df::unit *unit, int32_t amount, df::uni
|
|
|
|
auto list = ENUM_ATTR(unit_action_type, group, action->type);
|
|
|
|
auto list = ENUM_ATTR(unit_action_type, group, action->type);
|
|
|
|
for (size_t i = 0; i < list.size; i++) {
|
|
|
|
for (size_t i = 0; i < list.size; i++) {
|
|
|
|
if (list.items[i] == affectedActionTypes) {
|
|
|
|
if (list.items[i] == affectedActionTypes) {
|
|
|
|
int32_t *timer = getActionTimerPointer(action);
|
|
|
|
subtractActionTimerCore(action, amount);
|
|
|
|
if (timer != nullptr && *timer != 0) {
|
|
|
|
|
|
|
|
*timer = max(*timer - amount, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2073,15 +2075,19 @@ void Units::multiplyCategoryActionTimers(df::unit *unit, float amount, df::unit_
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setActionTimerCore(df::unit_action *action, int32_t amount) {
|
|
|
|
|
|
|
|
int32_t *timer = getActionTimerPointer(action);
|
|
|
|
|
|
|
|
if (timer != nullptr && *timer != 0) {
|
|
|
|
|
|
|
|
*timer = amount;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Units::setActionTimer(df::unit *unit, int32_t amount, df::unit_action_type affectedActionType)
|
|
|
|
void Units::setActionTimer(df::unit *unit, int32_t amount, df::unit_action_type affectedActionType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CHECK_NULL_POINTER(unit);
|
|
|
|
CHECK_NULL_POINTER(unit);
|
|
|
|
for (auto action : unit->actions) {
|
|
|
|
for (auto action : unit->actions) {
|
|
|
|
if (affectedActionType != action->type) continue;
|
|
|
|
if (affectedActionType != action->type) continue;
|
|
|
|
int32_t *timer = getActionTimerPointer(action);
|
|
|
|
setActionTimerCore(action, amount);
|
|
|
|
if (timer != nullptr && *timer != 0) {
|
|
|
|
|
|
|
|
*timer = amount;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2092,10 +2098,7 @@ void Units::setCategoryActionTimers(df::unit *unit, int32_t amount, df::unit_act
|
|
|
|
auto list = ENUM_ATTR(unit_action_type, group, action->type);
|
|
|
|
auto list = ENUM_ATTR(unit_action_type, group, action->type);
|
|
|
|
for (size_t i = 0; i < list.size; i++) {
|
|
|
|
for (size_t i = 0; i < list.size; i++) {
|
|
|
|
if (list.items[i] == affectedActionTypes) {
|
|
|
|
if (list.items[i] == affectedActionTypes) {
|
|
|
|
int32_t *timer = getActionTimerPointer(action);
|
|
|
|
setActionTimerCore(action, amount);
|
|
|
|
if (timer != nullptr && *timer != 0) {
|
|
|
|
|
|
|
|
*timer = amount;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|