PX_007 Posté(e) le 27 août 2016 Posté(e) le 27 août 2016 Bonjour à tous. Je suis actuellement dans le développement d'un QuakeCraft mais bloquant sur quelque chose je fais appel à vous dans l'espoir que quelqu'un puisse me venir en aide :) Pour vous expliquer le principe: je cherche à créer un délai entre 2 tirs avec le railgun (par exemple 1 seconde par tir) Jusque là rien de bien sorcier. Mais ça se complique un peu car en fonction du railgun de la personne le délai serait plus ou moins long. Là aussi j'ai réussi à faire un délai. Le problème que je rencontre est que je n'arrive pas à faire une progression du niveau d'xp en fonction du délai qui se base sur le raigun. Par exemple: Si le joueur a un railgun en diamant, le délai serait d'une seconde et la barre d'xp se remplierait significativement en 1 seconde de 0 à 0.99999 (et non 1 car cela compte 1 lvl) Par contre si le joueur à un raigun en bois et que le délai est de 1.5 secondes, la barre d'xp se remplierait significativement en 1.5 seconde. Mais je n'ai pas réussi à trouver un moyen que la barre se remplisse de 0 à 0.99999 en fonction du cooldown défini pour chaque railgun. C'est pourquoi je fais appel à la communauté dans l'espoir de trouver quelqu'un pour m'aider :) Je vous donne le code que j'utilise on right click: if player is holding diamond hoe or gold hoe or stone hoe or iron hoe or wooden hoe: if player is holding diamond hoe: set {_wait} to 0.5 second if player is holding gold hoe: set {_wait} to 1.05 second if player is holding iron hoe: set {_wait} to 1.1 second if player is holding stone hoe: set {_wait} to 1.15 second if player is holding wooden hoe: set {_wait} to 1.2 second cancel event set {_fire} to difference between {fire.%player%.lastused} and now#ICI je regarde le temps de recharge if {_fire} is less than {_wait}: stop else: set {fire.%player%.lastused} to now set {_location.1} to location of player set {_location.2} to location of targeted block increase y-coordinate of {_location.1} by 1 set {_x.1} to x-coordinate of {_location.1} set {_x.2} to x-coordinate of {_location.2} set {_y.1} to y-coordinate of {_location.1} set {_y.2} to y-coordinate of {_location.2} set {_z.1} to z-coordinate of {_location.1} set {_z.2} to z-coordinate of {_location.2} set {_x.difference} to ({_x.2} - {_x.1}) / 100 set {_y.difference} to ({_y.2} - {_y.1}) / 100 set {_z.difference} to ({_z.2} - {_z.1}) / 100 play raw sound "fireworks.launch" at player with pitch 1 volume 500 loop 100 times: increase x-coordinate of {_location.1} by {_x.difference} increase y-coordinate of {_location.1} by {_y.difference} increase z-coordinate of {_location.1} by {_z.difference} if player is holding diamond hoe: execute console command "particle flame %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding gold hoe: execute console command "particle reddust %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding iron hoe: execute console command "particle mobSpell %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding stone hoe: execute console command "particle portal %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding wooden hoe: execute console command "particle smoke %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" damage target entity by 0.1 set level progress of player to 0 loop 18 times: add 0.05 to level progress of player set level progress of player to 0.9 wait {_wait} set level progress of player to 0.99999 Merci d'avance :) PS: Ne m'y connaissant pas beaucoup sur les functions je n'ai pas essayé d'en faire une pour les délais
blueblasterz Posté(e) le 28 août 2016 Posté(e) le 28 août 2016 C'est pas forcément la solution la plus optimisée, mais tu peux définir une manière de remplir la barre d'xp différente pour chaque rail gun, comme ça tu peux bien remplir en 1s, 1,5s etc. Peux tu me donner les temps de rechargement de chacuns de tes rail gun ? Je vais essayer de te faire quelque chose :)
Gaël Erhlich Posté(e) le 28 août 2016 Posté(e) le 28 août 2016 Tu peux mettre un coefficient que tu définis au début de l'opération en fonction de la houe que tu as dans la main.
blueblasterz Posté(e) le 29 août 2016 Posté(e) le 29 août 2016 options: wDiam : 1 wGold : 1.25 wIron : 1.50 wStone : 1.75 wWood : 2 on right click: if player is holding diamond hoe or gold hoe or stone hoe or iron hoe or wooden hoe: if player is holding diamond hoe: set {_wait} to {@wDiam} second if player is holding gold hoe: set {_wait} to {@wGold} second if player is holding iron hoe: set {_wait} to {@wIron} second if player is holding stone hoe: set {_wait} to {@wStone} second if player is holding wooden hoe: set {_wait} to {@wWood} second cancel event set {_fire} to difference between {fire.%player%.lastused} and now#ICI je regarde le temps de recharge if {_fire} is less than {_wait}: stop else: set {fire.%player%.lastused} to now set {_location.1} to location of player set {_location.2} to location of targeted block increase y-coordinate of {_location.1} by 1 set {_x.1} to x-coordinate of {_location.1} set {_x.2} to x-coordinate of {_location.2} set {_y.1} to y-coordinate of {_location.1} set {_y.2} to y-coordinate of {_location.2} set {_z.1} to z-coordinate of {_location.1} set {_z.2} to z-coordinate of {_location.2} set {_x.difference} to ({_x.2} - {_x.1}) / 100 set {_y.difference} to ({_y.2} - {_y.1}) / 100 set {_z.difference} to ({_z.2} - {_z.1}) / 100 play raw sound "fireworks.launch" at player with pitch 1 volume 500 loop 100 times: increase x-coordinate of {_location.1} by {_x.difference} increase y-coordinate of {_location.1} by {_y.difference} increase z-coordinate of {_location.1} by {_z.difference} if player is holding diamond hoe: execute console command "particle flame %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding gold hoe: execute console command "particle reddust %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding iron hoe: execute console command "particle mobSpell %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding stone hoe: execute console command "particle portal %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding wooden hoe: execute console command "particle smoke %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" damage target entity by 0.1 set level progress of player to 0 set {_t} to "%{_wait}%" set {_temp::*} to {_t} split by " " set {_loopV} to "%{_temp::1} parsed as number * 2% ticks" parsed as timespan loop 10 times: if level progress of player is smaller than 0.9: add 0.099 to level progress of player wait {_loopV} else: stop trigger 2 changements dans ton code: - j'ai mis les cooldown en option, comme ça tu pourras les modifier facilement (d'ailleur j'ai modifié ceux que tu avais mis pour bien voir la différence de rechargement) -A l'aide d'un petit calcul je recharge la barre d'xp en 10 fois, en calculant combien de temps on attend entre chaque fois. Toutes les variables que j'ai utilisées sont temporaires, de plus j'ai ajouté une condition qui empêche le joueur de gagner un niveau. Ce calcule marche selon ta variable {_wait}. Note tout de même que la barre sera parfois rechargée un tout petit peu avant que le joueur puisse tirer une nouvelle fois, la faute à Skript et ses arrondis x) Voilà voilà j'ai pris mon temps mais au moins ça marche :)
PX_007 Posté(e) le 29 août 2016 Auteur Posté(e) le 29 août 2016 options: wDiam : 1 wGold : 1.25 wIron : 1.50 wStone : 1.75 wWood : 2 on right click: if player is holding diamond hoe or gold hoe or stone hoe or iron hoe or wooden hoe: if player is holding diamond hoe: set {_wait} to {@wDiam} second if player is holding gold hoe: set {_wait} to {@wGold} second if player is holding iron hoe: set {_wait} to {@wIron} second if player is holding stone hoe: set {_wait} to {@wStone} second if player is holding wooden hoe: set {_wait} to {@wWood} second cancel event set {_fire} to difference between {fire.%player%.lastused} and now#ICI je regarde le temps de recharge if {_fire} is less than {_wait}: stop else: set {fire.%player%.lastused} to now set {_location.1} to location of player set {_location.2} to location of targeted block increase y-coordinate of {_location.1} by 1 set {_x.1} to x-coordinate of {_location.1} set {_x.2} to x-coordinate of {_location.2} set {_y.1} to y-coordinate of {_location.1} set {_y.2} to y-coordinate of {_location.2} set {_z.1} to z-coordinate of {_location.1} set {_z.2} to z-coordinate of {_location.2} set {_x.difference} to ({_x.2} - {_x.1}) / 100 set {_y.difference} to ({_y.2} - {_y.1}) / 100 set {_z.difference} to ({_z.2} - {_z.1}) / 100 play raw sound "fireworks.launch" at player with pitch 1 volume 500 loop 100 times: increase x-coordinate of {_location.1} by {_x.difference} increase y-coordinate of {_location.1} by {_y.difference} increase z-coordinate of {_location.1} by {_z.difference} if player is holding diamond hoe: execute console command "particle flame %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding gold hoe: execute console command "particle reddust %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding iron hoe: execute console command "particle mobSpell %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding stone hoe: execute console command "particle portal %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" else if player is holding wooden hoe: execute console command "particle smoke %x-coordinate of {_location.1}% %y-coordinate of {_location.1}% %z-coordinate of {_location.1}% 0 0 0 0 1 force" damage target entity by 0.1 set level progress of player to 0 set {_t} to "%{_wait}%" set {_temp::*} to {_t} split by " " set {_loopV} to "%{_temp::1} parsed as number * 2% ticks" parsed as timespan loop 10 times: if level progress of player is smaller than 0.9: add 0.099 to level progress of player wait {_loopV} else: stop trigger 2 changements dans ton code: - j'ai mis les cooldown en option, comme ça tu pourras les modifier facilement (d'ailleur j'ai modifié ceux que tu avais mis pour bien voir la différence de rechargement) -A l'aide d'un petit calcul je recharge la barre d'xp en 10 fois, en calculant combien de temps on attend entre chaque fois. Toutes les variables que j'ai utilisées sont temporaires, de plus j'ai ajouté une condition qui empêche le joueur de gagner un niveau. Ce calcule marche selon ta variable {_wait}. Note tout de même que la barre sera parfois rechargée un tout petit peu avant que le joueur puisse tirer une nouvelle fois, la faute à Skript et ses arrondis x) Voilà voilà j'ai pris mon temps mais au moins ça marche :) J'ai testé et tout marche bien ! Merci beaucoup d'avoir pris le temps de m'aider :) 1
Messages recommandés