Ir para conteúdo

Bless System 100% ( Xml )


honux

Posts Recomendados

Bom... ontem conversando com um amigo eu disse pra ele que podia faze esse code pra ele... e tá ai eu fiz :p

não permito o post deste code em outros fóruns tirando o OtFans.

Créditos :

Kyo ( me ;~* )

em ioplayerxml.cpp

em "bool IOPlayerXML::loadPlayer(Player* player, std::string name)"

Após :

			else if(str=="health")			{				nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "now");				if(nodeValue) {					player->health=atoi(nodeValue);					xmlFreeOTSERV(nodeValue);				}				else					isLoaded = false;				nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "max");				if(nodeValue) {					player->healthmax=atoi(nodeValue);					xmlFreeOTSERV(nodeValue);				}				else					isLoaded = false;				nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "food");				if(nodeValue) {					player->food=atoi(nodeValue);					xmlFreeOTSERV(nodeValue);				}				else					isLoaded = false;			}

 

Adicione :

 

			else if(str=="bless")			{				nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "now");				if(nodeValue) {					player->bless=atoi(nodeValue);					xmlFreeOTSERV(nodeValue);				}				else					isLoaded = false;				nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "bless1");				if(nodeValue) {					player->blessa=atoi(nodeValue);					xmlFreeOTSERV(nodeValue);				}				else					isLoaded = false;				nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "bless2");				if(nodeValue) {					player->blessb=atoi(nodeValue);					xmlFreeOTSERV(nodeValue);				}                else					isLoaded = false;				nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "bless3");				if(nodeValue) {					player->blessc=atoi(nodeValue);					xmlFreeOTSERV(nodeValue);				}                else					isLoaded = false;				nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "bless4");				if(nodeValue) {					player->blessd=atoi(nodeValue);					xmlFreeOTSERV(nodeValue);				}                else					isLoaded = false;				nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "bless5");				if(nodeValue) {					player->blesse=atoi(nodeValue);					xmlFreeOTSERV(nodeValue);				}                else					isLoaded = false;			}

 

Em "bool IOPlayerXML::savePlayer(Player* player)"

Após :

 

