Thread: Taunt
View Single Post
  #5  
Old 05-15-2008, 08:02 PM
jenco420
Banned
 
Join Date: Jan 2006
Location: /dev/null
Posts: 99
Default

Well after a few days tweking and rewriting some code Mouya and i came up with a good system for taunt (well based on my players feedback)

Replace

Code:
void Mob::Taunt(NPC* who, bool always_succeed) {
	if (who == NULL)
		return;
	
	if(DivineAura())
		return;
	
	if (!always_succeed && IsClient())
		CastToClient()->CheckIncreaseSkill(TAUNT);
	
	int level = GetLevel();
	
	Mob *hate_top = who->GetHateMost();
	
	// Check to see if we're already at the top of the target's hate list
	// a mob will not be taunted if its target's health is below 20%
	if ((hate_top != this) 
	&& (who->GetLevel() < level) 
	&& (hate_top == NULL || hate_top->GetHPRatio() >= 20) ) {
		sint32 newhate, tauntvalue;

		float tauntchance;
		if(always_succeed) {
			tauntchance = 101;
		} else {
			
			// no idea how taunt success is actually calculated
			// TODO: chance for level 50+ mobs should be lower
			int level_difference = level - target->GetLevel();
			if (level_difference <= 5) {
				tauntchance = 25.0;	// minimum
				tauntchance += tauntchance * (float)GetSkill(TAUNT) / 200.0;	// skill modifier
				if (tauntchance > 65.0)
					tauntchance = 65.0;
			}
			else if (level_difference <= 10) {
				tauntchance = 30.0;	// minimum
				tauntchance += tauntchance * (float)GetSkill(TAUNT) / 200.0;	// skill modifier
				if (tauntchance > 85.0)
					tauntchance = 85.0;
			}
			else if (level_difference <= 15) {
				tauntchance = 40.0;	// minimum
				tauntchance += tauntchance * (float)GetSkill(TAUNT) / 200.0;	// skill modifier
				if (tauntchance > 90.0)
					tauntchance = 90.0;
			}
			else {
				tauntchance = 50.0;	// minimum
				tauntchance += tauntchance * (float)GetSkill(TAUNT) / 200.0;	// skill modifier
				if (tauntchance > 95.0)
					tauntchance = 95.0;
			}
		}
		if (tauntchance > MakeRandomFloat(0, 100)) {
			// this is the max additional hate added per succesfull taunt
			tauntvalue = (MakeRandomInt(5, 10) * level);
			//tauntvalue = (sint32) ((float)level * 10.0 * (float)rand()/(float)RAND_MAX + 1);
			// new hate: find diff of player's hate and whoever's at top of list, add that plus tauntvalue to players hate
			newhate = who->GetNPCHate(hate_top) - who->GetNPCHate(this) + tauntvalue;
			// add the hate
			who->CastToNPC()->AddToHateList(this, newhate);
		}
		else{
			//generate at least some hate reguardless of the outcome.
			who->CastToNPC()->AddToHateList(this, (MakeRandomInt(5, 10)*level));
		}
	}
	
	//generate at least some hate reguardless of the outcome.
	who->CastToNPC()->AddToHateList(this, (MakeRandomInt(5, 10)*level));
}
With

Code:
void Mob::Taunt(NPC* who, bool always_succeed) {
   if (who == NULL) // Make sure we have a target
      return;
   
   if(DivineAura())
      return;
   
   if (!always_succeed && IsClient()) // If the user is a Player and it's possible to fail, check to see if skill increases.
      CastToClient()->CheckIncreaseSkill(TAUNT);
   
   int level = GetLevel();
   
   Mob *hate_top = who->GetHateMost();
   
   // Check to see if we're already at the top of the target's hate list
   // a mob will not be taunted if its target's health is below 20%
   if ((hate_top != this)
   && (who->GetLevel() < level)
   && (hate_top == NULL || hate_top->GetHPRatio() >= 20) ) {
      sint32 newhate, tauntvalue;
      float tauntchance;

      int level_difference = level - target->GetLevel();
      tauntchance = 20.0 + (float)level_difference;
      tauntchance += tauntchance * ( (float)GetSkill(TAUNT) / 400.0);   // skill modifier
      
      if (tauntchance > 66.6) // TODO: Change this to whatever you want the maximum chance to taunt to be -- I picked a max of 66.6% success.
         tauntchance = 66.6;
      if (tauntchance < 0.0)
         tauntchance = 0.0; // TODO: Change this to whatever you want the minimum chance to taunt regardless of skill and level
      
      if ((tauntchance > MakeRandomFloat(0, 100)) || always_succeed) {
               // this is the max additional hate added per succesfull taunt, on live it always gave a set amount of hate change it to what you think it should add.
               tauntvalue = (10);
         // new hate: find diff of player's hate and whoever's at top of list, add that plus tauntvalue to players hate
         newhate = who->GetNPCHate(hate_top) - who->GetNPCHate(this) + tauntvalue;
         // add the hate
         who->CastToNPC()->AddToHateList(this, newhate);
         return;
      }
      //do nothing and give failed message
      Message(13, "You have failed to taunt your target.");
      return;
   }
}
Reply With Quote