mirror of
https://github.com/worldforge/cyphesis
synced 2026-08-13 12:26:04 -04:00
It's currently a copy of the Mason ruleset. Where Mason focuses on letting the users create the world themselves, Deeds instead focuses on allowing world authors to set up enticing worlds with gameplay and stories. In contrast to Mason there are more features available to the world authors which allow for automatic creation of entities and so on.
68 lines
2.5 KiB
Python
68 lines
2.5 KiB
Python
#This file is distributed under the terms of the GNU General Public license.
|
|
#Copyright (C) 2011 Jekin Trivedi <jekintrivedi@gmail.com> (See the file COPYING for details).
|
|
|
|
from atlas import *
|
|
from physics import *
|
|
from physics import Quaternion
|
|
from physics import Vector3D
|
|
from physics import Point3D
|
|
|
|
from random import *
|
|
|
|
import server
|
|
|
|
class Pulling(server.Task):
|
|
""" A task for pulling objects vertically using simple rope mechanism."""
|
|
def pull_operation(self, op):
|
|
""" Op handler for strike op which activates this task """
|
|
if len(op) < 1:
|
|
std.stderr.write("Pulling task has no target in pull op")
|
|
|
|
# FIXME Use weak references, once we have them
|
|
self.target = server.world.get_object_ref(op[0].id)
|
|
self.tool = op.to
|
|
self.points = []
|
|
self.points.append(self.character.location.coordinates)
|
|
|
|
def tick_operation(self, op):
|
|
""" Op handler for regular tick op """
|
|
res = Oplist()
|
|
|
|
if self.target() is None:
|
|
# print "Target is no more"
|
|
self.irrelevant()
|
|
return
|
|
|
|
if not self.target().location.parent:
|
|
self.irrelevant()
|
|
return
|
|
|
|
target_location = Location(self.target().location.parent,
|
|
self.target().location.coordinates)
|
|
target_location.velocity=Vector3D(0,0,-0.5)
|
|
new_loc = self.character.location.coordinates
|
|
origin = self.points[0]
|
|
# Get the diffrence in the location of user at current time to the time when he started the task
|
|
diff = origin.x - new_loc.x
|
|
target_entity_moving = Entity(self.target().id, location = target_location)
|
|
|
|
# Replicate the diffrence in position to the corresponding change in height.
|
|
target_location = Location(self.target().location.parent,
|
|
Point3D(self.target().location.coordinates.x,
|
|
self.target().location.coordinates.y,
|
|
self.target().location.coordinates.z + diff))
|
|
target_location.velocity=Vector3D(0,0,0)
|
|
target_entity = Entity(self.target().id, location = target_location)
|
|
|
|
# Make the mode fixed to remove the height constraint on entity.
|
|
if not hasattr(self.target(), 'mode') or self.target().mode != 'fixed':
|
|
target_entity.mode = 'fixed'
|
|
|
|
move=Operation("move", target_entity, to=self.target())
|
|
move.setFutureSeconds(0.2)
|
|
res.append(move)
|
|
|
|
res.append(self.next_tick(1.5))
|
|
|
|
return res
|
|
|