Example #1
0
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
	CombatDamage damage = *reinterpret_cast<CombatDamage*>(data);

	bool blockPrimary = g_game.combatBlockHit(damage.primary.type, caster, target, damage.primary.value, params.blockedByShield, params.blockedByArmor, params.itemId != 0);
	bool blockSecondary = g_game.combatBlockHit(damage.secondary.type, caster, target, damage.secondary.value, false, false, params.itemId != 0);
	if (blockPrimary) {
		if (blockSecondary) {
			return false;
		}
		damage.primary.value = 0;
	} else if (blockSecondary) {
		damage.secondary.value = 0;
	}

	if ((damage.primary.value < 0 || damage.secondary.value < 0) && caster) {
		Player* targetPlayer = target->getPlayer();
		if (targetPlayer && caster->getPlayer() && targetPlayer->getSkull() != SKULL_BLACK) {
			damage.primary.value /= 2;
			damage.secondary.value /= 2;
		}
	}

	bool result = g_game.combatChangeHealth(caster, target, damage);
	if (result) {
		CombatConditionFunc(caster, target, params, nullptr);
		CombatDispelFunc(caster, target, params, nullptr);
	}

	return result;
}
Example #2
0
bool Combat::CombatNullFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
	CombatConditionFunc(caster, target, params, NULL);
	CombatDispelFunc(caster, target, params, NULL);
	onCreatureDoCombat(caster, target, params.isAggressive);
	return true;
}
Example #3
0
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
	int32_t change = 0;
	if(Combat2Var* var = (Combat2Var*)data)
	{
		change = var->change;
		if(!change)
			change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
	}

	if(g_game.combatBlockHit(params.combatType, caster, target, change, params.blockedByShield, params.blockedByArmor, params.itemId != 0))
		return false;

	CombatParams _params = params;
	if(_params.element.damage && _params.element.type != COMBAT_NONE)
		g_game.combatBlockHit(_params.element.type, caster, target, _params.element.damage, params.blockedByShield, params.blockedByArmor, params.itemId != 0, true);

	if(caster && caster->getPlayer() && target->getPlayer())
	{
		_params.element.damage /= 2;
		if(change < 0)
			change /= 2;
	}

	if(!g_game.combatChangeHealth(_params, caster, target, change, false))
		return false;

	CombatConditionFunc(caster, target, params, NULL);
	CombatDispelFunc(caster, target, params, NULL);
	return true;
}
void Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
	CombatDamage damage = *reinterpret_cast<CombatDamage*>(data);
	if (damage.primary.value < 0) {
		if (caster && caster->getPlayer() && target->getPlayer()) {
			damage.primary.value /= 2;
		}
	}

	if (g_game.combatChangeMana(caster, target, damage.primary.value, damage.origin)) {
		CombatConditionFunc(caster, target, params, nullptr);
		CombatDispelFunc(caster, target, params, nullptr);
	}
}
Example #5
0
void Combat::doCombatDispel(Creature* caster, Creature* target, const CombatParams& params)
{
	if(!params.isAggressive || (caster != target && Combat::canDoCombat(caster, target) == RET_NOERROR))
	{
		CombatDispelFunc(caster, target, params, NULL);
		if(params.targetCallback)
			params.targetCallback->onTargetCombat(caster, target);

		if(params.impactEffect != NM_ME_NONE)
			g_game.addMagicEffect(target->getPosition(), params.impactEffect);

		if(caster && params.distanceEffect != NM_ME_NONE)
			addDistanceEffect(caster, caster->getPosition(), target->getPosition(), params.distanceEffect);
	}
}
Example #6
0
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
	Combat2Var* var = (Combat2Var*)data;
	int32_t manaChange = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
	Combat::checkPVPDamageReduction(caster, target, manaChange);
	bool result = g_game.combatChangeMana(caster, target, manaChange);

	if (result)
	{
		CombatConditionFunc(caster, target, params, NULL);
		CombatDispelFunc(caster, target, params, NULL);
	}

	return result;
}
Example #7
0
void Combat::doCombatDispel(Creature* caster, Creature* target, const CombatParams& params, bool check/* = true*/)
{
	if(check && params.isAggressive && (caster == target || Combat::canDoCombat(caster, target, true) != RET_NOERROR))
		return;

	CombatDispelFunc(caster, target, params, NULL);
	if(params.targetCallback)
		params.targetCallback->onTargetCombat(caster, target);

	if(params.effects.impact != MAGIC_EFFECT_NONE && (!caster || !caster->isGhost()
		|| g_config.getBool(ConfigManager::GHOST_SPELL_EFFECTS)))
		g_game.addMagicEffect(target->getPosition(), params.effects.impact);

	if(caster && params.effects.distance != SHOOT_EFFECT_NONE)
		addDistanceEffect(caster, caster->getPosition(), target->getPosition(), params.effects.distance);
}
Example #8
0
void Combat::doCombatDispel(const CreatureP& caster, const CreatureP& target, const CombatParams& params)
{
	if(params.isAggressive && (caster == target || Combat::canDoCombat(caster, target) != RET_NOERROR))
		return;

	CombatDispelFunc(caster, target, params, nullptr);
	if(params.targetCallback)
		params.targetCallback->onTargetCombat(caster, target);

	if(params.effects.impact != MAGIC_EFFECT_NONE && (!caster || !caster->isGhost()
		|| server.configManager().getBool(ConfigManager::GHOST_SPELL_EFFECTS)))
		server.game().addMagicEffect(target->getPosition(), params.effects.impact);

	if(caster && params.effects.distance != SHOOT_EFFECT_NONE)
		addDistanceEffect(caster, caster->getPosition(), target->getPosition(), params.effects.distance);
}
Example #9
0
void Combat::doCombatDispel(Creature* caster, Creature* target, const CombatParams& params)
{
	bool canCombat = !params.isAggressive || (caster != target && Combat::canDoCombat(caster, target) == RET_NOERROR);
	if ((caster == target || canCombat) && params.impactEffect != CONST_ME_NONE) {
		g_game.addMagicEffect(target->getPosition(), params.impactEffect);
	}

	if (canCombat) {
		CombatDispelFunc(caster, target, params, nullptr);
		if (params.targetCallback) {
			params.targetCallback->onTargetCombat(caster, target);
		}

		if (caster && params.distanceEffect != CONST_ME_NONE) {
			addDistanceEffect(caster, caster->getPosition(), target->getPosition(), params.distanceEffect);
		}
	}
}
Example #10
0
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
	Combat2Var* var = (Combat2Var*)data;
	int32_t manaChange = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
	if(manaChange < 0)
	{
		if(caster && caster->getPlayer() && target->getPlayer())
			manaChange = manaChange/2;
	}

	bool result = g_game.combatChangeMana(caster, target, manaChange);
	if(result)
	{
		CombatConditionFunc(caster, target, params, NULL);
		CombatDispelFunc(caster, target, params, NULL);
	}
	return result;
}
Example #11
0
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
	Combat2Var* var = (Combat2Var*)data;
	int32_t healthChange = random_range(var->minChange, var->maxChange);

	if(g_game.combatBlockHit(params.combatType, caster, target, healthChange, params.blockedByShield, params.blockedByArmor)){
		return false;
	}

	Combat::checkPVPDamageReduction(caster, target, healthChange);

	bool result = g_game.combatChangeHealth(params.combatType, params.hitEffect, params.hitTextColor, caster, target, healthChange);

	if(result){
		CombatConditionFunc(caster, target, params, NULL);
		CombatDispelFunc(caster, target, params, NULL);
	}

	return result;
}
Example #12
0
bool Combat::CombatManaFunc(const CreatureP& caster, const CreatureP& target, const CombatParams& params, void* data)
{
	int32_t change = 0;
	if(Combat2Var* var = (Combat2Var*)data)
	{
		change = var->change;
		if(!change)
			change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
	}

	if(change < 0 && caster && caster->getPlayer() && target->getPlayer() && target->getPlayer()->getSkull() != SKULL_BLACK)
		change = change / 2;

	if(!server.game().combatChangeMana(caster, target, change))
		return false;

	CombatConditionFunc(caster, target, params, nullptr);
	CombatDispelFunc(caster, target, params, nullptr);
	return true;
}
void Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
	CombatDamage damage = *reinterpret_cast<CombatDamage*>(data);
	if (g_game.combatBlockHit(damage, caster, target, params.blockedByShield, params.blockedByArmor, params.itemId != 0)) {
		return;
	}

	if ((damage.primary.value < 0 || damage.secondary.value < 0) && caster) {
		Player* targetPlayer = target->getPlayer();
		if (targetPlayer && caster->getPlayer() && targetPlayer->getSkull() != SKULL_BLACK) {
			damage.primary.value /= 2;
			damage.secondary.value /= 2;
		}
	}

	if (g_game.combatChangeHealth(caster, target, damage)) {
		CombatConditionFunc(caster, target, params, nullptr);
		CombatDispelFunc(caster, target, params, nullptr);
	}
}
Example #14
0
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
	Combat2Var* var = (Combat2Var*)data;
	int32_t healthChange = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);

	if(g_game.combatBlockHit(params.combatType, caster, target, healthChange, params.blockedByShield, params.blockedByArmor))
		return false;

	if(healthChange < 0)
	{
		if(caster && caster->getPlayer() && target->getPlayer())
			healthChange = healthChange / 2;
	}

	bool result = g_game.combatChangeHealth(params.combatType, caster, target, healthChange);
	if(result)
	{
		CombatConditionFunc(caster, target, params, NULL);
		CombatDispelFunc(caster, target, params, NULL);
	}
	return result;
}
Example #15
0
bool Combat::CombatHealthFunc(const CreatureP& caster, const CreatureP& target, const CombatParams& params, void* data)
{
	int32_t change = 0;
	if(Combat2Var* var = (Combat2Var*)data)
	{
		change = var->change;
		if(!change)
			change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
	}

	if(server.game().combatBlockHit(params.combatType, caster, target, change, params.blockedByShield, params.blockedByArmor))
		return false;

	if(change < 0 && caster && caster->getPlayer() && target->getPlayer() && target->getPlayer()->getSkull() != SKULL_BLACK)
		change = change / 2;

	if(!server.game().combatChangeHealth(params.combatType, caster, target, change, params.effects.hit, params.effects.color))
		return false;

	CombatConditionFunc(caster, target, params, nullptr);
	CombatDispelFunc(caster, target, params, nullptr);
	return true;
}
Example #16
0
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
	int32_t change = 0;
	if(Combat2Var* var = (Combat2Var*)data)
	{
		change = var->change;
		if(!change)
			change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
	}

	if(g_game.combatBlockHit(COMBAT_MANADRAIN, caster, target, change, false, false, params.itemId != 0))
		return false;

	if(change < 0 && caster && caster->getPlayer() && target->getPlayer())
		change /= 2;

	if(!g_game.combatChangeMana(caster, target, change))
		return false;

	CombatConditionFunc(caster, target, params, NULL);
	CombatDispelFunc(caster, target, params, NULL);
	return true;
}
Example #17
0
bool Combat::CombatnullptrFunc(Creature* caster, Creature* target, const CombatParams& params, void*)
{
	CombatConditionFunc(caster, target, params, nullptr);
	CombatDispelFunc(caster, target, params, nullptr);
	return true;
}
void Combat::CombatNullFunc(Creature* caster, Creature* target, const CombatParams& params, void*)
{
	CombatConditionFunc(caster, target, params, nullptr);
	CombatDispelFunc(caster, target, params, nullptr);
}
Example #19
0
bool Combat::CombatNullFunc(const CreatureP& caster, const CreatureP& target, const CombatParams& params, void* data)
{
	CombatConditionFunc(caster, target, params, nullptr);
	CombatDispelFunc(caster, target, params, nullptr);
	return true;
}