Banco Rozbujca
Banned
- Joined
- Aug 15, 2008
- Messages
- 64
- Reaction score
- 8
Znalaz?em kod c++ "OnDiePlayer". Jest on oparty na funkcji "onDie". Nie dotyczy potwor?w, lecz player?w.
Zaczynajmy:
w pliku creature.cpp pod:
dodajemy:
Otwieramy plik creatureevent.cpp :
Pod:
Dodajemy:
nast?pnie pod:
Wstawiamy:
Pod:
Dajemy:
Nad tym:
Wpisujemy to:
Pod:"
Dajemy:
Poni?ej:
Wpisujemy:
Teraz zajmiemy si? plikiem creatureevent.h:
Pod:
Dodajemy:
Poni?ej:
Dodajemy:
Pod:
Dodajemy:
Poni?ej:
Wklejamy:
No to ju? wszystko, teraz tylko musimy wej?? w opcje projektu i wklei? to:
Pozdrawiam,
Banco Rozbujca
Zaczynajmy:
w pliku creature.cpp pod:
Code:
//scripting event - onDie
CreatureEvent* eventDie = getCreatureEvent(CREATURE_EVENT_DIE);
if(eventDie){
eventDie->executeOnDie(this, corpse);
}
dodajemy:
Code:
#ifdef ON_PLAYER_DIE_DZOJO
if(this->getPlayer()){
g_creatureEvents->playerDie(this->getPlayer(), corpse);
}
#endif
Otwieramy plik creatureevent.cpp :
Pod:
Code:
m_logOutEvent = NULL;
Dodajemy:
Code:
#ifdef ON_PLAYER_DIE_DZOJO
m_playerDieEvent = NULL;
#endif
nast?pnie pod:
Code:
delete m_logOutEvent;
Wstawiamy:
Code:
#ifdef ON_PLAYER_DIE_DZOJO
delete m_playerDieEvent;
#endif
Pod:
Code:
case CREATURE_EVENT_LOGOUT:
delete m_logOutEvent;
m_logOutEvent = creatureEvent;
return true;
Dajemy:
Code:
#ifdef ON_PLAYER_DIE_DZOJO
case CREATURE_EVENT_DIE_PLAYER:
delete m_playerDieEvent;
m_playerDieEvent = creatureEvent;
return true;
#endif
Nad tym:
Code:
uint32_t CreatureEvents::playerLogOut(Player* player)
{
// fire global event if is registered
if(m_logOutEvent){
return m_logOutEvent->executeOnLogout(player);
}
return 0;
}
Wpisujemy to:
Code:
#ifdef ON_PLAYER_DIE_DZOJO
uint32_t CreatureEvents::playerDie(Player* player, Item* corpse)
{
// fire global event if is registered
if(m_playerDieEvent){
return m_playerDieEvent->executeOnDiePlayer(player, corpse);
}
return 0;
}
#endif
Pod:"
Code:
else if(str == "die"){
m_type = CREATURE_EVENT_DIE;
}
Dajemy:
PHP:
#ifdef ON_PLAYER_DIE_DZOJO
else if(str == "dieplayer"){
m_type = CREATURE_EVENT_DIE_PLAYER;
}
#endif
Poni?ej:
Code:
case CREATURE_EVENT_DIE:
return "onDie";
break;
Wpisujemy:
PHP:
#ifdef ON_PLAYER_DIE_DZOJO
case CREATURE_EVENT_DIE_PLAYER:
return "onDiePlayer";
break;
#endif
Teraz zajmiemy si? plikiem creatureevent.h:
Pod:
Code:
uint32_t playerLogOut(Player* player);
Dodajemy:
PHP:
#ifdef ON_PLAYER_DIE_DZOJO
uint32_t playerDie(Player* player, Item* corpse);
#endif
Poni?ej:
Code:
uint32_t executeOnDie(Creature* creature, Item* corpse);
Dodajemy:
PHP:
#ifdef ON_PLAYER_DIE_DZOJO
uint32_t executeOnDiePlayer(Player* player, Item* corpse);
#endif
Pod:
Code:
CreatureEvent* m_logOutEvent;
Dodajemy:
PHP:
#ifdef ON_PLAYER_DIE_DZOJO
CreatureEvent* m_playerDieEvent;
#endif
Poni?ej:
Code:
CREATURE_EVENT_DIE,
Wklejamy:
PHP:
#ifdef ON_PLAYER_DIE_DZOJO
CREATURE_EVENT_DIE_PLAYER,
#endif
No to ju? wszystko, teraz tylko musimy wej?? w opcje projektu i wklei? to:
Code:
-DON_PLAYER_DIE_DZOJO
Pozdrawiam,
Banco Rozbujca