当前位置: 首页>>代码示例>>C++>>正文


C++ getSelectedChar函数代码示例

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


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

示例1: getSelectedChar

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

	Player * ptarget = getSelectedChar(m_session);
	if(!ptarget) return false;

	if(strlen((char*)args)>75)
	{
		// send message to user
		char buf[256];
		snprintf((char*)buf,256,"The name was too long by %ui", strlen((char*)args)-75);
		SystemMessage(m_session, buf);
		return true;
	}

	for (uint32 i = 0; i < strlen(args); i++) {
		if(!isalpha(args[i]) && args[i]!=' ') {
			SystemMessage(m_session, "Error, name can only contain chars A-Z and a-z.");
			return true;
		}
	}

	Charter tempCharter(0, ptarget->GetLowGUID(), CHARTER_TYPE_GUILD);
	tempCharter.SignatureCount=0;
	tempCharter.GuildName = string(args);

	Guild * pGuild = Guild::Create();
	pGuild->CreateFromCharter(&tempCharter, ptarget->GetSession());
	SystemMessage(m_session, "Guild created");
	return true;
}
开发者ID:Chero,项目名称:abcwow,代码行数:33,代码来源:Level2.cpp

示例2: 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

示例3: 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

示例4: atoi

bool ChatHandler::HandleHideAreaCommand(const char* args)
{
    WorldPacket data;

    if (!*args)
        return false;

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

    Player *chr = getSelectedChar(m_session);
    if (chr == NULL)                              
    {
        FillSystemMessageData(&data, m_session, "No character selected.");
        m_session->SendPacket( &data );
        return true;
    }

    int offset = area / 32;
    uint32 val = (uint32)(1 << (area % 32));

    uint32 currFields = chr->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
    chr->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields ^ val));

    FillSystemMessageData(&data, m_session, "The area has been set as not explored.");
    m_session->SendPacket( &data );
    return true;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:27,代码来源:Level3.cpp

示例5: getSelectedChar

bool ChatHandler::HandleCreateInstanceCommand(const char* args, WorldSession* m_session)
{
    Player* plr = getSelectedChar(m_session, true);
    float x, y, z;
    uint32 mapid;
    if (sscanf(args, "%u %f %f %f", (unsigned int*)&mapid, &x, &y, &z) != 4)
        return false;

    if (!plr)
    {
        plr = m_session->GetPlayer();
        SystemMessage(m_session, "Auto-targeting self.");
    }
    if (!plr) return false;

    /* Create Map Manager */
    MapMgr* mgr = sInstanceMgr.CreateInstance(INSTANCE_NONRAID, mapid);
    if (mgr == NULL)
    {
        sLog.Error("CreateInstanceGMCommand", "CreateInstance() call failed for map %u", mapid);
        return false;      // Shouldn't happen
    }
    Log.Notice("CreateInstanceGMCommand", "GM created instance for map %u", mapid);

    LocationVector vec(x, y, z);
    m_session->GetPlayer()->SafeTeleport(mgr, vec);
    return true;

}
开发者ID:Nupper,项目名称:AscEmu,代码行数:29,代码来源:InstanceCommands.cpp

示例6: getSelectedChar

bool ChatHandler::HandleShowItems(const char* args, WorldSession* m_session)
{
	string q;
	Player* plr = getSelectedChar(m_session, true);
	if(!plr)
		return false;

	BlueSystemMessage(m_session, "Listing items for player %s", plr->GetName());
	int itemcount = 0;
	ItemIterator itr(plr->GetItemInterface());
	itr.BeginSearch();
	for(; !itr.End(); itr.Increment())
	{
		if(!(*itr))
			return false;

		itemcount++;
		SendItemLinkToPlayer((*itr)->GetProto(), m_session, true, plr, m_session->language);
	}

	itr.EndSearch();
	BlueSystemMessage(m_session, "Listed %d items for player %s", itemcount, plr->GetName());
	sGMLog.writefromsession(m_session, "used show items command on %s,", plr->GetName());
	return true;
}
开发者ID:lev1976g,项目名称:NoxicCore,代码行数:25,代码来源:cmd_item.cpp

示例7: getSelectedChar

