File: Bow.py

package info (click to toggle)
cyphesis-cpp 0.5.16-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,084 kB
  • ctags: 3,627
  • sloc: cpp: 30,418; python: 4,812; xml: 4,674; sh: 4,118; makefile: 902; ansic: 617
file content (30 lines) | stat: -rw-r--r-- 1,246 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#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 cyphesis.Thing import Thing
from Vector3D import Vector3D

import server

class Bow(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 Message(m1,m2,t)