static int spellguard_can_satisfy(spellguard_check_t *check, dumb_ptr<map_session_data> caster, dumb_ptr<env_t> env, int *near_miss) { tick_t tick = gettick(); int retval = check_prerequisites(caster, check->catalysts); if (retval && near_miss) *near_miss = 1; // close enough! retval = retval && caster->cast_tick <= tick /* Hasn't cast a spell too recently */ && check->mana <= caster->status.sp && check_prerequisites(caster, check->components); if (retval) { interval_t casttime = check->casttime; if (env->VAR(VAR_MIN_CASTTIME).ty == TYPE::INT) casttime = max(casttime, static_cast<interval_t>(env->VAR(VAR_MIN_CASTTIME).v.v_int)); caster->cast_tick = tick + casttime; /* Make sure not to cast too frequently */ consume_components(caster, check->components); pc_heal(caster, 0, -check->mana); } return retval; }
static int op_status_change(dumb_ptr<env_t> env, const_array<val_t> args) { dumb_ptr<block_list> subject = ARGENTITY(0); int invocation_id = env->VAR(VAR_INVOCATION).ty == TYPE::INVOCATION ? env->VAR(VAR_INVOCATION).v.v_int : 0; dumb_ptr<invocation> invocation_ = map_id_as_spell(invocation_id); assert (!ARGINT(3)); assert (!ARGINT(4)); assert (!ARGINT(5)); skill_status_effect(subject, static_cast<StatusChange>(ARGINT(1)), ARGINT(2), static_cast<interval_t>(ARGINT(6)), invocation_id); if (invocation_ && subject->bl_type == BL::PC) record_status_change(invocation_, subject->bl_id, StatusChange(ARGINT(1))); return 0; }
static int op_instaheal(dumb_ptr<env_t> env, const_array<val_t> args) { dumb_ptr<block_list> caster = (env->VAR(VAR_CASTER).ty == TYPE::ENTITY) ? map_id2bl(env->VAR(VAR_CASTER).v.v_int) : NULL; dumb_ptr<block_list> subject = ARGENTITY(0); if (!caster) caster = subject; if (caster->bl_type == BL::PC && subject->bl_type == BL::PC) { dumb_ptr<map_session_data> caster_pc = caster->as_player(); dumb_ptr<map_session_data> subject_pc = subject->as_player(); MAP_LOG_PC(caster_pc, "SPELLHEAL-INSTA PC%d FOR %d", subject_pc->status.char_id, ARGINT(1)); } battle_heal(caster, subject, ARGINT(1), ARGINT(2), 0); return 0; }
static int op_override_attack(dumb_ptr<env_t> env, const_array<val_t> args) { dumb_ptr<block_list> psubject = ARGENTITY(0); int charges = ARGINT(1); interval_t attack_delay = static_cast<interval_t>(ARGINT(2)); int attack_range = ARGINT(3); StatusChange icon = StatusChange(ARGINT(4)); int look = ARGINT(5); int stopattack = ARGINT(6); dumb_ptr<map_session_data> subject; if (psubject->bl_type != BL::PC) return 0; subject = psubject->as_player(); if (subject->attack_spell_override) { dumb_ptr<invocation> old_invocation = map_id_as_spell(subject->attack_spell_override); if (old_invocation) spell_free_invocation(old_invocation); } subject->attack_spell_override = trigger_spell(subject->bl_id, env->VAR(VAR_INVOCATION).v.v_int); subject->attack_spell_charges = charges; if (subject->attack_spell_override) { dumb_ptr<invocation> attack_spell = map_id_as_spell(subject->attack_spell_override); if (attack_spell && stopattack) attack_spell->flags |= INVOCATION_FLAG::STOPATTACK; char_set_weapon_icon(subject, charges, icon, look); char_set_attack_info(subject, attack_delay, attack_range); } return 0; }