Ejemplo n.º 1
0
//this is called whenever we are damaged to process possible fleeing
void Mob::CheckFlee() {
	//if were allready fleeing, dont need to check more...
	if(flee_mode && curfp)
		return;
	
	//dont bother if we are immune to fleeing
	if(SpecAttacks[IMMUNE_FLEEING] || spellbonuses.ImmuneToFlee)
		return;

	if(!flee_timer.Check())
		return;	//only do all this stuff every little while, since
				//its not essential that we start running RIGHT away
	
	//see if were possibly hurt enough
	float ratio = GetHPRatio();
	if(ratio >= RuleI(Combat, FleeHPRatio))
		return;
	
	//we might be hurt enough, check con now..
	Mob *hate_top = GetHateTop();
	if(!hate_top) {
		//this should never happen...
		StartFleeing();
		return;
	}
	
	float other_ratio = hate_top->GetHPRatio();
	if(other_ratio < 20) {
		//our hate top is almost dead too... stay and fight
		return;
	}
	
	//base our flee ratio on our con. this is how the 
	//attacker sees the mob, since this is all we can observe
	uint32 con = GetLevelCon(hate_top->GetLevel(), GetLevel());
	float run_ratio;
	switch(con) {
		//these values are not 100% researched
		case CON_GREEN:
			run_ratio = RuleI(Combat, FleeHPRatio);
			break;
		case CON_LIGHTBLUE:
			run_ratio = RuleI(Combat, FleeHPRatio) * 8 / 10;
			break;
		case CON_BLUE:
			run_ratio = RuleI(Combat, FleeHPRatio) * 6 / 10;
			break;
		default:
			run_ratio = RuleI(Combat, FleeHPRatio) * 4 / 10;
			break;
	}
	if(ratio < run_ratio)
	{
		if( RuleB(Combat, FleeIfNotAlone) 
		  || ( !RuleB(Combat, FleeIfNotAlone) 
		    && (entity_list.GetHatedCount(hate_top, this) == 0)))
			StartFleeing();

	}
}
Ejemplo n.º 2
0
void Mob::ProcessFlee()
{

	//Stop fleeing if effect is applied after they start to run.
	//When ImmuneToFlee effect fades it will turn fear back on and check if it can still flee.
	if (flee_mode && (GetSpecialAbility(IMMUNE_FLEEING) || spellbonuses.ImmuneToFlee) &&
			!spellbonuses.IsFeared && !spellbonuses.IsBlind) {
		curfp = false;
		return;
	}

	//see if we are still dying, if so, do nothing
	float fleeratio = GetSpecialAbility(FLEE_PERCENT);
	fleeratio = fleeratio > 0 ? fleeratio : RuleI(Combat, FleeHPRatio);
	if (GetHPRatio() < fleeratio)
		return;

	//we are not dying anymore... see what we do next

	flee_mode = false;

	//see if we are legitimately feared or blind now
	if (!spellbonuses.IsFeared && !spellbonuses.IsBlind) {
		//not feared or blind... were done...
		curfp = false;
		return;
	}
}
Ejemplo n.º 3
0
void Mob::ProcessFlee() {
    //see if we are still dying, if so, do nothing
    if(GetHPRatio() < (float)RuleI(Combat, FleeHPRatio))
        return;

    //we are not dying anymore... see what we do next

    flee_mode = false;

    //see if we are legitimately feared now
    sint8 slot = GetBuffSlotFromType(SE_Fear);
    if(slot == -1) {
        //not feared... were done...
        curfp = false;
        return;
    }
}
Ejemplo n.º 4
0
float Mob::GetFearSpeed() {
    if(flee_mode) {
        //we know ratio < FLEE_HP_RATIO
        float speed = GetRunspeed();
        float ratio = GetHPRatio();

		// mob's movement will halt with a decent snare at HP specified by rule.
		if (ratio <= RuleI(Combat, FleeSnareHPRatio) && GetSnaredAmount() > 40) {
				return 0.0001f;
		}

		if (ratio < FLEE_HP_MINSPEED)
			ratio = FLEE_HP_MINSPEED;

        speed = speed * 0.5 * ratio / 100;
 
        return(speed);
    }
    return(GetRunspeed());
}
Ejemplo n.º 5
0
float Mob::GetFearSpeed() {
	if(flee_mode) {
		//we know ratio < FLEE_HP_RATIO
		float speed = GetBaseRunspeed();
		float ratio = GetHPRatio();
		float multiplier = RuleR(Combat, FleeMultiplier);

		if(GetSnaredAmount() > 40)
			multiplier = multiplier / 6.0f;

		speed = speed * ratio * multiplier / 100;

		//NPC will eventually stop. Snares speeds this up.
		if(speed < 0.09)
			speed = 0.0001f;
		
		return(speed);
	}
	return(GetRunspeed());
}
Ejemplo n.º 6
0
void Mob::ProcessFlee() {

	//Stop fleeing if effect is applied after they start to run. 
	//When ImmuneToFlee effect fades it will turn fear back on and check if it can still flee. 
	if(flee_mode && (SpecAttacks[IMMUNE_FLEEING] || spellbonuses.ImmuneToFlee) && !spellbonuses.IsFeared){
		curfp = false;
		return;
	}

	//see if we are still dying, if so, do nothing
	if(GetHPRatio() < (float)RuleI(Combat, FleeHPRatio))
		return;
	
	//we are not dying anymore... see what we do next
	
	flee_mode = false;
	
	//see if we are legitimately feared now
	if(!spellbonuses.IsFeared) {
		//not feared... were done...
		curfp = false;
		return;
	}
}