[7.8] Bless System

Thunder Tiger

Staff Xserver
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 26/12/05Posts: 21

Olá amigos decidi postar meu sistema de blessing para vocês.

Para quem não sabe sou Rappa Carnaúba(Sapphire da OTFans)

Vamos comecar,

em player.h abaixo de

 

void kickPlayer();

 

adicione

 

#ifdef __SAP_BLESS_SYSTEM__	int bless;#endif //__SAP_BLESS_SYSTEM__

 

substitua:

 

  virtual int getLostExperience(){ 	 return (int)std::floor(((double)experience * 0.1));	}

 

por:

 

#ifdef __SAP_BLESS_SYSTEM__	virtual int getLostExperience(){        switch(bless){    case 1: 	 return (int)std::floor(((double)experience * 0.09));    case 2: 	 return (int)std::floor(((double)experience * 0.08));    case 3: 	 return (int)std::floor(((double)experience * 0.07));    case 4: 	 return (int)std::floor(((double)experience * 0.06));    case 5: 	 return (int)std::floor(((double)experience * 0.05));    default: 	 return (int)std::floor(((double)experience * 0.1));    }  } #else    virtual int getLostExperience(){ 	 return (int)std::floor(((double)experience * 0.1));	} #endif //#ifdef __SAP_BLESS_SYSTEM__

 

agora em player.cpp

No construtor Player::Player

abaixo de

 

tradeItem = NULL;

 

 

#ifdef __SAP_BLESS_SYSTEM__	bless = 0;#endif //__SAP_BLESS_SYSTEM__

 

Agora na funcão void Player::die()

substitua

 

lostMana = (long)(sumMana * 0.1);

 

por

 

#ifdef __SAP_BLESS_SYSTEM__	switch(bless){    case 1: 	 lostMana = (long)(sumMana * 0.09);    case 2: 	 lostMana = (long)(sumMana * 0.08);    case 3: 	 lostMana = (long)(sumMana * 0.07);    case 4: 	 lostMana = (long)(sumMana * 0.06);    case 5: 	 lostMana = (long)(sumMana * 0.05);    default: 	 lostMana = (long)(sumMana * 0.1);    }   #else  	 lostMana = (long)(sumMana * 0.1);#endif //__SAP_BLESS_SYSTEM__

 

mais abaixo substitua

 

lostSkillTries = (long) (sumSkillTries * 0.1);

 

por:

 

#ifdef __SAP_BLESS_SYSTEM__	switch(bless){    case 1: 	 lostSkillTries = (long) (sumSkillTries * 0.09);    case 2: 	 lostSkillTries = (long) (sumSkillTries * 0.08);    case 3: 	 lostSkillTries = (long) (sumSkillTries * 0.07);    case 4: 	 lostSkillTries = (long) (sumSkillTries * 0.06);    case 5: 	 lostSkillTries = (long) (sumSkillTries * 0.05);    default: 	 lostSkillTries = (long) (sumSkillTries * 0.1);	}    #else  	 lostSkillTries = (long) (sumSkillTries * 0.1);#endif //__SAP_BLESS_SYSTEM__

 

abaixo de:

 

	if(newLevel != level){  std::stringstream lvMsg;  lvMsg << "You were downgraded from level " << level << " to level " << newLevel << ".";  client->sendTextMessage(MSG_EVENT_ADVANCE, lvMsg.str().c_str());	}

 

adicione

 

	#ifdef __SAP_BLESS_SYSTEM__	bless = 0;	#endif //__SAP_BLESS_SYSTEM__

 

Para quem usa mysql

ioplayersql.cpp

abaixo de

 

player->experience = result.getDataLong("experience");

 

adicione:

 

#ifdef __SAP_BLESS_SYSTEM__	player->bless = result.getDataInt("bless");#endif //__SAP_BLESS_SYSTEM__

 

agora em savePlayer

abaixo de:

 

query << "`experience` = " << player->experience << ", ";

 

adicione:

 

#ifdef __SAP_BLESS_SYSTEM__	query << "`bless` = " << player->bless << ", ";#endif //__SAP_BLESS_SYSTEM__

 

Para quem usa XML

ioplayerxml.cpp

abaixo de:

 

	if(readXMLInteger(root, "exp", intValue)){ 	 player->experience = intValue;  }  else 	 isLoaded = false;

 

adicione:

 

	if(readXMLInteger(root, "bless", intValue)){ 	 player->bless = intValue;  }  else 	 isLoaded = false;

 

agora em savePlayer,

abaixo de

 

	sb << player->experience;   xmlSetProp(root, (const xmlChar*)"exp", (const xmlChar*)sb.str().c_str());    sb.str("");

 

adicione:

 

	sb << player->bless;   xmlSetProp(root, (const xmlChar*)"bless", (const xmlChar*)sb.str().c_str());    sb.str("");

 

agora em npc.cpp

no lua_register adicione

 

	#ifdef __SAP_BLESS_SYSTEM__	lua_register(luaState, "getPlayerBless", NpcScript::luaGetPlayerBless);	lua_register(luaState, "doPlayerAddBless", NpcScript::luaDoPlayerAddBless);	#endif //__SAP_BLESS_SYSTEM__

 

no final do npc.cpp adicione:

 

#ifdef __SAP_BLESS_SYSTEM__int NpcScript::luaGetPlayerBless(lua_State* L){	int cid = (int)lua_tonumber(L, -1);	lua_pop(L, 1);	Npc* mynpc = getNpc(L);	Player* player = dynamic_cast<Player*>(g_game.getCreatureByID(cid));	if(player)   lua_pushnumber(L, player->bless);	else   lua_pushnumber(L, -1);	return 1;}int NpcScript::luaDoPlayerAddBless(lua_State* L){   	int cid = (int)lua_tonumber(L, -2);	int bless = (int)lua_tonumber(L, -1);	lua_pop(L, 2);	Npc* mynpc = getNpc(L);	Player* player = dynamic_cast<Player*>(g_game.getCreatureByID(cid));	if(player) {   if(player->bless < 5){   player->bless += 1;   mynpc->doSay("Here you are your bless, take care young adventure.");   player->sendMagicEffect(player->getPosition(), NM_ME_MAGIC_POISON);   }   else{   mynpc->doSay("Sorry, young adventurer you already have all bless.");   lua_pushnumber(L, 0);   }   }   else{  std::cout << "Error when giving a bless to player." << std::endl;  lua_pushnumber(L, -1);   }   return 0;}  #endif //__SAP_BLESS_SYSTEM__

 

npc.h

abaixo de:

 

static int luaSelfGetPos(lua_State *L);

 

adicione

 

#ifdef __SAP_BLESS_SYSTEM__	static int luaDoPlayerAddBless(lua_State* L);	static int luaGetPlayerBless(lua_State* L);#endif //__SAP_BLESS_SYSTEM__

 

Agora em project->project options "C++ Compiler" adicionem -D__SAP_BLESS_SYSTEM__

Creditos:

Rappa Carnaúba;(Eu)

Abraços!

bless.lua

 

focus = 0talk_start = 0target = 0following = falseattacking = falsetalk_state = 0price = 20000function onThingMove(creature, thing, oldpos, oldstackpos)endfunction onCreatureAppear(creature)endfunction onCreatureDisappear(cid, pos) 	 if focus == cid then          selfSay('Good bye then.')          focus = 0          talk_start = 0 	 endendfunction onCreatureTurn(creature)endfunction msgcontains(txt, str) 	 return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))endfunction onCreatureSay(cid, type, msg) 	 msg = string.lower(msg) 	 if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then 	 selfSay('Hello ' .. creatureGetName(cid) .. '! Im selling bless.') 	 focus = cid 	 talk_start = os.clock()	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then    selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.') 	 elseif focus == cid then  talk_start = os.clock()  if msgcontains(msg, 'blessing') or msgcontains(msg, 'bless') then                        if getPlayerBless(cid) > 4 then                                selfSay('Sorry, young adventurer you already have all bless.')                                talk_state = 0    elseif getPlayerLevel(creatureGetName(cid)) < 20 then    selfSay('Sorry, you need level 20 to buy bless.')    talk_state = 0 	 elseif not isPremium(cid) then    selfSay('Sorry, you must be premium to be blessed.')    talk_state = 0 	 else    selfSay('Do you want to buy bless for ' .. price ..' gold coins ?')    talk_state = 1 	 end  elseif talk_state == 1 then 	 if msgcontains(msg, 'yes') then    if pay(cid,price) then   	 doPlayerAddBless(cid, 1)    else   	 selfSay('Sorry, you do not have enough money.')    end    end 	 talk_state = 0    elseif msgcontains(msg, 'bye')  and getDistanceToCreature(cid) < 4 then   	 selfSay('Good bye, ' .. creatureGetName(cid) .. '!')   	 focus = 0   	 talk_start = 0    end 	 endendfunction onCreatureChangeOutfit(creature)endfunction onThink() 	 if (os.clock() - talk_start) > 30 then    if focus > 0 then   	 selfSay('Next Please...')    end   	 focus = 0 	 end  if focus ~= 0 then 	 if getDistanceToCreature(focus) > 5 then    selfSay('Good bye then.')    focus = 0 	 end  endend

 

aiola

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 07/10/06Posts: 23

serve pra q?

byetcha

Odafas

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/10/06Posts: 22

Otimo Bless System..

valew ae cara!

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



-

-

-

*~Mapper~*
*~Designer~*
*~Admin~*
*~PHP Programer~*
*~Homem~*




Kenzo

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 08/10/06Posts: 131Char no Tibia: Kenzo Phoenix

Vei muito bom ;}

 

Posta mais codes ai por qe no ot networks vc posta umonte ;}

 

//Kenzo

Visite a melhor parte do Fórum XTibia! Basta você apenas clicar aqui e deixar sua opinião sobre qualquer um dos assuntos!

Está com dúvidas no Tibia? Quer dicas de como melhorar seu character? Mande uma PM e lhe responderei a medida do possível.

"Tonight
I'm gonna have myself a real good time
I feel alive
And the world is turning inside out
Yeah!
And floating around in ecstasy

So don't stop me now
Don't stop me
'Cause I'm having a good time
I'm having a good time

I'm a shooting star leaping through the sky
Like a tiger defying the laws of gravity
I'm a racing car passing by like Lady Godiva
I'm gonna go go go
There's no stopping me...
"

Dont Stop me Now - McFly

tibiaa4e

Ex amante de Tibia
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 18/12/05Posts: 912Gênero: MasculinoChar no Tibia: Kohzete

svn antiga né ?

 

flws :hi:

Aposentado de OTserver e Tibia

Meus melhores tutoriais
Enciclopédia Pasta Data
Tutorial de quest

Tyrur

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 10/06/08Posts: 48Char no Tibia: GOD Tyrur

Cara parabens

 

ai pelo topico

 

deve ter dado um trabalhão

 

flw

Olá XTibiano:

Sua assinatura estava com um problema na TAG SPOILER e foi movida para a parte "Sobre mim".
Agradecemos a sua compreensão.

Atenciosamente,
JV Chequer

Otaviobls

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 15/12/08Posts: 39Char no Tibia: Tlying

Porra queria pra 8.4 ;/

mais ta valendo!

XStrikerSoulX

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 18/10/09Posts: 15Char no Tibia: Diak Akan

lol, entendi nada, absolutamente só algumas coisas sauhasuhasuash

n sei nada absolutamente nada de scripting, e é tão antigo?

existe esses bagulho desses arquivo nos 8.5+?