コード例 #1
0
void GroupObjectImplementation::calcGroupLevel() {
	int highestPlayer = 0;
	groupLevel = 0;

	for (int i = 0; i < getGroupSize(); i++) {
		Reference<SceneObject*> member = getGroupMember(i);

		if (member->isPet()) {
			CreatureObject* creature = cast<CreatureObject*>(member.get());

			groupLevel += creature->getLevel() / 5;

		} else if (member->isPlayerCreature()) {
			CreatureObject* creature = cast<CreatureObject*>(member.get());

			int memberLevel = creature->getLevel();

			if (memberLevel > highestPlayer) {
				groupLevel += (memberLevel - highestPlayer + (highestPlayer / 5));
				highestPlayer = memberLevel;
			} else {
				groupLevel += memberLevel / 5;
			}
		}
	}

	GroupObjectDeltaMessage6* msg = new GroupObjectDeltaMessage6(_this.getReferenceUnsafeStaticCast());

	msg->updateLevel(this->groupLevel);
	msg->close();

	broadcastMessage(msg);
}
void GroupObjectImplementation::calcGroupLevel() {
	groupLevel = 0;

	for (int i = 0; i < getGroupSize(); i++) {
		SceneObject* member = getGroupMember(i);

		if (member->isCreatureObject()) {
			CreatureObject* creature = cast<CreatureObject*>(member);

			int currentlevel = groupLevel - getGroupSize();
			int memberlevel = creature->getLevel();

			if (memberlevel > currentlevel)
				groupLevel = memberlevel + getGroupSize();
		}
	}

	GroupObjectDeltaMessage6* msg = new GroupObjectDeltaMessage6(_this.get());

	msg->updateLevel(this->groupLevel);
	msg->close();

	broadcastMessage(msg);
}