Ir para conteúdo

Doplayerremoveskill!


Clic

Posts Recomendados

Meu primeiro code!! e ele foi muito facil de faze!! Deer Mudar sinais!!!

então vamo ao code!

 

Em luascript.cpp abaixo de:

	//doPlayerAddSkillTry(cid,skillid,n)
lua_register(m_luaState, "doPlayerAddSkillTry", LuaScriptInterface::luaDoPlayerAddSkillTry);

Adicione abaixo:

	//doPlayerRemoveSkillTry(cid,skillid,n)
lua_register(m_luaState, "doPlayerRemoveSkillTry", LuaScriptInterface::luaDoPlayerRemoveSkillTry);

 

Ainda em luascript.cpp procure por:

int LuaScriptInterface::luaDoPlayerAddSkillTry(lua_State *L)
{
//doPlayerAddSkillTry(uid,skillid,n)
uint32_t n = popNumber(L);
uint32_t skillid = popNumber(L);
uint32_t cid = popNumber(L);

ScriptEnviroment* env = getScriptEnv();

Player* player = env->getPlayerByUID(cid);
if(player){
	player->addSkillAdvance((skills_t)skillid, n);
	lua_pushnumber(L, LUA_NO_ERROR);
}
else{
	reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
	lua_pushnumber(L, LUA_ERROR);
}
return 1;
}

 

Adicione abaixo:

int LuaScriptInterface::luaDoPlayerRemoveSkillTry(lua_State *L)
{
//doPlayerRemoveSkillTry(uid,skillid,n)
uint32_t n = popNumber(L);
uint32_t skillid = popNumber(L);
uint32_t cid = popNumber(L);

ScriptEnviroment* env = getScriptEnv();

Player* player = env->getPlayerByUID(cid);
if(player){
	player->removeSkill((skills_t)skillid, n);
	lua_pushnumber(L, LUA_NO_ERROR);
}
else{
	reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
	lua_pushnumber(L, LUA_ERROR);
}
return 1;
}

 

Agora em luascript.h procure por:

	static int luaDoPlayerAddSkillTry(lua_State *L);

Adicione abaixo:

	static int luaDoPlayerRemoveSkillTry(lua_State *L);

 

agore em player.cpp procure por:

void Player::addSkillAdvance(skills_t skill, uint32_t count)
{
skills[skill][SKILL_TRIES] += count * g_config.getNumber(ConfigManager::RATE_SKILL);

#if __DEBUG__
std::cout << getName() << ", has the vocation: " << (int)getVocationId() << " and is training his " << getSkillName(skill) << "(" << skill << "). Tries: " << skills[skill][SKILL_TRIES] << "(" << vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL] + 1) << ")" << std::endl;
std::cout << "Current skill: " << skills[skill][SKILL_LEVEL] << std::endl;
#endif

//Need skill up?
if(skills[skill][SKILL_TRIES] >= vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL] + 1)){
 	skills[skill][SKILL_LEVEL]++;
 	skills[skill][SKILL_TRIES] = 0;
	skills[skill][SKILL_PERCENT] = 0;				 
	std::stringstream advMsg;
	advMsg << "You advanced in " << getSkillName(skill) << ".";
	client->sendTextMessage(MSG_EVENT_ADVANCE, advMsg.str());
	client->sendSkills();
}
else{
	//update percent
	uint32_t newPercent = std::min((uint32_t)100, (100*skills[skill][SKILL_TRIES])/vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL]+1));
 	if(skills[skill][SKILL_PERCENT] != newPercent){
		skills[skill][SKILL_PERCENT] = newPercent;
		client->sendSkills();
 	}
}
}

 

Adicione abaixo:

void Player::removeSkill(skills_t skill, uint32_t count)
{
skills[skill][SKILL_TRIES] -= count * g_config.getNumber(ConfigManager::RATE_SKILL);

#if __DEBUG__
std::cout << getName() << ", has the vocation: " << (int)getVocationId() << " and is training his " << getSkillName(skill) << "(" << skill << "). Tries: " << skills[skill][SKILL_TRIES] << "(" << vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL] + 1) << ")" << std::endl;
std::cout << "Current skill: " << skills[skill][SKILL_LEVEL] << std::endl;
#endif

//Need skill up?
if(skills[skill][SKILL_TRIES] >= vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL] - 1)){
 	skills[skill][SKILL_LEVEL]--;
 	skills[skill][SKILL_LEVEL] > 0;
 	skills[skill][SKILL_TRIES] = 0;
	skills[skill][SKILL_PERCENT] = 0;				 
	std::stringstream advMsg;
	advMsg << "You come back in " << getSkillName(skill) << ".";
	client->sendTextMessage(MSG_EVENT_ADVANCE, advMsg.str());
	client->sendSkills();
}
else{
	//update percent
	uint32_t newPercent = std::min((uint32_t)100, (100*skills[skill][SKILL_TRIES])/vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL]-1));
 	if(skills[skill][SKILL_PERCENT] != newPercent){
		skills[skill][SKILL_PERCENT] = newPercent;
		client->sendSkills();
 	}
}
}

 

Agora em player.h procure por:

	void addSkillAdvance(skills_t skill, uint32_t count);

Adicione abaixo:

	void removeSkill(skills_t skill, uint32_t count);

 

Poste 100 nesse topico!! espero tem um poco de sucesso nele!

Grato, Clic.

 

Créditos a Mim(Clic)

Editado por Clic
Link para o comentário
Compartilhar em outros sites

Você acha que eu sou oque? um colex? ;D

 

Que tal explicar pra que serve.

 

Abraços,

Alttli.

Malz! Eu tava fazendo uma action com DoplayerAddSkillTry!

eu colokei pra i negativo ai nao foi!! ai eu criei esse comando!

ou seja ele serve para actions moveevents e nao sei se serve pra talkactions!

Ele remove um determinado skill euma determinada quantidade de skill do player!

doPlayerRemovveSKill(cid,2,5)

ele remove 5 skill do skill de sword!

se vc tentar:

doPlayerAddSkillTry(cid,2,-5)

ele adiciona 1 skill no skill de sword!

 

Grato, Clic.

Link para o comentário
Compartilhar em outros sites

  • 11 years later...
×
×
  • Criar Novo...