• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ getSelectedCreature函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中getSelectedCreature函数的典型用法代码示例。如果您正苦于以下问题:C++ getSelectedCreature函数的具体用法?C++ getSelectedCreature怎么用?C++ getSelectedCreature使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getSelectedCreature函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getSelectedCreature

bool ChatHandler::HandleNPCEquipCommand(const char * args, WorldSession * m_session)
{
    Creature* crt = getSelectedCreature(m_session, false);
    if(crt == NULL)
    {
        RedSystemMessage(m_session, "Please select a creature before using this command.");
        return true;
    }

    if(strlen(args) < 1)
        return false;

    uint32 slot = 0, itemid = 0;
    if(sscanf(args, "%u %u", &slot, &itemid) < 1)
        return false;

    if(slot > 2)
        return false;

    crt->SetWeaponDisplayId(slot, itemid);
    if(crt->m_spawn)
        crt->SaveToDB();

    BlueSystemMessage(m_session, "Equipped item %u in creature's %s", itemid, ((slot == 0) ? "Main hand" : (slot == 1) ? "Off hand" : "Ranged slot"));
    sWorld.LogGM(m_session, "Equipped item %u in creature's %s", itemid, ((slot == 0) ? "Main hand" : (slot == 1) ? "Off hand" : "Ranged slot"));
    return true;
}
开发者ID:Refuge89,项目名称:Hearthstone,代码行数:27,代码来源:Level2.cpp


示例2: getSelectedChar

bool ChatHandler::HandleDismountCommand(const char* args, WorldSession *m_session)
{
	Unit *m_target = NULL;
	Player *m_plyr = getSelectedChar(m_session, false);
	if(m_plyr)
		m_target = m_plyr;
	else
	{
		Creature *m_crt = getSelectedCreature(m_session, false);
		if(m_crt)
			m_target = m_crt;
	}

	if(!m_target)
	{
		RedSystemMessage(m_session, "No target found.");
		return true;
	}

	if(m_target->GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID) == 0)
	{
		RedSystemMessage(m_session, "Target is not mounted.");
		return true;
	}

	m_target->SetUInt32Value( UNIT_FIELD_MOUNTDISPLAYID , 0);
	if(m_target->HasFlag(UNIT_FIELD_FLAGS, U_FIELD_FLAG_MOUNT_SIT)) m_target->RemoveFlag( UNIT_FIELD_FLAGS , U_FIELD_FLAG_MOUNT_SIT );

	BlueSystemMessage(m_session, "Now unmounted.");
	return true;
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:31,代码来源:Level0.cpp


示例3: atoi

bool ChatHandler::HandleFactionIdCommand(const char* args)
{
    if (!*args)
        return false;

    uint32 factionId = (uint32) atoi((char*)args);

    if (!sFactionTemplateStore.LookupEntry(factionId))
    {
        PSendSysMessage(LANG_WRONG_FACTION, factionId);
        return true;
    }

    Creature* pCreature = getSelectedCreature();

    if(!pCreature)
    {
        SendSysMessage(LANG_SELECT_CREATURE);
        return true;
    }

    pCreature->setFaction(factionId);

    pCreature->SaveToDB();

    return true;
}
开发者ID:chrayn,项目名称:mangos-06,代码行数:27,代码来源:Level2.cpp


示例4: getSelectedChar

bool ChatHandler::HandleDismountCommand(const char* args, WorldSession *m_session)
{
	Unit* m_target = NULL;

	Player* p_target = getSelectedChar(m_session, false);

	if(p_target)
		m_target = TO_UNIT(p_target);
	else
	{
		Creature* m_crt = getSelectedCreature(m_session, false);
		if(m_crt)
			m_target = m_crt;
	}

	if(!m_target)
		RedSystemMessage(m_session, "No target found.");
	else if( !m_target->GetUInt32Value( UNIT_FIELD_MOUNTDISPLAYID) )
		RedSystemMessage(m_session, "Target is not mounted.");
	else 
	{
		m_target->Dismount();
		BlueSystemMessage(m_session, "Unit has been dismounted.");
	}
	return true;

}
开发者ID:Ballwinkle,项目名称:Ascent_NG,代码行数:27,代码来源:Level0.cpp


示例5: getSelectedCreature

