i am currently trying to write a gamemode (i cant give any details right now because some people want me to not make it public yet)
it is actualy complete but has one grave problem and i have no idea how to solve it.
i want to assign a certain velocity to a player, like this:
player.world_object.velocity.x = 5
the result is following:
everyone else sees this player getting launched in a specific direction, but the player himself does not seem to receive this information, in other words everyone thinks he is moving , while he himself is just standing still and thus teleporting back to his original position.
i clearly want to avoid using a set_location function beacause it would ignore any collisions with blocks/walls.
In case someone didnt get it (since i am pretty poor at expressing myself):
- player gets pushed in a certain direction
- but teleportes himself back at the end
has anybody an idea how to fix that? I assume i have to send something to the client, no idea what though...
how do i assign a velocity?
-
Dr.Morphman
Scripter
- Posts: 73
- Joined: Sun Feb 24, 2013 9:55 am
-
thepolm3
Scripter
- Posts: 424
- Joined: Sat Feb 16, 2013 10:49 pm
I think it it player.world_object.velocity.set()
or it might be a send_contained()
or it might be a send_contained()
-
Dr.Morphman
Scripter
- Posts: 73
- Joined: Sun Feb 24, 2013 9:55 am
nah velocity.set() had the same result
and i canot find a loader capable of solving this issue, therefore i give up upon the whole idea
my idea was to create a script that replaces inflicted damage with knockback,
so your goal would become knocking the enemy off the stage (fall kills count for the person who shot you last)
meaning you have to pay attention to the angle you hit your enemy from instead of the body part you want to shoot
on top of that it would give mappers an opportunity to create maps for it (for example a platform in the sky)
i am a bit disappointed about the fact that i am unable to finish it since everyone who tested this script with me (as far as it worked) had pretty much fun, therefore if someone else wants to pick it up, feel free to do so:
setting a velocity calculated collisions with blocks/walls but for some reason standing close to a wall was not enough not protect you (meaning you were thrown through it, making it impossible to cheat the system) this is why i want to avoid a set_location() function
some additional suggestions:
- knockback is depending on the player's HP insdead of inflicted damage (similiar to the smashbros series)
- making everyone play a platform that is slowly decomposing (creating maps wont be possible that way)
and i canot find a loader capable of solving this issue, therefore i give up upon the whole idea
my idea was to create a script that replaces inflicted damage with knockback,
so your goal would become knocking the enemy off the stage (fall kills count for the person who shot you last)
meaning you have to pay attention to the angle you hit your enemy from instead of the body part you want to shoot
on top of that it would give mappers an opportunity to create maps for it (for example a platform in the sky)
i am a bit disappointed about the fact that i am unable to finish it since everyone who tested this script with me (as far as it worked) had pretty much fun, therefore if someone else wants to pick it up, feel free to do so:
Code: Select all
from math import sqrt
from pyspades.server import *
from commands import get_player, name
def apply_script(protocol, connection, config):
class KnockbackConnection(connection):
cat = None
paws = None
def on_hit(self, hit_amount, hit_player, type, grenade):
if self.team != hit_player.team: # prevents you from exterminating your comrades
hit_player.cat = self.name # saves the killer's name oh yeah cats are cute
self.paws = type # saves the killer's kill type
xp, yp, zp = self.get_location()
xv, yv, zv = hit_player.get_location()
vec_push_x = xv - xp # i never learned in school how to do taxes
vec_push_y = yv - yp # or how to apply for university or a job but
vec_push_z = zv - zp # thank god i am able to calculate vectors now
vec_value = sqrt( (xv - xp)**2 + (yv - yp)**2 )
if vec_value == 0: vec_value = 1 # just in case
hit_player.world_object.velocity.x = (vec_push_x / vec_value) * (hit_amount / 10)
hit_player.world_object.velocity.y = (vec_push_y / vec_value) * (hit_amount / 10)
hit_player.world_object.velocity.z = (vec_push_z / vec_value) * (hit_amount / 100) # fall damage is being calculated with z-velocity (attacks from above can kill the victim instantly)
return connection.on_hit(self, 0, hit_player, type, grenade)
def on_fall(self, damage): # detecting kills
if damage >= self.hp and self.cat != None and self.paws != None: # for those who are actualy smart enough to die from their own stupidity
last_cat = get_player(self.protocol, self.cat)
kill_action.player_id = self.player_id
kill_action.killer_id = last_cat.player_id
kill_action.kill_type = last_cat.paws
kill_action.respawn_time = config.get("respawn_time")
for players in self.protocol.players.values():
players.send_contained(kill_action)
return connection.on_fall(self, 0)
else: return connection.on_fall(self, damage)
def on_spawn(self, pos): # resets some values
self.cat = None
self.paws = None
return connection.on_spawn(self, pos)
return protocol, KnockbackConnection
setting a velocity calculated collisions with blocks/walls but for some reason standing close to a wall was not enough not protect you (meaning you were thrown through it, making it impossible to cheat the system) this is why i want to avoid a set_location() function
some additional suggestions:
- knockback is depending on the player's HP insdead of inflicted damage (similiar to the smashbros series)
- making everyone play a platform that is slowly decomposing (creating maps wont be possible that way)
-
Lostmotel
League Participant
- Posts: 298
- Joined: Sun Nov 18, 2012 1:09 pm
-
thepolm3
Scripter
- Posts: 424
- Joined: Sat Feb 16, 2013 10:49 pm
I've a feeling that you can use connection . set_velocity ()
-
Dr.Morphman
Scripter
- Posts: 73
- Joined: Sun Feb 24, 2013 9:55 am
mh unfortunately set_velocity() does not work either
oh well thanks for your concern but i suspect it is not possible to change a players velocity like that
oh well thanks for your concern but i suspect it is not possible to change a players velocity like that
-
thepolm3
Scripter
- Posts: 424
- Joined: Sat Feb 16, 2013 10:49 pm
I know Its impossible to change orientation too... I think It might be a pyspades glitch
-
Dr.Morphman
Scripter
- Posts: 73
- Joined: Sun Feb 24, 2013 9:55 am
thepolm3 wrote:I know Its impossible to change orientation too... I think It might be a pyspades glitchhah funny, i thought the exact same
ookay it was at least worth a try asking for help here
Who is online
Users browsing this forum: No registered users and 3 guests
