Day.png);">
Apprendre


Vous êtes
nouveau sur
Oniromancie?

Visite guidée
du site


Découvrir
RPG Maker

RM 95
RM 2000/2003
RM XP
RM VX/VX Ace
RM MV/MZ

Apprendre
RPG Maker

Tutoriels
Guides
Making-of

Dans le
Forum

Section Entraide

Sorties: "Dread Mac Farlane", (...) / Tutos: Checklist de la composition (...) / Sorties: Dread Mac Farlane - episode 8 / Sorties: Dread Mac Farlane - episode 7 / Jeux: Ce qui vit Dessous / Chat

Bienvenue
visiteur !




publicité RPG Maker!

Statistiques

Liste des
membres


Contact

Mentions légales

310 connectés actuellement

29415783 visiteurs
depuis l'ouverture

8323 visiteurs
aujourd'hui



Barre de séparation

Partenaires

Indiexpo

Akademiya RPG Maker

Blog Alioune Fall

Fairy Tail Constellations

Hellsoft

Level Up!

Zarok

Kingdom Ultimate

Tashiroworld

Tous nos partenaires

Devenir
partenaire



Limited Inventory 1.1c

Permet d'avoir une limite différente pour chaque objet dans le menu Objets par défaut et d'ajouter l'option "ne peut pas être jeté".

