skriptMC/deacoudre.sk
2021-06-29 23:37:58 +02:00

129 lines
5.8 KiB
Text

options:
X1: 103.5
Z1: -312.5
Yeau: 57.5
X2: 99.5
Z2: -304.5
on load:
ScriptList("add", script)
on unload:
ScriptList("remove", script)
command deacoudre [<text>]: # lancement de la partie
executable by: players
description: Lance une partie de dé à coudre.
trigger:
if arg-1 is set:
if arg-1 is "spawn":
if player is op:
set {thimble.location} to location of player
send "&aLe dé à coudre téléportes désormais ici."
stop
else:
send option("errorMessage")
stop
if {thimble.location} is not set:
send "&4Tu n'as pas défini de point de téléportation : &r&l/deacoudre spawn"
stop
if {party.player.%uuid of player%} is set:
if {thimble} is true:
delete {thimble}
loop {party.list::*}:
send "&cPartie de dé à coudre terminée." to loop-value
set gamemode of loop-value to creative
else:
set {thimble} to true
loop {party.list::*}:
send "&aDémarrage de la partie de dé à coudre !" to loop-value
teleport loop-value to {thimble.location}
set gamemode of loop-value to adventure
feed loop-value
heal loop-value
cure loop-value
execute console command "fill 103 57 -313 99 57 -305 water"
# execute console command "fill %{@X1}% %{@Yeau}% %{@Z1}% %{@X2}% %{@Yeau}% %{@Z2}% water"
else:
send "&4Tu n'es pas dans une partie."
function getDifference(arg: text, block: block, comparative: number) :: number:
if {_arg} is "x":
set {_res} to difference between X-location of {_block} and {_comparative}
if {_arg} is "y":
set {_res} to difference between Y-location of {_block} and {_comparative}
if {_arg} is "z":
set {_res} to difference between Z-location of {_block} and {_comparative}
return {_res}
every 0.5 second in "world": # pose du bloc et téléporatation
if {thimble} is not true:
stop
loop {party.list::*}:
set action bar of loop-value to "&dEn partie de &lDé à coudre&r&d."
if block at loop-value is water: # si dans l'eau
# vérification que c'est l'eau du dé à coudre
set {_xLocationBlock1} to getDifference("x", block at loop-value, {@X1})
set {_xLocationBlock2} to getDifference("x", block at loop-value, {@X2})
set {_zLocationBlock1} to getDifference("z", block at loop-value, {@Z1})
set {_zLocationBlock2} to getDifference("z", block at loop-value, {@Z2})
set {_yLocationBlock} to getDifference("y", block at loop-value, {@Yeau})
if {_xLocationBlock1} and {_xLocationBlock2} and {_zLocationBlock1} and {_zLocationBlock2} <= 0:
continue
if {_xLocationBlock1} and {_xLocationBlock2} >= abs({@X1} - {@X2}):
continue
if {_yLocationBlock} != 0:
continue
if {_zLocationBlock1} and {_zLocationBlock2} >= abs({@Z1} - {@Z2}):
continue
# vérification si c'est un jump qui est dur à faire (entre 4 blocs pleins)
set {_niceJump} to true
set {_blockX} to X-location of block at loop-value
set {_blockY} to Y-location of block at loop-value
set {_blockZ} to Z-location of block at loop-value
if block at location ({_blockX} - 1), {_blockY}, {_blockZ} in world "world" is water:
set {_niceJump} to false
if block at location ({_blockX} + 1), {_blockY}, {_blockZ} in world "world" is water:
set {_niceJump} to false
if block at location {_blockX}, {_blockY}, ({_blockZ} - 1) in world "world" is water:
set {_niceJump} to false
if block at location {_blockX}, {_blockY}, ({_blockZ} + 1) in world "world" is water:
set {_niceJump} to false
# pose du bloc (or si jump difficile + message, laine si normal)
set block at loop-value to wool
if {thimble.dead.%uuid of loop-value%} is not set:
if {_niceJump} is true:
set block at loop-value to gold block
set {_player} to userOrNick(loop-value)
loop {party.list::*}:
send "&a&l%{_player}%&r&e a réalisé un dé à coudre !" to loop-value-2
else:
delete {thimble.dead.%uuid of loop-value%}
# téléportation et feed/heal
teleport loop-value to {thimble.location}
feed loop-value
heal loop-value
on death:
if {thimble} is true:
if {party.player.%uuid of player%} is set:
cancel event
set gamemode of player to spectator
set {thimble.dead.%uuid of player%} to true
set {_finPartie} to 0
loop {party.list::*}:
if {thimble.dead.%uuid of loop-value%} is not set:
set {_gagnant} to userOrNick(loop-value)
add 1 to {_finPartie}
else:
set {_player} to userOrNick(loop-value)
send "&c%{_player}%&b a été éliminé !" to loop-value
if {_finPartie} is 1 or 0:
loop {party.list::*}:
if {_gagnant} is set:
send "&a&l%{_gagnant}%&r&l a gagné la partie !!" to loop-value
else:
send "&cTu étais tout seul à jouer... bravo quand même ?" to loop-value
execute player command "deacoudre"