Treasure.cpp
Treasure.hCódigo:#include "StdAfx.h" TREASURE_CUSTOM Treasure; char treasureMapName[][15] = {"Lorencia", "Devias", "Noria"}; BYTE treasureMapNumber[] = {0, 2, 3}; BYTE Index = (BYTE)(rand() % sizeof(treasureMapNumber)); bool TREASURE_CUSTOM::Load() { ZeroMemory(this->_winner,sizeof(this->_winner)); this->_enabled = GetPrivateProfileInt("Pirata Jack","Ativar",1,CFG_PIRATA) > 0 ? true : false; this->_timeOpen = GetPrivateProfileInt("Pirata Jack","TimeOpen",1,CFG_PIRATA) * 60; this->_timeBuy = GetPrivateProfileInt("Pirata Jack","TimeBuy",1,CFG_PIRATA); this->_timeClose = GetPrivateProfileInt("Pirata Jack","TimeClose",1,CFG_PIRATA) * 60; this->_state = treasureOff; this->_timeCount = this->_timeOpen; this->_index = -1; this->_shopNumber = 11; return true; } void TREASURE_CUSTOM::Check() { if(!this->_enabled) { return; } if(this->_timeCount > 0) { this->_timeCount--; return; } if(this->_state == treasureOff) { ZeroMemory(this->_winner,sizeof(this->_winner)); this->_state = treasureOn; this->_timeCount = this->_timeClose; short X, Y; BYTE Map = treasureMapNumber[Index]; while(func.GetBoxPosition(Map,10,10,240,240,X,Y) == 0) {} this->_index = gObjAddMonsters(); if(this->_index >= 0 && this->_index < OBJECT_MIN) { OBJECTSTRUCT* lpNpc = &gObj[this->_index]; lpNpc->Class = 201; lpNpc->MapNumber = Map; lpNpc->X = X; lpNpc->Y = Y; lpNpc->Dir = (rand() % 7); lpNpc->m_RecallMon = this->_index; lpNpc->TargetNumber = -1; lpNpc->TX = lpNpc->X; lpNpc->TY = lpNpc->Y; lpNpc->MTX = lpNpc->X; lpNpc->MTY = lpNpc->Y; lpNpc->m_OldX = lpNpc->X; lpNpc->m_OldY = lpNpc->Y; lpNpc->StartX = (BYTE)(lpNpc->X); lpNpc->StartY = (BYTE)(lpNpc->Y); lpNpc->m_ActState.Emotion = 0; lpNpc->m_ActState.Attack = 0; lpNpc->m_ActState.EmotionCount = 0; lpNpc->PathCount = 0; lpNpc->m_MoveRange = 0; lpNpc->m_PosNum = -1; Functions::gObjSetMonster(this->_index, 201); gObjViewportListProtocolCreate(&gObj[this->_index]); lpNpc->ShopNumber = this->_shopNumber; char Buffer[60]; sprintf_s(Buffer,"O pirata Jack escondeu seu tesouro em %s",treasureMapName[Index]); for(int i = OBJECT_MIN; i != OBJECT_MAX; i++) { if(gObj[i].Connected == 3) { GCServerMsgStringSend(Buffer,i,0); GCServerMsgStringSend("Procure-o e ganhe recompensas!",i,0); } } } else { this->_timeCount = this->_timeOpen; this->_index = -1; this->_state = treasureOff; } } else if(this->_state == treasureOn) { this->_state = treasureOff; this->_timeCount = this->_timeOpen; if(this->_index != -1) { gObjDel(this->_index); } if(this->_winner[0] == 0) { for(int i = OBJECT_MIN; i != OBJECT_MAX; i++) { if(gObj[i].Connected == 3) { GCServerMsgStringSend("O tesouro do pirata Jack foi destruído por monstros",i,0); GCServerMsgStringSend("Tente ajudá-lo novamente na próxima vez",i,0); } } } else { ZeroMemory(this->_winner,sizeof(this->_winner)); } this->_index = -1; } } void TREASURE_CUSTOM::Talk(OBJECTSTRUCT* Npc, OBJECTSTRUCT* Player) { if(!this->_enabled) { ChatTargetSend(Npc,"Como eu parei aqui? Vixi! Acho que estou perdido",Player->m_Index); return; } if(this->_state == treasureOn) { if(this->_winner[0] == 0) { this->_timeCount = this->_timeBuy; strcpy_s(this->_winner,Player->Name); ChatTargetSend(Npc,"Obrigado por vir! O tesouro é todo seu!",Player->m_Index); char Buffer[2][60]; sprintf_s(Buffer[0],"O tesouro foi encontrado por %s",Player->Name); sprintf_s(Buffer[1],"Localização: %s %02d/%02d",treasureMapName[Index],Npc->X,Npc->Y); for(int i = OBJECT_MIN; i != OBJECT_MAX; i++) { if(gObj[i].Connected == 3) { GCServerMsgStringSend(Buffer[0], i, 0); GCServerMsgStringSend(Buffer[1], i, 0); } } } else { if(_stricmp(this->_winner,Player->Name)) { ChatTargetSend(Npc,"Parece que você chegou meio tarde, não é?!",Player->m_Index); } } } else { ChatTargetSend(Npc,"Não tem doce no meu baú para você",Player->m_Index); } } BYTE TREASURE_CUSTOM::ShopNumber() const { return this->_shopNumber; } const char* TREASURE_CUSTOM::Winner() const { return this->_winner; }
Créditos: GetulioCódigo:#pragma once enum TreasureState { treasureOff, treasureOn }; class TREASURE_CUSTOM { public: bool Load(); void Check(); void Talk(OBJECTSTRUCT* Npc, OBJECTSTRUCT* Player); BYTE ShopNumber() const; const char* Winner() const; private: bool _enabled; BYTE _state; DWORD _timeCount; DWORD _timeBuy; DWORD _timeOpen; DWORD _timeClose; int _index; BYTE _shopNumber; char _winner[11]; }; extern TREASURE_CUSTOM Treasure;
Maykon,Teria Como cê passa Aquele GameServer que o Zard Robou de você,se puder mano envia pelo MP Agradeço !
Olá, para qual versão?
Pode posta o funcion GetBoxPosition
É pra qual servidor e como deve ser instalado ? (não tem informações)
você esta na areá de Source , se você quiser aprender um pouco mais aconselho ir para área de tutorial , mais respondendo sua pergunta .
Esse source é utilizada em GameServers 97D . ou pode ser em outros desde que você saiba adpatar .
Há 1 usuários navegando neste tópico. (0 registrados e 1 visitantes)
Marcadores