Script pour RPG Maker VX
Ecrit par modern algebra (site de l'auteur)
Publié par cari974 (lui envoyer un message privé)
Signaler un script cassé

❤ 0

Auteur : modern algebra
Logiciel : RPG Maker VX
Nombre de scripts : 1
Source : https://rmrk.net/index.php/topic,32918.0.html

Conditions d'utilisation
Ce script est sous la licence Creative Commons Attribution - Non Commercial - Share Alike 2.5 Canada.
Vous pouvez :
- Utiliser le matériel pour un usage personnel
- Utiliser le matériel à des fins non commerciales
- Redistribuer le matériel sous les mêmes conditions

Vous devez :
- Créditer l'auteur (modern algebra)

Vous ne pouvez pas :
- Vendre ce matériel tel quel ou comme constituant d'un produit.

Installation
Placer le script eu dessus de Main.

Portion de code : Tout sélectionner

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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
#==============================================================================
#  Limited Inventory
#  Version: 1.1c
#  Author: modern algebra
#  Date: September 27, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#    This script allows you to set an inventory limit to how many item slots
#   your inventory can hold. It allows some items to be stackable, and you can
#   also set items to be undiscardable
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    Place this script above Main and below other custom scripts.
#
#    To set a number of the default conditions for this script, please see the 
#   Editable Regions at 53, 84, and 109. Be sure to read the comments next to 
#   each consant to see what it does.
#
#    To set an item as non-discardable, put this command into its note box:
#
#      \NONDISCARD
#
#    To set an item to have a stack size different from the default, use this 
#   command in its note box:
# 
#      \STACKMAX[x]
#
#   where x is and integer and the new maximum stack size for that item.
#
#    To resize the party inventory in-game, say after an event where the get a
#   new backpack or whatever, then all you need to do is put this code into a 
#   call script:
#
#      resize_inventory (x)
#   
#   where x is an integer and the new number of slots in the party inventory.
#==============================================================================
 
#==============================================================================
# *** Vocab
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constants  - MA_LOOT_LABEL, MA_COMMAND_DISCARD, MA_COMMAND_EXCHANGE,
#                   MA_AMOUNT_PREFIX, MA_COMMAND_USE, MA_COMMAND_DESTROY,
#                   MA_WARNING_LABEL, MA_WARNING_YES, MA_WARNING_NO
#==============================================================================
 
module Vocab
  #==========================================================================
  # * Constants
  #==========================================================================
  #//////////////////////////////////////////////////////////////////////////
  # EDITABLE REGION
  #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  MA_AMOUNT_PREFIX = "x"           # Prefix before item amount in each stack
  MA_LOOT_LABEL = "Loot"           # Label for Discard Pile items
  MA_COMMAND_DISCARD = "Discard"   # Command to discard items
  MA_COMMAND_EXCHANGE = "Exchange" # Command to switch loot item with party item
  MA_COMMAND_TAKE = "Take"         # Command to take from Loot pile
  MA_COMMAND_USE = "Use"           # Command to Use an item
  MA_COMMAND_DESTROY = "Destroy"   # Command to completely destroy item
  # Question printed when deciding whether or not to leave inventory when loot
  # still has items in it
  MA_WARNING_LABEL = "#{MA_COMMAND_DESTROY} all items in #{MA_LOOT_LABEL}?"
  MA_WARNING_YES = "Yes"           # Command to Leave inventory when warned
  MA_WARNING_NO = "No"             # Command to stay in inventory when warned.
  #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  # END EDITABLE REGION
  #//////////////////////////////////////////////////////////////////////////
end
 
#==============================================================================
# *** Sound
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constants  - MA_DISCARD_SE, MA_EXCHANGE_SE, MA_TAKE_SE, MA_DESTROY_SE
#==============================================================================
 
module Sound
  #==========================================================================
  # * Constants
  #==========================================================================
  #//////////////////////////////////////////////////////////////////////////
  # EDITABLE REGION
  #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  MA_DISCARD_SE = "Move"   # SE played when discarding item from inventory
  MA_EXCHANGE_SE = "Move"  # SE played when switching loot item for party item
  MA_TAKE_SE = "Equip"     # SE played when taking item from loot
  MA_DESTROY_SE = "Close1" # SE played when destroying item from loot
  #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  # END EDITABLE REGION
  #//////////////////////////////////////////////////////////////////////////
end
 
#==============================================================================
# *** RPG
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constants  - MA_DEFAULT_STACK_AMOUNT, MA_DEFAULT_INVENTORY_SIZE,
#                   MA_EMPTYSLOTS_ICON_ID, MA_WARN_WINDOW
#    modified class - BaseItem
#==============================================================================
 
module RPG
  #==========================================================================
  # * Constants
  #==========================================================================
  #//////////////////////////////////////////////////////////////////////////
  # EDITABLE REGION
  #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  MA_DEFAULT_STACK_AMOUNT = 1    # The default maximum stack amount for items
  MA_DEFAULT_INVENTORY_SIZE = 18 # The default maximum slot number for inventory
  MA_EMPTYSLOTS_ICON_ID = 144    # The icon for empty slots
  MA_WARN_WINDOW = true          # Warn before leaving inventory with items in loot?
  #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  # END EDITABLE REGION
  #//////////////////////////////////////////////////////////////////////////
  #==========================================================================
  # ** BaseItem
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  Summary of Changes:
  #    new methods - ma_stack_amount, ma_discardable?
  #==========================================================================
  class BaseItem
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Stack Amount
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def ma_stack_amount
      return self.note[/\\STACKMAX\[(\d+)\]/i] != nil ? $1.to_i : RPG::MA_DEFAULT_STACK_AMOUNT
    end
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Non-Discardable
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def ma_discardable?
      return self.note[/\\NONDISCARD/i] == nil
    end
  end
end
 
#==============================================================================
# ** Game Temp
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new public instance variables - slots_to_discard
#==============================================================================
 
class Game_Temp
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :slots_to_discard # A Game_LimitedInventory object
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias algmod_grafikal009_init_tmp_lim_inventory_94n6 initialize
  def initialize
    # Run Original method
    algmod_grafikal009_init_tmp_lim_inventory_94n6
    # Create Inventory object
    @slots_to_discard = Game_LimitedInventory.new (-1)
  end
end
 
#==============================================================================
# ** Game LimInvSlot
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This class holds the data on a single slot of the inventory
#==============================================================================
 
class Game_LimInvSlot
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :item_type # The type of item held in this slot
  attr_reader   :item_id   # The ID of the item currently held
  attr_reader   :amount    # The number of items this slot holds
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize
    @item_type = -1
    @item_id = 0
    @amount = 0
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Add Item
  #    n         : the amount to add
  #    item_type : the type of item being added
  #    item_id   : the ID of item being added
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def add_item (n, item_type = -1, item_id = 0)
    # Set item if that is sent through
    if item_type != -1
      @item_type = item_type
      @item_id = item_id
    end
    x = space_left
    # Check amount
    if n > x
      # If more given than can fit
      @amount += x
      return n - x
    else
      # If the n given will fit
      @amount += n
      return 0
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Remove Item
  #    n : the amount to remove
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def remove_item (n)
    @amount -= n
    if @amount <= 0
      n = -1*@amount
      # Delete item from this slot
      @item_type = -1
      @item_id = 0
      @amount = 0
      return n
    end
    return 0
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def item
    return case @item_type
    when -1 then nil                    # No item stored
    when 0 then $data_items[@item_id]   # Item
    when 1 then $data_weapons[@item_id] # Weapon
    when 2 then $data_armors[@item_id]  # Armour
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Space Left
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def space_left
    return 1 if item == nil
    return item.ma_stack_amount - @amount
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Equal?
  #    other : another Game_LimInvSlot
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def == (other)
    return false if !other.is_a? (Game_LimInvSlot)
    return false if other.item_type != @item_type
    return false if other.item_id != @item_id
    return false if other.amount != @amount
    return super (other)
  end
end
 
#==============================================================================
# ** Game_LimitedInventory
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This is an array to store the party's inventory
#==============================================================================
 
class Game_LimitedInventory
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variable
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :max_size # The maximum number of slots. If -1, infinite.
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #    size : the number of slots available
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (size)
    @max_size = size
    clear
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Clear
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def clear
    @items = []
    @weapons = []
    @armors = []
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Resize
  #    size : the number of slots available
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def resize (size)
    old_size = slots.size
    # If new size is smaller
    if size < old_size
      # Save discarded items
      index = slots.size - 1
      while slots.size > @max_size
        slot = slots[index]
        if slot.item.ma_discardable?
          type, id, n = slot.item_type, slot.item_id, slot.amount
          # Discard additional slots
          remove_item (type, id, n)
          $game_temp.slots_to_discard.add_item (type, id, n)
        else
          index -= 1
        end
        break if index < 0
      end
    end
    @max_size = size
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Add Item
  #    type : the type of item being added
  #    id   : the ID of item being added
  #    n    : the amount to add
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def add_item (type, id, n = 1)
    array = case type
    when 0 then @items
    when 1 then @weapons
    when 2 then @armors
    end
    sort_index = 0
    # Go through all slots
    array.each { |slot|
      # If you can place the item in this slot
      if slot.item_id == id
        n = slot.add_item (n, type, id)
        break if n == 0
        sort_index += 1
      elsif slot.item_id < id
        sort_index += 1
      else
        break
      end
    }
    if n > 0
      # If there are empty slots
      while @max_size == -1 || ((@items.size + @weapons.size + @armors.size) < @max_size)
        slot = Game_LimInvSlot.new
        n = slot.add_item (n, type, id)
        array.insert (sort_index, slot)
        sort_index += 1
        break if n == 0
      end
    end
    return n
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Remove Item
  #    type : the type of item being removed
  #    id   : the ID of item being removed
  #    n    : the amount to remove
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def remove_item (type, id, n = 1)
    array = case type
    when 0 then @items
    when 1 then @weapons
    when 2 then @armors
    end
    # Go through all slots in reverse order
    array.reverse.each { |slot|
      # If this slot has the right item in it, remove from this slot
      if slot.item_type == type && slot.item_id == id
        n = slot.remove_item (n)
        array.delete (slot) if slot.amount == 0
        break if n == 0
      end
    }
    return n
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Item Slots
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def slots
    return @items + @weapons + @armors
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check Space
  #    item : an RPG::Item, RPG::Weapon, or RPG::Armor object
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def enough_space? (slot)
    return true if @max_size == -1 || slots.size < @max_size
    # Check array for other instances of the item
    array = [@items, @weapons, @armors][slot.item_type]
    array.each { |i|
      if i.item_id > slot.item_id
        break
      elsif i.item_id == slot.item_id
        return true if i.space_left < slot.item.ma_stack_amount
      end
    }
    return false
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Equals?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def == (other)
    return false unless other.is_a? (Game_LimitedInventory)
    return false if @max_size != other.max_size
    return false if slots != other.slots
    return super (other)
  end
end
 
#==============================================================================
# ** Game Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - change_equip
#==============================================================================
 
class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Change Equip
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdrnalgbra_gkl009_invlimits_cng_eqp_82h4 change_equip
  def change_equip (*args)
    # Run Original Method
    mdrnalgbra_gkl009_invlimits_cng_eqp_82h4 (*args)
    # Since you gain items before you lose them, check if item is Loot when it
    # could be in Party inventory
    if !$game_temp.slots_to_discard.slots.empty?
      # Take as many from loot as possible
      $game_temp.slots_to_discard.slots.reverse.each { |slot|
        break unless $game_party.limit_inventory.enough_space? (slot)
        item, type, id, n = slot.item, slot.item_type, slot.item_id, slot.amount
        $game_party.gain_item (item, n)
        $game_temp.slots_to_discard.remove_item (type, id, n)
      }
    end
  end
end
 
#==============================================================================
# ** Game Party
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new instance variable - limit_inventory
#    aliased methods - initialize, gain_item
#==============================================================================
 
class Game_Party
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :limit_inventory # A Game_LimitedInventory object
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modlg_lm_inv_grafkal_init_4n56 initialize
  def initialize
    # Run Original method
    modlg_lm_inv_grafkal_init_4n56
    # Create Inventory object
    @limit_inventory = Game_LimitedInventory.new (RPG::MA_DEFAULT_INVENTORY_SIZE)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Gain Items (or lose)
  #     item          : Item
  #     n             : Number
  #     include_equip : Include equipped items
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias drnlgbr_grafikal_limited_inventory_gn_itm_94n6 gain_item
  def gain_item(item, n, include_equip = false)
    # Run Original method
    drnlgbr_grafikal_limited_inventory_gn_itm_94n6 (item, n, include_equip)
    if item != nil
      type = item.is_a? (RPG::Item) ? 0 : item.is_a? (RPG::Weapon) ? 1 : 2
      # Gain or lose item depending on everything.
      if n > 0
        n2 = @limit_inventory.add_item (type, item.id, n)
        n -= n2
        # If it is a nondiscardable item and you cannot hold all of them
        if !item.ma_discardable?
          while n2 > 0
            # Find first nondiscardable item in the inventory
            for i in 0...@limit_inventory.slots.size
              slot = @limit_inventory.slots[i]
              if slot.item.ma_discardable?
                l_type, id = slot.item_type, slot.item_id
                # Find smallest slot of that item
                while l_type == slot.item_type && id == slot.item_id
                  i += 1
                  slot = @limit_inventory.slots[i]
                end
                l_item, l_n = @limit_inventory.slots[i - 1].item, @limit_inventory.slots[i - 1].amount
                break
              end
            end
            # Remove that item from inventory
            lose_item (l_item, l_n)
            $game_temp.slots_to_discard.add_item (l_type, id, l_n)
            n3 = @limit_inventory.add_item (type, item.id, n2)
            n -= n3
            n2 = n3
          end
        end
      else
        n2 = @limit_inventory.remove_item (type, item.id, -1*n)
        n += n2
        n2 *= -1
      end
    end
    return if item == nil
    # Send rest to loot
    if n2 > 0
      $game_temp.slots_to_discard.add_item (type, item.id, n2)
    elsif n2 < 0
      $game_temp.slots_to_discard.remove_item (type, item.id, -1*n2)
    end
  end
end
 
#==============================================================================
# ** Game Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - command_end
#    new method - resize_inventory
#==============================================================================
 
class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Resize Inventory
  #    new_size : the size you now want the inventory to be
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def resize_inventory (new_size)
    $game_party.limit_inventory.resize (new_size)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Command End
  #``````````````````````````````````````````````````````````````````````````
  #  If there are items in $game_temp.loot, open up the inventory
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_grid_inventory_open_inventory_end_command command_end
  def command_end
    # Run Original Method
    modalg_grid_inventory_open_inventory_end_command
    unless $game_temp.slots_to_discard.slots.empty?
      $scene = Scene_Item.new
    end
  end
end
 
#==============================================================================
# ** Window Item
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten methods - draw_item, item_rect
#    aliased method - item, refresh, dispose, top_row=
#==============================================================================
 
class Window_Item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdrnalg_gral9_ivntlim_rfrsh_2n45 refresh
  def refresh (inventory = $game_party.limit_inventory, columns = @column_max)
    if self.is_a? (Window_EquipItem)
      mdrnalg_gral9_ivntlim_rfrsh_2n45
      return
    end
    @is_loot = inventory == $game_temp.slots_to_discard
    @spacing = 32
    @data = []
    @empty_sprites.each { |sprite| sprite.dispose } unless @empty_sprites == nil
    @empty_sprites = []
    @column_max = columns
    for slot in inventory.slots
      next unless include?(slot.item)
      @data.push(slot)
      if slot.item.is_a?(RPG::Item) and slot.item_id == $game_party.last_item_id
        self.index = @data.size - 1
      end
    end
    @item_max = inventory.max_size == -1 ? @data.size : inventory.max_size
    create_contents
    # Calculate number of empty slots to draw
    empty_slots = (inventory.max_size == -1 || !$scene.is_a? (Scene_Item)) ? 0 : inventory.max_size - inventory.slots.size
    @wlh = (self.contents.height * @column_max) / ([@data.size + empty_slots, 1].max)
    @wlh = @wlh > 32 ? 32 : @wlh < WLH ? WLH : @wlh
    for i in 0...@data.size
      draw_item(i)
    end
    sprite_viewport = Viewport.new (self.x + 16, self.y + 16, self.width - 32, self.height - 32)
    viewport_adjusted = false
    for i in @data.size...empty_slots + @data.size
      rect = item_rect (i)
      if rect.y + rect.height > page_row_max*@wlh && !viewport_adjusted
        sprite_viewport.rect.height = rect.y
        viewport_adjusted = true
      end
      sprite = Sprite_Base.new (sprite_viewport)
      sprite.x, sprite.y = rect.x, rect.y
      sprite.visible = self.visible
      sprite.blend_type = 2
      empty_bmp = Bitmap.new (rect.width, rect.height) if empty_bmp == nil
      sprite.bitmap = empty_bmp.dup
      sprite.bitmap.fill_rect (0, 1, rect.width, rect.height - 2, Color.new (127, 127, 127, 105))
      @empty_sprites.push (sprite)
    end
    empty_bmp.dispose unless empty_bmp == nil
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Item Rect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def item_rect (index)
    wlh = @wlh == nil ? WLH : @wlh
    rect = Rect.new(0, 0, 0, 0)
    rect.width = (contents.width + @spacing) / @column_max - @spacing
    rect.height = wlh
    rect.x = index % @column_max * (rect.width + @spacing)
    rect.y = index / @column_max * wlh
    return rect
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Top Row
  #     row : row shown on top
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def top_row=(row)
    old_oy = self.oy
    super (row)
    @empty_sprites.each { |sprite| sprite.y -= (self.oy - old_oy) }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Item
  #     index : item number
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdrnalgbr_rfl009_limitedinvntry_drwitm_2hd4 draw_item
  def draw_item(index)
    if self.is_a? (Window_EquipItem)
      mdrnalgbr_rfl009_limitedinvntry_drwitm_2hd4 (index)
      return
    end
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    item = @data[index].item
    if item != nil
      n = @data[index].amount
      enabled = @is_loot ? true : enable?(item)
      rect.width -= 4
      y = rect.y + ((rect.height - WLH) / 2)
      draw_item_name(item, rect.x, y, enabled)
      self.contents.draw_text(rect, sprintf("#{Vocab::MA_AMOUNT_PREFIX}%2d", n), 2) unless n < 2
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_grfkl_lim_nvtry_item_8rn item
  def item 
    return ma_grfkl_lim_nvtry_item_8rn if self.is_a? (Window_EquipItem)
    return ma_grfkl_lim_nvtry_item_8rn == nil ? nil : ma_grfkl_lim_nvtry_item_8rn.item
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Sprite Disposal
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def dispose
    super
    @empty_sprites.each { |sprite| sprite.dispose } unless self.is_a? (Window_EquipItem)
  end
end
 
#==============================================================================
# ** Window_EmptyCount
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This window displays the number of free slots in the inventory.
#==============================================================================
 
class Window_EmptyCount < Window_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #     inventory : a Game_LimitedInventory object
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (inventory = $game_party.limit_inventory)
    super(Graphics.width - 128, 0, 128, WLH + 32)
    self.opacity = 0
    refresh (inventory)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh
  #     inv : a Game_LimitedInventory object
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def refresh (inv)
    self.contents.clear
    # Draw Icon
    empty_slots = inv.max_size == -1 ? "8" : (inv.max_size - inv.slots.size).to_s
    tw = self.contents.text_size (empty_slots).width
    self.contents.draw_text (0, 0, 96, WLH, empty_slots, 2)
    draw_icon (RPG::MA_EMPTYSLOTS_ICON_ID, 68 - tw, 0)
  end
end
 
#==============================================================================
# ** Window_InvCommand
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This is a Window_Command, specialized to allow for frequent resetting of the
# commands
#==============================================================================
 
class Window_InvCommand < Window_Command
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Reset Commands
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def reset_commands (commands)
    @commands = commands
    @item_max = commands.size
    row_max = (commands.size + @column_max - 1) / @column_max
    self.height = (row_max*WLH) + 32
    self.create_contents
    refresh
  end
end
 
#==============================================================================
# ** Window Warning
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This window checks before destroying slot items
#==============================================================================
 
class Window_Warning < Window_Selectable
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize
    x = (Graphics.width - 256) / 2
    y = (Graphics.height - (32 + 2*WLH)) / 2
    super (x, y, 256, 32 + 2*WLH)
    @item_max = 2
    @column_max = 2
    @index = 1
    create_contents
    # Draw Warning Label
    self.contents.draw_text (0, 0, contents.width, WLH, Vocab::MA_WARNING_LABEL, 1)
    # Draw Yes and No Options
    index = 0
    [Vocab::MA_WARNING_YES, Vocab::MA_WARNING_NO].each { |command|
      rect = item_rect (index)
      self.contents.draw_text (rect, command, 1)
      index += 1
    }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get rectangle for displaying items
  #     index : item number
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = (self.contents.width / 4) - 10
    rect.height = WLH
    rect.x = rect.width + (index*(20 + rect.width))
    rect.y = WLH
    return rect
  end
end
 
#==============================================================================
# ** Scene Equip
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - return_scene
#==============================================================================
 
class Scene_Equip
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Return Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias rnalbr_grafikal009_invlimits_rtrn_scn_eqp_4wk4 return_scene
  def return_scene
    if $game_temp.slots_to_discard.slots.empty?
      rnalbr_grafikal009_invlimits_rtrn_scn_eqp_4wk4
    else
      $scene = Scene_Item.new
    end
  end
end
 
#==============================================================================
# ** Scene Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - battle_end
#==============================================================================
 
class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * End Battle
  #     result : Results (0: win, 1: escape, 2:lose)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mrnagbr_gkal009_vntrylim_bttlend_5dm4 battle_end
  def battle_end(result)
    # Run original Method
    mrnagbr_gkal009_vntrylim_bttlend_5dm4 (result)
    if !$game_temp.slots_to_discard.slots.empty? && !$scene.is_a? (Scene_Gameover)
      $scene = Scene_Item.new
    end
  end
end
 
#==============================================================================
# ** Scene Item
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - start, terminate
#==============================================================================
 
class Scene_Item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start processing
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def start 
    super
    create_menu_background
    @activated_frame = false
    @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @help_window = Window_Help.new
    @help_window.width = Graphics.width
    @help_window.viewport = @viewport
    wlh = Window_Base::WLH
    @item_window = Window_Item.new(0, 32 + wlh, Graphics.width, Graphics.height - 32 - wlh)
    @item_window.help_window = @help_window
    @item_window.active = false
    @item_window.viewport = @viewport
    @active_window = @item_window
    @target_window = Window_MenuStatus.new(0, 0)
    @target_window.x = Graphics.width - @target_window.width
    @target_window.height = Graphics.height
    @target_window.z = 150
    hide_target_window
    # Create Empty Counter
    @emptycount_window = Window_EmptyCount.new
    @emptycount_window.viewport = @viewport
    # Create Loot Window
    wdth = Graphics.width / 2
    hght = Graphics.height - 64 - 2*wlh
    @loot_window = Window_Item.new (wdth, 64 + (2*wlh), wdth, hght)
    @loot_window.index = -1
    @loot_window.viewport = @viewport
    # Create Loot Label Window
    @lootlabel_window = Window_Base.new (wdth, 32 + wlh, wdth, 32 + wlh)
    @lootlabel_window.visible = false
    @lootlabel_window.contents.font.color = @lootlabel_window.system_color
    @lootlabel_window.contents.draw_text (0, 0, 240, wlh, Vocab::MA_LOOT_LABEL, 1)
    @lootlabel_window.viewport = @viewport
    commands = [Vocab::MA_COMMAND_USE, Vocab::MA_COMMAND_DISCARD]
    @command_window = Window_InvCommand.new (160, commands)
    @command_window.visible = false
    @command_window.active = 0
    @loot_window.active = false
    # If no loot, hide the window
    if $game_temp.slots_to_discard.slots.empty?
      @loot_window.visible = false
      @loot_window.refresh ($game_temp.slots_to_discard, 1)
      @overloaded_initially = false
    else
      show_loot 
      @overloaded_initially = true
    end
    @last_index = $game_party.last_item_id
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Return Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_grfk_inventoy_lmt_rtrnscn_1h45 return_scene
  def return_scene
    # If Still items left in Loot
    if RPG::MA_WARN_WINDOW && !$game_temp.slots_to_discard.slots.empty?
      # Give warning
      @warning_window = Window_Warning.new
      return
    end
    if @overloaded_initially
      $scene = Scene_Map.new
    else
      # Run Original Method
      malg_grfk_inventoy_lmt_rtrnscn_1h45
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Show Target Window
  #     right : Right justification flag (if false, left justification)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def show_target_window(right)
    right = @loot_window.visible ? @active_window == @item_window : right
    @item_window.active = false
    width_remain = Graphics.width - @target_window.width
    @target_window.x = right ? width_remain : 0
    @target_window.visible = true
    @target_window.active = true
    if right
      @viewport.rect.set(0, 0, width_remain, @target_window.height)
      @viewport.ox = 0
    else
      @viewport.rect.set(@target_window.width, 0, width_remain, @target_window.height)
      @viewport.ox = @target_window.width
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Hide Target Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def hide_target_window
    @item_window.active = true
    @target_window.visible = false
    @target_window.active = false
    @viewport.rect.set(0, 0, Graphics.width, Graphics.height)
    @viewport.ox = 0
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Termination processing
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdlg_graf009_invlimit_trmnte_itemscene_5bd3 terminate
  def terminate (*args)
    # Run Original Method
    mdlg_graf009_invlimit_trmnte_itemscene_5bd3 (*args)
    # Dispose of new windows
    @emptycount_window.dispose
    @loot_window.dispose
    @lootlabel_window.dispose
    @command_window.dispose
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Frame
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_gfl009_limitedinventory_upt_2h45 update
  def update
    # If Warning Window Active
    if @warning_window != nil
      update_warning_window
      return
    end
    malg_gfl009_limitedinventory_upt_2h45
    @loot_window.update
    @command_window.update
    if @activated_frame
      @activated_frame = false
      return
    end
    if @loot_window.active
      update_item_selection
    elsif @command_window.active
      update_command_selection
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Item Selection
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias moal_rfkl9_invntr_limit_upditmselect_1hr4 update_item_selection
  def update_item_selection
    @command_window.visible = false if @command_window.visible
    # Switch between windows by pressing Left or Right
    if @loot_window.visible && (Input.trigger? (Input::LEFT) || Input.trigger? (Input::RIGHT))
      Sound.play_cursor
      @active_window.index = -1
      loot_window_active = @loot_window.active
      @active_window.active = false
      @active_window = loot_window_active ? @item_window : @loot_window
      @active_window.active = true
      @active_window.index = 0
      @activated_frame = true
    end
    # IF ESC pressed
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      # If exchanging
      if @loot_window.index > -1 && @item_window.active
        slot = @active_window.ma_grfkl_lim_nvtry_item_8rn
        slot2 = @loot_window.ma_grfkl_lim_nvtry_item_8rn
        type, id, n = slot2.item_type, slot2.item_id, slot2.amount
        if slot != nil 
          if !slot.item.ma_discardable? # Undiscardable Item
            Sound.play_buzzer
            return
          else
            type2, id2, n2 = slot.item_type, slot.item_id, slot.amount
            $game_temp.slots_to_discard.add_item (type2, id2, n2)
            $game_party.limit_inventory.remove_item (type2, id2, n2)
          end
        end
        $game_party.limit_inventory.add_item (type, id, n)
        $game_temp.slots_to_discard.remove_item (type, id, n)
        RPG::SE.new (Sound::MA_EXCHANGE_SE).play
        check_to_hide_loot
        @loot_window.active = false
        @loot_window.index = -1
      else # If selecting
        item = @active_window.item
        if item != nil && (@loot_window.active || item.ma_discardable? || $game_party.item_can_use? (item))
          Sound.play_decision
          @active_window = @loot_window.active ? @loot_window : @item_window
          start_command_window
        else
          Sound.play_buzzer
        end
      end
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Command
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update_command_selection
    removed_from_loot = false
    if Input.trigger?(Input::B)
      Sound.play_cancel
      # Deactivate Command Window
      @command_window.active = false
      @command_window.index = -1
      @command_window.visible = false
      # Reactivat previous Window
      @active_window.active = true
    elsif Input.trigger?(Input::C)
      if @active_window == @item_window
        case @command_window.index
        when 0 # Use
          moal_rfkl9_invntr_limit_upditmselect_1hr4
          @command_window.active = false if $game_party.item_can_use?(@item) && @item.scope != 0
        when 1 # Discard
          # Get slot
          slot = @item_window.ma_grfkl_lim_nvtry_item_8rn
          unless slot.item.ma_discardable?
            Sound.play_buzzer
            return
          end
          type, id, n = slot.item_type, slot.item_id, slot.amount
          # Discard additional slots
          $game_party.limit_inventory.remove_item (type, id, n)
          $game_temp.slots_to_discard.add_item (type, id, n)
          # Deactivate Command Window
          @command_window.active = false
          @command_window.index = -1
          @command_window.visible = false
          # Reactivate previous Window
          if @loot_window.visible
            @item_window.refresh ($game_party.limit_inventory, 1)
            @loot_window.refresh ($game_temp.slots_to_discard, 1)
          else
            show_loot
          end
          @item_window.active = true
          RPG::SE.new (Sound::MA_DISCARD_SE).play
        end
        @emptycount_window.refresh ($game_party.limit_inventory)
      else # Called from Loot Window
        slot = @loot_window.ma_grfkl_lim_nvtry_item_8rn
        # Get slot stats
        type, id, n = slot.item_type, slot.item_id, slot.amount
        case @command_window.index
        when 0 # Take
          # If inventory has empty spaces
          if $game_party.limit_inventory.enough_space? (@loot_window.ma_grfkl_lim_nvtry_item_8rn)
            # Remove from loot and add to Inventory
            n2 = $game_party.limit_inventory.add_item (type, id, n)
            $game_temp.slots_to_discard.remove_item (type, id, n - n2)
            RPG::SE.new (Sound::MA_TAKE_SE).play
            removed_from_loot = true
          else
            Sound.play_buzzer
          end
        when 1 # Exchange
          # Deactivate Command Window
          @command_window.visible = false
          @command_window.active = false
          # Activate Item Window
          @item_window.active = true
          @item_window.index = 0
          @active_window = @item_window
          Sound.play_decision
        when 2 # Destroy
          $game_party.drnlgbr_grafikal_limited_inventory_gn_itm_94n6 (slot.item, -1*n)
          $game_temp.slots_to_discard.remove_item (type, id, n)
          RPG::SE.new (Sound::MA_DESTROY_SE).play
          removed_from_loot = true
        end
        if removed_from_loot
          @command_window.active = false
          @command_window.visible = false
          check_to_hide_loot
        end
      end
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Warning
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update_warning_window
    @warning_window.update
    if Input.trigger? (Input::B)
      # Play Cancel SE
      Sound.play_cancel
      # Dispose Warning
      @warning_window.dispose
      @warning_window = nil
    elsif Input.trigger? (Input::C)
      # Play Decision SE
      Sound.play_decision
      # When Yes
      if @warning_window.index == 0
        # End Scene
        clear_loot_slots
        return_scene
      end
      @warning_window.dispose
      @warning_window = nil
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Use Item (apply effects to non-ally targets)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_grkl_liminv_ustmnntrgt_2hb4 use_item_nontarget
  def use_item_nontarget
    # Get last instance of this item in the inventory.
    id = @item_window.index
    while id == @item_window.index
      @item_window.index += 1
      id += 1 if @item == @item_window.item
    end
    @item_window.index -= 1
    modalg_grkl_liminv_ustmnntrgt_2hb4
    $game_party.last_item_id = @item_window.index
    # Refresh Item Window if that slot is now empty
    if @item_window.item == nil
      @item_window.refresh
      @emptycount_window.refresh ($game_party.limit_inventory)
      hide_target_window
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Show Loot
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def show_loot
    @loot_window.refresh ($game_temp.slots_to_discard, 1)
    @loot_window.update
    @loot_window.visible = true
    @lootlabel_window.visible = true
    @item_window.width = Graphics.width / 2
    @item_window.refresh ($game_party.limit_inventory, 1)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check to Hide Loot
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def check_to_hide_loot
    @loot_window.refresh ($game_temp.slots_to_discard, 1)
    @emptycount_window.refresh ($game_party.limit_inventory)
    # If there are no more items in loot
    if $game_temp.slots_to_discard.slots.size == 0
      # Hide Loot Window
      @loot_window.visible = false
      @loot_window.active = false
      @loot_window.index = -1
      @lootlabel_window.visible = false
      @item_window.width = Graphics.width
      @item_window.index = 0
      @item_window.refresh ($game_party.limit_inventory, 2)
      @item_window.active = true
      @active_window = @item_window
    else
      @item_window.refresh ($game_party.limit_inventory, 1)
      @loot_window.active = true
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start Command Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def start_command_window
    # Set command window based on which window it is called from
    if @item_window.active
      @command_window.reset_commands ([Vocab::MA_COMMAND_USE, Vocab::MA_COMMAND_DISCARD])
      item = @item_window.item
      @command_window.draw_item (0, false) unless $game_party.item_can_use? (item)
      @command_window.draw_item (1, false) unless item.ma_discardable?
    elsif @loot_window.active
      cmnds = [Vocab::MA_COMMAND_TAKE, Vocab::MA_COMMAND_EXCHANGE, Vocab::MA_COMMAND_DESTROY]
      @command_window.reset_commands (cmnds)
      @command_window.draw_item (0, $game_party.limit_inventory.enough_space? (@loot_window.ma_grfkl_lim_nvtry_item_8rn))
    end
    rect = @active_window.item_rect (@active_window.index)
    x = @active_window.x + 16 + rect.x
    if x < (Graphics.width / 2)
      x += rect.width
    else
      x -= @command_window.width
    end
    @command_window.x = x
    # Get y coordinate
    y = @active_window.y + 16 + rect.y - ((@command_window.height - rect.height) / 2)
    y = (y + @command_window.height) > Graphics.height ? (Graphics.height - @command_window.height) : y
    @command_window.y = y < @active_window.y ? @active_window.y : y
    @command_window.index = 0
    @command_window.visible = true
    @command_window.active = true
    # Deactivate last window
    @active_window.active = false
    @activated_frame = true
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Clear Loot Slots
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def clear_loot_slots
    # Destroy all items in Loot
    unless $game_temp.slots_to_discard.slots.empty?
      # Update Party Hash and remove items
      $game_temp.slots_to_discard.slots.each { |slot|
        $game_party.drnlgbr_grafikal_limited_inventory_gn_itm_94n6 (slot.item, -1*slot.amount)
      }
      RPG::SE.new (Sound::MA_DESTROY_SE).play
      $game_temp.slots_to_discard.clear
    end
  end
end



Démo (en anglais)


Mis à jour le 23/5/2021.





Aucun commentaire n'a été posté pour le moment.

Suite à de nombreux abus, le post en invités a été désactivé. Veuillez vous inscrire si vous souhaitez participer à la conversation.

Haut de page

Merci de ne pas reproduire le contenu de ce site sans autorisation.
Contacter l'équipe - Mentions légales

Plan du site

Communauté: Accueil | Forum | Chat | Commentaires | News | Flash-news | Screen de la semaine | Sorties | Tests | Gaming-Live | Interviews | Galerie | OST | Blogs | Recherche
Apprendre: Visite guidée | RPG Maker 95 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker MV | Tutoriels | Guides | Making-of
Télécharger: Programmes | Scripts/Plugins | Ressources graphiques / sonores | Packs de ressources | Midis | Eléments séparés | Sprites
Jeux: Au hasard | Notre sélection | Sélection des membres | Tous les jeux | Jeux complets | Le cimetière | RPG Maker 95 | RPG Maker 2000 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker VX Ace | RPG Maker MV | Autres | Proposer
Ressources RPG Maker 2000/2003: Chipsets | Charsets | Panoramas | Backdrops | Facesets | Battle anims | Battle charsets | Monstres | Systems | Templates
Ressources RPG Maker XP: Tilesets | Autotiles | Characters | Battlers | Window skins | Icônes | Transitions | Fogs | Templates
Ressources RPG Maker VX: Tilesets | Charsets | Facesets | Systèmes
Ressources RPG Maker MV: Tilesets | Characters | Faces | Systèmes | Title | Battlebacks | Animations | SV/Ennemis
Archives: Palmarès | L'Annuaire | Livre d'or | Le Wiki | Divers