Esempio n. 1
0
void Vector::normInNewSpace(float ssx,float ssy, float ssz)
{//ssx,ssy,ssz is multiplied to change Vector to the current space
 //this is to get a vector in current space equal to a normlized 
 // in the original space
 formulate();
 ssx *=ssx; ssy *= ssy; ssz *= ssz;
 double t = sqrt(vm[0]*vm[0]/ssz+vm[1]*vm[1]/ssy+vm[2]*vm[2]/ssz); 
 deScale(t,t,t);

}
Esempio n. 2
0
void pkCU::calculateDamage(bool hasCrit)
{
	const pokemon_nonvolatile& cPKNV = getPKNV();
	const pokemon_nonvolatile& tPKNV = getTPKNV();
	const move_nonvolatile& cMNV = cPKNV.getMove(getICAction());

	fpType partitionEnvironmentProbability = (1.0 / (fpType) numRandomEnvironments);
	damageComponents_t& cDMG = getDamageComponent();

	uint32_t power = (hasCrit)?cDMG.damageCrit:cDMG.damage;

	boost::array<size_t, 2> iREnv = {{ SIZE_MAX, getIBase() }};
	for (size_t iEnv = 0; iEnv != numRandomEnvironments; ++iEnv )
	{
		if (numRandomEnvironments > 1) 
		{
			if ((iEnv + 1) == numRandomEnvironments) { iREnv[1] = getIBase(); }
			else { duplicateState(iREnv, partitionEnvironmentProbability); }
		};

		// find the mean random value for this partition of the random environment
		fpType randomValue = (iEnv / (fpType)numRandomEnvironments) + ( 1.0 / (fpType)numRandomEnvironments / 2.0);

		// scale our random value modifier to 0.85..1.0
		randomValue = deScale(randomValue, 1.0, 0.85);

		uint32_t& actualDamage = getDamageComponent(iREnv[1]).damage;
		actualDamage = (uint32_t)((fpType)power * randomValue);

		int result = 0;
		CALLPLUGIN(result, PLUGIN_ON_CALCULATEDAMAGE, onSetPower_rawType, 
			*this, cMNV, cPKNV, tPKNV, getTMV(), getTTMV(), getPKV(), getTPKV(), actualDamage);

		// inflict damage caused upon the targetPokemon:
		getTTMV(iREnv[1]).cModHP(getTPKNV(), -1 * actualDamage);
	}
}