bool ChatHandler::HandleGetSkillsInfoCommand(const char *args, WorldSession *m_session)
{
    Player* plr = getSelectedChar(m_session, true);
    if (!plr) return false;
    uint32 nobonus = 0;
    int32 bonus = 0;
    uint32 max = 0;
    BlueSystemMessage(m_session, "Player: %s has skills", plr->GetName());
    for (uint32 SkillId = 0; SkillId <= SkillNameManager->maxskill; SkillId++)
    {
        if (plr->_HasSkillLine(SkillId))
        {
            char* SkillName = SkillNameManager->SkillNames[SkillId];
            if (!SkillName)
            {
                RedSystemMessage(m_session, "Invalid skill: %u", SkillId);
                continue;
            }
            nobonus = plr->_GetSkillLineCurrent(SkillId, false);
            bonus = plr->_GetSkillLineCurrent(SkillId, true) - nobonus;
            max = plr->_GetSkillLineMax(SkillId);
            BlueSystemMessage(m_session, " %s: Value: %u, MaxValue: %u. (+ %d bonus)", SkillName, nobonus, max, bonus);
        }
    }
    return true;
}
开发者ID:Nupper,项目名称:AscEmu_Vanilla,代码行数:26,代码来源:Level1.cpp

示例8: 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

示例9: atoi

bool ChatHandler::HandleModifyExpCommand(uint8* args)
{
    wowWData data;

    if (!*args)
        return false;

	uint32 Arg = atoi((char*)args);
		
	Character * pChar = getSelectedChar();
	if(pChar)
	{
		int32 expuser =(pChar->pClient->getCurrentChar()->getUpdateValue(PLAYER_XP));
								
		if(Arg<0)
		{
			int32 newexp = expuser + Arg;
			if(newexp < 0 )
			{
				ChangeSelectedChar(PLAYER_XP, (uint32)0, 1000000000, 0, "XP");
				return true;
			}
		}						
		ChangeSelectedChar(PLAYER_XP, (uint32)expuser+Arg, 1000000000, 0, "XP");
	}
    return true;
}
开发者ID:AwkwardDev,项目名称:WoWPython,代码行数:27,代码来源:Level1.cpp

示例10: strtok

bool ChatHandler::HandleLearnSkillCommand(const char *args, WorldSession *m_session)
{
    uint32 skill, min, max;
    min = max = 1;
    char *pSkill = strtok((char*)args, " ");
    if (!pSkill)
        return false;
    else
        skill = atol(pSkill);

    BlueSystemMessage(m_session, "Adding skill line %d", skill);

    char *pMin = strtok(NULL, " ");
    if (pMin)
    {
        min = atol(pMin);
        char *pMax = strtok(NULL, "\n");
        if (pMax)
            max = atol(pMax);
    }
    else
    {
        return false;
    }

    Player *plr = getSelectedChar(m_session, true);
    if (!plr) return false;
    if (plr->GetTypeId() != TYPEID_PLAYER) return false;
    sGMLog.writefromsession(m_session, "used add skill of %u %u %u on %s", skill, min, max, plr->GetName());

    plr->_AddSkillLine(skill, min, max);

    return true;
}
开发者ID:Nupper,项目名称:AscEmu_Vanilla,代码行数:34,代码来源:Level1.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 = 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

示例12: getSelectedChar

/**
	Handles .achieve criteria
	.achieve criteria id                : completes achievement criteria "id" for the selected player
*/
bool ChatHandler::HandleAchievementCriteriaCommand(const char* args, WorldSession* m_session)
{
	if(!*args)
		return false;

	Player* plr = getSelectedChar(m_session, true);
	if(!plr)
	{
		plr = m_session->GetPlayer();
		SystemMessage(m_session, "Auto-targeting self.");
	}

	uint32 criteria_id = atol(args);
	if(criteria_id == 0)
	{
		if(stricmp(args, "all") == 0)
		{
			plr->GetAchievementMgr().GMCompleteCriteria(m_session, -1);
			SystemMessage(m_session, "All achievement criteria have now been completed for that player.");
			sGMLog.writefromsession(m_session, "completed all achievement criteria for player %s", plr->GetName());
			return true;
		}
		return false;
	}

	if(plr->GetAchievementMgr().GMCompleteCriteria(m_session, criteria_id))
	{
		SystemMessage(m_session, "The achievement criteria has now been completed for that player.");
		sGMLog.writefromsession(m_session, "completed achievement criteria %u for player %s", criteria_id, plr->GetName());
	}
	return true;
}
开发者ID:dberga,项目名称:arcbliz,代码行数:36,代码来源:Level1.cpp