bool ChatHandler::HandleMonsterYellCommand(const char* args, WorldSession* m_session)
{
	Unit* crt = getSelectedCreature(m_session, false);
	if(!crt)
		crt = getSelectedChar(m_session, false);

	if(!crt)
	{
		RedSystemMessage(m_session, "Please select a creature or player before using this command.");
		return true;
	}

	if(crt->IsPlayer())
	{
		WorldPacket* data = this->FillMessageData(CHAT_MSG_YELL, LANG_UNIVERSAL, args, crt->GetGUID(), 0);
		crt->SendMessageToSet(data, true);
		delete data;
	}
	else
	{
		crt->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, args);
	}

	return true;
}
开发者ID:RAlexis,项目名称:ArcEmu_MoP,代码行数:25,代码来源:Level2.cpp


示例6: atoi

bool ChatHandler::HandleRandomCommand(const char* args)
{
    if(!*args)
        return false;

    int option = atoi((char*)args);

    if (option != 0 && option != 1)
    {
        //m_session->GetPlayer( )->SendMessageToSet( &data, true );
        SendSysMessage(LANG_USE_BOL);
        return true;
    }

    Creature* pCreature = getSelectedCreature();

    if(!pCreature)
    {
        SendSysMessage(LANG_SELECT_CREATURE);
        return true;
    }

    // fix me : 'moverandom' doesn't exist in https://svn.mangosproject.org/trac/MaNGOS/wiki/Database/creature ?
    // perhaps it should be 'state'?
    sDatabase.PExecute("UPDATE `creature` SET `moverandom` = '%i' WHERE `guid` = '%u'", option, pCreature->GetGUIDLow());

    pCreature->setMoveRandomFlag(option > 0);

    SendSysMessage(LANG_VALUE_SAVED);

    return true;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:32,代码来源:Level2.cpp


示例7: strtok

bool ChatHandler::HandleSpawnTimeCommand(const char* args)
{
    if(!*args)
        return false;

    char* stime = strtok((char*)args, " ");

    if (!stime)
        return false;

    int i_stime = atoi((char*)stime);

    if (i_stime < 0)
    {
        SendSysMessage(LANG_BAD_VALUE);
        return true;
    }

    Creature *pCreature = getSelectedCreature();
    uint64 u_guid = 0;

    if (pCreature)
        u_guid = pCreature->GetDBTableGUIDLow();
    else
        return false;

    sDatabase.PExecuteLog("UPDATE `creature` SET `spawntimesecs`=%i WHERE `guid`=%u",i_stime,u_guid);
    PSendSysMessage("Spawn time changed to: %i",i_stime);

    return true;
}
开发者ID:chrayn,项目名称:mangos-06,代码行数:31,代码来源:Level2.cpp


示例8: atoi

bool ChatHandler::HandleAddEmoteCommand(char* args)
{
    // play emote
    uint32 emote = atoi((char*)args);
    Creature* target = getSelectedCreature();
    if(!target)
    {
        SendSysMessage(LANG_SELECT_CREATURE);
        return true;
    }
    target->SetUInt32Value(UNIT_NPC_EMOTESTATE,emote);

    bool exists = false;
    QueryResult *result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid=%u",target->GetGUIDLow());
    if(result)
    {
        delete result;
        exists = true;
    }

    if(exists)
    {
        WorldDatabase.PExecute("UPDATE creature_addon SET emote=%u WHERE guid=%u",emote,target->GetGUIDLow());
        SendSysMessage("Creature_addon emote updated");
    }
    else
    {
        WorldDatabase.PExecute("REPLACE INTO creature_addon (guid, emote) VALUES (%u,%u)",target->GetGUIDLow(),emote);
        SendSysMessage("Creature_addon emote assigned");
    }

    return true;
}
开发者ID:lauwdude,项目名称:mangos,代码行数:33,代码来源:Level_pe.cpp


示例9: getSelectedChar

bool ChatHandler::HandleCastSpellNECommand(const char* args, WorldSession *m_session)
{
	Unit *caster = m_session->GetPlayer();
	Unit *target = getSelectedChar(m_session, false);
	if(!target)
		target = getSelectedCreature(m_session, false);
	if(!target)
	{
		RedSystemMessage(m_session, "Must select a char or creature.");
		return false;
	}

	uint32 spellId = atol(args);
	SpellEntry *spellentry = dbcSpell.LookupEntry(spellId);
	if(!spellentry)
	{
		RedSystemMessage(m_session, "Invalid spell id!");
		return false;
	}
	BlueSystemMessage(m_session, "Casting spell %d on target.", spellId);

	WorldPacket data;

	data.Initialize( SMSG_SPELL_START );
	data << caster->GetNewGUID();
	data << caster->GetNewGUID();
	data << spellId;
	data << uint8(0);
	data << uint16(0);
	data << uint32(0);
	data << uint16(2);
	data << target->GetGUID();
	//		WPAssert(data.size() == 36);
	m_session->SendPacket( &data );

	data.Initialize( SMSG_SPELL_GO );
	data << caster->GetNewGUID();
	data << caster->GetNewGUID();
	data << spellId;
	data << uint8(0) << uint8(1) << uint8(1);
	data << target->GetGUID();
	data << uint8(0);
	data << uint16(2);
	data << target->GetGUID();
	//		WPAssert(data.size() == 42);
	m_session->SendPacket( &data );

	switch ( target->GetTypeId() )
	{
		case TYPEID_PLAYER:
			if ( caster != target )
				sGMLog.writefromsession( m_session, "casted spell %d on PLAYER %s", spellId, static_cast< Player* >( target )->GetName() );
			break;
		case TYPEID_UNIT:
			sGMLog.writefromsession( m_session, "casted spell %d on CREATURE %u [%s], sqlid %u", spellId, static_cast< Creature* >( target )->GetEntry(), static_cast< Creature* >( target )->GetCreatureInfo() ? static_cast< Creature* >( target )->GetCreatureInfo()->Name : "unknown", static_cast< Creature* >( target )->GetSQL_id() );
			break;
	}

	return true;
}
开发者ID:Chero,项目名称:abcwow,代码行数:60,代码来源:Level2.cpp


示例10: getSelectedChar

bool ChatHandler::HandleCastSpellCommand(const char* args, WorldSession *m_session)
{
	Unit *caster = m_session->GetPlayer();
	Unit *target = getSelectedChar(m_session, false);
	if(!target)
		target = getSelectedCreature(m_session, false);
	if(!target)
	{
		RedSystemMessage(m_session, "Must select a char or creature.");
		return false;
	}

	uint32 spellid = atol(args);
	SpellEntry *spellentry = dbcSpell.LookupEntry(spellid);
	if(!spellentry)
	{
		RedSystemMessage(m_session, "Invalid spell id!");
		return false;
	}
	
	Spell *sp = new Spell(caster, spellentry, false, NULL);
	if(!sp)
	{
		RedSystemMessage(m_session, "Spell failed creation!");
		delete sp;
		return false;
	}

	BlueSystemMessage(m_session, "Casting spell %d on target.", spellid);
	SpellCastTargets targets;
	targets.m_unitTarget = target->GetGUID();
	sp->prepare(&targets);
	return true;
}
开发者ID:Chero,项目名称:abcwow,代码行数:34,代码来源:Level2.cpp


示例11: getSelectedChar

bool ChatHandler::HandleDismountCommand(const char* /*args*/, WorldSession* m_session)
{
    Unit* m_target = NULL;

    Player* p_target = getSelectedChar(m_session, false);

    if (p_target)
        m_target = p_target;
    else
    {
        if (Creature* m_crt = getSelectedCreature(m_session, false))
            m_target = m_crt;
    }

    if (!m_target)
    {
        RedSystemMessage(m_session, "No target found.");
        return true;
    }

    if (!m_target->GetMount())
    {
        RedSystemMessage(m_session, "Target is not mounted.");
        return true;
    }

    if (p_target)
        p_target->Dismount();

    if (m_target)
        m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0);

    return true;
}
开发者ID:lev1976g,项目名称:easywow,代码行数:34,代码来源:Level0.cpp


