Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from commands import *
- from pyspades.world import *
- from pyspades.constants import *
- from pyspades.server import *
- from pyspades.common import *
- MAX_BLOOD = 2000
- BLOOD_COLOR = (175, 20, 20)
- def apply_script(protocol, connection, config):
- class BloodConnection(connection):
- def on_hit(hitter, hit_amount, hittee, type, grenade):
- if MAX_BLOOD <= 0:
- return connection.on_hit(hitter, hit_amount, hittee, type, grenade)
- #hitter.protocol.send_chat("on hit: " + hitter.name + ", " + str(hit_amount) + ", " + hittee.name + ", " + str(type) + ", " + str(grenade))
- result = connection.on_hit(hitter, hit_amount, hittee, type, grenade)
- if result == False:
- return False
- if result is not None:
- hit_amount = result
- #hitter.protocol.send_chat("hit not cancelled, new damage " + str(hit_amount))
- pos = hittee.world_object.position
- pos2 = hitter.world_object.position
- for i in range(min(10, int(hit_amount / 10) + 1)):
- #hitter.protocol.send_chat("trace")
- dir = pos - pos2
- dir.normalize()
- dir.x = dir.x + random.random() * 0.4 - 0.2
- dir.y = dir.y + random.random() * 0.4 - 0.2
- dir.z = dir.z + random.random() - 0.2
- dir.normalize()
- c = Character(hittee.world_object.world, pos, dir)
- loc = c.cast_ray()
- if loc:
- #if cast_ray(hittee.world_object.world.map.map, pos.x, pos.y, pos.z, dir.x, dir.y, dir.z, 8, x, y, z):
- x, y, z = loc
- #hitter.protocol.send_chat(str(x) + ", " + str(y) + ", " + str(z) + ", ray found")
- if x < 0 or y < 0 or z < 0 or z >= 512 or y >= 512 or z >= 62:
- continue
- #hitter.protocol.send_chat("painting")
- if hitter.protocol.map.get_color(x, y, z) == BLOOD_COLOR:
- continue
- if hitter.protocol.index >= MAX_BLOOD:
- solid = hitter.protocol.map.get_point(hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][0], hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][1], hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][2])
- if solid and hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][3] is not None:
- hitter.protocol.map.set_point(hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][0], hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][1], hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][2], hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][3])
- set_color.value = make_color(*hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][3])
- set_color.player_id = 32
- hitter.protocol.send_contained(set_color)
- block_action.x = hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][0]
- block_action.y = hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][1]
- block_action.z = hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD][2]
- block_action.player_id = 32
- block_action.value = DESTROY_BLOCK
- hitter.protocol.send_contained(block_action, save = True)
- block_action.value = BUILD_BLOCK
- hitter.protocol.send_contained(block_action, save = True)
- hitter.protocol.blood[hitter.protocol.index % MAX_BLOOD] = (x, y, z, hitter.protocol.map.get_color(x, y, z))
- hitter.protocol.index = hitter.protocol.index + 1
- #hitter.protocol.send_chat(str(hitter.protocol.index))
- hitter.protocol.map.set_point(x, y, z, BLOOD_COLOR)
- set_color.value = make_color(*BLOOD_COLOR)
- set_color.player_id = 32
- hitter.protocol.send_contained(set_color)
- block_action.x = x
- block_action.y = y
- block_action.z = z
- block_action.player_id = 32
- block_action.value = DESTROY_BLOCK
- hitter.protocol.send_contained(block_action, save = True)
- block_action.value = BUILD_BLOCK
- hitter.protocol.send_contained(block_action, save = True)
- #hitter.protocol.send_chat("end")
- return hit_amount
- class BloodProtocol(protocol):
- blood = {}
- index = 0
- return BloodProtocol, BloodConnection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement