コード例 #1
0
CreatureObject* CreatureManagerImplementation::spawnCreature(uint32 templateCRC, uint32 objectCRC, float x, float z, float y, uint64 parentID, bool persistent) {
	CreatureTemplate* creoTempl = creatureTemplateManager->getTemplate(templateCRC);

	if (creoTempl == NULL)
		return spawnCreature(objectCRC, x, z, y, parentID);

	CreatureObject* creature = NULL;

	String templateToSpawn;

	if (objectCRC == 0) {
		templateToSpawn = getTemplateToSpawn(templateCRC);
		objectCRC = templateToSpawn.hashCode();
	}

	creature = createCreature(objectCRC, persistent, templateCRC);

	if (creature != NULL && creature->isAiAgent()) {
		AiAgent* npc = cast<AiAgent*>(creature);
		npc->loadTemplateData(creoTempl);
	} else if (creature == NULL) {
		error("could not spawn template " + templateToSpawn);
	}

	placeCreature(creature, x, z, y, parentID);

	return creature;
}
コード例 #2
0
CreatureObject* CreatureManagerImplementation::spawnCreatureAsEventMob(uint32 templateCRC, float x, float z, float y, uint64 parentID) {
	CreatureTemplate* creoTempl = creatureTemplateManager->getTemplate(templateCRC);

	if (creoTempl == NULL)
		return NULL;

	CreatureObject* creo = NULL;

	String templateToSpawn = getTemplateToSpawn(templateCRC);
	uint32 objectCRC = templateToSpawn.hashCode();

	creo = createCreature(objectCRC, false, templateCRC);

	if (creo != NULL && creo->isAiAgent()) {
		AiAgent* creature = cast<AiAgent*>(creo);
		creature->loadTemplateData(creoTempl);

		UnicodeString eventName;
		eventName = creature->getDisplayedName() + " (event)";
		creature->setCustomObjectName(eventName, false);

	} else if (creo == NULL) {
		error("could not spawn template " + templateToSpawn);
	}

	placeCreature(creo, x, z, y, parentID);

	if (creo != NULL && creo->isAiAgent())
		cast<AiAgent*>(creo)->activateLoad("");

	return creo;
}