コード例 #1
0
def shoot_in_direction(direction, instance, res):
    Usage.set_cooldown_on_attached(instance.tool, instance.actor)

    arrows = instance.actor.find_in_contains(arrow_filter)
    if len(arrows):
        direction.normalize()

        # Adjust the start position of the arrow, so it's outside of the actor, at mid height
        start_adjust = Vector3D(direction)
        start_adjust.y = 0
        start_adjust.normalize()
        start_adjust.y = instance.actor.location.bbox.high_corner.y * 0.8

        new_loc = instance.actor.location.copy()
        new_loc.pos += start_adjust

        new_loc.orientation = Quaternion(Vector3D(0, 0, 1), direction, Vector3D(1, 0, 0))

        mode_data = {"mode": "projectile", "$eid": instance.actor.id, "extra": {"damage": 20}}

        # TODO: match with animation in client
        res.append(instance.actor.start_action("bow/releasing", 1))
        res.append(Operation("move", Entity(arrows[0].id,
                                            location=new_loc,
                                            velocity=direction * 60,
                                            mode="projectile",
                                            mode_data=mode_data),
                             to=arrows[0].id))
コード例 #2
0
def strike(instance):
    # Check that we can reach the target with our weapon
    extraReach = 0.0
    if instance.tool.props.reach:
        extraReach = instance.tool.props.reach

    # If there's a cooldown we need to mark the actor
    Usage.set_cooldown_on_attached(instance.tool, instance.actor)

    # Send sight even if we miss
    instance.actor.send_world(Operation("sight", instance.op))

    # Melee weapons only handles one target
    target = instance.get_arg("targets", 0)
    if target:
        # Ignore pos
        if instance.actor.can_reach(target, extraReach):
            damage = 0
            if instance.tool.props.damage:
                damage = instance.tool.props.damage
            hit_op = Operation('hit',
                               Entity(damage=damage, hit_type=instance.op.id),
                               to=target.entity)
            return (server.OPERATION_BLOCKED, hit_op,
                    Operation('sight', hit_op))
        else:
            return (server.OPERATION_BLOCKED,
                    instance.actor.client_error(instance.op, "Too far away"))
    else:
        return (server.OPERATION_BLOCKED)
コード例 #3
0
ファイル: Melee.py プロジェクト: zkactivity-dev/cyphesis
    def do_strike(self):
        self.usage.actor.send_world(Operation("sight", self.usage.op))

        # If there's a cooldown we need to mark the actor
        Usage.set_cooldown_on_attached(self.usage.tool, self.usage.actor)

        target = self.usage.get_arg("targets", 0)
        if target:
            # Take a swing
            # Check that we can reach the target with our weapon
            extra_reach = 0.0
            if self.usage.tool.props.reach:
                extra_reach = self.usage.tool.props.reach

            if self.usage.actor.can_reach(target, extra_reach):
                damage = 0
                if self.usage.tool.props.damage:
                    damage = self.usage.tool.props.damage
                hit_op = Operation('hit', Entity(damage=damage, hit_type=self.usage.op.parent, id=self.usage.actor.id),
                                   to=target.entity)
                return server.OPERATION_BLOCKED, hit_op
            else:
                return server.OPERATION_BLOCKED, self.usage.actor.client_error(self.usage.op, "Too far away")
        else:
            print("No target")
        return server.OPERATION_BLOCKED
コード例 #4
0
ファイル: Tinderbox.py プロジェクト: worldforge/cyphesis
def ignite(instance):
    Usage.set_cooldown_on_attached(instance.tool, instance.actor)
    target = instance.get_arg("targets", 0)
    if instance.actor.can_reach(target):
        return server.OPERATION_BLOCKED, Operation("create", Entity(parent='fire', status=0.05, location=Location(target.entity), pos=[0, 0, 0]), to=target.entity)
    else:
        return server.OPERATION_BLOCKED, instance.actor.client_error(instance.op, "Too far away")
コード例 #5
0
ファイル: Melee.py プロジェクト: worldforge/cyphesis
def strike(instance):
    # Check that we can reach the target with our weapon
    extra_reach = 0.0
    if instance.tool.props.reach:
        extra_reach = instance.tool.props.reach

    # If there's a cooldown we need to mark the actor
    Usage.set_cooldown_on_attached(instance.tool, instance.actor)

    # Send sight even if we miss
    instance.actor.send_world(Operation("sight", instance.op))

    # Melee weapons only handles one target
    target = instance.get_arg("targets", 0)
    if target:
        # Ignore pos
        if instance.actor.can_reach(target, extra_reach):
            damage = 0
            if instance.tool.props.damage:
                damage = instance.tool.props.damage
            hit_op = Operation('hit', Entity(damage=damage, hit_type=instance.op.id), to=target.entity)
            return server.OPERATION_BLOCKED, hit_op, Operation('sight', hit_op)
        else:
            return server.OPERATION_BLOCKED, instance.actor.client_error(instance.op, "Too far away")
    else:
        return server.OPERATION_BLOCKED
