cyphesis/rulesets/deeds/world/objects/tools/Bow.py
Erik Ogenvik 2dca4949ed Created "deeds" ruleset and made it default.
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.
2013-11-15 21:14:47 +01:00

29 lines
1.2 KiB
Python

#This file is distributed under the terms of the GNU General Public license.
#Copyright (C) 1999 Aloril (See the file COPYING for details).
#return Operation("create",Entity(name='wood',type=['lumber'],location=self.location.parent.location.copy()),to=self)
from atlas import *
from physics import Vector3D
import server
class Bow(server.Thing):
"""This is base class for bows, this one just ordinary bow"""
def shoot_operation(self, op):
ammo = op[0].id
to_ = op[1].id
target = server.world.get_object(to_)
vel = target.location.coordinates - self.location.parent.location.coordinates
time = vel.mag() / 5
vel = vel.unit_vector() * 5
loc1 = Location(self.location.parent.location.parent,self.location.parent.location.coordinates)
loc1.velocity = vel
loc2 = Location(target.location.parent,Point3D(0,0,0))
loc2.velocity = Vector3D(0,0,0)
m1 = Operation("move",Entity(ammo,location=loc1),to=ammo)
m2 = Operation("move",Entity(ammo,location=loc2),to=ammo)
m2.setFutureSeconds(time)
t = Operation("set",Entity(to_,status=-1),to=to_)
t.setFutureSeconds(time)
return Oplist(m1,m2,t)