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


C++ Condition::getTicks方法代码示例

本文整理汇总了C++中Condition::getTicks方法的典型用法代码示例。如果您正苦于以下问题:C++ Condition::getTicks方法的具体用法?C++ Condition::getTicks怎么用?C++ Condition::getTicks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Condition的用法示例。


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

示例1: regeneratePlayer

void BedItem::regeneratePlayer(Player* player) const
{
	int32_t sleptTime = int32_t(time(NULL) - sleepStart);

	Condition* condition = player->getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT);

	if (condition) {
		int32_t regen = 0;

		if (condition->getTicks() != -1) {
			regen = std::min<int32_t>((condition->getTicks() / 1000), sleptTime) / 30;
			int32_t newRegenTicks = condition->getTicks() - (regen * 30000);

			if (newRegenTicks <= 0) {
				player->removeCondition(condition);
				condition = NULL;
			} else {
				condition->setTicks(newRegenTicks);
			}
		} else {
			regen = sleptTime / 30;
		}

		player->changeHealth(regen, false);
		player->changeMana(regen);
	}

	int32_t soulRegen = sleptTime / (60 * 15);
	player->changeSoul(soulRegen);
}
开发者ID:24312108k,项目名称:forgottenserver,代码行数:30,代码来源:beds.cpp

示例2: AddPlayerStats

void ProtocolGameBase::AddPlayerStats(NetworkMessage& msg)
{
	msg.addByte(0xA0);

	msg.add<uint16_t>(std::min<int32_t>(player->getHealth(), std::numeric_limits<uint16_t>::max()));
	msg.add<uint16_t>(std::min<int32_t>(player->getPlayerInfo(PLAYERINFO_MAXHEALTH), std::numeric_limits<uint16_t>::max()));

	msg.add<uint32_t>(player->getFreeCapacity());
	msg.add<uint32_t>(player->getCapacity());

	msg.add<uint64_t>(player->getExperience());

	msg.add<uint16_t>(player->getLevel());
	msg.addByte(player->getPlayerInfo(PLAYERINFO_LEVELPERCENT));
	msg.addDouble(0, 3); // experience bonus

	msg.add<uint16_t>(std::min<int32_t>(player->getMana(), std::numeric_limits<uint16_t>::max()));
	msg.add<uint16_t>(std::min<int32_t>(player->getPlayerInfo(PLAYERINFO_MAXMANA), std::numeric_limits<uint16_t>::max()));

	msg.addByte(std::min<uint32_t>(player->getMagicLevel(), std::numeric_limits<uint8_t>::max()));
	msg.addByte(std::min<uint32_t>(player->getBaseMagicLevel(), std::numeric_limits<uint8_t>::max()));
	msg.addByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVELPERCENT));

	msg.addByte(player->getSoul());

	msg.add<uint16_t>(player->getStaminaMinutes());

	msg.add<uint16_t>(player->getBaseSpeed() / 2);

	Condition* condition = player->getCondition(CONDITION_REGENERATION);
	msg.add<uint16_t>(condition ? condition->getTicks() / 1000 : 0x00);

	msg.add<uint16_t>(player->getOfflineTrainingTime() / 60 / 1000);
}
开发者ID:samuel2498,项目名称:nowy,代码行数:34,代码来源:protocolgamebase.cpp

示例3: talkToChannel

bool Chat::talkToChannel(Player* player, SpeakClasses type, const std::string& text, uint16_t channelId)
{
	ChatChannel* channel = getChannel(player, channelId);

	if (!channel || !player) {
		return false;
	}

	if (player->getAccountType() < ACCOUNT_TYPE_GAMEMASTER) {
		if (player->getLevel() < 2 && channelId < CHANNEL_PARTY && channelId != CHANNEL_ADVERTISINGROOKGAARD) {
			player->sendCancel("You may not speak into channels as long as you are on level 1.");
			return false;
		} else if ((channelId == CHANNEL_ADVERTISING || channelId == CHANNEL_ADVERTISINGROOKGAARD) && player->hasCondition(CONDITION_CHANNELMUTEDTICKS, channelId)) {
			player->sendCancel("You may only place one offer in two minutes.");
			return false;
		} else if (channelId == CHANNEL_HELP && player->hasCondition(CONDITION_CHANNELMUTEDTICKS, CHANNEL_HELP)) {
			player->sendCancel("You are muted from the Help channel for using it inappropriately.");
			return false;
		}
	}

	if (channelId == CHANNEL_HELP && player->getAccountType() >= ACCOUNT_TYPE_TUTOR && text.length() > 6) {
		if (text.length() > 6 && text.substr(0, 6) == "!mute ") {
			std::string param = text.substr(6);
			trimString(param);
			Player* paramPlayer = g_game.getPlayerByName(param);

			if (paramPlayer && paramPlayer->getAccountType() < player->getAccountType()) {
				if (!paramPlayer->hasCondition(CONDITION_CHANNELMUTEDTICKS, CHANNEL_HELP)) {
					Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_CHANNELMUTEDTICKS, 3600000, 0, false, CHANNEL_HELP);
					paramPlayer->addCondition(condition);

					std::ostringstream ss;
					ss << paramPlayer->getName() << " has been muted by " << player->getName() << " for using Help Channel inappropriately.";
					channel->sendToAll(ss.str(), SPEAK_CHANNEL_R1);
				} else {
					player->sendCancel("That player is already muted.");
				}
			} else {
				player->sendCancel("A player with that name is not online.");
			}

			return true;
		} else if (text.length() > 8 && text.substr(0, 8) == "!unmute ") {
			std::string param = text.substr(8);
			trimString(param);
			Player* paramPlayer = g_game.getPlayerByName(param);

			if (paramPlayer && paramPlayer->getAccountType() < player->getAccountType()) {
				Condition* condition = paramPlayer->getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP);

				if (condition && condition->getTicks() > 0) {
					paramPlayer->removeCondition(condition);

					std::ostringstream ss;
					ss << paramPlayer->getName() << " has been unmuted by " << player->getName() << ".";
					channel->sendToAll(ss.str(), SPEAK_CHANNEL_R1);
				} else {
					player->sendCancel("That player is not muted.");
				}
			} else {
				player->sendCancel("A player with that name is not online.");
			}

			return true;
		}
	}

	if (channelId == CHANNEL_GUILD && player->getGuildLevel() > 1) {
		type = SPEAK_CHANNEL_O;
	}

	return channel->talk(player, type, text);
}
开发者ID:24312108k,项目名称:forgottenserver,代码行数:74,代码来源:chat.cpp


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