void trigger_push_active (edict_t *self) { if (self->delay > level.time) { self->nextthink = level.time + 0.1; trigger_effect (self); } else { self->touch = NULL; self->think = trigger_push_inactive; self->nextthink = level.time + 0.1; self->delay = self->nextthink + self->wait; } }
Consume_item Strange_device::activate(Actor* const actor) { assert(actor); if (data_->is_identified) { const std::string item_name = name(Item_ref_type::plain, Item_ref_inf::none); const std::string item_name_a = name(Item_ref_type::a, Item_ref_inf::none); msg_log::add("I activate " + item_name_a + "..."); //Damage user? Fail to run effect? Condition degrade? Warning? const std::string hurt_msg = "It hits me with a jolt of electricity!"; bool is_effect_failed = false; bool is_cond_degrade = false; bool is_warning = false; int bon = 0; if (actor->has_prop(Prop_id::blessed)) { bon += 2; } if (actor->has_prop(Prop_id::cursed)) { bon -= 2; } const int RND = rnd::range(1, 8 + bon); switch (condition_) { case Condition::breaking: { if (RND == 5 || RND == 6) { msg_log::add(hurt_msg, clr_msg_bad); actor->hit(rnd::dice(2, 4), Dmg_type::electric); } is_effect_failed = RND == 3 || RND == 4; is_cond_degrade = RND <= 2; is_warning = RND == 7 || RND == 8; } break; case Condition::shoddy: { if (RND == 4) { msg_log::add(hurt_msg, clr_msg_bad); actor->hit(rnd::dice(1, 4), Dmg_type::electric); } is_effect_failed = RND == 3; is_cond_degrade = RND <= 2; is_warning = RND == 5 || RND == 6; } break; case Condition::fine: { is_cond_degrade = RND <= 2; is_warning = RND == 3 || RND == 4; } break; } if (!map::player->is_alive()) { return Consume_item::no; } Consume_item consumed_state = Consume_item::no; if (is_effect_failed) { msg_log::add("It suddenly stops."); } else { consumed_state = trigger_effect(); } if (consumed_state == Consume_item::no) { if (is_cond_degrade) { if (condition_ == Condition::breaking) { msg_log::add("The " + item_name + " breaks!"); consumed_state = Consume_item::yes; } else { msg_log::add("The " + item_name + " makes a terrible grinding noise."); msg_log::add("I seem to have damaged it."); condition_ = Condition(int(condition_) - 1); } } if (is_warning) { msg_log::add("The " + item_name + " hums ominously."); } } game_time::tick(); return consumed_state; } else //Not identified { msg_log::add("This device is completely alien to me, "); msg_log::add("I could never understand it through normal means."); return Consume_item::no; } }