示例12: atol

bool ChatHandler::HandleNPCEquipTwoCommand(const char * args, WorldSession * m_session)
{
	if(!args)
		return false;

	uint32 ItemID = atol(args);
	Creature * SelectedCreature = getSelectedCreature(m_session, false);
	if(!SelectedCreature)
	{
		m_session->SystemMessage("Please select a creature to modify.");
		return true;
	}

	m_session->SystemMessage("Creature: %s (%u) SpawnID: %u - Item2: %u.", SelectedCreature->GetCreatureInfo()->Name, SelectedCreature->GetProto()->Id, SelectedCreature->spawnid, SelectedCreature->m_spawn->Item2SlotDisplay);

	if(ItemID == 0)
	{
		SelectedCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0);
		SelectedCreature->SaveToDB();
		m_session->SystemMessage("Reset item 2 of %s (%u).", SelectedCreature->GetCreatureInfo()->Name, SelectedCreature->GetProto()->Id);
		return true;
	}

	ItemPrototype * ItemProvided = ItemPrototypeStorage.LookupEntry(ItemID);
	if(!ItemProvided)
	{
		m_session->SystemMessage("Item ID: %u does not exist.", ItemID);
		return true;
	}
	SelectedCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, ItemProvided->ItemId);
	SelectedCreature->SaveToDB();
	return true;
}
开发者ID:xiaofeng,项目名称:Arcemu,代码行数:33,代码来源:Level2.cpp


