Game.cpp
Pod
Kod:
w
Kod:
Wklejamy
Kod:
Gdziekolwiek w game.cpp (najlepiej na dole )
Kod:
Game.h
Public
Kod:
Creature.h
Pod
Kod:
wklejamy
Kod:
Creature.cpp
Pod
Kod:
wklejamy
Kod:
Protocol76.cpp
Pod
Kod:
Kod:
Pod
Kod:
Kod:
Protocol76.h
Pod
Kod:
wklejamy
Kod:
Player.cpp
Podmie?
Kod:
Na to:
Kod:
Pod
Kod:
stopEvent(c->eventCheck);
stopEvent(c->eventCheckAttacking);
w
Kod:
bool Game::removeCreature(Creature* c)
Wklejamy
Kod:
stopEvent(c->eventCheckFollow);
Gdziekolwiek w game.cpp (najlepiej na dole )
Kod:
void Game::checkCreatureFollow(unsigned long id)
{
OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::checkCreatureFollow");
Player *player = getPlayerByID(id);
if(!player)
return;
if(!player->pathList.empty()) {
Position toPos = player->pathList.front();
player->pathList.pop_front();
player->lastmove = OTSYS_TIME();
this->thingMove(player, player, toPos.x, toPos.y, player->pos.z, 1);
flushSendBuffers();
}
if(!player->pathList.empty()) {
long long delay = player->getSleepTicks();
stopEvent(player->eventCheckFollow);
player->eventCheckFollow = addEvent(makeTask(delay, std::bind2nd(std::mem_fun(&Game::checkCreatureFollow), id)));
}
else {
player->eventCheckFollow = 0;
}
}
void Game:layerFollow(Player* player, Creature *followCreature)
{
OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game:layerFollow()");
if(followCreature->isRemoved || player->isRemoved || !player || !followCreature){
player->eventCheckFollow = 0;
player->followCreature = 0;
return;
}
player->pathList = getPathTo(player, player->pos, followCreature->pos, false);
long long delay = player->getSleepTicks();
player->eventCheckFollow = addEvent(makeTask(delay, std::bind2nd(std::mem_fun(&Game::checkCreatureFollow), player->getID())));
}
void Game:layerSetFollowCreature(Player* player, unsigned long creatureid)
{
OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game:layerSetFollowCreature()");
if(player->isRemoved || !player)
return;
if(creatureid == 0) {
stopEvent(player->eventCheckFollow);
player->eventCheckFollow = 0;
player->followCreature = 0;
}
Creature* followCreature = NULL;
if(creatureid != 0) {
followCreature = getCreatureByID(creatureid);
}
if(followCreature) {
player->followCreature = followCreature->getID();
stopEvent(player->eventCheckFollow);
playerFollow(player, followCreature);
}
}
Game.h
Public
Kod:
void checkCreatureFollow(unsigned long id);
void playerFollow(Player* player, Creature *followCreature);
void playerSetFollowCreature(Player* player, unsigned long creatureid);
Creature.h
Pod
Kod:
unsigned long attackedCreature;
wklejamy
Kod:
unsigned long followCreature;
std::list<Position> pathList;
unsigned long eventCheckFollow;
Creature.cpp
Pod
Kod:
eventCheck = 0;
eventCheckAttacking = 0;
wklejamy
Kod:
eventCheckFollow = 0;
followCreature = 0;
Protocol76.cpp
Pod
Kod:
wklejamycase 0xA1: // attack
parseAttack(msg);
break;
Kod:
case 0xA2: // attack
parseFollow(msg);
break;
Pod
Kod:
wklejamyvoid Protocol76:arseAttack(NetworkMessage &msg)
{
unsigned long creatureid = msg.GetU32();
game->playerSetAttackedCreature(player, creatureid);
}
Kod:
void Protocol76:arseFollow(NetworkMessage &msg)
{
unsigned long creatureid = msg.GetU32();
game->playerSetFollowCreature(player, creatureid);
}
Protocol76.h
Pod
Kod:
void parseAttack(NetworkMessage &msg);
wklejamy
Kod:
void parseFollow(NetworkMessage &msg);
Player.cpp
Podmie?
Kod:
void Player:nThingMove(const Creature *creature, const Thing *thing, const Position *oldPos,
unsigned char oldstackpos, unsigned char oldcount, unsigned char count)
{
client->sendThingMove(creature, thing, oldPos, oldstackpos, oldcount, count);
}
Na to:
Kod:
Pozdrawiam i my?l?, ?e kod sie wam przyda. Testowany prze ze mnie idzia?a na 100%void Player:nThingMove(const Creature *creature, const Thing *thing, const Position *oldPos,
unsigned char oldstackpos, unsigned char oldcount, unsigned char count)
{
const Creature *constantCreature = dynamic_cast<const Creature*>(thing);
if(constantCreature && constantCreature->getID() == this->followCreature){
g_game.playerFollow(this, const_cast<Creature*>(constantCreature));
}
client->sendThingMove(creature, thing, oldPos, oldstackpos, oldcount, count);
}
Notka moderatorska: |
Wy??czaj u?mieszki, gdy wstawiasz skrypt. |