コード例 #6
0
def shoot_poison_in_direction(direction, instance, res):
    Usage.set_cooldown_on_attached(instance.tool, instance.actor)

    direction.normalize()

    # Adjust the start position of the projectile, so it's outside of the actor, at mid height
    start_adjust = Vector3D(direction)
    start_adjust.y = 0
    start_adjust.normalize()
    start_adjust.y = instance.actor.location.bbox.high_corner.y * 0.8

    new_loc = instance.actor.location.copy()
    new_loc.pos += start_adjust

    new_loc.orientation = Quaternion(Vector3D(0, 0, 1), direction,
                                     Vector3D(1, 0, 0))
    mode_data = {"mode": "projectile", "$eid": instance.actor.id}

    res.append(
        Operation("create",
                  Entity(parent="poisonball",
                         location=new_loc,
                         velocity=direction * 60,
                         mode="projectile",
                         mode_data=mode_data,
                         damage_poison=instance.tool.props.damage),
                  to=instance.tool.id))
コード例 #7
0
ファイル: Trowel.py プロジェクト: worldforge/cyphesis
def sow(instance):
    Usage.set_cooldown_on_attached(instance.tool, instance.actor)

    task = Cultivate(instance, duration=11, tick_interval=1, name="Cultivate")

    instance.actor.send_world(Operation("sight", instance.op))

    return (server.OPERATION_BLOCKED, instance.actor.start_task('cultivate', task))
コード例 #8
0
def sow(instance):
    Usage.set_cooldown_on_attached(instance.tool, instance.actor)

    task = Cultivate(instance, duration=11, tick_interval=1, name="Cultivate")

    instance.actor.send_world(Operation("sight", instance.op))

    return server.OPERATION_BLOCKED, instance.actor.start_task(
        'cultivate', task)
コード例 #9
0
def ignite(instance):
    Usage.set_cooldown_on_attached(instance.tool, instance.actor)
    target = instance.get_arg("targets", 0)
    if instance.actor.can_reach(target):
        return server.OPERATION_BLOCKED, \
               Operation("create",
                         Entity(parent='fire', status=0.05, location=Location(target.entity), pos=[0, 0, 0]),
                         to=target.entity)
    else:
        return server.OPERATION_BLOCKED, instance.actor.client_error(
            instance.op, "Too far away")
コード例 #10
0
def use(instance):
    usage_name = instance.op.parent

    task = Usage.delay_task_if_needed(
        Use(instance,
            duration=5,
            tick_interval=1,
            name=usage_name.capitalize()))
    Usage.set_cooldown_on_attached(instance.tool, instance.actor)

    instance.actor.send_world(Operation("sight", instance.op))

    return server.OPERATION_BLOCKED, instance.actor.start_task(
        usage_name, task)
コード例 #11
0
def strike(instance):
    """Strike another entity with a weapon."""

    # Check that we can reach the target with our weapon
    extra_reach = 0.0
    if instance.tool.props.reach:
        extra_reach = instance.tool.props.reach

    # If there's a cooldown we need to mark the actor
    Usage.set_cooldown_on_attached(instance.tool, instance.actor)

    # Send sight even if we miss
    instance.actor.send_world(Operation("sight", instance.op))

    # Melee weapons only handles one target
    target = instance.get_arg("targets", 0)
    if target:
        cooldown_prop = instance.tool.props.cooldown
        if cooldown_prop:
            task = Melee(instance, tick_interval=cooldown_prop, name="Melee")
            task_op = instance.actor.start_task('melee', task)
        else:
            task_op = None

        # Ignore pos
        if instance.actor.can_reach(target, extra_reach):
            damage = 0
            if instance.tool.props.damage:
                damage = instance.tool.props.damage
            hit_op = Operation('hit',
                               Entity(damage=damage,
                                      hit_type=instance.op.parent,
                                      id=instance.actor.id),
                               to=target.entity)
            return server.OPERATION_BLOCKED, hit_op, task_op
        else:
            return server.OPERATION_BLOCKED, instance.actor.client_error(
                instance.op, "Too far away"), task_op
    else:
        return server.OPERATION_BLOCKED