示例13: BlueSystemMessage

bool ChatHandler::HandleGOExport(const char * args, WorldSession * m_session)
{
	/*if(!m_session->GetPlayer()->m_GM_SelectedGO)
		return false;

	std::stringstream name;
	if (*args)
	{
		name << "GO_" << args << ".sql";
	}
	else
	{
		name << "GO_" << m_session->GetPlayer()->m_GM_SelectedGO->GetEntry() << ".sql";
	}

	m_session->GetPlayer()->m_GM_SelectedGO->SaveToFile(name);

	BlueSystemMessage(m_session, "Go saved to: %s", name.str().c_str());*/

	Creature * pCreature = getSelectedCreature(m_session, true);
	if(!pCreature) return true;
	WorldDatabase.WaitExecute("INSERT INTO creature_names_export SELECT * FROM creature_names WHERE entry = %u", pCreature->GetEntry());
	WorldDatabase.WaitExecute("INSERT INTO creature_proto_export SELECT * FROM creature_proto WHERE entry = %u", pCreature->GetEntry());
	WorldDatabase.WaitExecute("INSERT INTO vendors_export SELECT * FROM vendors WHERE entry = %u", pCreature->GetEntry());
	QueryResult * qr = WorldDatabase.Query("SELECT * FROM vendors WHERE entry = %u", pCreature->GetEntry());
	if(qr != NULL)
	{
		do
		{
			WorldDatabase.WaitExecute("INSERT INTO items_export SELECT * FROM items WHERE entry = %u", qr->Fetch()[1].GetUInt32());
		} while (qr->NextRow());
		delete qr;
	}
	return true;
}
开发者ID:Chero,项目名称:abcwow,代码行数:35,代码来源:Level2.cpp


示例14: atoi

bool ChatHandler::HandleNPCFlagCommand(const char* args)
{
    if (!*args)
        return false;

    uint32 npcFlags = (uint32) atoi((char*)args);

    Creature* pCreature = getSelectedCreature();

    if(!pCreature)
    {
        SendSysMessage(LANG_SELECT_CREATURE);
        return true;
    }

    pCreature->SetUInt32Value(UNIT_NPC_FLAGS, npcFlags);

    pCreature->SaveToDB();

    SendSysMessage(LANG_VALUE_SAVED_REJOIN);

    uint32 entry = pCreature->GetUInt32Value( OBJECT_FIELD_ENTRY );
    m_session->SendCreatureQuery( entry, pCreature->GetGUID() );

    return true;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:26,代码来源:Level2.cpp


示例15: getSelectedCreature

bool ChatHandler::HandleDelVendorItemCommand(const char* args)
{
    if (!*args)
        return false;

    Creature* vendor = getSelectedCreature();
    if (!vendor || !vendor->isVendor())
    {
        SendSysMessage("You must select vendor");
        return true;
    }

    char* pitem = strtok((char*)args, " ");
    uint32 itemId = atol(pitem);

    ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId);
    if(!pProto)
    {
        PSendSysMessage(LANG_ITEM_NOT_FOUND, itemId);
        return true;
    }

    if (!vendor->RemoveItem(itemId))
    {
        PSendSysMessage(LANG_ITEM_NOT_IN_LIST,itemId);
        return true;
    }

    sDatabase.PExecuteLog("DELETE FROM `npc_vendor` WHERE `entry`='%u' AND `item`='%u'",vendor->GetEntry(), itemId);
    PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,pProto->Name1);
    return true;
}
开发者ID:chrayn,项目名称:mangos-06,代码行数:32,代码来源:Level2.cpp


