• Anmelden

1

Mittwoch, 21. Oktober 2009, 12:18

Neues Inventar-Script mit 2 Slots

Hallo zusammen.
Ich hoffe Ihr könnt mir dabei Helfen.
Ich brauche ein Neues Inventar-Script(Nur für eine Person),mit dem ich beim drücken der ESC Taste sofort auf das Inventar komme.
(Status,Skills usw. wird nicht mehr gebraucht)
Sobald dieses Inventar aufgerufen wurde,möchte ich ein Inventar-Gegenstand auswählen und in einen der beiden Slots platzieren können.
Dieser Gegenstand im Slot soll später zb. mit X (Slot1) oder Y (Slot2) angewendet werden können.
Ich weiss,das ich sehr viel verlange.Trotzdem hoffe ich das jemand von Euch ein solches Script schreiben kann.
Oder mir anders dabei Helfen kann.
Ich habe ein Bild davon gemacht wie ich mir das ganze vorgestellt habe.
Attachment 10579
Realität ist auch nur eine Art von Rollenspiel.

2

Mittwoch, 21. Oktober 2009, 18:54

Ich hab mich mal dran versucht:
Mit Escape rufst du das Menü auf, mit A,S,D (die Buttons X,Y,Z) weißt du Items den Slots zu.
Auf der Karte kannst du sie dann benutzen sofern sie einnehmbar sind.
Es ist nicht vollständig getested, sollte aber klappen, Bugs bitte melden.
Scripts:
Spoiler: Änderungen an standard Klassen
Als neues Script über Main einfügen

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#==============================================================================
# ** Window_Help
#==============================================================================
class Window_Help < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x=0,y=0,w=640,h=64)
    super(x, y, w, h)
    self.contents = Bitmap.new(width - 32, height - 32)
  end
end
#==============================================================================
# ** Game_Party
#==============================================================================
class Game_Party
  attr_accessor( :item_in_slot )
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias_method( :initialize_ohne_playms_slotedit, :initialize)
  def initialize
    @item_in_slot = []
    initialize_ohne_playms_slotedit
  end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias_method( :main_ohne_playms_slotedit, :main)
  alias_method( :update_ohne_playms_slotedit, :update)
  BUTTON1 = Input::X
  BUTTON2 = Input::Y
  BUTTON3 = Input::Z
  def main
    @window_slots = Window_Slots.new
    @window_slots.x = 640-@window_slots.width
    @window_slots.y = 0
    main_ohne_playms_slotedit
    @window_slots.dispose
  end
  #--------------------------------------------------------------------------
  def update
    @window_slots.update
    if Input.trigger?(BUTTON1) then
      use_item_in(0)
    end
    if Input.trigger?(BUTTON2) then
      use_item_in(1)
    end
    if Input.trigger?(BUTTON3) then
      use_item_in(2)
    end
    update_ohne_playms_slotedit
  end
  #--------------------------------------------------------------------------
  def use_item_in(slot)
    if ($game_party.item_in_slot[slot] != nil) and 
      ($game_party.actors[0].item_effect($data_items[$game_party.item_in_slot[slot]]) == true) then
      $game_system.se_play($data_items[$game_party.item_in_slot[slot]].menu_se)
      $game_player.animation_id = $data_items[$game_party.item_in_slot[slot]].animation2_id
      $game_party.item_in_slot[slot] = nil
    else
      $game_system.se_play($data_system.buzzer_se)
    end
  end
  #--------------------------------------------------------------------------
end
zum Lesen den Text mit der Maus markieren

Spoiler: Windows
Die WindowKlassen auch als neues Script über Main einfügen

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#==============================================================================
# ** Window_Item2
#==============================================================================
class Window_Item2 < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 32+128, 32+160)
    @column_max = 4
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        $game_party.item_number(i).times{@data.push($data_items[i])}
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.size = 10
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 4 * 32
    y = index / 4 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # If cursor position is less than 0
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # Get current row
    row = @index / @column_max
    # If current row is before top row
    if row < self.top_row
      # Scroll so that current row becomes top row
      self.top_row = row
    end
    # If current row is more to back than back row
    if row > self.top_row + (self.page_row_max - 1)
      # Scroll so that current row becomes back row
      self.top_row = row - (self.page_row_max - 1)
    end
    # Calculate cursor coordinates
    x = @index % @column_max * 32
    y = @index / @column_max * 32 - self.oy
    # Update cursor rectangle
    self.cursor_rect.set(x, y, 32, 32)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.contents.font.size = 20
    @help_window.set_text(self.item == nil ? "" : "#{item.name}, #{self.item.description}")
  end
