RPG Creator : créez votre MMORPG ou RPG sans aucune connaissance en programmation
Disponible le 4 Juin !
- Jouez à votre jeu sur tablettes tactiles, Smartphones et navigateurs Web
- Personnalisez vos menus
- Dessinez facilement et rapidement vos cartes
- Créez des actions pour le combat A-RPG
Salut, je partage avec vous un script pour assigner un poids aux objets, et fixer une limite au poids que peut porter le joueur. Ce script a été créé par Tidloc avec l'aide d'Albertfish, puis corrigé, amélioré et traduit par moi, pifou92000. Si vous l'utilisez, ces 3 pseudos sont nécessaires dans les credits du projet.
EDIT : excusez, c'est mon premier message ici et je crois que je suis pas vraiment dans la bonne section. C'est un partage de script, pas un tuto sur les scripts. Si un modo passe par là ça serait sympa de le déplacer.
I - Présentation
Avec ce script, vous pourrez fixer un poids à chaque objet, arme et armure du jeu. Vous pourrez définir le poids maximum que peut porter le joueur, et le modifier par la suite. Le joueur jeter les objets depuis le menu. Lorsqu'il portera trop de choses, le personnage sera ralenti, et un interrupteur s'activera si vous le désirez (voir dans le script). J'ai ajouté deux fonctions en plus de traduire et corriger les bugs, elles sont toutes les deux désactivables : 1) Les objets ayant un prix de 0 (objets impossibles à vendre) ne pourront pas non plus être jetés. 2) Le poids de l'équipement des personnages comptera dans le poids porté, au lieu de compter seulement le poids dans l'inventaire.
Je tiens à préciser que je suis plus un bidouilleur qu'un vrai scripteur, je procède par essai. Il est donc possible qu'il y ait des bugs. Si vous en rencontrez un, merci de me le signaler. Si vous voulez la version originale (attention aux bugs), c'est ici !
II - Installation/réglages
Créez un nouveau script au-dessus de Main, que vous pouvez appeler comme bon vous semble. Mettez-y le code suivant :
################################################################################ # >>> Script de poids <<< # # créé par Tidloc avec l'aide d'Albertfish # # corrigé, amélioré et traduit par pifou92000 # ################################################################################ # Ce script autorise le joueur à porter uniquemement un poids limité. # # Pour définir le poids d'un objet, arme ou armure, il suffit de mettre # # \w<POIDS> dans sa description. S'il n'y a pas de poids entré, le poids de # # cet objet vaudra zéro. Lorsque le joueur portera un poids trop élevé, # # il marchera moins vite. # # Lien du script avant les modifications de pifou92000 : # # http://rmrk.net/index.php/topic,36737.0.html # ################################################################################ # Pour changer la limite pendant le jeu, utilisez la commande suivante : # # $game_temp._tidloc_groupweight_max = NOUVELLE VALEUR # ################################################################################ # Ce script est libre d'utilisation, mais merci d'ajouter aux credits : # # Tidloc, Albertfish, et pifou92000. # ################################################################################
TIDLOC_GROUPWEIGHT_MAX = 10 # poids maximum que le joueur peut porter. # Au-delà de ce poids, il sera ralenti.
TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH = 1 # interrupteur activé si la limite de # poids est dépassée. Mettez 0 pour # qu'aucun interrupteur ne soit activé.
for i in 1...$data_items.size if $data_items[i].description[0] != nil text = $data_items[i].description text2 = "" text.gsub!(/\\w<([0-9]+)>/) {"\1[#{$1}]"} while ((c = text.slice!(/./m)) != nil) if c != "\1" text2 += c else text.sub!(/\[([_A-Za-z0-9-]+)\]/, "") self._tidloc_itemweight[i]=$1.to_i end end $data_items[i].description = text2 end self._tidloc_itemweight[i] = 0 if self._tidloc_itemweight[i].nil? end for i in 1...$data_weapons.size if $data_weapons[i].description[0] != nil text = $data_weapons[i].description text2 = "" text.gsub!(/\\w<([0-9]+)>/) {"\1[#{$1}]"} while ((c = text.slice!(/./m)) != nil) if c != "\1" text2 += c else text.sub!(/\[([_A-Za-z0-9-]+)\]/, "") self._tidloc_weaponweight[i]=$1.to_i end end $data_weapons[i].description = text2 end self._tidloc_weaponweight[i] = 0 if self._tidloc_weaponweight[i].nil? end for i in 1...$data_armors.size if $data_armors[i].description[0] != nil text = $data_armors[i].description text2 = "" text.gsub!(/\\w<([0-9]+)>/) {"\1[#{$1}]"} while ((c = text.slice!(/./m)) != nil) if c == "\1" text.sub!(/\[([_A-Za-z0-9-]+)\]/, "") self._tidloc_armorweight[i]=$1.to_i else text2 += c end end $data_armors[i].description = text2 end self._tidloc_armorweight[i] = 0 if self._tidloc_armorweight[i].nil? end end
def _tidloc_pweight(new_weight=TIDLOC_GROUPWEIGHT_MAX) self._tidloc_groupweight_max = new_weight end end
class Game_Party def tidloc_slowing(slow=true) # Si le joueur est ralenti : if slow $game_player.tidloc_alt_speed -1 else $game_player.tidloc_alt_speed 1 end end
alias tidloc_iweight_item gain_item def gain_item(item_id, n, equip=false) if item_id > 0 && !equip $game_temp._tidloc_groupweight += $game_temp._tidloc_itemweight[item_id] * ([[item_number(item_id) + n, 0].max, 99].min - item_number(item_id)) end # Si le groupe porte trop lourd : if $game_temp._tidloc_groupweight > $game_temp._tidloc_groupweight_max && !$game_temp._tidloc_iweight_slow $game_temp._tidloc_iweight_slow = true $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, true) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1 tidloc_slowing tidloc_iweight_item(item_id, n) elsif $game_temp._tidloc_groupweight <= $game_temp._tidloc_groupweight_max && $game_temp._tidloc_iweight_slow $game_temp._tidloc_iweight_slow = false $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, false) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1 tidloc_slowing false tidloc_iweight_item(item_id, n) else tidloc_iweight_item(item_id, n) end end
alias tidloc_iweight_weap gain_weapon def gain_weapon(weapon_id, n, equip=false) if weapon_id > 0 && !equip $game_temp._tidloc_groupweight += $game_temp._tidloc_weaponweight[weapon_id] * ([[weapon_number(weapon_id) + n, 0].max, 99].min - weapon_number(weapon_id)) end if $game_temp._tidloc_groupweight > $game_temp._tidloc_groupweight_max && !$game_temp._tidloc_iweight_slow $game_temp._tidloc_iweight_slow = true $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, true) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1 tidloc_slowing tidloc_iweight_weap(weapon_id, n) elsif $game_temp._tidloc_groupweight <= $game_temp._tidloc_groupweight_max && $game_temp._tidloc_iweight_slow $game_temp._tidloc_iweight_slow = false $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, false) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1 tidloc_slowing false tidloc_iweight_weap(weapon_id, n) else tidloc_iweight_weap(weapon_id, n) end end
alias tidloc_iweight_arm gain_armor def gain_armor(armor_id, n, equip=false) if armor_id > 0 && !equip $game_temp._tidloc_groupweight += $game_temp._tidloc_armorweight[armor_id] * ([[armor_number(armor_id) + n, 0].max, 99].min - armor_number(armor_id)) end if $game_temp._tidloc_groupweight > $game_temp._tidloc_groupweight_max && !$game_temp._tidloc_iweight_slow $game_temp._tidloc_iweight_slow = true $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, true) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1 tidloc_slowing tidloc_iweight_arm(armor_id, n) elsif $game_temp._tidloc_groupweight <= $game_temp._tidloc_groupweight_max && $game_temp._tidloc_iweight_slow $game_temp._tidloc_iweight_slow = false $game_switches.[]=(TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH, false) if TIDLOC_GROUPWEIGHT_MAXWEIGHT_SWITCH != -1 tidloc_slowing false tidloc_iweight_arm(armor_id, n) else tidloc_iweight_arm(armor_id, n) end end end
class Game_Player def tidloc_set_speed(speed=4) @move_speed = speed end
def tidloc_alt_speed(speed=0) @move_speed += speed end end
class Scene_Item alias _tidloc_iweight_main main def main @todo_window = Window_Command.new(100, ["Utiliser", "Jeter"]) @todo_window.x = 160 @todo_window.active = false @todo_window.visible = false @todo_window.z = 300 _tidloc_iweight_main @todo_window.dispose end
alias _tidloc_iweight_update update def update @todo_window.update if @todo_window.active == true update_todo return end _tidloc_iweight_update end
alias _tidloc_iweight_item update_item def update_item if Input.trigger?(Input::C) @item = @item_window.item @item_window.active = false @todo_window.visible = true @todo_window.active = true return end _tidloc_iweight_item end
def update_todo if Input.trigger?(Input::B) @todo_window.active = false @todo_window.visible = false @item_window.active = true return end if Input.trigger?(Input::C) @todo_window.active = false @todo_window.visible = false @item_window.active = true if @todo_window.index == 0 unless @item.is_a?(RPG::Item) $game_system.se_play($data_system.buzzer_se) return end unless $game_party.item_can_use?(@item.id) $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) if @item.scope >= 3 @item_window.active = false @target_window.x = (@item_window.index + 1) % 2 * 304 @target_window.visible = true @target_window.active = true if @item.scope == 4 || @item.scope == 6 @target_window.index = -1 else @target_window.index = 0 end else if @item.common_event_id > 0 $game_temp.common_event_id = @item.common_event_id $game_system.se_play(@item.menu_se) if @item.consumable $game_party.lose_item(@item.id, 1) @item_window.draw_item(@item_window.index) end $scene = Scene_Map.new return # Si vous voulez pouvoir jeter end # tous les objets, même les objets end # de quête (qui ont prix = 0), return # supprimez les lignes indiquées : else if @item.is_a?(RPG::Item) if $data_items[@item.id].price == 0 # celle-ci $game_system.se_play($data_system.buzzer_se) # celle-ci else # celle-ci $game_system.se_play($data_system.decision_se) $game_party.gain_item(@item.id,-1) end # celle-ci elsif @item.is_a?(RPG::Weapon) if $data_weapons[@item.id].price == 0 # celle-ci $game_system.se_play($data_system.buzzer_se) # celle-ci else # celle-ci $game_system.se_play($data_system.decision_se) $game_party.gain_weapon(@item.id,-1) end # celle-ci elsif @item.is_a?(RPG::Armor) if $data_armors[@item.id].price == 0 # celle-ci $game_system.se_play($data_system.buzzer_se) # celle-ci else # celle-ci $game_system.se_play($data_system.decision_se) $game_party.gain_armor(@item.id,-1) end # celle-ci end @item_window.refresh return end end end end
class Scene_Shop alias _tidloc_iweight_buy update_buy def update_buy _tidloc_iweight_buy if Input.trigger?(Input::C) @item = @buy_window.item if @item == nil or @item.price > $game_party.gold $game_system.se_play($data_system.buzzer_se) return end case @item when RPG::Item number = $game_party.item_number(@item.id) max2 = $game_temp._tidloc_itemweight[@item.id] when RPG::Weapon number = $game_party.weapon_number(@item.id) max2 = $game_temp._tidloc_weaponweight[@item.id] when RPG::Armor number = $game_party.armor_number(@item.id) max2 = $game_temp._tidloc_armorweight[@item.id] end if number == 99 $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) max = @item.price == 0 ? 99 : $game_party.gold / @item.price max2 = ($game_temp._tidloc_groupweight_max - $game_temp._tidloc_groupweight) / max2 max = [max, 99 - number, max2].min @buy_window.active = false @buy_window.visible = false @number_window.set(@item, max, @item.price) @number_window.active = true @number_window.visible = true end end end class Scene_Equip def update_item if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @right_window.active = true @item_window.active = false @item_window.index = -1 return end if Input.trigger?(Input::C) $game_system.se_play($data_system.equip_se) item = @item_window.item @actor.equip(@right_window.index, item == nil ? 0 : item.id, true) @right_window.active = true @item_window.active = false @item_window.index = -1 @right_window.refresh @item_window.refresh return end end end
class Game_Actor < Game_Battler def equip(equip_type, id, equip = false) case equip_type when 0 if id == 0 or $game_party.weapon_number(id) > 0 # Si vous ne voulez pas que le poids $game_party.gain_weapon(@weapon_id, 1, equip) # des objets équipés compte dans le @weapon_id = id # poids porté, supprimez tous les $game_party.gain_weapon(id, -1, equip) # ", equip" de cette class. end when 1 if id == 0 or $game_party.armor_number(id) > 0 update_auto_state($data_armors[@armor1_id], $data_armors[id]) $game_party.gain_armor(@armor1_id, 1, equip) @armor1_id = id $game_party.gain_armor(id, -1, equip) end when 2 if id == 0 or $game_party.armor_number(id) > 0 update_auto_state($data_armors[@armor2_id], $data_armors[id]) $game_party.gain_armor(@armor2_id, 1, equip) @armor2_id = id $game_party.gain_armor(id, -1, equip) end when 3 # ?? if id == 0 or $game_party.armor_number(id) > 0 update_auto_state($data_armors[@armor3_id], $data_armors[id]) $game_party.gain_armor(@armor3_id, 1, equip) @armor3_id = id $game_party.gain_armor(id, -1, equip) end when 4 # ??? if id == 0 or $game_party.armor_number(id) > 0 update_auto_state($data_armors[@armor4_id], $data_armors[id]) $game_party.gain_armor(@armor4_id, 1, equip) @armor4_id = id $game_party.gain_armor(id, -1, equip) end end end end
Il faut ensuite sauvegarder le poids porté, et le poids maximum, chose à laquelle l'auteur n'avait pas pensé. Dans Scene_Save, mettez à la ligne 77 :
Voilà, c'est installé. Maintenant, comment le personnaliser ? Déjà, vous pouvez si vous le souhaitez désactiver les options dont je vous ai parlé dans la partie "Présentation". Vous avez des informations pour cela aux lignes 261 et 359 du script. Pour modifier le poids maximum de départ, c'est à la ligne 22. Pour changer l'interrupteur qui s'active quand le poids porté est trop élevé, c'est à la ligne 25.
Si vous voulez afficher le poids porté dans le menu à la place du nombre de pas (optionnel), remplacez Window_Steps par ceci :
#============================================================================== # ** Window_Steps #------------------------------------------------------------------------------ # This window displays step count on the menu screen. #==============================================================================
C'est bien beau d'avoir installé un script, mais encore faut-il savoir s'en servir ! Pour assigner un poids à un objet/arme/armure, mettez dans la description de cet objet : \w<POIDS> en remplaçant bien évidemment "POIDS" par le poids souhaité de cet objet (un nombre entier et positif !). Le calcul du poids porté se fera automatiquement après que le joueur trouve un objet, l'achète ou le gagne en combat. Si le joueur possède déjà des objets équipés au début du jeu, il faut utiliser la commande : $game_temp._tidloc_groupweight += SOMME en remplaçant "SOMME" par la somme des poids des équipements de tous les personnages au début du jeu.
Si vous voulez modifier le poids maximum qui peut être transporté, utilisez dans la commande d'événement "script" : $game_temp._tidloc_groupweight_max = NOMBRE pour que le poids maximum soit égal à la valeur "NOMBRE". $game_temp._tidloc_groupweight_max += NOMBRE pour ajouter la valeur "NOMBRE" au poids maximum. $game_temp._tidloc_groupweight_max -= NOMBRE pour soustraire la valeur "NOMBRE" au poids maximum.
Attention : Après cette modification, il n'y a pas de rafraîchissement automatique : il faut donner un objet au joueur pour qu'il se rende compte que la variable de poids maximum a changé. Il vous suffit donc de donner un objet au joueur et de lui reprendre, juste après le changement de la variable.
Utilisateurs parcourant actuellement ce forum : Aucun utilisateur inscrit et 3 invités
Vous ne pouvez pas publier de nouveaux sujets dans ce forum Vous ne pouvez pas répondre aux sujets dans ce forum Vous ne pouvez pas éditer vos messages dans ce forum Vous ne pouvez pas supprimer vos messages dans ce forum Vous ne pouvez pas insérer de pièces jointes dans ce forum