示例13: 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

示例14: RedSystemMessage

bool ChatHandler::HandleModifySpeedCommand(const char* args, WorldSession *m_session)
{
	WorldPacket data;

	if (!*args)
		return false;

	float Speed = (float)atof((char*)args);

	if (Speed > 255 || Speed < 1)
	{
		RedSystemMessage(m_session, "Incorrect value. Range is 1..255");
		return true;
	}

	Player *chr = getSelectedChar(m_session);
	if( chr == NULL )
		return true;
	
	char buf[256];

	// send message to user
	BlueSystemMessage(m_session, "You set the speed of %s to %2.2f.", chr->GetName(), Speed);

	// send message to player
	snprintf((char*)buf,256, "%s set your speed to %2.2f.", m_session->GetPlayer()->GetName(), Speed);
	SystemMessage(chr->GetSession(), buf);

	chr->SetPlayerSpeed(RUN, Speed);
	chr->SetPlayerSpeed(SWIM, Speed);
	chr->SetPlayerSpeed(RUNBACK, Speed);
	chr->SetPlayerSpeed(FLY, Speed);

	return true;
}
开发者ID:Centraly,项目名称:SummitEmu,代码行数:35,代码来源:Level1.cpp

示例15: getSelectedChar

bool ChatHandler::HandleAddInvItemCommand(const char *args, WorldSession *m_session)
{
	uint32 itemid, count=1;
	int32 randomprop=0;

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

	if(sscanf(args, "%u %u %d", &itemid, &count, &randomprop) < 1)
		return false;

	Player * chr = getSelectedChar( m_session, false );
	if ( chr == NULL )
		chr = m_session->GetPlayer();
	
	ItemPrototype* it = ItemPrototypeStorage.LookupEntry(itemid);
	if(it)
	{
		sGMLog.writefromsession(m_session, "used add item command, item id %u [%s] to %s", it->ItemId, it->Name1, chr->GetName());
		Item *item;
		item = objmgr.CreateItem( itemid, chr);
		item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, ((count > it->MaxCount) ? it->MaxCount : count));
		if(it->Bonding==ITEM_BIND_ON_PICKUP)
			item->SoulBind();
		if(randomprop!=0)
		{
			if(randomprop<0)
				item->SetRandomSuffix(abs(int(randomprop)));
			else
				item->SetRandomProperty(randomprop);

			item->ApplyRandomProperties(false);
		}
	  
		if(!chr->GetItemInterface()->AddItemToFreeSlot(item))
		{
			m_session->SendNotification("No free slots were found in your inventory!");
			item->DeleteMe();
			return true;
		}

		char messagetext[512];
		snprintf(messagetext, 512, "Adding item %s (id: %d) to %s's inventory.", GetItemLinkByProto(it, m_session->language).c_str(), (unsigned int)it->ItemId, chr->GetName());
		SystemMessage(m_session, messagetext);
		snprintf(messagetext, 128, "%s added item %d (%s) to your inventory.", m_session->GetPlayer()->GetName(), (unsigned int)itemid, it->Name1);
		snprintf(messagetext, 512, "%s added item %s to your inventory.", m_session->GetPlayer()->GetName(), GetItemLinkByProto(it, chr->GetSession()->language).c_str());
		
		SystemMessageToPlr(chr,  messagetext);

		SlotResult *lr = chr->GetItemInterface()->LastSearchResult();
		chr->GetSession()->SendItemPushResult(item,false,true,false,true,lr->ContainerSlot,lr->Slot,count);

		return true;
	} else {
		RedSystemMessage(m_session, "Item %d is not a valid item!", itemid);
		return true;
	}
}
开发者ID:AegisEmu,项目名称:AegisEmu,代码行数:60,代码来源:Level1.cpp


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