What's new

-Tibia 7.60 [7.6] Bless System

Status
Not open for further replies.

Thorge D

Advanced User
Joined
Jul 24, 2014
Messages
300
Reaction score
29
Autor: Miziak

Opis:
Code:
Bless 1: daje nam dodatkowy "%" do atak?w magicznych po czym ka?dy nast?pny powi?ksza ten "%".(config.lua)
Bless 2: Daje dodatkowy "%" do ataku magicznego reszta jak wy?ej.
Bless 3: Chroni przed utrat? przedmiot?w przy ?mierci.
Bless 4: Chroni przed utrat? skilli i lvl'u przy ?mierci.
Nom to tyle wi?c teraz kod:

W ioplayerxml.cpp pod:
[CPP]nodeValue = (char*)xmlGetProp(root, (const xmlChar *) "cap");
if(nodeValue) {
player->capacity = atoi(nodeValue);
xmlFreeOTSERV(nodeValue);
}
else
isLoaded = false;[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
nodeValue = (char*)xmlGetProp(root, (const xmlChar *) "bless");
if(nodeValue) {
player->blessing = atoi(nodeValue);
xmlFreeOTSERV(nodeValue);
}
else
isLoaded = false;
#endif[/CPP]
W tym samym pliku pod:
[CPP]sb << player->getCapacity(); xmlSetProp(root, (const xmlChar*) "cap", (const xmlChar*)sb.str().c_str()); sb.str("");[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
sb << player->blessing; xmlSetProp(root, (const xmlChar*) "bless", (const xmlChar*)sb.str().c_str()); sb.str("");
#endif[/CPP]
teraz w player.cpp pod:
[CPP]lastlogin = 0;[/CPP]
dodajemy:
[CPP] #ifdef __MIZIAK_BLESSING__
blessing = 0;
#endif[/CPP]
dalej w tym samym pliku pod:
[CPP]#ifdef YUR_AOL
if (items[SLOT_NECKLACE] && items[SLOT_NECKLACE]->getID() == ITEM_AOL)
{
removeItemInventory(SLOT_NECKLACE);
return;
}
#endif //YUR_AOL[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
if(blessing >= 3){
return;
}
#endif[/CPP]

Hmm teraz zak?adam, ?e ka?dy ma sl w swoim silniku wi?c:
Mamy tak? oto cz??? kodu:
[CPP]if(!aol){
experience -= getLostExperience();
}
else{
aol = false;
}[/CPP]
wi?c gdy to znajdziemy ten warunek:
[CPP]if(!aol){[/CPP]
zamieniamy na ten:
[CPP]if(!aol && blessing != 4){[/CPP]
oraz pod zedytowan? ca?o?ci? kt?ra powinna wygl?da? tak:
[CPP]if(!aol && blessing != 4){
experience -= getLostExperience();
}
else{
aol = false;
}[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
if(blessing > 0)
blessing = 0;
#endif[/CPP]

Ok, przechodzimy do pliku player.h gdzie pod:
[cpp]bool gainHealthTick();[/cpp]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
int blessing;
#endif[/CPP]
nast?pnie w pliku game.cpp pod:
[CPP]int GameState::applyAmulets(Player* player, int damage, attacktype_t atype)
{
if (!player || atype == ATTACK_NONE)
return damage;

double newDamage = (double)damage;
Item* necklace = player->getItem(SLOT_NECKLACE);
Item* ring = player->getItem(SLOT_RING);[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
if (player->blessing > 0)
{
std::stringstream absorb;
switch(player->blessing){
case 1:
{
double dmg = std::ceil(newDamage * (100 - g_config.BLESS_1_ABSORB) / 100);
newDamage = dmg;
absorb << "Bogowie uchronili Cie przed " << damage - dmg << "pkt. obrarzen z " << damage << ".";
break;
}
case 2:
{
double dmg = std::ceil(newDamage * (100 - g_config.BLESS_2_ABSORB) / 100);
newDamage = dmg;
absorb << "Bogowie uchronili Cie przed " << damage - dmg << "pkt. obrarzen z " << damage << ".";
break;
}
case 3:
{
double dmg = std::ceil(newDamage * (100 - g_config.BLESS_3_ABSORB) / 100);
newDamage = dmg;
absorb << "Bogowie uchronili Cie przed " << damage - dmg << "pkt. obrarzen z " << damage << ".";
break;
}
case 4:
{
double dmg = std::ceil(newDamage * (100 - g_config.BLESS_4_ABSORB) / 100);
newDamage = dmg;
absorb << "Bogowie uchronili Cie przed " << damage - dmg << "pkt. obrarzen z " << damage << ".";
break;
}
}
player->sendTextMessage(MSG_TO_BLESS, absorb.str().c_str());
}
#endif[/CPP]
dalej w tym samym pliku nad:
[CPP]#ifdef YUR_DRAINS
if (me->attackType & ATTACK_MANADRAIN)
{
manaDamage = std::min(damage, targetCreature->mana);
targetCreature->drainMana(manaDamage);
damage = 0;
}
else
#endif //YUR_DRAINS[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
if(attackPlayer && attackPlayer->blessing > 1){
double newdamage;
std::stringstream add;
switch(attackPlayer->blessing){
case 2:
{
newdamage = damage*g_config.BLESS_2_ADD_DAMAGE/100;
if(me->offensive && me->minDamage != 0)
add << "Bogowie dodali do twego ataku " << (int)newdamage << "pkt. obrazen.";
break;
}
case 3:
{
newdamage = damage*g_config.BLESS_3_ADD_DAMAGE/100;
if(me->offensive && me->minDamage != 0)
add << "Bogowie dodali do twego ataku " << (int)newdamage << "pkt. obrazen.";
break;
}
case 4:
{
newdamage = damage*g_config.BLESS_4_ADD_DAMAGE/100;
if(me->offensive && me->minDamage != 0)
add << "Bogowie dodali do twego ataku " << (int)newdamage << "pkt. obrazen.";
break;
}
}
attackPlayer->sendTextMessage(MSG_BLUE_TEXT, add.str().c_str());
damage += (int)newdamage;
}
#endif[/CPP]

Teraz w luascript.cpp pod:
[CPP]#ifdef SD_BURST_ARROW
BURST_DMG_LVL = atof(getGlobalStringField("burstarrowdmg", 1, "2.0").c_str());
BURST_DMG_MLVL = atof(getGlobalStringField("burstarrowdmg", 2, "3.0").c_str());
BURST_DMG_LO = atof(getGlobalStringField("burstarrowdmg", 3, "0.24").c_str());
BURST_DMG_HI = atof(getGlobalStringField("burstarrowdmg", 4, "0.55").c_str());
#endif //SD_BURST_ARROW[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
BLESS_1_ABSORB = atoi(getGlobalStringField("blessAbsorbPrecent", 1, "5").c_str());
BLESS_2_ABSORB = atoi(getGlobalStringField("blessAbsorbPrecent", 2, "10").c_str());
BLESS_3_ABSORB = atoi(getGlobalStringField("blessAbsorbPrecent", 3, "20").c_str());
BLESS_4_ABSORB = atoi(getGlobalStringField("blessAbsorbPrecent", 4, "30").c_str());

BLESS_2_ADD_DAMAGE = atoi(getGlobalStringField("blessAddDamage", 1, "10").c_str());
BLESS_3_ADD_DAMAGE = atoi(getGlobalStringField("blessAddDamage", 2, "15").c_str());
BLESS_4_ADD_DAMAGE = atoi(getGlobalStringField("blessAddDamage", 3, "20").c_str());
#endif[/CPP]
w luascript.h pod:
[CPP]#ifdef SD_BURST_ARROW
double BURST_DMG_LVL;
double BURST_DMG_MLVL;
double BURST_DMG_LO;
double BURST_DMG_HI;
#endif //SD_BURST_ARROW[/CPP]
dodaj:
[CPP]#ifdef __MIZIAK_BLESSING__
double BLESS_1_ABSORB;
double BLESS_2_ABSORB;
double BLESS_3_ABSORB;
double BLESS_4_ABSORB;

double BLESS_2_ADD_DAMAGE;
double BLESS_3_ADD_DAMAGE;
double BLESS_4_ADD_DAMAGE;
#endif[/CPP]
teraz w const76.h pod:
[CPP]enum MessageClasses {[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
MSG_TO_BLESS = 0x02,
#endif[/CPP]
przechodzimy do npc.cpp gdzie pod:
[CPP]lua_register(luaState, "selfGetPosition", NpcScript::luaSelfGetPos);[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
lua_register(luaState, "getCreatureBlessing", NpcScript::luaGetCreatureBlessing);
#endif[/CPP]
oraz pod:
[CPP]int NpcScript::luaCreatureGetName(lua_State *L){
int id = (int)lua_tonumber(L, -1);
lua_pop(L,1);
Npc* mynpc = getNpc(L);
lua_pushstring(L, mynpc->game->getCreatureByID(id)->getName().c_str());
return 1;
}[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
int NpcScript::luaGetCreatureBlessing(lua_State *L){
int id = (int)lua_tonumber(L, -1);
lua_pop(L,1);
Npc* mynpc = getNpc(L);
Creature* creature = mynpc->game->getCreatureByID(id);
Player* player = creature? dynamic_cast<Player*>(creature) : NULL;
lua_pushnumber(L, player->blessing);
return 1;
}
#endif[/CPP]
teraz npc.h pod:
[CPP]static int luaSelfGetPos(lua_State *L);[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
static int luaGetCreatureBlessing(lua_State *L);
#endif[/CPP]

Teraz ju? naprawd? ostatnia cz??? kodu
W commands.cpp pod:
[CPP]{"/kick",&Commands::kickPlayer},[/CPP]
dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
{"/bless",&Commands::setBless},
{"!bless",&Commands::getBless},
#endif[/CPP]
oraz na samym ko?cu pliku dodajemy:
[CPP]#ifdef __MIZIAK_BLESSING__
bool Commands::setBless(Creature* c, const std::string &cmd, const std::string &param)
{
int bless;
std::string name;
std::istringstream in(param.c_str());

std::getline(in, name, ',');
in >> bless;

Creature* creature = game->getCreatureByName(name);
Player* player = dynamic_cast<Player*>(creature);

if (player){
player->blessing = bless;
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
(*it).second->sendMagicEffect(player->pos, NM_ME_SOUND_YELLOW);
}
}

return true;
}

bool Commands::getBless(Creature* c, const std::string &cmd, const std::string &param)
{
Player* player = dynamic_cast<Player*>(c);

if(player){
std::stringstream bless;
switch(player->blessing)
{
case 0:
bless << "Aktualnie posiadasz zadnych blogoslawienstw.";
break;
case 1:
bless << "Aktualnie posiadasz jedno blogoslawienstwo.";
break;
case 2:
bless << "Aktualnie posiadasz dwa blogoslawienstwa.";
break;
case 3:
bless << "Aktualnie posiadasz trzy blogoslawienstwa.";
break;
case 4:
bless << "Aktualnie posiadasz cztery blogoslawienstwa.";
break;
}
player->sendTextMessage(MSG_ADVANCE, bless.str().c_str());
}

return true;
}
#endif[/CPP]
w commands.h pod:
[CPP]bool kickPlayer(Creature* c, const std::string &cmd, const std::string &param);[/CPP]
dodaj:
[CPP]#ifdef __MIZIAK_BLESSING__
bool setBless(Creature* c, const std::string &cmd, const std::string &param);
bool getBless(Creature* c, const std::string &cmd, const std::string &param);
#endif[/CPP]

KONIEC

Teraz tylko do parametr?w kompilacji:
Code:
-D__MIZIAK_BLESSING__

Do config lua:
Code:
-- Bless absorb damage
-- {bless 1, bless 2, bless 3, bless 4}
blessAbsorbPrecent = {"10", "20", "30", "40"}

-- Bless add damage
-- {bless 2, bless 3, bless 4}
blessAddDamage = {"10", "15", "20"}

oraz commands.xml:
[XML]<command cmd="/bless" access="3" />
<command cmd="!bless" access="0" />[/XML]

Gdzie:
Code:
/bless Imi?_gracza,jaki_bless -- nadaje graczowi blessa
!bless - wy?wietla graczowi jaki ma aktualnie bless
 
Status
Not open for further replies.
Top