Created
October 28, 2010 11:53
-
-
Save scottdavis/651191 to your computer and use it in GitHub Desktop.
Taunt function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Mob::Taunt(NPC* who, bool always_succeed) { | |
| if (who == NULL) | |
| return; | |
| if(GetInvul()) | |
| return; | |
| if(!CombatRange(who)) | |
| return; | |
| if(!always_succeed && IsClient()) | |
| CastToClient()->CheckIncreaseSkill(TAUNT, who, 10); | |
| // @LADOTH 07192009 pet should say taunting attacker master | |
| Mob* owner = GetOwner(); | |
| if( owner && owner->IsClient() && IsNPC() ) | |
| { | |
| owner->Message(0, "Taunting Attacker Master"); | |
| } | |
| 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 - who->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; | |
| // @LADOTH 09272009 taunts just enough to get on top of the hate list | |
| newhate = who->GetNPCHate(hate_top) - who->GetNPCHate(this) + 1; | |
| // add the hate | |
| who->CastToNPC()->AddToHateList(this, newhate); | |
| who->Say("I'll teach you to interfere with me %s!", this->GetCleanName()); | |
| } | |
| } | |
| // @LADOTH 09272009 add one for default taunt condition | |
| //generate at least some hate reguardless of the outcome. | |
| //who->CastToNPC()->AddToHateList(this, (MakeRandomInt(5, 10)*level)); | |
| who->CastToNPC()->AddToHateList(this, 1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment