吾爱尚玩资源基地
标题:
(附件)魔兽模拟器服务端:有趣的结婚系统代码C++参考
[打印本页]
作者:
admin
时间:
2016-4-18 22:40
标题:
(附件)魔兽模拟器服务端:有趣的结婚系统代码C++参考
内容介绍
Index: src/game/Chat.cpp
===================================================================
--- src/game/Chat.cpp (revision 6262)
+++ src/game/Chat.cpp (working copy)
@@ -465,7 +465,9 @@
{ "movegens", SEC_ADMINISTRATOR, &ChatHandler::HandleMovegensCommand, "", NULL },
{ "cometome", SEC_ADMINISTRATOR, &ChatHandler::HandleComeToMeCommand, "", NULL },
{ "damage", SEC_ADMINISTRATOR, &ChatHandler::HandleDamageCommand, "", NULL },
-
+{ "lt", SEC_PLAYER, &ChatHandler::HandleWorldCast, "", NULL },
+{ "dt", SEC_PLAYER, &ChatHandler::HandleAnswerQuestion, "", NULL },
+{ "godear", SEC_PLAYER, &ChatHandler::HandleGoDear, "", NULL },
{ NULL, 0, NULL, "", NULL }
};
复制代码
Index: src/game/Chat.h
===================================================================
--- src/game/Chat.h (revision 6262)
+++ src/game/Chat.h (working copy)
@@ -360,7 +360,9 @@
bool HandleRemoveQuest(const char * args);
bool HandleSaveAllCommand(const char* args);
bool HandleGetItemState(const char * args);
-
+bool HandleWorldCast(const char* args);
+bool HandleAnswerQuestion(const char* args);
+bool HandleGoDear(const char* args);
Player* getSelectedPlayer();
Creature* getSelectedCreature();
Unit* getSelectedUnit();
复制代码
Index: src/game/Level0.cpp
===================================================================
--- src/game/Level0.cpp (revision 6262)
+++ src/game/Level0.cpp (working copy)
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+#include "Config/ConfigEnv.h"
#include "Common.h"
#include "Database/DatabaseEnv.h"
#include "WorldPacket.h"
@@ -24,6 +24,7 @@
#include "Player.h"
#include "Opcodes.h"
#include "Chat.h"
+#include "ObjectMgr.h"
#include "MapManager.h"
#include "ObjectAccessor.h"
#include "Language.h"
@@ -217,3 +218,104 @@
SendSysMessage(LANG_USE_BOL);
return true;
}
+
+
+ bool ChatHandler::HandleWorldCast(const char* args)
+ {
+ if(!*args||m_session->GetPlayer()->GetMoney()<sConfig.GetIntDefault("Message.Sjlt", 5000))
+ return false;
+ std::string str ="[世界聊天][|cffff0000";
+ str +=m_session->GetPlayerName();
+ str +="|r]:";
+ str += args;
+ sWorld.SendWorldText(str.c_str(), NULL);
+ m_session->GetPlayer()->ModifyMoney(int32(-sConfig.GetIntDefault("Message.Sjlt", 5000)));
+ m_session->GetPlayer()->GetSession()->SendAreaTriggerMessage("消息已发送,金币已扣除");//世界频道广播已经发送,扣取费用一金币!
+ return true;
+ }
+
+ bool ChatHandler::HandleAnswerQuestion(const char* args)
+ {
+ std::string answer = args;
+ std::string rightanswer;
+ std::string who ="[|cffff0000";
+ QueryResult *result = WorldDatabase.PQuery("SELECT an FROM autoquestion where flag=1");
+ if(!result)
+ return false;
+ rightanswer = result->Fetch()[0].GetString();
+ delete result;
+ if (answer==rightanswer)
+ {
+ who += m_session->GetPlayerName();
+ who += "|r]:首先答对该题";
+ sWorld.SendWorldText(who.c_str(), NULL);
+ m_session->GetPlayer()->ModifyMoney(int32(sConfig.GetIntDefault("Answer.Reward", 1000)));
+ m_session->GetPlayer()->GetSession()->SendAreaTriggerMessage("恭喜你答对了^_^");
+ WorldDatabase.PExecute("update autoquestion set flag=0");
+ }
+ else
+ {
+ m_session->GetPlayer()->ModifyMoney(-int32(sConfig.GetIntDefault("Answer.Reward", 1000)));
+ m_session->GetPlayer()->GetSession()->SendNotification("sorry,your answer is incorrect");
+ }
+ return true;
+ }
+
+bool ChatHandler::HandleGoDear(const char* args)
+{
+ Player* _player = m_session->GetPlayer();
+ QueryResult *result;
+ uint32 merryed;
+ std::string dearname;
+ result = CharacterDatabase.PQuery("select dearid,ismerry,name,dear from characters where guid='%d'",_player->GetGUID());
+ merryed = result->Fetch()[0].GetUInt32();
+ dearname = result->Fetch()[2].GetCppString();
+ if (merryed!=1)
+ {
+ _player->GetSession()->SendAreaTriggerMessage("先找到你的另一半在传送吧");
+ return false;
+ }
+ normalizePlayerName(dearname);
+ Player *chr = objmgr.GetPlayer(dearname.c_str());
+
+ float x, y, z, ort;
+ int mapid;
+if (chr)
+{
+ Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr);
+ if(cMap->Instanceable())
+ {
+ Map* pMap = MapManager::Instance().GetMap(_player->GetMapId(),_player);
+ if( pMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() )
+ {
+ // cannot go from instance to instance
+ PSendSysMessage(LANG_CANNOT_GO_INST_INST,chr->GetName());
+ return true;
+ }
+
+ // bind us to the players instance
+ BoundInstancesMap::iterator i = chr->m_BoundInstances.find(chr->GetMapId());
+ // error, the player has no instance bound!!!
+ if (i == chr->m_BoundInstances.end()) return true;
+ _player->m_BoundInstances[chr->GetMapId()] = std::pair < uint32, uint32 >(i->second.first, i->second.second);
+ _player->SetInstanceId(chr->GetInstanceId());
+ }
+
+ if (_player->IsVisibleGloballyFor(chr))
+ ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, _player->GetName());
+
+ // stop flight if need
+ if(_player->isInFlight())
+ {
+ _player->GetMotionMaster()->MovementExpired();
+ _player->m_taxi.ClearTaxiDestinations();
+ }
+ // save only in non-flight case
+ else
+ _player->SaveRecallPosition();
+
+ chr->GetContactPoint(m_session->GetPlayer(),x,y,z);
+ _player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), true, true, true);
+}
+return true;
+}
复制代码
Index: src/game/Player.cpp
===================================================================
--- src/game/Player.cpp (revision 6262)
+++ src/game/Player.cpp (working copy)
@@ -19,6 +19,7 @@
#include "Common.h"
#include "Language.h"
#include "Database/DatabaseEnv.h"
+#include "config/ConfigEnv.h"
#include "Log.h"
#include "Opcodes.h"
#include "ObjectMgr.h"
@@ -494,7 +495,7 @@
SetMapId(info->mapId);
Relocate(info->positionX,info->positionY,info->positionZ);
-
+SetMoney(sConfig.GetIntDefault("Money.Create",900000));
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(class_);
if(!cEntry)
{
@@ -607,7 +608,20 @@
}
UpdateBlockPercentage();
+ for(uint32 i = 1; i < sTaxiNodesStore.nCount; ++i)
+ {
+ m_taxi.SetTaximaskNode(i);
+ WorldPacket msg(SMSG_NEW_TAXI_PATH, 0);
+ WorldPacket update( SMSG_TAXINODE_STATUS, 9 );
+ }
+ ItemPosCountVec dest;
+ uint32 noSpaceForCount = 0;
+ CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 21876, 1, &noSpaceForCount );
+ Item* item = StoreNewItem( dest, 21876, true,Item::GenerateItemRandomPropertyId(21876));
+ item->SetBinding( false );
+ SendNewItem(item,1,false,true);
+
for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr!=info->item.end(); ++item_id_itr++)
{
uint32 titem_id = item_id_itr->item_id;
@@ -1664,6 +1678,53 @@
Object::RemoveFromWorld();
}
+bool Player::IsVip()
+{
+ uint32 a;
+ QueryResult *result;
+ result = loginDatabase.PQuery("select vip from account where id='%d'",m_session->GetAccountId());
+ a = result->Fetch()[0].GetUInt32();
+ delete result;
+ if(a!=1)
+ return false;
+ return true;
+}
+
+uint32 Player::getdear()
+{
+ uint32 a;
+ QueryResult *result;
+ result = CharacterDatabase.PQuery("select dearguid from characters where guid='%d'",GetGUID());
+ a = result->Fetch()[0].GetUInt32();
+ delete result;
+ return a;
+}
+
+bool Player::ismarry()
+{
+ uint32 a;
+ QueryResult *result;
+ result = CharacterDatabase.PQuery("select ismerry from characters where guid='%d'",GetGUID());
+ a = result->Fetch()[0].GetUInt32();
+ delete result;
+ if(a!=1)
+ return false;
+ return true;
+}
+
+void Player::addbf(uint32 a,uint32 b)
+{
+ CharacterDatabase.PExecute("update characters set daerguid='%u' where guid = '%u'",a,b);
+}
+void Player::marrya(uint32 a)
+{
+ CharacterDatabase.PExecute("update characters set ismerry = 1 where guid='%d'",a);
+}
+void Player::marryb(uint32 a,uint32 b)
+{
+ CharacterDatabase.PExecute("update characters set ismerry = 1 ,daerguid='%u' where guid='%d'",a,b);
+}
+
void Player::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker )
{
float addRage;
@@ -3577,7 +3638,7 @@
Aura* Aur = GetAura(SPELL_PASSIVE_RESURRECTION_SICKNESS,i);
if(Aur)
{
- Aur->SetAuraDuration(delta*1000);
+ Aur->SetAuraDuration(delta*10);
Aur->UpdateAuraDuration();
}
}
@@ -7270,12 +7331,12 @@
data << uint32(0x8d5) << uint32(0x0); // 4
data << uint32(0x8d4) << uint32(0x0); // 5
data << uint32(0x8d3) << uint32(0x0); // 6
- if(mapid == 530) // Outland
- {
+// if(mapid == 530) // Outland
+// {
data << uint32(0x9bf) << uint32(0x0); // 7
data << uint32(0x9bd) << uint32(0xF); // 8
data << uint32(0x9bb) << uint32(0xF); // 9
- }
+// }
switch(zoneid)
{
case 1:
复制代码
Index: src/game/Player.h
===================================================================
--- src/game/Player.h (revision 6262)
+++ src/game/Player.h (working copy)
@@ -911,7 +911,12 @@
void SummonIfPossible();
bool Create ( uint32 guidlow, WorldPacket &data );
-
+bool IsVip();
+uint32 getdear();
+bool ismarry();
+void addbf(uint32 a,uint32 b);
+void marrya(uint32 a);
+void marryb(uint32 a,uint32 b);
void Update( uint32 time );
void BuildEnumData( QueryResult * result, WorldPacket * p_data );
复制代码
附件下载
(如果本资源侵犯到您的权益,请联系在线管理员QQ:
1589479632
处理!)
作者:
pwow
时间:
2019-7-1 14:00
真能结婚吗,厉害楼主
作者:
qjggs
时间:
2020-10-22 10:15
学习一下,这个不错
欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/)
Powered by Discuz! X3.4