Jump to content

Success Prob when Training GrandMaster Skills


Recommended Posts

  • Bronze

Hi guys. I had too much free time today so I thought I would check how does Grandmaster training look like in Source. It calculated training count and compared to required training count, so I changed it to % chance of training. I will try to explain how does my algorithm work. I generate number between 1 and 100, and then I compare it with success prob in the table.

 

// ADD_GRANDMASTER_SKILL
bool CHARACTER::LearnGrandMasterSkill(DWORD dwSkillVnum)	//SAVIRIS EDIT - Dziwny algorytm treningu zastąpiony najzwyklejszą szansą na przeczytanie
{
	CSkillProto * pkSk = CSkillManager::instance().Get(dwSkillVnum);
 
	if (!pkSk)
		return false;
 
	if (!IsLearnableSkill(dwSkillVnum))
	{
		ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ľö·ĂÇŇ Ľö ľř´Â ˝şĹłŔÔ´Ď´Ů."));
		return false;
	}
 
	sys_log(0, "learn grand master skill[%d] cur %d, next %d", dwSkillVnum, get_global_time(), GetSkillNextReadTime(dwSkillVnum));
 
	if (pkSk->dwType == 0)
	{
		ChatPacket(CHAT_TYPE_INFO, LC_TEXT("±×·Łµĺ ¸¶˝şĹÍ Ľö·ĂŔ» ÇŇ Ľö ľř´Â ˝şĹłŔÔ´Ď´Ů."));
		return false;
	}
 
	if (GetSkillMasterType(dwSkillVnum) != SKILL_GRAND_MASTER)
	{
		if (GetSkillMasterType(dwSkillVnum) > SKILL_GRAND_MASTER)
			ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ĆŰĆĺĆ® ¸¶˝şĹÍµČ ˝şĹłŔÔ´Ď´Ů. ´ő ŔĚ»ó Ľö·Ă ÇŇ Ľö ľř˝Ŕ´Ď´Ů."));
		else
			ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ŔĚ ˝şĹłŔş ľĆÁ÷ ±×·Łµĺ ¸¶˝şĹÍ Ľö·ĂŔ» ÇŇ °ćÁöżˇ Ŕ̸ŁÁö ľĘľŇ˝Ŕ´Ď´Ů."));
		return false;
	}
 
	std::string strTrainSkill;
	{
		std::ostringstream os;
		os << "training_grandmaster_skill.skill" << dwSkillVnum;
		strTrainSkill = os.str();
	}
 
	// ż©±âĽ­ Č®·üŔ» °č»ęÇŐ´Ď´Ů.
	BYTE bLastLevel = GetSkillLevel(dwSkillVnum);
 
	int idx = MIN(9, GetSkillLevel(dwSkillVnum) - 30);
 
	sys_log(0, "LearnGrandMasterSkill %s table idx %d value %d", GetName(), idx, aiGrandMasterSkillBookCountForLevelUp[idx]);
 
	int iBookCount = aiGrandMasterSkillBookCountForLevelUp[idx];
 
	if (FindAffect(AFFECT_SKILL_BOOK_BONUS))
	{
		if (iBookCount&1)
			iBookCount = iBookCount / 2 + 1; 
		else
			iBookCount = iBookCount / 2; 
 
		RemoveAffect(AFFECT_SKILL_BOOK_BONUS);
	}
 
	int n = number(1, 100);
	sys_log(0, "Number(%d)", n);
 
	DWORD nextTime = get_global_time() + number(28800, 43200);
 
	bool bSuccess = false;
 
	const int aiGrandMasterSkillBookSuccessProb[10] = 
		{ //1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10	<-- Poziomy G
			95, 85, 75, 65, 55, 45, 35, 25, 15, 5
		};
	if (n <= aiGrandMasterSkillBookSuccessProb[idx])
	{
		bSuccess = true;
	}
 
	if (test_server)
	{
		ChatPacket(CHAT_TYPE_INFO, "[TEST] Dane: aiGrandMasterSkillBookSuccessProb[%d] = %d, n = %d", idx, aiGrandMasterSkillBookSuccessProb[idx], n);
	}
 
	if (bSuccess)
	{
		SkillLevelUp(dwSkillVnum, SKILL_UP_BY_QUEST);
	}
 
	SetSkillNextReadTime(dwSkillVnum, nextTime);
 
	if (bLastLevel == GetSkillLevel(dwSkillVnum))
	{
		ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("Ĺ©Ŕą, ±â°ˇ żŞ·ůÇĎ°í ŔÖľî! ŔĚ°Ĺ Ľł¸¶ ÁÖČ­ŔÔ¸¶Ŕΰˇ!? Á¨Ŕĺ!"));
		ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ľö·ĂŔĚ ˝ÇĆĐ·Î łˇłµ˝Ŕ´Ď´Ů. ´Ů˝Ă µµŔüÇŘÁֽñ⠹ٶř´Ď´Ů."));
		LogManager::instance().CharLog(this, dwSkillVnum, "GM_READ_FAIL", "");
		return false;
	}
 
	ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("¸öżˇĽ­ ąş°ˇ ČűŔĚ ĹÍÁ® łŞżŔ´Â ±âşĐŔĚľß!"));
	ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("¶ß°Ĺżî ą«ľůŔĚ °čĽÓ żëĽÚŔ˝Äˇ°í ŔÖľî! ŔĚ°Ç, ŔĚ°ÍŔş!"));
	ChatPacket(CHAT_TYPE_INFO, LC_TEXT("´ő łôŔş °ćÁöŔÇ Ľö·ĂŔ» Ľş°řŔűŔ¸·Î łˇł»ĽĚ˝Ŕ´Ď´Ů."));
	LogManager::instance().CharLog(this, dwSkillVnum, "GM_READ_SUCCESS", "");
	return true;
}
// END_OF_ADD_GRANDMASTER_SKILL

 

Here's my algorithm. I deleted stuff which was designed for Ymir locale as nobody uses it, so my script works for all locale.

 

How to edit success % chance of training?

It is simple as 2+2. You have to edit aiGrandMasterSkillBookSuccessProb table. As the comment says, each number is success prob for grandmaster skill level. As You can see, it is 95 for G1->G2, 85 for G2->G3 etc.

 

Oh, I'd forgot. This function is invoked by pc.learn_grand_master_skill() quest function.

 

Any questions? Feel free to ask, I will try to answer as I'm not so skilled in C++.

 

Copying to other boards without my permission is prohibited.

  • Love 3
Link to comment
Share on other sites

  • 1 year later...
  • 5 years later...

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.