Od Thorge D (me): Dla poszukiwaczy tego kodu udost?pniam go.
1. Autor: Miziak
2. Link do oryginalnego tematu:
3. Opis: Eventy w LUA zwi?zane z Creaturami nie ma co du?o pisa?.
4. Kod:
w actions.cpp pod:
[CPP]it = actionItemMap.begin();
while(it != actionItemMap.end()) {
delete it->second;
actionItemMap.erase(it);
it = actionItemMap.begin();
}[/CPP]
dodajemy:
[CPP]ActionCreatureMap::iterator cs = creatureScriptMap.begin();
while(cs != creatureScriptMap.end()){
delete cs->second;
creatureScriptMap.erase(cs);
cs = creatureScriptMap.begin();
}[/CPP]
nast?pnie pod:
[cpp]else if(readXMLInteger(p,"actionid",actionid)){
action = loadAction(p);
actionItemMap[actionid] = action;
action = NULL;
}
else{
std::cout << "missing action id." << std::endl;
}
}[/cpp]
dodajemy:
[CPP]else if(strcmp(str, "creature") == 0){
std::string evt;
if(readXMLString(p,"event",evt)){
action = loadAction(p);
std::string id = (char*)xmlGetProp(p,(xmlChar*)"id");
evt += id;
creatureScriptMap[evt] = action;
action = NULL;
}else
puts("missing event declatation.");
}[/CPP]
nast?pnie pod:
[CPP]player->sendCancel("You cannot throw there.");
return false;
}
Position itempos = game->getThingMapPos(player, from_pos);
game->autoCloseTrade(item);
PositionEx posFromEx(from_pos,from_stack);
PositionEx posToEx(to_pos,to_stack);
if(action->executeUse(player,item,posFromEx,posToEx))
return true;
}[/CPP]
dodaj:
[CPP]bool Actions::creatureEvent(std::string evt, Player* player, Creature* creature, Item* item, int tab[]){
bool ret = false;
for(ActionCreatureMap::iterator it = creatureScriptMap.begin(); it != creatureScriptMap.end(); ++it){
Action *action = it->second;
if(action){
if(evt == "login" && it->first.find("login") != std::string::npos)
if(action->executeLogin(player))
ret = true;
if(evt == "logout" && it->first.find("logout") != std::string::npos)
if(action->executeLogout(player))
ret = true;
if(evt == "death" && it->first.find("death") != std::string::npos)
if(action->executeDeath(player, creature, item))
ret = true;
if(evt == "advance" && it->first.find("advance") != std::string::npos)
if(action->executeAdvance(player, tab[0], tab[1], tab[2]))
ret = true;
if(evt == "kill" && it->first.find("kill") != std::string::npos)
if(action->executeKill(player, creature, item))
ret = true;
}
}
return ret;
}[/CPP]
dalej pod:
[CPP]int thingId2 = script->AddThingToMap(thing,posTo);
script->internalAddThing(luaState,thing,thingId2);
script->internalAddPositionEx(luaState,posTo);
}
else{
script->internalAddThing(luaState,NULL,0);
PositionEx posEx;
script->internalAddPositionEx(luaState,posEx);
}
lua_pcall(luaState, 5, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}[/CPP]
dodajemy:
[CPP]bool Action::executeLogin(Player *player){
//onLogin(uidplayer)
script->ClearMap();
script->_player = player;
PositionEx playerpos = player->pos;
unsigned int cid = script->AddThingToMap((Thing*)player,playerpos);
lua_State* luaState = script->getLuaState();
lua_pushstring(luaState, "onLogin");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_pushnumber(luaState, cid);
lua_pcall(luaState, 1, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}
bool Action::executeLogout(Player *player){
//onLogout(uidplayer)
script->ClearMap();
script->_player = player;
PositionEx playerpos = player->pos;
unsigned int cid = script->AddThingToMap((Thing*)player,playerpos);
lua_State* luaState = script->getLuaState();
lua_pushstring(luaState, "onLogout");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_pushnumber(luaState, cid);
lua_pcall(luaState, 1, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}
bool Action::executeDeath(Player *player, Creature* cre, Item* corpse){
//onDeath(uidplayer, attackeruid, corpse)
script->ClearMap();
script->_player = player;
PositionEx playerpos = player->pos;
unsigned int cid = script->AddThingToMap((Thing*)player,playerpos);
//script->_cre = cre;
PositionEx crepos = cre->pos;
unsigned int acid = script->AddThingToMap((Thing*)cre,crepos);
PositionEx corpos = corpse->pos;
unsigned int itemid = script->AddThingToMap(corpse,corpos);
lua_State* luaState = script->getLuaState();
lua_pushstring(luaState, "onDeath");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_pushnumber(luaState, cid);
lua_pushnumber(luaState, acid);
script->internalAddThing(luaState,corpse,itemid);
lua_pcall(luaState, 3, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}
bool Action::executeAdvance(Player *player, int skill, int oldlvl, int newlvl){
//onAdvance(uidplayer, skill, oldlvl, newlvl)
script->ClearMap();
script->_player = player;
PositionEx playerpos = player->pos;
unsigned int cid = script->AddThingToMap((Thing*)player,playerpos);
lua_State* luaState = script->getLuaState();
lua_pushstring(luaState, "onAdvance");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_pushnumber(luaState, cid);
lua_pushnumber(luaState, skill);
lua_pushnumber(luaState, oldlvl);
lua_pushnumber(luaState, newlvl);
lua_pcall(luaState, 4, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}
bool Action::executeKill(Player *player, Creature* cre, Item* corpse){
//onKill(killer, target, corpse)
script->ClearMap();
script->_player = player;
PositionEx playerpos = player->pos;
unsigned int cid = script->AddThingToMap((Thing*)player,playerpos);
PositionEx crepos = cre->pos;
unsigned int acid = script->AddThingToMap((Thing*)cre,crepos);
PositionEx corpos = corpse->pos;
unsigned int itemid = script->AddThingToMap(corpse,corpos);
lua_State* luaState = script->getLuaState();
lua_pushstring(luaState, "onKill");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_pushnumber(luaState, cid);
lua_pushnumber(luaState, acid);
script->internalAddThing(luaState,corpse,itemid);
lua_pcall(luaState, 3, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}[/CPP]
teraz w actions.h pod:
[CPP]bool UseItemEx(Player* player, const Position &from_pos,
const unsigned char from_stack,const Position &to_pos,
const unsigned char to_stack,const unsigned short itemid);[/CPP]
dodajemy:
[CPP]bool creatureEvent(std::string, Player*, Creature*, Item*, int[]);[/CPP]
nast?pnie pod:
[CPP]protected:
std::string datadir;
typedef std::map<unsigned short, Action*> ActionUseMap;[/CPP]
dodajemy:
[CPP]typedef std::map<std::string, Action*> ActionCreatureMap;
ActionCreatureMap creatureScriptMap;[/CPP]
dalej pod:
[CPP]void setBlockWalls(bool v){blockwalls = v;};[/CPP]
dodajemy:
[CPP]bool executeLogin(Player *);
bool executeLogout(Player *);
bool executeDeath(Player *, Creature *, Item *);
bool executeAdvance(Player *, int, int, int);
bool executeKill(Player *, Creature *, Item *);[/CPP]
przeskakujemy do game.cpp i w nim nad:
[CPP]if(attackedplayer){
attackedplayer->onThingDisappear(attackedplayer,stackpos);[/CPP]
wklejamy:
[CPP]if(dynamic_cast<Player*>(attacker) && attackedCreature)
actions.creatureEvent("kill", dynamic_cast<Player*>(attacker), attackedCreature, corpseitem, NULL);[/CPP]
teraz pod linijk?:
[CPP]if(attackedplayer){
attackedplayer->onThingDisappear(attackedplayer,stackpos);[/CPP]
dodajemy:
[CPP]attackedplayer->dieorlogout = true;
if(attacker)
actions.creatureEvent("death", attackedplayer, attacker, corpseitem, NULL);[/CPP]
nast?pnie pod:
[CPP]//c->eventCheckAttacking = addEvent(makeTask(2000, std::bind2nd(std::mem_fun(&Game::checkCreatureAttacking), c->getID())));
}
}
else {
//we cant add the player, server is full
success = false;
}[/CPP]
dodaj:
[CPP]if(p)
actions.creatureEvent("login", p, NULL, NULL, NULL);[/CPP]
dalej pod:
[CPP]bool Game::removeCreature(Creature* c)
{
OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::removeCreature()");
if(c->isRemoved == true)
return false;
#ifdef __DEBUG__
std::cout << "removing creature "<< std::endl;
#endif[/CPP]
dodaj:
[CPP]Player* pc = dynamic_cast<Player*>(c);
if(pc)
if(!pc->dieorlogout)
actions.creatureEvent("logout", pc, NULL, NULL, NULL);[/CPP]
teraz w player.cpp pod:
[CPP]#ifdef ELEM_VIP_LIST
#include "networkmessage.h"
#endif //ELEM_VIP_LIST[/CPP]
dodaj:
[CPP]#include "actions.h"
extern Actions actions;[/CPP]
nast?pnie pod:
[CPP]#ifdef YUR_LIGHT_ITEM
lightItem = 0;
#endif //YUR_LIGHT_ITEM[/CPP]
dodaj:
[CPP]dieorlogout = false;[/CPP]
teraz pod:
[CPP]void Player::addSkillTryInternal(int skilltry,int skill){
skills[skill][SKILL_TRIES] += skilltry;
//for skill level advances
//int reqTries = (int) ( SkillBases[skill] * pow((float) VocMultipliers[skill][voc], (float) ( skills[skill][SKILL_LEVEL] - 10) ) );
#if __DEBUG__
//for debug
cout << Creature::getName() << ", has the vocation: " << (int)vocation << " and is training his " << getSkillName(skill) << "(" << skill << "). Tries: " << skills[skill][SKILL_TRIES] << "(" << getReqSkillTries(skill, (skills[skill][SKILL_LEVEL] + 1), vocation) << ")" << std::endl;
cout << "Current skill: " << skills[skill][SKILL_LEVEL] << std::endl;
#endif
//Need skill up?
if (skills[skill][SKILL_TRIES] >= getReqSkillTries(skill, (skills[skill][SKILL_LEVEL] + 1), vocation)) {[/CPP]
dodajemy:
[CPP]int tab[] = {skill, skills[skill][SKILL_LEVEL], skills[skill][SKILL_LEVEL]+1};
actions.creatureEvent("advance", this, NULL, NULL, tab);[/CPP]
Dalej pod:
[CPP]void Player::addManaSpent(unsigned long spent){
if(spent == 0)
return;
#ifdef YUR_MULTIPLIERS
spent *= g_config.MANA_MUL[vocation];
#endif //YUR_MULTIPLIERS
this->manaspent += spent;
//Magic Level Advance
int reqMana = this->getReqMana(this->maglevel+1, this->vocation);
if (this->access < g_config.ACCESS_PROTECT && this->manaspent >= reqMana) {
this->manaspent -= reqMana;[/CPP]
dodaj:
[CPP]int tab[] = {7, this->maglevel, this->maglevel+1};
actions.creatureEvent("advance", this, NULL, NULL, tab);[/CPP]
nast?pnie pod:
[CPP]void Player::addExp(exp_t exp)
{
this->experience += exp;
int lastLv = this->level;
while (this->experience >= this->getExpForLv(this->level+1)) {
this->level++;
this->healthmax += g_config.HP_GAIN[(int)vocation];
this->health += g_config.HP_GAIN[(int)vocation];
this->manamax += g_config.MANA_GAIN[(int)vocation];
this->mana += g_config.MANA_GAIN[(int)vocation];
this->capacity += g_config.CAP_GAIN[(int)vocation];
}
if(lastLv != this->level)
{
this->setNormalSpeed();
g_game.changeSpeed(this->getID(), this->getSpeed());[/CPP]
dodaj:
[CPP]int tab[] = {8, lastLv, level};
actions.creatureEvent("advance", this, NULL, NULL, tab);[/CPP]
teraz w player.h pod:
[CPP]#ifdef TRS_GM_INVISIBLE
int oldlookhead, oldlookbody, oldlooklegs, oldlookfeet, oldlooktype, oldlookcorpse, oldlookmaster;
bool gmInvisible;
#endif //TRS_GM_INVISIBLE[/CPP]
dodaj:
[CPP]bool dieorlogout;[/CPP]
Teraz do actions.xml dodaj:
[XML]<creature event="login" id="1" script="creaturescripts/login.lua" />
<creature event="logout" id="1" script="creaturescripts/logout.lua" />
<creature event="death" id="1" script="creaturescripts/death.lua" />
<creature event="advance" id="1" script="creaturescripts/adv.lua" />
<creature event="kill" id="1" script="creaturescripts/kill.lua" />[/XML]
niestety paczka testowych skrypt?w, kt?r? mieli?my rozpakowa? bezpo?rednio w data/actions/scripts odesz?a w sin? dal ;(
Teraz rebuild.
Testowane na czystym jurku f.
1. Autor: Miziak
2. Link do oryginalnego tematu:
3. Opis: Eventy w LUA zwi?zane z Creaturami nie ma co du?o pisa?.
4. Kod:
w actions.cpp pod:
[CPP]it = actionItemMap.begin();
while(it != actionItemMap.end()) {
delete it->second;
actionItemMap.erase(it);
it = actionItemMap.begin();
}[/CPP]
dodajemy:
[CPP]ActionCreatureMap::iterator cs = creatureScriptMap.begin();
while(cs != creatureScriptMap.end()){
delete cs->second;
creatureScriptMap.erase(cs);
cs = creatureScriptMap.begin();
}[/CPP]
nast?pnie pod:
[cpp]else if(readXMLInteger(p,"actionid",actionid)){
action = loadAction(p);
actionItemMap[actionid] = action;
action = NULL;
}
else{
std::cout << "missing action id." << std::endl;
}
}[/cpp]
dodajemy:
[CPP]else if(strcmp(str, "creature") == 0){
std::string evt;
if(readXMLString(p,"event",evt)){
action = loadAction(p);
std::string id = (char*)xmlGetProp(p,(xmlChar*)"id");
evt += id;
creatureScriptMap[evt] = action;
action = NULL;
}else
puts("missing event declatation.");
}[/CPP]
nast?pnie pod:
[CPP]player->sendCancel("You cannot throw there.");
return false;
}
Position itempos = game->getThingMapPos(player, from_pos);
game->autoCloseTrade(item);
PositionEx posFromEx(from_pos,from_stack);
PositionEx posToEx(to_pos,to_stack);
if(action->executeUse(player,item,posFromEx,posToEx))
return true;
}[/CPP]
dodaj:
[CPP]bool Actions::creatureEvent(std::string evt, Player* player, Creature* creature, Item* item, int tab[]){
bool ret = false;
for(ActionCreatureMap::iterator it = creatureScriptMap.begin(); it != creatureScriptMap.end(); ++it){
Action *action = it->second;
if(action){
if(evt == "login" && it->first.find("login") != std::string::npos)
if(action->executeLogin(player))
ret = true;
if(evt == "logout" && it->first.find("logout") != std::string::npos)
if(action->executeLogout(player))
ret = true;
if(evt == "death" && it->first.find("death") != std::string::npos)
if(action->executeDeath(player, creature, item))
ret = true;
if(evt == "advance" && it->first.find("advance") != std::string::npos)
if(action->executeAdvance(player, tab[0], tab[1], tab[2]))
ret = true;
if(evt == "kill" && it->first.find("kill") != std::string::npos)
if(action->executeKill(player, creature, item))
ret = true;
}
}
return ret;
}[/CPP]
dalej pod:
[CPP]int thingId2 = script->AddThingToMap(thing,posTo);
script->internalAddThing(luaState,thing,thingId2);
script->internalAddPositionEx(luaState,posTo);
}
else{
script->internalAddThing(luaState,NULL,0);
PositionEx posEx;
script->internalAddPositionEx(luaState,posEx);
}
lua_pcall(luaState, 5, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}[/CPP]
dodajemy:
[CPP]bool Action::executeLogin(Player *player){
//onLogin(uidplayer)
script->ClearMap();
script->_player = player;
PositionEx playerpos = player->pos;
unsigned int cid = script->AddThingToMap((Thing*)player,playerpos);
lua_State* luaState = script->getLuaState();
lua_pushstring(luaState, "onLogin");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_pushnumber(luaState, cid);
lua_pcall(luaState, 1, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}
bool Action::executeLogout(Player *player){
//onLogout(uidplayer)
script->ClearMap();
script->_player = player;
PositionEx playerpos = player->pos;
unsigned int cid = script->AddThingToMap((Thing*)player,playerpos);
lua_State* luaState = script->getLuaState();
lua_pushstring(luaState, "onLogout");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_pushnumber(luaState, cid);
lua_pcall(luaState, 1, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}
bool Action::executeDeath(Player *player, Creature* cre, Item* corpse){
//onDeath(uidplayer, attackeruid, corpse)
script->ClearMap();
script->_player = player;
PositionEx playerpos = player->pos;
unsigned int cid = script->AddThingToMap((Thing*)player,playerpos);
//script->_cre = cre;
PositionEx crepos = cre->pos;
unsigned int acid = script->AddThingToMap((Thing*)cre,crepos);
PositionEx corpos = corpse->pos;
unsigned int itemid = script->AddThingToMap(corpse,corpos);
lua_State* luaState = script->getLuaState();
lua_pushstring(luaState, "onDeath");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_pushnumber(luaState, cid);
lua_pushnumber(luaState, acid);
script->internalAddThing(luaState,corpse,itemid);
lua_pcall(luaState, 3, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}
bool Action::executeAdvance(Player *player, int skill, int oldlvl, int newlvl){
//onAdvance(uidplayer, skill, oldlvl, newlvl)
script->ClearMap();
script->_player = player;
PositionEx playerpos = player->pos;
unsigned int cid = script->AddThingToMap((Thing*)player,playerpos);
lua_State* luaState = script->getLuaState();
lua_pushstring(luaState, "onAdvance");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_pushnumber(luaState, cid);
lua_pushnumber(luaState, skill);
lua_pushnumber(luaState, oldlvl);
lua_pushnumber(luaState, newlvl);
lua_pcall(luaState, 4, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}
bool Action::executeKill(Player *player, Creature* cre, Item* corpse){
//onKill(killer, target, corpse)
script->ClearMap();
script->_player = player;
PositionEx playerpos = player->pos;
unsigned int cid = script->AddThingToMap((Thing*)player,playerpos);
PositionEx crepos = cre->pos;
unsigned int acid = script->AddThingToMap((Thing*)cre,crepos);
PositionEx corpos = corpse->pos;
unsigned int itemid = script->AddThingToMap(corpse,corpos);
lua_State* luaState = script->getLuaState();
lua_pushstring(luaState, "onKill");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_pushnumber(luaState, cid);
lua_pushnumber(luaState, acid);
script->internalAddThing(luaState,corpse,itemid);
lua_pcall(luaState, 3, 1, 0);
bool ret = (script->internalGetNumber(luaState) != 0);
return ret;
}[/CPP]
teraz w actions.h pod:
[CPP]bool UseItemEx(Player* player, const Position &from_pos,
const unsigned char from_stack,const Position &to_pos,
const unsigned char to_stack,const unsigned short itemid);[/CPP]
dodajemy:
[CPP]bool creatureEvent(std::string, Player*, Creature*, Item*, int[]);[/CPP]
nast?pnie pod:
[CPP]protected:
std::string datadir;
typedef std::map<unsigned short, Action*> ActionUseMap;[/CPP]
dodajemy:
[CPP]typedef std::map<std::string, Action*> ActionCreatureMap;
ActionCreatureMap creatureScriptMap;[/CPP]
dalej pod:
[CPP]void setBlockWalls(bool v){blockwalls = v;};[/CPP]
dodajemy:
[CPP]bool executeLogin(Player *);
bool executeLogout(Player *);
bool executeDeath(Player *, Creature *, Item *);
bool executeAdvance(Player *, int, int, int);
bool executeKill(Player *, Creature *, Item *);[/CPP]
przeskakujemy do game.cpp i w nim nad:
[CPP]if(attackedplayer){
attackedplayer->onThingDisappear(attackedplayer,stackpos);[/CPP]
wklejamy:
[CPP]if(dynamic_cast<Player*>(attacker) && attackedCreature)
actions.creatureEvent("kill", dynamic_cast<Player*>(attacker), attackedCreature, corpseitem, NULL);[/CPP]
teraz pod linijk?:
[CPP]if(attackedplayer){
attackedplayer->onThingDisappear(attackedplayer,stackpos);[/CPP]
dodajemy:
[CPP]attackedplayer->dieorlogout = true;
if(attacker)
actions.creatureEvent("death", attackedplayer, attacker, corpseitem, NULL);[/CPP]
nast?pnie pod:
[CPP]//c->eventCheckAttacking = addEvent(makeTask(2000, std::bind2nd(std::mem_fun(&Game::checkCreatureAttacking), c->getID())));
}
}
else {
//we cant add the player, server is full
success = false;
}[/CPP]
dodaj:
[CPP]if(p)
actions.creatureEvent("login", p, NULL, NULL, NULL);[/CPP]
dalej pod:
[CPP]bool Game::removeCreature(Creature* c)
{
OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::removeCreature()");
if(c->isRemoved == true)
return false;
#ifdef __DEBUG__
std::cout << "removing creature "<< std::endl;
#endif[/CPP]
dodaj:
[CPP]Player* pc = dynamic_cast<Player*>(c);
if(pc)
if(!pc->dieorlogout)
actions.creatureEvent("logout", pc, NULL, NULL, NULL);[/CPP]
teraz w player.cpp pod:
[CPP]#ifdef ELEM_VIP_LIST
#include "networkmessage.h"
#endif //ELEM_VIP_LIST[/CPP]
dodaj:
[CPP]#include "actions.h"
extern Actions actions;[/CPP]
nast?pnie pod:
[CPP]#ifdef YUR_LIGHT_ITEM
lightItem = 0;
#endif //YUR_LIGHT_ITEM[/CPP]
dodaj:
[CPP]dieorlogout = false;[/CPP]
teraz pod:
[CPP]void Player::addSkillTryInternal(int skilltry,int skill){
skills[skill][SKILL_TRIES] += skilltry;
//for skill level advances
//int reqTries = (int) ( SkillBases[skill] * pow((float) VocMultipliers[skill][voc], (float) ( skills[skill][SKILL_LEVEL] - 10) ) );
#if __DEBUG__
//for debug
cout << Creature::getName() << ", has the vocation: " << (int)vocation << " and is training his " << getSkillName(skill) << "(" << skill << "). Tries: " << skills[skill][SKILL_TRIES] << "(" << getReqSkillTries(skill, (skills[skill][SKILL_LEVEL] + 1), vocation) << ")" << std::endl;
cout << "Current skill: " << skills[skill][SKILL_LEVEL] << std::endl;
#endif
//Need skill up?
if (skills[skill][SKILL_TRIES] >= getReqSkillTries(skill, (skills[skill][SKILL_LEVEL] + 1), vocation)) {[/CPP]
dodajemy:
[CPP]int tab[] = {skill, skills[skill][SKILL_LEVEL], skills[skill][SKILL_LEVEL]+1};
actions.creatureEvent("advance", this, NULL, NULL, tab);[/CPP]
Dalej pod:
[CPP]void Player::addManaSpent(unsigned long spent){
if(spent == 0)
return;
#ifdef YUR_MULTIPLIERS
spent *= g_config.MANA_MUL[vocation];
#endif //YUR_MULTIPLIERS
this->manaspent += spent;
//Magic Level Advance
int reqMana = this->getReqMana(this->maglevel+1, this->vocation);
if (this->access < g_config.ACCESS_PROTECT && this->manaspent >= reqMana) {
this->manaspent -= reqMana;[/CPP]
dodaj:
[CPP]int tab[] = {7, this->maglevel, this->maglevel+1};
actions.creatureEvent("advance", this, NULL, NULL, tab);[/CPP]
nast?pnie pod:
[CPP]void Player::addExp(exp_t exp)
{
this->experience += exp;
int lastLv = this->level;
while (this->experience >= this->getExpForLv(this->level+1)) {
this->level++;
this->healthmax += g_config.HP_GAIN[(int)vocation];
this->health += g_config.HP_GAIN[(int)vocation];
this->manamax += g_config.MANA_GAIN[(int)vocation];
this->mana += g_config.MANA_GAIN[(int)vocation];
this->capacity += g_config.CAP_GAIN[(int)vocation];
}
if(lastLv != this->level)
{
this->setNormalSpeed();
g_game.changeSpeed(this->getID(), this->getSpeed());[/CPP]
dodaj:
[CPP]int tab[] = {8, lastLv, level};
actions.creatureEvent("advance", this, NULL, NULL, tab);[/CPP]
teraz w player.h pod:
[CPP]#ifdef TRS_GM_INVISIBLE
int oldlookhead, oldlookbody, oldlooklegs, oldlookfeet, oldlooktype, oldlookcorpse, oldlookmaster;
bool gmInvisible;
#endif //TRS_GM_INVISIBLE[/CPP]
dodaj:
[CPP]bool dieorlogout;[/CPP]
Teraz do actions.xml dodaj:
[XML]<creature event="login" id="1" script="creaturescripts/login.lua" />
<creature event="logout" id="1" script="creaturescripts/logout.lua" />
<creature event="death" id="1" script="creaturescripts/death.lua" />
<creature event="advance" id="1" script="creaturescripts/adv.lua" />
<creature event="kill" id="1" script="creaturescripts/kill.lua" />[/XML]
niestety paczka testowych skrypt?w, kt?r? mieli?my rozpakowa? bezpo?rednio w data/actions/scripts odesz?a w sin? dal ;(
Teraz rebuild.
Testowane na czystym jurku f.