MCPcopy Create free account
hub / github.com/TurningWheel/Barony / increaseSkill

Method increaseSkill

src/entity.cpp:2464–2765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2462-------------------------------------------------------------------------------*/
2463
2464bool Entity::increaseSkill(int skill, bool notify)
2465{
2466 Stat* myStats = this->getStats();
2467 int player = -1;
2468 if ( this->behavior == &actPlayer )
2469 {
2470 player = this->skill[2];
2471 }
2472
2473 if ( myStats == NULL )
2474 {
2475 return false;
2476 }
2477
2478 if ( skill == PRO_LEGACY_SWIMMING )
2479 {
2480 if ( !(svFlags & SV_FLAG_HUNGER) )
2481 {
2482 // hunger off and swimming is raised.
2483 serverUpdatePlayerGameplayStats(player, STATISTICS_HOT_TUB_TIME_MACHINE, 1);
2484 }
2485 return true;
2486 }
2487 if ( skill >= NUMPROFICIENCIES )
2488 {
2489 return false;
2490 }
2491
2492 if ( this->behavior == &actPlayer )
2493 {
2494 if ( gameModeManager.currentSession.challengeRun.isActive()
2495 && gameModeManager.currentSession.challengeRun.eventType == GameModeManager_t::CurrentSession_t::ChallengeRun_t::CHEVENT_NOSKILLS )
2496 {
2497 return false;
2498 }
2499 }
2500
2501 bool increased = false;
2502
2503 Uint32 color = makeColorRGB(255, 255, 0);
2504 if ( myStats->getProficiency(skill) < 100 )
2505 {
2506 myStats->setProficiency(skill, myStats->getProficiency(skill) + 1);
2507 if ( notify )
2508 {
2509 if ( player >= 0 )
2510 {
2511 messagePlayerColor(player, MESSAGE_SPAM_MISC, color, Language::get(615), getSkillLangEntry(skill));
2512 if ( players[player]->isLocalPlayer() )
2513 {
2514 skillUpAnimation[player].addSkillUp(skill, myStats->getProficiency(skill) - 1, 1);
2515 }
2516 }
2517 }
2518 switch ( myStats->getProficiency(skill) )
2519 {
2520 case 20:
2521 messagePlayerColor(player, MESSAGE_PROGRESSION, color, Language::get(616), getSkillLangEntry(skill));

Callers 15

attackMethod · 0.95
awardXPMethod · 0.95
actPlayerFunction · 0.80
buyItemFromShopFunction · 0.80
actArrowFunction · 0.80
makeFollowerFunction · 0.80
actMonsterFunction · 0.80
actThrownFunction · 0.80

Calls 15

getStatsMethod · 0.95
modMPMethod · 0.95
makeColorRGBFunction · 0.85
messagePlayerColorFunction · 0.85
getSkillLangEntryFunction · 0.85
steamAchievementClientFunction · 0.85
statGetCHRFunction · 0.85
getStatForProficiencyFunction · 0.85
sendPacketSafeFunction · 0.85
getProficiencyMethod · 0.80

Tested by

no test coverage detected