def handleRadial(self, owner, target, action): if action == RadialIdentifier.serverMenu1: sim = self.getKernel().serviceManager().simulationService() datapad = self.getKernel().serviceManager().equipmentService( ).getEquippedObject(owner, "datapad") pcd = sim.createObject(target.getStringAttribute("deed_pcd"), ContainerPermission.NO_VIEW) mobile = sim.createObject(target.getStringAttribute("deed_mobile"), ContainerPermission.RIDEABLE) if not (datapad is None or pcd is None or mobile is None): #Set Owner mobile.owner_id = owner.id pcd.owner_id = owner.id #Link the two pieces mobile.setIntAttribute("pcd_id", pcd.id) pcd.setIntAttribute("mobile_id", mobile.id) #Store any called vehicles self.getKernel().serviceManager().playerService( ).storeAllCalledMounts(owner) #Add the the pcd to the datapad, and mobile to world datapad.add(owner, pcd) pos = owner.position mobile.position = vector3(pos.x, pos.y - 0.3, pos.z) mobile.orientation = owner.orientation owner.container().add(owner, mobile) #Destroy the deed target.container().remove(owner, target)
def handleRadial(self, owner, target, action): if action == RadialIdentifier.serverMenu1: sim = self.getKernel().serviceManager().simulationService() datapad = self.getKernel().serviceManager().equipmentService().getEquippedObject(owner, "datapad") pcd = sim.createObject(target.getStringAttribute("deed_pcd"), ContainerPermission.NO_VIEW) mobile = sim.createObject(target.getStringAttribute("deed_mobile"), ContainerPermission.RIDEABLE) if not (datapad is None or pcd is None or mobile is None): #Set Owner mobile.owner_id = owner.id pcd.owner_id = owner.id #Link the two pieces mobile.setIntAttribute("pcd_id", pcd.id) pcd.setIntAttribute("mobile_id", mobile.id) #Store any called vehicles self.getKernel().serviceManager().playerService().storeAllCalledMounts(owner) #Add the the pcd to the datapad, and mobile to world datapad.add(owner, pcd) pos = owner.position mobile.position = vector3(pos.x, pos.y-0.3, pos.z) mobile.orientation = owner.orientation owner.container().add(owner, mobile) #Destroy the deed target.container().remove(owner, target)
def run(self): simulation = self.getKernel().serviceManager().simulationService() actor = self.getActor() digits = re.findall(r'\-?\d+(?:\.\d*)?', self.getCommandString()) length = len(digits) waypoint_position = vector3() if length == 3: waypoint_position.x = float(digits[0]) waypoint_position.y = float(digits[1]) waypoint_position.z = float(digits[2]) elif length == 2: waypoint_position.x = float(digits[0]) waypoint_position.z = float(digits[1]) elif length == 0: waypoint_position = actor.position else: SystemMessage.sendSystemMessage(actor, "[SYNTAX] /waypoint <x> <z> or /waypoint <x> <y> <z>", True, False) return planet = simulation.getSceneNameById(actor.scene_id) player = self.getKernel().serviceManager().equipmentService().getPlayerObject(actor) waypoint = simulation.createObject('object/waypoint/shared_waypoint.iff').castToWaypoint() waypoint.setCoordinates(waypoint_position) waypoint.setPlanet(planet) waypoint.setColor(WaypointColor.BLUE) waypoint.activate() player.addWaypoint(waypoint)
def CreateStartingCharacter(kernel, scale, base_model, customization, full_name, profession, hair_model, hair_customization, start_city): # Simulation Service to add to scene simulation = kernel.serviceManager().simulationService() # Set Female if base_model.find('female') == -1: gender = 'male' else: gender = 'female' # Get Starting Location # HARDCODE FOR NOW... startLoc = Locations['coronet'] # Create appropriate creature object... species = GetSpecies(base_model) creature = simulation.createObject(base_model.replace('player/', 'player/shared_'), ContainerPermission.CREATURE) creature.scene_id = simulation.getSceneIdByName(startLoc.name) creature.custom_name = full_name creature.position = vector3(startLoc.x, startLoc.y, startLoc.z) if customization: creature.setCustomizationFromInts(customization) creature.bank_credits = 2000 creature.speed_base = 5.75 # Set Starting Stats startStats = StartStats[species + ":" + profession] SetStartingStats(creature, startStats) # Set Starting Skills SetStartingSkills(creature, species, profession) # Create Base Player Object player = simulation.createObject('object/player/shared_player.iff') # Create datapad datapad = simulation.createObject('object/tangible/datapad/shared_character_datapad.iff', ContainerPermission.CREATURE_CONTAINER) # Create inventory inventory = simulation.createObject('object/tangible/inventory/shared_character_inventory.iff', ContainerPermission.CREATURE_CONTAINER) # Create bank bank = simulation.createObject('object/tangible/bank/shared_character_bank.iff', ContainerPermission.CREATURE_CONTAINER) # Create mission mission = simulation.createObject('object/tangible/mission_bag/shared_mission_bag.iff', ContainerPermission.CREATURE_CONTAINER) # Create hair hair = simulation.createObject(hair_model.replace('/hair_','/shared_hair_')) # Create Starting Items startingItems = GetStartingItems(species, profession, gender) # Add all sub objects to creature (parent) creature.add(creature, datapad) creature.add(creature, inventory) creature.add(creature, bank) creature.add(creature, mission) if (hair): hair.setCustomizationFromInts(hair_customization) creature.add(creature, hair) creature.add(creature, player) # Now add the objects to the inventory # Wearables get equipped for item in startingItems: item_obj = simulation.createObject(item) if 'wearables' in item: creature.add(creature, item_obj) else: inventory.add(creature, item_obj) return creature
def handleRadial(self, owner, target, action): if owner.id == target.owner_id: if action == RadialIdentifier.serverVehicleExit or action == RadialIdentifier.serverVehicleEnter: if owner.container().id == target.id and action == RadialIdentifier.serverVehicleExit: #Exit target.transfer(owner, owner,target.container(), target.position) target.toggleStateOff(ACTION.MOUNTED_CREATURE) elif action == RadialIdentifier.serverVehicleEnter: #Enter owner.container().transfer(owner, owner, target, vector3(0, 0, 0)) target.toggleStateOn(ACTION.MOUNTED_CREATURE) elif action == RadialIdentifier.vehicleStore: sim = self.getKernel().serviceManager().simulationService() pcd = sim.findObjectById(target.getIntAttribute("pcd_id")) if pcd: if owner.container().id == target.id: target.transfer(owner, owner, target.container(), target.position) target.container().transfer(owner, target, pcd, vector3(0, 0, 0))
def handleRadial(self, owner, target, action): if action == RadialIdentifier.vehicleGenerate: sim = self.getKernel().serviceManager().simulationService() mobile = sim.findObjectById(target.getIntAttribute("mobile_id")) if mobile: if target.hasContainedObjects(): #Call it! playServ = self.getKernel().serviceManager().playerService() playServ.storeAllCalledMounts(owner) pos = owner.position mobile.orientation = owner.orientation mobile.container().transfer(mobile, mobile, owner.container(), vector3(pos.x, pos.y-0.3, pos.z)) else: #Store it! if owner.container().id == mobile.id: #Move the player out first mobile.transfer(owner, owner, mobile.container(), mobile.position) mobile.container().transfer(owner, mobile, target, vector3(0, 0, 0))
def handleElevatorAction(self, target, owner, expected_elevator_action, effect_name): static_service = self.getKernel().serviceManager().staticService() simulation_service = self.getKernel().serviceManager().simulationService() for data in static_service.getElevatorDataForObject(target.id): if data.going_down == expected_elevator_action: #Move the player destination_cell = simulation_service.findObjectById(data.dst_cell) new_position = vector3(owner.position.x, data.dst_position.y, owner.position.z) owner.updatePosition(destination_cell, new_position, owner.orientation) SystemMessage.sendEffect(owner, effect_name, data.dst_orientation, data.dst_position)
def handleElevatorAction(self, target, owner, expected_elevator_action, effect_name): static_service = self.getKernel().serviceManager().staticService() simulation_service = self.getKernel().serviceManager().simulationService() for data in static_service.getElevatorDataForObject(target.id): if data.going_down == expected_elevator_action: #Move the player destination_cell = simulation_service.findObjectById(data.dst_cell) new_position = vector3(owner.position.x, data.dst_position.y, owner.position.z) owner.updatePosition(new_position, owner.orientation, destination_cell) SystemMessage.sendEffect(owner, effect_name, data.dst_orientation, data.dst_position)
def handleRadial(self, owner, target, action): if owner.id == target.owner_id: if action == RadialIdentifier.serverVehicleExit or action == RadialIdentifier.serverVehicleEnter: if owner.container( ).id == target.id and action == RadialIdentifier.serverVehicleExit: #Exit target.transfer(owner, owner, target.container(), target.position) target.toggleStateOff(ACTION.MOUNTED_CREATURE) elif action == RadialIdentifier.serverVehicleEnter: #Enter owner.container().transfer(owner, owner, target, vector3(0, 0, 0)) target.toggleStateOn(ACTION.MOUNTED_CREATURE) elif action == RadialIdentifier.vehicleStore: sim = self.getKernel().serviceManager().simulationService() pcd = sim.findObjectById(target.getIntAttribute("pcd_id")) if pcd: if owner.container().id == target.id: target.transfer(owner, owner, target.container(), target.position) target.container().transfer(owner, target, pcd, vector3(0, 0, 0))
def run(self): simulation = self.getKernel().serviceManager().simulationService() actor = self.getActor() digits = re.findall(r'\-?\d+(?:\.\d*)?', self.getCommandString()) length = len(digits) waypoint_position = vector3() if length == 3: waypoint_position.x = float(digits[0]) waypoint_position.y = float(digits[1]) waypoint_position.z = float(digits[2]) elif length == 2: waypoint_position.x = float(digits[0]) waypoint_position.z = float(digits[1]) elif length == 0: waypoint_position = actor.position else: SystemMessage.sendSystemMessage( actor, "[SYNTAX] /waypoint <x> <z> or /waypoint <x> <y> <z>", True, False) return planet = simulation.getSceneNameById(actor.scene_id) player = self.getKernel().serviceManager().equipmentService( ).getPlayerObject(actor) waypoint = simulation.createObject( 'object/waypoint/shared_waypoint.iff').castToWaypoint() waypoint.setCoordinates(waypoint_position) waypoint.setPlanet(planet) waypoint.setColor(WaypointColor.BLUE) waypoint.activate() player.addWaypoint(waypoint)
def CreateStartingCharacter(kernel, scale, base_model, customization, full_name, profession, hair_model, hair_customization, start_city): # Simulation Service to add to scene simulation = kernel.serviceManager().simulationService() # Set Female if base_model.find('female') == -1: gender = 'male' else: gender = 'female' # Get Starting Location # HARDCODE FOR NOW... startLoc = Locations['bestine'] # Create appropriate creature object... species = GetSpecies(base_model) creature = simulation.createObject( base_model.replace('player/', 'player/shared_'), ContainerPermission.CREATURE) creature.scene_id = simulation.getSceneIdByName(startLoc.name) creature.custom_name = full_name creature.position = vector3(startLoc.x, startLoc.y, startLoc.z) if customization: creature.setCustomizationFromInts(customization) creature.bank_credits = 2000 creature.speed_base = 5.75 # Set Starting Stats startStats = StartStats[species + ":" + profession] SetStartingStats(creature, startStats) # Set Starting Skills SetStartingSkills(creature, species, profession) # Create Base Player Object player = simulation.createObject('object/player/shared_player.iff') # Create datapad datapad = simulation.createObject( 'object/tangible/datapad/shared_character_datapad.iff', ContainerPermission.CREATURE_CONTAINER) # Create inventory inventory = simulation.createObject( 'object/tangible/inventory/shared_character_inventory.iff', ContainerPermission.CREATURE_CONTAINER) # Create bank bank = simulation.createObject( 'object/tangible/bank/shared_character_bank.iff', ContainerPermission.CREATURE_CONTAINER) # Create mission mission = simulation.createObject( 'object/tangible/mission_bag/shared_mission_bag.iff', ContainerPermission.CREATURE_CONTAINER) # Create hair hair = simulation.createObject( hair_model.replace('/hair_', '/shared_hair_')) # Create Starting Items startingItems = GetStartingItems(species, profession, gender) # Add all sub objects to creature (parent) creature.add(creature, datapad) creature.add(creature, inventory) creature.add(creature, bank) creature.add(creature, mission) if (hair): hair.setCustomizationFromInts(hair_customization) creature.add(creature, hair) creature.add(creature, player) # Now add the objects to the inventory # Wearables get equipped for item in startingItems: item_obj = simulation.createObject(item) if 'wearables' in item: creature.add(creature, item_obj) else: inventory.add(creature, item_obj) return creature
# swgpy from swgpy import app, utility, weather from swgpy.weather import WeatherEvent, WeatherSequence # modules import random service_mgr = kernel.serviceManager() weather_svc = service_mgr.weatherService() #This script is called every 30 minutes. #Weather duration is now set in minutes: weather_event(duration(mins),weatherType,cloudVector(X,Y,Z)). #Each of the following is a list of weather sequences. Each sequence runs until its duration has expired. #At the end of the sequence, NOSTORM is used to set the weather back to clear. Whilst each weather sequence list #is running, no other weather sequence can be used on the same scene until the sequences have expired. lightStormSequence = WeatherSequence() lightStormSequence.append(WeatherEvent(20, weather.WEATHER.CLOUDY, utility.vector3(1.0, 0.0, 0.0))) lightStormSequence.append(WeatherEvent(10, weather.WEATHER.LIGHTSTORM, utility.vector3(1.0, 0.0, 0.0))) lightStormSequence.append(WeatherEvent(10, weather.WEATHER.CLOUDY, utility.vector3(1.0, 0.0, 0.0))) lightStormSequence.append(WeatherEvent(10, weather.WEATHER.NOSTORM, utility.vector3(1.0, 0.0, 0.0))) mediumStormSequence = WeatherSequence() mediumStormSequence.append(WeatherEvent(20, weather.WEATHER.CLOUDY, utility.vector3(1.0, 0.0, 0.0))) mediumStormSequence.append(WeatherEvent(3, weather.WEATHER.LIGHTSTORM, utility.vector3(1.0, 0.0, 0.0))) mediumStormSequence.append(WeatherEvent(10, weather.WEATHER.MEDIUMSTORM, utility.vector3(1.0, 0.0, 0.0))) mediumStormSequence.append(WeatherEvent(3, weather.WEATHER.LIGHTSTORM, utility.vector3(1.0, 0.0, 0.0))) mediumStormSequence.append(WeatherEvent(10, weather.WEATHER.CLOUDY, utility.vector3(1.0, 0.0, 0.0))) mediumStormSequence.append(WeatherEvent(10, weather.WEATHER.NOSTORM, utility.vector3(1.0, 0.0, 0.0))) heavyStormSequence = WeatherSequence() heavyStormSequence.append(WeatherEvent(20, weather.WEATHER.CLOUDY, utility.vector3(1.0, 0.0, 0.0))) heavyStormSequence.append(WeatherEvent(3, weather.WEATHER.LIGHTSTORM, utility.vector3(1.0, 0.0, 0.0)))