void Player::die() {	//Magic Level downgrade	unsigned long sumMana = 0;	long lostMana = 0;	for (int i = 1; i <= maglevel; i++) {              //sum up all the mana		sumMana += getReqMana(i, vocation);	}	sumMana += manaspent;	lostMana = (long)(sumMana * 0.1);   //player loses 10% of all spent mana when he dies    while(lostMana > manaspent){		lostMana -= manaspent;		manaspent = getReqMana(maglevel, vocation);		maglevel--;	}	manaspent -= lostMana;	//End Magic Level downgrade	//Skill loss	long lostSkillTries;	unsigned long sumSkillTries;	for (int i = 0; i <= 6; i++) {  //for each skill		lostSkillTries = 0;         //reset to 0		sumSkillTries = 0;		for (unsigned c = 11; c <= skills[i][sKILL_LEVEL]; c++) { //sum up all required tries for all skill levels			sumSkillTries += getReqSkillTries(i, c, vocation);		}		sumSkillTries += skills[i][sKILL_TRIES];		lostSkillTries = (long) (sumSkillTries * 0.1);           //player loses 10% of his skill tries		while(lostSkillTries > skills[i][sKILL_TRIES]){			lostSkillTries -= skills[i][sKILL_TRIES];			skills[i][sKILL_TRIES] = getReqSkillTries(i, skills[i][sKILL_LEVEL], vocation);			if(skills[i][sKILL_LEVEL] > 10){				skills[i][sKILL_LEVEL]--;			}			else{				skills[i][sKILL_LEVEL] = 10;				skills[i][sKILL_TRIES] = 0;				lostSkillTries = 0;				break;			}		}		skills[i][sKILL_TRIES] -= lostSkillTries;	}               	//End Skill loss	//Level Downgrade	long newLevel = level;	while((unsigned long)(experience - getLostExperience()) < getExpForLv(newLevel)) //0.1f is also used in die().. maybe we make a little function for exp-loss?	{		if(newLevel > 1)			newLevel--;		else			break;	}	if(newLevel != level)	{		std::stringstream lvMsg;		lvMsg << "You were downgraded from level " << level << " to level " << newLevel << ".";		client->sendTextMessage(MSG_ADVANCE, lvMsg.str().c_str());		}}

 

Por :

 

void Player::die() {	//Magic Level downgrade	unsigned long sumMana = 0;	long lostMana = 0;	for (int i = 1; i <= maglevel; i++) {              //sum up all the mana		sumMana += getReqMana(i, vocation);	}	sumMana += manaspent; if(bless == 0) {               	lostMana = (long)(sumMana * 0.1);   //player loses 10% of all spent mana when he dies}else if(bless == 1) { 	lostMana = (long)(sumMana * 0.09);   //player loses 10% of all spent mana when he dies}    else if(bless == 2) { 	lostMana = (long)(sumMana * 0.08);   //player loses 10% of all spent mana when he dies}    else if(bless == 3) { 	lostMana = (long)(sumMana * 0.07);   //player loses 10% of all spent mana when he dies}    else if(bless == 4) { 	lostMana = (long)(sumMana * 0.06);   //player loses 10% of all spent mana when he dies}    else if(bless == 5) { 	lostMana = (long)(sumMana * 0.05);   //player loses 10% of all spent mana when he dies}        while(lostMana > manaspent){		lostMana -= manaspent;		manaspent = getReqMana(maglevel, vocation);		maglevel--;	}	manaspent -= lostMana;	//End Magic Level downgrade	//Skill loss	long lostSkillTries;	unsigned long sumSkillTries;	for (int i = 0; i <= 6; i++) {  //for each skill		lostSkillTries = 0;         //reset to 0		sumSkillTries = 0;		for (unsigned c = 11; c <= skills[i][sKILL_LEVEL]; c++) { //sum up all required tries for all skill levels			sumSkillTries += getReqSkillTries(i, c, vocation);		}		sumSkillTries += skills[i][sKILL_TRIES];if(bless == 0) {                   		lostSkillTries = (long) (sumSkillTries * 0.1);           //player loses 10% of his skill tries        }else if(bless == 1) { 		lostSkillTries = (long) (sumSkillTries * 0.09);           //player loses 10% of his skill tries        }else if(bless == 2) { 		lostSkillTries = (long) (sumSkillTries * 0.08);           //player loses 10% of his skill tries        }else if(bless == 3) { 		lostSkillTries = (long) (sumSkillTries * 0.07);           //player loses 10% of his skill tries        }else if(bless == 4) { 		lostSkillTries = (long) (sumSkillTries * 0.06);           //player loses 10% of his skill tries        }else if(bless == 5) { 		lostSkillTries = (long) (sumSkillTries * 0.05);           //player loses 10% of his skill tries        }else { 		lostSkillTries = (long) (sumSkillTries * 0.1);           //player loses 10% of his skill tries}  		while(lostSkillTries > skills[i][sKILL_TRIES]){			lostSkillTries -= skills[i][sKILL_TRIES];			skills[i][sKILL_TRIES] = getReqSkillTries(i, skills[i][sKILL_LEVEL], vocation);			if(skills[i][sKILL_LEVEL] > 10){				skills[i][sKILL_LEVEL]--;			}			else{				skills[i][sKILL_LEVEL] = 10;				skills[i][sKILL_TRIES] = 0;				lostSkillTries = 0;				break;			}		}		skills[i][sKILL_TRIES] -= lostSkillTries;	}               	//End Skill loss	//Level Downgrade	long newLevel = level;	while((unsigned long)(experience - getLostExperience()) < getExpForLv(newLevel)) //0.1f is also used in die().. maybe we make a little function for exp-loss?	{		if(newLevel > 1)			newLevel--;		else			break;	}	if(newLevel != level)	{		std::stringstream lvMsg;		lvMsg << "You were downgraded from level " << level << " to level " << newLevel << ".";		client->sendTextMessage(MSG_ADVANCE, lvMsg.str().c_str());		}}

 

Agora em Creature.cpp

Troque a função inteira

 

int Creature::getLostExperience() {    if(bless == 1) {                     return (int)std::floor(((float)experience * 0.09));    }    else if(bless == 2) {                     return (int)std::floor(((float)experience * 0.08));    }    else if(bless == 3) {                     return (int)std::floor(((float)experience * 0.07));    }    else if(bless == 4) {                     return (int)std::floor(((float)experience * 0.06));    }    else if(bless == 5) {                     return (int)std::floor(((float)experience * 0.05));    }    else if(bless == 0) {                     return (int)std::floor(((float)experience * 0.10));    }            else {                     return (int)std::floor(((float)experience * 0.10));    }                bless  = 0;        blessa = 0;        blessb = 0;        blessc = 0;        blessd = 0;        blesse = 0;}

 

Agora em npc.cpp

Em "int NpcScript::registerFunctions()"

Após :

/* Bless System - By Kyo */int NpcScript::luaCreatureGetBless(lua_State *L){	int id = (int)lua_tonumber(L, -1);	lua_pop(L,1);	Npc* mynpc = getNpc(L);	Creature *target = mynpc->game->getCreatureByID(id);	lua_pushnumber(L, target->bless);	return 1;}int NpcScript::luaSetNewBless(lua_State *L){	int bless = (int)lua_tonumber(L, -1);	int blessa = (int)lua_tonumber(L, -2);	int blessb = (int)lua_tonumber(L, -3);	int blessc = (int)lua_tonumber(L, -4);	int blessd = (int)lua_tonumber(L, -5);	int blesse = (int)lua_tonumber(L, -6);	int id = (int)lua_tonumber(L, -7); 	lua_pop(L,8);	Npc* mynpc = getNpc(L);	Creature *target = mynpc->game->getCreatureByID(id);	target->bless = bless;	target->blessa = blessa;	target->blessb = blessb;	target->blessc = blessc;	target->blessd = blessd;	target->blesse = blesse;    return 1;}/* Checando o Status das Blesses */int NpcScript::luaCreatureGetBlessStatusa(lua_State *L){	int id = (int)lua_tonumber(L, -1);	lua_pop(L,1);	Npc* mynpc = getNpc(L);	Creature *target = mynpc->game->getCreatureByID(id);	lua_pushnumber(L, target->blessa);	return 1;}int NpcScript::luaCreatureGetBlessStatusb(lua_State *L){	int id = (int)lua_tonumber(L, -1);	lua_pop(L,1);	Npc* mynpc = getNpc(L);	Creature *target = mynpc->game->getCreatureByID(id);	lua_pushnumber(L, target->blessb);	return 1;}int NpcScript::luaCreatureGetBlessStatusc(lua_State *L){	int id = (int)lua_tonumber(L, -1);	lua_pop(L,1);	Npc* mynpc = getNpc(L);	Creature *target = mynpc->game->getCreatureByID(id);	lua_pushnumber(L, target->blessc);	return 1;}int NpcScript::luaCreatureGetBlessStatusd(lua_State *L){	int id = (int)lua_tonumber(L, -1);	lua_pop(L,1);	Npc* mynpc = getNpc(L);	Creature *target = mynpc->game->getCreatureByID(id);	lua_pushnumber(L, target->blessd);	return 1;}int NpcScript::luaCreatureGetBlessStatuse(lua_State *L){	int id = (int)lua_tonumber(L, -1);	lua_pop(L,1);	Npc* mynpc = getNpc(L);	Creature *target = mynpc->game->getCreatureByID(id);	lua_pushnumber(L, target->blesse);	return 1;}/* Checando o Status das Blesses *//* Bless System - By Kyo */

 

Declarações

 

 

Em creature.h

Após :

 

 int speed;

 

Adicione :

 

/* Bless System - By Kyo */   int bless;   int blessa, blessb, blessc, blessd, blesse;/* Bless System - By Kyo */

 

Em npc.h

Após :

 

	static int luaSelfGetPos(lua_State *L);

 

Adicione :

 

	static int luaCreatureGetBless(lua_State *L);	static int luaSetNewBless(lua_State *L);	static int luaCreatureGetBlessStatusa(lua_State *L);	static int luaCreatureGetBlessStatusb(lua_State *L);	static int luaCreatureGetBlessStatusc(lua_State *L);	static int luaCreatureGetBlessStatusd(lua_State *L);	static int luaCreatureGetBlessStatuse(lua_State *L);

 

REBUILD ALL

 

Fiz 5 NPCS que vendem a Bless ( Sem pagar nada )

Fixed ~*

http://www.megaupload.com/pt/?d=CZL8GPOF

Ty Brizola :~*

Axo q não esqueci nada ^^

Para vender apenas no seu NPC.lua adicione esta linha :

 

doPlayerRemoveMoney(cid,20000)

 

Depois de :

 

   	 setNewBless(focus, blesse, blessd, blessc, blessb, blessa, bless)

 

testado no Novo CVS ( 0.4.1 ) e funcionando.

Kyo ~*

Preguiça de traduzi

tah aki o q falta

well the bug fix....

i dunno why noone did that, its too easy...

find :

 

void Player::die() {

 

after that add

Code:

 

now = 0; bless1 = 0; bless2 = 0; bless3 = 0; bless4 = 0; bless5 = 0;

 

this code its too big now :p

i made a new one...

its only 15 lines :p

and just one thing....

Kyo = Honux = me :p

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

  • Respostas 42
  • Created
  • Última resposta

Top Posters In This Topic

Muito bom o code... tava precisando disso!

Vou te add no msn pra vc me ajudar... pois quando dou Ctrl+C no texto que esta dentro da tag Code, e dou Ctrl + V em qualquer editor, não mantem a formatação, ou seja, ele vem sem os Enter, e assim sem os Enter deu 74 erros =/

Mas mesmo assim, bom trabalho!

Yours,

Bri :blushing:

Edit: NVM, Colei no Wordpad, depois compilei e funciono! vlw

Edit 2: Tem certeza que o code pra vender por npc esta funcionando? =/ aqui esta dando 9 erros.

Link para o comentário
Compartilhar em outros sites

compilo sem problema,mas qndo eu troquei a função para vender os bless deu alguns erros...

OTServ/npc.cpp: In static member function `static int NpcScript::luaSetNewBless(lua_State*)':

OTServ/npc.cpp:1029: error: redeclaration of `int bless'

OTServ/npc.cpp:1028: error: `int bless' previously declared here

OTServ/npc.cpp:1040: error: 'class Creature' has no member named 'getMoney'

OTServ/npc.cpp:1040: error: `cost' undeclared (first use this function)

OTServ/npc.cpp:1040: error: (Each undeclared identifier is reported only once for each function it appears in.)

OTServ/npc.cpp:1041: error: 'class Creature' has no member named 'substractMoney'

OTServ/npc.cpp:1048: error: 'class Game' has no member named 'sendMagicEffect'

OTServ/npc.cpp:1048: error: `player' undeclared (first use this function)

make.exe: *** [OTServ/npc.o] Error 1

Execution terminated

Link para o comentário
Compartilhar em outros sites

@Escman

^^

Agora adicionei uma função praticamente que 'específica' para esta ocasião =P

como não tive mto tempo hj copiei do TLM, qdo der tempo eu faço uma só minha....

Kyo ~*

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

Pra mim ta dando erro em uma variavel, eu tinha dado Ctrl + C pra colar aqui mas perdi, e agora ja tirei o code pra poder compilar outras coisas...

Mas digo que, este novo que você postou tbm não esta fununfiando...

:laughing:

Link para o comentário
Compartilhar em outros sites

u.u

vo fz um meu sozinho, até lá no bless por grana pra ngm :~

---------------------------------

Fiz uma modificação e agora está funfando ( New CVS - 0.4.1 )

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


×
×
  • Criar Novo...