end
#==============================================================================
# ** Window_Slots
#==============================================================================
class Window_Slots < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(160, 64, 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.font.size = 16
    self.contents.draw_text( 0, 0, 32, 32, "Slot 1")
    self.contents.draw_text(32, 0, 32, 32, "Slot 2")
    self.contents.draw_text(64, 0, 32, 32, "Slot 3")
    z = 0
    for i in $game_party.item_in_slot
      draw_item($data_items[i],z) if i != nil
      z += 1
    end
    @slots = $game_party.item_in_slot.dup
  end
  def draw_item(item,z)
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt( z*32 + 4, 36, bitmap, Rect.new(0, 0, 24, 24), 255)
  end
  def update
    if @slots != $game_party.item_in_slot
      refresh
    end
  end
end
zum Lesen den Text mit der Maus markieren

Spoiler: Scene
Die neue Menu Scene, auch als neues Script über Main einfügen

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#==============================================================================
# ** Scene_Item_in_Slots_stecken
#    von Playm
#==============================================================================
class Scene_Menu
  BUTTON1 = Input::X
  BUTTON2 = Input::Y
  BUTTON3 = Input::Z
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    #Creat Mapscreen
    @spriteset = Spriteset_Map.new
    # Make help window, item window
    @help_window = Window_Help.new(0,0,320,64)
    @item_window = Window_Item2.new
    @item_window.y += 64
    @window_slots = Window_Slots.new
    # Associate help window
    @item_window.help_window = @help_window
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @item_window.dispose
    @window_slots.dispose
    @spriteset.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @item_window.update
    @window_slots.update
    update_item
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_item
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Map.new
      return
    end
    # If button was pressed
    if Input.trigger?(BUTTON1)
      item_in_slot(0)
    end
    if Input.trigger?(BUTTON2)
      item_in_slot(1)
    end
    if Input.trigger?(BUTTON3)
      item_in_slot(2)
    end
  end
  #--------------------------------------------------------------------------
  # * Item in Slot[slot_nr] setzen
  #--------------------------------------------------------------------------
  def item_in_slot(slot_nr)
    # Get currently selected data on the item window
    @item = @item_window.item
    # If it can't be used
    unless $game_party.item_can_use?(@item.id)
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    if $game_party.item_in_slot[slot_nr] == nil
      $game_party.item_in_slot[slot_nr] = @item.id
    else
      $game_party.gain_item($game_party.item_in_slot[slot_nr],1)
      $game_party.item_in_slot[slot_nr] = @item.id
    end
    $game_party.lose_item(@item.id,1)
    @item_window.refresh
    return
  end
  #--------------------------------------------------------------------------
end
zum Lesen den Text mit der Maus markieren


Ich hoffe das ist das was du suchst.

3

Mittwoch, 21. Oktober 2009, 19:13

Re:

Boah Playm.
Habe ich schon erwähnt das du der Beste bist.
Ich habe die Scripts getestet und es funktioniert einwandfrei.
Ein Super großes Dankeschön an dich.
Sollten noch Fehler auftauchen melde ich mich bei dir.
MFG
Realität ist auch nur eine Art von Rollenspiel.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Asandril« (1. November 2009, 02:23)


4

Sonntag, 1. November 2009, 02:33

Re:

Hallo Playm.
Leider hab ich beim 'Inventar Script mit 2 Slots' festgestellt,sobald ich ein Item im Slot habe das mit einem Common Event verknüpft ist und ich es benutzen will,passiert dann leider nichts.Das heisst er führt von diesem Item nicht den Common Event befehl aus.Das zweite was ich bemerkt habe,obwohl ich das Item als nicht Consumable eingestellt habe verschwindet dieser trotzdem aus dem Slot.
Ich habe dir eine Demo angehängt,damit du dir ein besseres Bild davon machen kannst.
Ich hoffe du kannst mir dabei helfen.
MFG
Demo Update 2.11.09
Demo.rar
Realität ist auch nur eine Art von Rollenspiel.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Asandril« (2. November 2009, 19:25)


5

Sonntag, 1. November 2009, 14:24

Ups, berichtigt
Spoiler: Code
als neues Script über Main einfügen

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # * Methode um Items auf der Map zu benutzen
  #--------------------------------------------------------------------------
  def use_item_in(slot)
    # Variablen
    item = $data_items[$game_party.item_in_slot[slot]];
    #Bedingung1: Item vorhanden; Bedingung2: Der Held kann es benutzen;
    bedingung1 = ( $game_party.item_in_slot[slot] != nil   )
    bedingung2 = ( $game_party.actors[0].item_effect(item) )
    # Abfrage
    if (bedingung1 and bedingung2) then
      $game_system.se_play(item.menu_se);
      $game_player.animation_id = item.animation2_id;
      if(item.common_event_id > 0)then
        # Common Event aufrufen
        $game_temp.common_event_id = item.common_event_id;
      end
      # Wenn es konsumierbar ist, entferne es nach dem Benutzen
      if(item.consumable)then;$game_party.item_in_slot[slot] = nil;end
    else
      $game_system.se_play($data_system.buzzer_se)
    end
  end
  #--------------------------------------------------------------------------
end
zum Lesen den Text mit der Maus markieren

6

Sonntag, 1. November 2009, 14:32

Re:

Klasse.
Danke Playm.Jetzt funktioniert es.
Sollte nochmal ein Problem damit auftauchen meld ich mich sofort bei dir.
MFG
Realität ist auch nur eine Art von Rollenspiel.

7

Montag, 2. November 2009, 19:20

Re:

Hi Playm.
Ich mal wieder.
Ich habe bemerkt sobald ich bei meinen Slots A,S oder D drücke und noch kein Item im Slot vorhanden ist,
zeigt er mir diesen Fehler an :
Attachment 10677
Ich habe die Demo Oben erneuert mit deinem neuen Script,damit du dir wieder ein besseres Bild von machen kannst.

Ich hoffe du kannst mir wieder einmal dabei helfen.
MFG
Realität ist auch nur eine Art von Rollenspiel.

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »Asandril« (2. November 2009, 19:29)


8

Montag, 2. November 2009, 19:51

=/
Tut mir leid, ich hätte das Script genauer testen sollen, ersetz den Part4 mit dem hier:
Spoiler: Code
neuer Teil4

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # * Methode um Items auf der Map zu benutzen
  #--------------------------------------------------------------------------
  def use_item_in(slot)
    # Breche ab, wenn der Slot leer ist
    if($game_party.item_in_slot[slot] == nil) then
      $game_system.se_play($data_system.buzzer_se);return;
    end
    # Variablen
    item = $data_items[$game_party.item_in_slot[slot]];
    # Abfrage
 
    if( $game_party.actors[0].item_effect(item) ) then
      $game_system.se_play(item.menu_se);
      $game_player.animation_id = item.animation2_id;
      if(item.common_event_id > 0)then
        # Common Event aufrufen
        $game_temp.common_event_id = item.common_event_id;
      end
      # Wenn es konsumierbar ist, entferne es nach dem Benutzen
      if(item.consumable)then;$game_party.item_in_slot[slot] = nil;end
    else
      $game_system.se_play($data_system.buzzer_se)
    end
  end
  #--------------------------------------------------------------------------
end
zum Lesen den Text mit der Maus markieren
Ich hoffe diesmal klappt es ^^"

9

Montag, 2. November 2009, 23:13

Re:

Hi Playm.
Danke das du dir noch mal die Mühe gemacht hast und nachgeschaut hast.
Nach einigen Tests habe ich auch keine anderen Fehler mehr festgestellt.
Danke nochmals.
MFG
Realität ist auch nur eine Art von Rollenspiel.

Social Bookmarks