Page 1 of 1

Block Punch!!

Posted: Wed May 15, 2013 4:25 pm
by danhezee
What if there was a script that allowed a player to hit other players while holding the block. It would be low damage like 5 hp or something.

Is it possible?

Re: Block Punch!!

Posted: Wed May 15, 2013 4:42 pm
by Vengeance
I don't exaclty know if it is possible, but it is a pretty cool idea. Then you could defend yourself while holding a block. Maybe it can work, but does it?

Re: Block Punch!!

Posted: Wed May 15, 2013 5:06 pm
by learn_more
how do you want to differentiate between placing a block and hitting a player?

Re: Block Punch!!

Posted: Wed Oct 16, 2013 1:13 pm
by Kuma
not really possible, because you can only place the block... (maybe i am wrong)

Re: Block Punch!!

Posted: Thu Oct 17, 2013 5:17 pm
by VladVP
This challenge requires two things to be resolved first:
  1. Detecting a mouse click.
  2. Detecting which player (if there is one at all) is in front of the player who clicked.
Number 2 should definitely be doable, but I don't know about how we should go about managing to do number 1.

Re: Block Punch!!

Posted: Thu Oct 17, 2013 5:37 pm
by Kuma
VladVP wrote:
This challenge requires two things to be resolved first:
  1. Detecting a mouse click.
  2. Detecting which player (if there is one at all) is in front of the player who clicked.
Number 2 should definitely be doable, but I don't know about how we should go about managing to do number 1.
Well, How can we differentiate between a block place and block punch (If you you say if the block is attempted to be placed in the air it means its a punch it wrong and what will happen if the player is looking down?)

Re: Block Punch!!

Posted: Thu Oct 17, 2013 5:40 pm
by Jdrew
How would you punch someone? What if you just like run into them and it hits them?

Re: Block Punch!!

Posted: Thu Oct 17, 2013 6:03 pm
by Kuma
jdrew wrote:
How would you punch someone? What if you just like run into them and it hits them?
Vlad said about clicking while looking at other player

Re: Block Punch!!

Posted: Thu Oct 17, 2013 6:24 pm
by Jdrew
And that is possible?

Re: Block Punch!!

Posted: Thu Oct 17, 2013 7:15 pm
by VladVP
jdrew wrote:
And that is possible?
It should be, as the client probably sends a lot of weird and useless things to the server. Unfortunately, I've never seen anything in the pyspades API which could help detect a mouse click. (Apart from on_hit() and on_block_destroy(), but that's not really useful in this conjunction, is it?)

Re: Block Punch!!

Posted: Thu Oct 17, 2013 8:03 pm
by Dr.Morphman
yeah it is all about finding a suitable hook, once you find one it is going to be easy

here is a suggestion from my side using on_orientation_update() as hook:
Code: Select all
from commands import name, add, admin, alias 
from pyspades.constants import BLOCK_TOOL
from pyspades.server import *        
from pyspades.collision import vector_collision, distance_3d_vector

def apply_script(protocol, connection, config): 

    class blockpunchconnection(connection):

        def on_orientation_update(self, x, y, z):

            if self.tool == BLOCK_TOOL:

                for babydonthurtme in self.protocol.players.values():

                    if distance_3d_vector(self.world_object.position, babydonthurtme.world_object.position) <= 3:

                        if self.world_object.validate_hit(babydonthurtme.world_object, MELEE, 2) and self != babydonthurtme:

                            babydonthurtme.hit(5, self, MELEE_KILL)

    return protocol, blockpunchconnection
im not realy in the mood today to create a whole script but this draft here was already working when i tested it, just replace the hook with whatever one you want and its basicaly done, (on_shoot_set() does not work with blocks for some reason therefore i assume you canot attack people by simply clicking the mouse while holding a block [except you actualy place the block somewhere, but look at block_kill.py for that])
hooks that may be suitable in my opinion as well: on_walk_update, on_animation_update, on_tool_changed

Re: Block Punch!!

Posted: Fri Oct 18, 2013 3:03 am
by Kuma
That could work, But how about we use on_block_build_attempt() and the users must have block punch on using a command after that when they try to place a block on someone they get hit but we return False so the block doesn't get place?

on_block_build_attempt(self, x, y, z):

Re: Block Punch!!

Posted: Fri Oct 18, 2013 5:30 pm
by Dr.Morphman
as vlad said before you canot find anything detecting clicks (except on_shoot_set which does not work with blocks) so on_block_build_attempt would require you to actualy place a block on the ground but i have written something like that before
the code i posted should be sufficient all you need to do now is find a suitable hook and adjust it