Exemple #1
0
void Creature::gainHealth(Creature* caster, int32_t healthGain)
{
	if(healthGain > 0)
	{
		int32_t prevHealth = getHealth();
		changeHealth(healthGain);

		int32_t effectiveGain = getHealth() - prevHealth;
		if(caster)
			caster->onTargetGainHealth(this, effectiveGain);
	}
	else
		changeHealth(healthGain);
}
Exemple #2
0
void Creature::gainHealth(const CombatSource& combatSource, int32_t healthGain)
{
	if(healthGain > 0){
		int32_t prevHealth = getHealth();
		changeHealth(healthGain);

		int32_t effectiveGain = getHealth() - prevHealth;
		if(combatSource.isSourceCreature()){
			combatSource.getSourceCreature()->onTargetCreatureGainHealth(this, effectiveGain);
		}
	}
	else{
		changeHealth(healthGain);
	}
}
void Creature::gainHealth(Creature* healer, int32_t healthGain)
{
	changeHealth(healthGain);
	if (healer) {
		healer->onTargetCreatureGainHealth(this, healthGain);
	}
}
Exemple #4
0
/*--------------------------- PLAYER INTERFACE */
void Creature::enterTurn()
{
	//Creature's turn-based constraints
	changeAttack({getConstraint(CC_TURN_ATTACK_CHANGE)});
	changeHealth({getConstraint(CC_TURN_HEALTH_CHANGE)});
	changeShield({getConstraint(CC_TURN_SHIELD_CHANGE)});
}
void Creature::drainHealth(Creature* attacker, CombatType_t combatType, int32_t damage)
{
	changeHealth(-damage, false);

	if (attacker) {
		attacker->onAttackedCreatureDrainHealth(this, damage);
	}
}
Exemple #6
0
void Creature::removeFromBoard()
{
	_isOnBoard = false;
	//Creature's death-based constraints
	changeAttack({getConstraint(CC_DEATH_ATTACK_CHANGE)});
	changeHealth({getConstraint(CC_DEATH_HEALTH_CHANGE)});
	changeShield({getConstraint(CC_DEATH_ATTACK_CHANGE)});
}
Exemple #7
0
void Creature::drainHealth(CombatType combatType, const CombatSource& combatSource, int32_t damage, bool showtext)
{
	lastDamageSource = combatType;
	changeHealth(-damage);
	
	if(combatSource.isSourceCreature()){
		combatSource.getSourceCreature()->onAttackedCreatureDrainHealth(this, damage);
	}
}
Exemple #8
0
void Creature::drainHealth(Creature* attacker, CombatType_t combatType, int32_t damage)
{
	lastDamageSource = combatType;
	onAttacked();

	changeHealth(-damage);
	if(attacker)
		attacker->onTargetDrainHealth(this, damage);
}
Exemple #9
0
void Creature::receiveAttack(Creature& attacker, int attack, int forced, int loopCount)
{
	if(loopCount >= 2) //If both creatures mirror attacks, no one is damaged
		return;

	bool attackMirrored = getConstraintBool(CC_TEMP_MIRROR_ATTACKS);
	if(attackMirrored) //If attacks are mirrored, we send it back
		attacker.receiveAttack(*this, attack, forced, loopCount+1);

	bool attackBlocked = getConstraintBool(CC_TEMP_BLOCK_ATTACKS);
	if(not attackBlocked)  // Only attack if attacks are not blocked
		changeHealth({-attack, forced});
}
Exemple #10
0
void Creature::makeAttack(Creature& victim)
{
	bool isParalyzed = getConstraintBool(CC_TEMP_IS_PARALYZED);
	if(isParalyzed) //Creature can not be used
		return;

	bool attackDisabled = getConstraintBool(CC_TEMP_DISABLE_ATTACKS);
	if(attackDisabled) //Creature can not attack
		return;

	int attackForced = getConstraint(CC_TEMP_FORCE_ATTACKS);

	bool attackBackfires = getConstraintBool(CC_TEMP_BACKFIRE_ATTACKS);
	if(attackBackfires)	//Attack turns agains the creature
		changeHealth({_attack, attackForced});
	else
		victim.receiveAttack(*this, _attack, attackForced);
}