示例16: atol

bool ChatHandler::HandleNPCEquipThreeCommand(const char* args, WorldSession* m_session)
{
	if(!args)
		return false;

	uint32 ItemID = atol(args);
	Creature* SelectedCreature = getSelectedCreature(m_session, false);
	if(!SelectedCreature)
	{
		m_session->SystemMessage("Please select a creature to modify.");
		return true;
	}

	m_session->SystemMessage("Creature: %s (%u) SpawnID: %u - Item3: %u.", SelectedCreature->GetCreatureInfo()->Name, SelectedCreature->GetProto()->Id, SelectedCreature->spawnid, SelectedCreature->GetEquippedItem(RANGED));

	if(ItemID == 0)
	{
		SelectedCreature->SetEquippedItem(RANGED, 0);
		SelectedCreature->SaveToDB();
		m_session->SystemMessage("Reset item 3 of %s (%u).", SelectedCreature->GetCreatureInfo()->Name, SelectedCreature->GetProto()->Id);
		return true;
	}

	ItemPrototype* ItemProvided = ItemPrototypeStorage.LookupEntry(ItemID);
	if(!ItemProvided)
	{
		m_session->SystemMessage("Item ID: %u does not exist.", ItemID);
		return true;
	}
	SelectedCreature->SetEquippedItem(RANGED, ItemID);
	SelectedCreature->SaveToDB();
	return true;
}
开发者ID:Ikesters,项目名称:ArcPro,代码行数:33,代码来源:Level2.cpp


示例17: GET_PLAYER

bool ChatHandler::HandleDismountCommand(const char* args, WorldSession *m_session)
{
	Unit *m_target = NULL;

	GET_PLAYER(RANK_COADMIN);

	if(plr)
		m_target = plr;
	else if (RANK_CHECK(RANK_ADMIN))
	{
		Creature *m_crt = getSelectedCreature(m_session, false);
		if(m_crt)
			m_target = m_crt;
	}

	if(!m_target)
	{
		RedSystemMessage(m_session, "No target found.");
		return true;
	}

	if(m_target->GetMount() == 0)
	{
		RedSystemMessage(m_session, "Target is not mounted.");
		return true;
	}

	if(plr && plr->m_MountSpellId)
		plr->RemoveAura(plr->m_MountSpellId);

	m_target->SetUInt32Value( UNIT_FIELD_MOUNTDISPLAYID , 0);
	BlueSystemMessage(m_session, "Now unmounted.");
	return true;
}
开发者ID:Naqvamp,项目名称:Underworld_Core,代码行数:34,代码来源:Level0.cpp


示例18: getSelectedCreature

bool ChatHandler::HandleNpcComeCommand(const char* args, WorldSession* m_session)
{
	// moves npc to players location
	Player * plr = m_session->GetPlayer();
	Creature * crt = getSelectedCreature(m_session, true);
	if(!crt) return true;

	crt->GetAIInterface()->MoveTo(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetOrientation());
	return true;
}
开发者ID:Chero,项目名称:abcwow,代码行数:10,代码来源:Level2.cpp


示例19: getSelectedCreature

bool ChatHandler::HandleNpcComeCommand(const char* args, WorldSession* m_session)
{
	// moves npc to players location
	Player * plr = m_session->GetPlayer();
	Creature * crt = getSelectedCreature(m_session, true);
	if(!crt) return true;

	crt->GetAIInterface()->MoveTo(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetOrientation());
	sGMLog.writefromsession(m_session,"used npc come command on %s, sqlid %u",crt->GetCreatureInfo()->Name,crt->GetSQL_id());
	return true;
}
开发者ID:Chero,项目名称:abcwow,代码行数:11,代码来源:Level2.cpp



注:本文中的getSelectedCreature函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ getSelectedIndex函数代码示例发布时间:2022-05-28
下一篇:
C++ getSelectedChar函数代码示例发布时间:2022-05-28
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap