TH

[7.8] Bless System

Por Thunder Tiger, 06 de out. de 2006 em Linguagens de Programação

script
8
3.8k
Thunder TigerT
06 de outubro de 2006 às 14:17

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

 

2 semanas depois...
aiolaA
17 de outubro de 2006 às 18:28

serve pra q?

byetcha

1 mês depois...
OdafasO
01 de novembro de 2006 às 14:57

Otimo Bless System..

valew ae cara!

1 mês depois...
KenzoK
31 de dezembro de 2006 às 20:23

Vei muito bom ;}

 

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

 

//Kenzo

Editado Dezembro 31 por Kenzo

tibiaa4eT
02 de janeiro de 2007 às 02:54

svn antiga né ?

 

flws :hi:

1 ano depois...
TyrurT
29 de julho de 2008 às 17:01

Cara parabens

 

ai pelo topico

 

deve ter dado um trabalhão

 

flw

6 meses depois...
OtavioblsO
04 de janeiro de 2009 às 00:14

Porra queria pra 8.4 ;/

mais ta valendo!

1 ano depois...
26 de janeiro de 2010 às 19:21

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+?