def create_arbiter(requester, target, arbiter_entry): go_template, session = WorldDatabaseManager.gameobject_template_get_by_entry( arbiter_entry) session.close() if not go_template: return None in_between_pos = requester.location.get_point_in_middle( target.location) # TODO: Need a factory for GO's that also handles guids. instance = SpawnsGameobjects() instance.spawn_id = DuelManager.ARBITERS_GUID instance.spawn_entry = arbiter_entry instance.spawn_map = requester.map_ instance.spawn_rotation0 = 0 instance.spawn_orientation = 0 instance.spawn_rotation2 = 0 instance.spawn_rotation1 = 0 instance.spawn_rotation3 = 0 instance.spawn_positionX = in_between_pos.x instance.spawn_positionY = in_between_pos.y instance.spawn_positionZ = in_between_pos.z instance.spawn_state = True DuelManager.ARBITERS_GUID += 1 go_arbiter = GameObjectManager(gobject_template=go_template, gobject_instance=instance) go_arbiter.faction = requester.faction go_arbiter.load() go_arbiter.send_update_surrounding() # spawn arbiter return go_arbiter
def handle_summon_object(casting_spell, effect, caster, target): object_entry = effect.misc_value # Validate go template existence. go_template = WorldDatabaseManager.gameobject_template_get_by_entry( object_entry) if not go_template: Logger.error( f'Gameobject with entry {object_entry} not found for spell {casting_spell.spell_entry.ID}.' ) return target = None if isinstance(effect.targets.resolved_targets_a[0], ObjectManager): target = effect.targets.resolved_targets_a[0].location elif isinstance(effect.targets.resolved_targets_a[0], Vector): target = effect.targets.resolved_targets_a[0] if not target: Logger.error( f'Unable to resolve target, go entry {object_entry}, spell {casting_spell.spell_entry.ID}.' ) return GameObjectManager.spawn(object_entry, target, caster.map_, summoner=caster, spell_id=casting_spell.spell_entry.ID, override_faction=caster.faction)
def spawn(entry, location, map_id, override_faction=0, despawn_time=1): go_template, session = WorldDatabaseManager.gameobject_template_get_by_entry( entry) session.close() if not go_template: return None instance = SpawnsGameobjects() instance.spawn_id = GameObjectManager.CURRENT_HIGHEST_GUID + 1 instance.spawn_entry = entry instance.spawn_map = map_id instance.spawn_rotation0 = 0 instance.spawn_rotation2 = 0 instance.spawn_rotation1 = 0 instance.spawn_rotation3 = 0 instance.spawn_positionX = location.x instance.spawn_positionY = location.y instance.spawn_positionZ = location.z instance.spawn_orientation = location.o if despawn_time < 1: despawn_time = 1 instance.spawn_spawntimemin = despawn_time instance.spawn_spawntimemax = despawn_time instance.spawn_state = GameObjectStates.GO_STATE_READY gameobject = GameObjectManager(gobject_template=go_template, gobject_instance=instance, is_summon=True) if override_faction > 0: gameobject.faction = override_faction gameobject.load() return gameobject
def spawn(entry, location, map_id, summoner=None, spell_id=0, override_faction=0, despawn_time=1): go_template = WorldDatabaseManager.gameobject_template_get_by_entry(entry) if not go_template: return None instance = SpawnsGameobjects() instance.spawn_id = GameObjectManager.CURRENT_HIGHEST_GUID + 1 instance.spawn_entry = entry instance.spawn_map = map_id instance.spawn_rotation0 = 0 instance.spawn_rotation2 = 0 instance.spawn_rotation1 = 0 instance.spawn_rotation3 = 0 instance.spawn_positionX = location.x instance.spawn_positionY = location.y instance.spawn_positionZ = location.z instance.spawn_orientation = location.o if despawn_time < 1: despawn_time = 1 instance.spawn_spawntimemin = despawn_time instance.spawn_spawntimemax = despawn_time instance.spawn_state = GameObjectStates.GO_STATE_READY gameobject = GameObjectManager( gobject_template=go_template, gobject_instance=instance, summoner=summoner ) if spell_id: gameobject.spell_id = spell_id if override_faction: gameobject.faction = override_faction gameobject.set_uint32(GameObjectFields.GAMEOBJECT_FACTION, override_faction) gameobject.load() return gameobject