Bienvenue visiteur !
|
Statistiques
Liste des membres
Contact
Mentions légales
233 connectés actuellement
30946020 visiteurs depuis l'ouverture
2058 visiteurs aujourd'hui
Partenaires
Tous nos partenaires
Devenir partenaire
|
Keroberus -
posté le 21/07/2015 à 11:49:29 (9 messages postés)
| | Domaine concerné: script Logiciel utilisé: RPG MAKER VX ACE Bonjour tous le monde, je me suis lancé dans un petit projet solitaire, mon jeu avance bien mais la je suis coincé , j'ai trouver un script pour le craft, mais j'ai limité le nombre d'objet à 10 mais quand je craft, cela consomme toujours les objets pour le craft, mais sa ne me donne pas plus d'objet pour autant, en gros si quelqu'un saurait m'aider pour modifier le script afin d'imposer une limite au niveau du stock, un grand merci
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
| #=begin
#===============================================================================
# SeM's Final Fantasy IX Synthesis VXA
#
# - v1.1
# By SeMcDun
# Last Update: 05/02/2013
#===============================================================================
# Description;
# A simple crafting script.
#
# How to use;
# Set up a shop variable in the SYNTHESIS module below and fill it with
# objects you want to synth.
# Make sure any objects you include have the necessary synth tags.
# Set your chosen variable to the number of shop you want to use.
# Call the Synthesis scene.
#
#===============================================================================
# Version History;
#
# v1.0
# 2013.01.27 - Completed
#
# v1.1
# 2013.02.05 - Compatibility Update
# Changed variable names
#
#===============================================================================
# Installation;
# -- Paste above Main and below Materials.
#===============================================================================
# Note:
#
#===============================================================================
# Script Calls
#-------------------------------------------------------------------------------
#
#===============================================================================
# Weapon Notetags
#-------------------------------------------------------------------------------
# <synth xy>
# x - Either W, A or I. Weapon Armour or Item
# y - Index of the item.
#
# <synth_cost x>
# x - Gold cost to synth the item.
#
#===============================================================================
# Armour Notetags
#-------------------------------------------------------------------------------
# <synth xy>
# x - Either W, A or I. Weapon Armour or Item
# y - Index of the item.
#
# <synth_cost x>
# x - Gold cost to synth the item.
#
#===============================================================================
# Item Notetags
#-------------------------------------------------------------------------------
# <synth xy>
# x - Either W, A or I. Weapon Armour or Item
# y - Index of the item.
#
# <synth_cost x>
# x - Gold cost to synth the item.
#
#===============================================================================
$imported = {} if $imported.nil?
$imported["SEM-Synthesis"] = true
#===============================================================================
# ■ SEM::SYNTHESIS
#===============================================================================
module SEM
module SYNTHESIS
# Set up shops here
SHOP = []
SHOP[1] = [
["W" , 2],
["I" , 40],
["A", 3],
["I", 2],
["W", 1],
["W", 51],
["I" , 4],
["I" , 5]
]
SHOP[2] = [
["I", 2]
]
# Variable of the shop
SHOP_VARIABLE = 1
# Attack Increase icon
ATTACK_ICON = 131
# Defense Increase icon
DEFENSE_ICON = 139
end
module VOCAB
SYNTHESIS = "Créer objet"
SYNTH_PRICE = "Prix"
SYNTH_FUNDS = "Coût:"
SYNTH_STOCK = "Stock:"
SYNTH_EQUIPPED = "Equipé:"
SYNTH_REQUIRED = "Besoin d'objet:"
SYNTH_ITEM = "Objet"
EXIT_SYNTH = "Sortir"
# When an item is already equipped by an actor
SYNTH_CURRENTLY_EQUIPPED = "Equipé"
end
module REGEXP
module WEAPON
SYNTH = /<(?:SYNTH|synth)[ ]([IWA])(\d+)>/i
SYNTH_COST = /<(?:SYNTH_COST|synth_cost)[ ](\d+)>/i
end
module ARMOUR
SYNTH = /<(?:SYNTH|synth)[ ]([IWA])(\d+)>/i
SYNTH_COST = /<(?:SYNTH_COST|synth_cost)[ ](\d+)>/i
end
module ITEM
SYNTH = /<(?:SYNTH|synth)[ ]([IWA])(\d+)>/i
SYNTH_COST = /<(?:SYNTH_COST|synth_cost)[ ](\d+)>/i
end
end
end
#==============================================================================
# ■ DataManager
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_ssy load_database; end
def self.load_database
load_database_ssy
load_notetags_ssy
end
#--------------------------------------------------------------------------
# new method: load_notetags_ssy
#--------------------------------------------------------------------------
def self.load_notetags_ssy
for weapon in $data_weapons
next if weapon.nil?
weapon.load_weapon_notetags_ssy
end
for armor in $data_armors
next if armor.nil?
armor.load_armor_notetags_ssy
end
for item in $data_items
next if item.nil?
item.load_item_notetags_ssy
end
end
end # DataManager
#==============================================================================
# ■ RPG::Weapon
#==============================================================================
class RPG::Weapon < RPG::EquipItem
attr_accessor :synth_materials
attr_accessor :synth_cost
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
def load_weapon_notetags_ssy
@synth_materials = []
@synth_cost = 0
#---
self.note.split(/[\r\n]+/).each { |line|
case line
when SEM::REGEXP::WEAPON::SYNTH
itype = $1.to_s
index = $2.to_i
@synth_materials.push(RPG::Weapon::Material.new(itype, index))
when SEM::REGEXP::WEAPON::SYNTH_COST
@synth_cost = $1.to_i
end
}
end
end
#==============================================================================
# ■ RPG::Weapon::Material
#==============================================================================
class RPG::Weapon::Material
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_reader :itype
attr_reader :index
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(itype, index)
@itype = itype
@index = index
end
end # RPG::Weapon::Material
#==============================================================================
# ■ RPG::Armor
#==============================================================================
class RPG::Armor < RPG::EquipItem
attr_accessor :synth_materials
attr_accessor :synth_cost
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
def load_armor_notetags_ssy
@synth_materials = []
@synth_cost = 0
#---
self.note.split(/[\r\n]+/).each { |line|
case line
when SEM::REGEXP::ARMOUR::SYNTH
itype = $1.to_s
index = $2.to_i
@synth_materials.push(RPG::Armor::Material.new(itype, index))
when SEM::REGEXP::ARMOUR::SYNTH_COST
@synth_cost = $1.to_i
end
}
end
end
#==============================================================================
# ■ RPG::Armor::Material
#==============================================================================
class RPG::Armor::Material
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_reader :itype
attr_reader :index
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(itype, index)
@itype = itype
@index = index
end
end # RPG::Armor::Material
#==============================================================================
# ■ RPG::Item
#==============================================================================
class RPG::Item < RPG::UsableItem
attr_accessor :synth_materials
attr_accessor :synth_cost
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
def load_item_notetags_ssy
@synth_materials = []
@synth_cost = 0
#---
self.note.split(/[\r\n]+/).each { |line|
case line
when SEM::REGEXP::ITEM::SYNTH
itype = $1.to_s
index = $2.to_i
@synth_materials.push(RPG::Item::Material.new(itype, index))
when SEM::REGEXP::ITEM::SYNTH_COST
@synth_cost = $1.to_i
end
}
end
end
#==============================================================================
# ■ RPG::Item::Material
#==============================================================================
class RPG::Item::Material
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_reader :itype
attr_reader :index
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(itype, index)
@itype = itype
@index = index
end
end # RPG::Item::Material
#===============================================================================
# * Scene_Synthesis
#===============================================================================
class Scene_Synthesis < Scene_Base
attr_accessor :item_window
def start
create_main_viewport
create_items_window
create_info_window
create_actor_window
create_title_window
create_command_window
#@item_window.hide
#@info_window.hide
#@actor_window.hide
#@title_window.hide
@command_window.open
@command_window.activate
@command_window.select(0)
end
def create_command_window
x = (Graphics.width / 2) - 80
y = (Graphics.height / 2) - 38
@command_window = Window_SynthIntro.new(x, y)
@command_window.viewport = Viewport.new
@command_window.viewport.z += 500
@command_window.back_opacity = 255
@command_window.set_handler(:synth, method(:on_intro_ok))
@command_window.set_handler(:exit, method(:on_intro_cancel))
@command_window.set_handler(:cancel, method(:on_intro_cancel))
@command_window.refresh
end
def on_intro_ok
#@item_window.show
#@info_window.show
#@actor_window.show
#@title_window.show
@item_window.activate
@item_window.select(0)
@command_window.close
end
def on_intro_cancel
return_scene
end
def create_title_window
@title_window = Window_ItemTitle.new(0, 0, 300, 48)
end
def create_items_window
@item_window = Window_SynthItems.new(0, 48, 300, Graphics.height - 96 - 32 - 48 - 32)
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
@item_window.refresh
end
def on_item_ok
# Because it is active;
# The player HAS enough money
# The player HAS enough of the required items
# Remove the gold
$game_party.lose_gold(@item_window.item.synth_cost)
# Remove the items required
@item_window.item.synth_materials.each do |remove_item|
case remove_item.itype
when "W"
item_name = $data_weapons[remove_item.index]
when "A"
item_name = $data_armors[remove_item.index]
when "I"
item_name = $data_items[remove_item.index]
end
$game_party.lose_item(item_name, 1)
# Removed the gold cost AND removed the items required...
# Add the created item
end
$game_party.gain_item(@item_window.item, 1)
@item_window.refresh
@info_window.refresh(@item_window.item)
@item_window.activate
end
def on_item_cancel
@command_window.open
@command_window.activate
@command_window.select(0)
@item_window.unselect
end
def create_info_window
@info_window = Window_SynthInfo.new(300, 0, 244, Graphics.height - 96 - 32 - 32)
@info_window.refresh(nil)
end
def create_actor_window
@actor_window = Window_SynthActors.new(0, Graphics.height - 96 - 32 - 32, Graphics.width, 96 + 32 + 32)
@actor_window.refresh(nil)
end
alias scene_synthesis_update_ssy update
def update
scene_synthesis_update_ssy
if @this_item != @item_window.item
@this_item = @item_window.item
@item_window.refresh
@info_window.refresh(@item_window.item)
@actor_window.refresh(@item_window.item)
end
end
end
#===============================================================================
# * Window_SynthItems
#===============================================================================
class Window_SynthItems < Window_ItemList
attr_accessor :data
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# * Display in Enabled State?
#--------------------------------------------------------------------------
def enable?(item)
@got_items = []
# Check if they player has enough money to buy the item
if $game_party.gold >= item.synth_cost
# Get first item
item.synth_materials.each do |mat|
case mat.itype
when "W"
item_name = $data_weapons[mat.index]
when "A"
item_name = $data_armors[mat.index]
when "I"
item_name = $data_items[mat.index]
end
# Got the material... now loop through all items
$game_party.all_items.each do |party_item|
if item_name == party_item
@got_items.push(item_name)
$game_party.lose_item(item_name, 1)
end
end
end
if @got_items.size == item.synth_materials.size
# Same number was found
# True, but return each of the items in got_items
@got_items.each do |return_item|
$game_party.gain_item(return_item, 1)
end
return true
else
@got_items.each do |return_item|
$game_party.gain_item(return_item, 1)
end
return false
end
else
false
end
end
#--------------------------------------------------------------------------
# * Create Item List
#--------------------------------------------------------------------------
def make_item_list
@data = []
# Fill the list with items from the synth shop.
SEM::SYNTHESIS::SHOP[$game_variables[SEM::SYNTHESIS::SHOP_VARIABLE]].each do |item|
# Each item, add it to the data list
case item[0]
when "W"
@data.push($data_weapons[item[1]])
when "A"
@data.push($data_armors[item[1]])
when "I"
@data.push($data_items[item[1]])
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
if item
rect = item_rect(index)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enable?(item))
draw_item_price(rect, item)
end
end
def draw_item_price(rect, item)
draw_text(rect.x, rect.y, rect.width, line_height, item.synth_cost, 2)
end
end
#===============================================================================
# * Window_SynthInfo
#===============================================================================
class Window_SynthInfo < Window_Base
alias window_synthinfo_init_ssy initialize
def initialize(x, y, ww, wh)
window_synthinfo_init_ssy(x, y, ww, wh)
refresh(nil)
end
def refresh(item)
contents.clear
change_color(normal_color)
draw_text(4, 24 * 0, 120, 24, "#{SEM::VOCAB::SYNTH_FUNDS}")
draw_currency_value(value, currency_unit, 8, line_height * 0, contents.width - 8)
change_color(normal_color)
draw_text(4, 24 * 1 + 8, 120, 24, "#{SEM::VOCAB::SYNTH_STOCK}")
draw_text(4, 24 * 1 + 8, 204, 24, $game_party.item_number(item), 2)
draw_text(4, 24 * 2 + 16, 120, 24, "#{SEM::VOCAB::SYNTH_EQUIPPED}")
# Loop through all equipped items
# Any time "item" is found, +1
@equipped_items = 0
$game_party.members.each do |member|
member.equips.each do |equips|
if item
if equips == item
# Item is the same, add 1
@equipped_items += 1
end
end
end
end
draw_text(4, 24 * 2 + 16, 204, 24, @equipped_items, 2)
draw_horz_line(24 * 3 + 24)
contents.font.size -= 4
draw_text(4, 24 * 5, 180, 24, "#{SEM::VOCAB::SYNTH_REQUIRED}")
contents.font.size += 4
@got_items = []
if item
counter = 0
item.synth_materials.each do |mat|
case mat.itype
when "W"
item_name = $data_weapons[mat.index]
icon = $data_weapons[mat.index].icon_index
when "A"
item_name = $data_armors[mat.index]
icon = $data_armors[mat.index].icon_index
when "I"
item_name = $data_items[mat.index]
icon = $data_items[mat.index].icon_index
end
if enable?(item_name)
@got_items.push(item_name)
enabled = true
else
enabled = false
end
draw_item_name(item_name, 4, 24 * (6 + counter), enabled, width = 140)
counter += 1
end
end
# Return Items
@got_items.each do |return_item|
$game_party.gain_item(return_item, 1)
end
end
#--------------------------------------------------------------------------
# * Get Party Gold
#--------------------------------------------------------------------------
def value
$game_party.gold
end
#--------------------------------------------------------------------------
# Get Currency Unit
#--------------------------------------------------------------------------
def currency_unit
Vocab::currency_unit
end
#--------------------------------------------------------------------------
# * Draw Horizontal Line
#--------------------------------------------------------------------------
def draw_horz_line(y)
line_y = y + line_height / 2 - 1
contents.fill_rect(0, line_y, contents_width, 2, line_color)
end
#--------------------------------------------------------------------------
# * Get Color of Horizontal Line
#--------------------------------------------------------------------------
def line_color
color = normal_color
color.alpha = 48
color
end
#--------------------------------------------------------------------------
# * Display in Enabled State?
#--------------------------------------------------------------------------
def enable?(item)
# Maybe get the number of items for the first item into a temp array? Hm
$game_party.all_items.each do |party_item|
if party_item == item
# Found an item, add to @got_items
$game_party.lose_item(item, 1)
return true
end
end
return false
end
end
#===============================================================================
# * Window_SynthActors
#===============================================================================
class Window_SynthActors < Window_Base
def initialize(x, y, ww, wh)
super
end
def refresh(item)
contents.clear
counter = 0
$game_party.members.each do |member|
# Draw face
draw_actor_face(member, counter * ((Graphics.width - 16) / $game_party.members.count), 0, enabled = true)
# If the item is equippable by the actor...
if member.equippable?(item)
case item.etype_id
when 0
draw_icon(SEM::SYNTHESIS::ATTACK_ICON, 16 + counter * ((Graphics.width - 16) / $game_party.members.count), (24*4 + 8))
if member.equips[0] != nil
difference = item.params[2] - member.equips[0].params[2]
else
difference = item.params[2]
end
if difference < 0
# Negative: Draw red
change_color(power_down_color)
elsif difference == 0
# Equal
difference = SEM::VOCAB::SYNTH_CURRENTLY_EQUIPPED
elsif difference > 0
# Positive: Draw green
change_color(power_up_color)
end
draw_text(44 + counter * ((Graphics.width - 16) / $game_party.members.count), (24 * 4) + 8, 70, 24, difference)
change_color(normal_color)
when 1
draw_icon(SEM::SYNTHESIS::DEFENSE_ICON, 16 + counter * ((Graphics.width - 16) / $game_party.members.count), (24*4 + 8))
if member.equips[1] != nil
difference = item.params[3] - member.equips[1].params[3]
else
difference = item.params[3]
end
if difference < 0
# Negative: Draw red
change_color(power_down_color)
elsif difference == 0
# Equal
# Check if it's equipped
if member.equips[1] == item
difference = SEM::VOCAB::SYNTH_CURRENTLY_EQUIPPED
else
difference = 0
end
elsif difference > 0
# Positive: Draw green
change_color(power_up_color)
end
draw_text(44 + counter * ((Graphics.width - 16) / $game_party.members.count), (24 * 4) + 8, 70, 24, difference)
change_color(normal_color)
when 2
draw_icon(SEM::SYNTHESIS::DEFENSE_ICON, 16 + counter * ((Graphics.width - 16) / $game_party.members.count), (24*4 + 8))
if member.equips[2] != nil
difference = item.params[3] - member.equips[2].params[3]
else
difference = item.params[3]
end
if difference < 0
# Negative: Draw red
change_color(power_down_color)
elsif difference == 0
# Equal
if member.equips[2] == item
difference = SEM::VOCAB::SYNTH_CURRENTLY_EQUIPPED
else
difference = 0
end
elsif difference > 0
# Positive: Draw green
change_color(power_up_color)
end
draw_text(44 + counter * ((Graphics.width - 16) / $game_party.members.count), (24 * 4) + 8, 70, 24, difference)
change_color(normal_color)
when 3
draw_icon(SEM::SYNTHESIS::DEFENSE_ICON, 16 + counter * ((Graphics.width - 16) / $game_party.members.count), (24*4 + 8))
if member.equips[3] != nil
difference = item.params[3] - member.equips[3].params[3]
else
difference = item.params[3]
end
if difference < 0
# Negative: Draw red
change_color(power_down_color)
elsif difference == 0
# Equal
if member.equips[3] == item
difference = SEM::VOCAB::SYNTH_CURRENTLY_EQUIPPED
else
difference = 0
end
elsif difference > 0
# Positive: Draw green
change_color(power_up_color)
end
draw_text(44 + counter * ((Graphics.width - 16) / $game_party.members.count), (24 * 4) + 8, 70, 24, difference)
change_color(normal_color)
when 4
draw_icon(SEM::SYNTHESIS::DEFENSE_ICON, 16 + counter * ((Graphics.width - 16) / $game_party.members.count), (24*4 + 8))
if member.equips[4] != nil
difference = item.params[3] - member.equips[4].params[3]
else
difference = item.params[3]
end
if difference < 0
# Negative: Draw red
change_color(power_down_color)
elsif difference == 0
# Equal
if member.equips[4] == item
difference = SEM::VOCAB::SYNTH_CURRENTLY_EQUIPPED
else
difference = 0
end
elsif difference > 0
# Positive: Draw green
change_color(power_up_color)
end
draw_text(44 + counter * ((Graphics.width - 16) / $game_party.members.count), (24 * 4) + 8, 96, 24, difference)
change_color(normal_color)
end
end
counter += 1
end
end
#--------------------------------------------------------------------------
# * Draw Face Graphic
# enabled : Enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_face(face_name, face_index, x, y, enabled = true)
bitmap = Cache.face(face_name)
rect = Rect.new((face_index % 4 * 96), face_index / 4 * 96, 96, 96)
contents.blt(x + 15, y, bitmap, rect, enabled ? 255 : translucent_alpha)
bitmap.dispose
end
end
#===============================================================================
# * Window_ItemTitle
#===============================================================================
class Window_ItemTitle < Window_Base
def initialize(x, y, ww, wh)
super
draw_text(4, 0, 120, 24, "#{SEM::VOCAB::SYNTH_ITEM}")
draw_text(0, 0, self.width - 24, 24, "#{SEM::VOCAB::SYNTH_PRICE}", 2)
end
end
#===============================================================================
# * Window_ShopIntro
#===============================================================================
class Window_SynthIntro < Window_Command
alias window_shopintro_init_ssy initialize
def initialize(x, y)
window_shopintro_init_ssy(x, y)
refresh
end
#--------------------------------------------------------------------------
# * Get Window Height
#--------------------------------------------------------------------------
def window_height
fitting_height(2)
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
add_command(SEM::VOCAB::SYNTHESIS, :synth)
add_command(SEM::VOCAB::EXIT_SYNTH, :exit)
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
change_color(normal_color, command_enabled?(index))
draw_text(item_rect_for_text(index), command_name(index), 1)
end
end
|
|
terzarok -
posté le 21/07/2015 à 14:51:45 (345 messages postés)
| | Salut
Je ne suis pas sûr de comprendre ton problème.
Parce que j'aime les visuels, je vais faire un schéma pour mieux m'expliquer ...
Quand tu fais par exemple une épée à partir de bois et de métal, ça ferait :
Stock départ :
42 bois (-10 utilisés)
18 fer (-6 utilisés)
l
l
V
Stock final :
32 bois
12 fer
1 épée (créée)
C'est bien ça ?
Si j'ai bon, je pense qu'un simple appel de variables pourrait t'aider.
En reprenant l'exemple que j'ai fait, avec les valeurs bidon :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| Variable NombreRessources= nombre d'objet "Bois"
Si NombreRessources >= 10
Alors
----- Variable NombreRessources= nombre d'objet "Fer"
----- Si NombreRessources>=6
----- Alors
----- ----- Retirer objet "Bois" : 10
----- ----- Retirer objet "Fer" : 6
----- ----- Ajouter objet "Epée" : 1
----- Sinon
----- ----- Message : "Pas assez de Fer"
Fin Condition
Sinon
----- Message : "Pas assez de Bois"
Fin Condition |
|
Il y a des gens qui passeraient des heures à expliquer qu'ils sont débordés. Moi sur Deviantart |
Keroberus -
posté le 21/07/2015 à 17:46:07 (9 messages postés)
| | oui c'est pas mal ^^ en faite ca c'etait ma 2eme question lol, mais merci c'est très gentil, faire un screen sa sert pas à grand chose pour expliquer mais en faite, voila j'ai 10 potions donc le max et si je craft, il élimine les objets pour le craft mais il ne me rajoute pas de potions, exemple: nombre d'objet max dans l'inventaire 10, dans mon inventaire j'ai 10 potions 10 herbes 10 champis en sachant que pour faire 1 potion j'ai besoin de 1 herbe 1 champi, si apres je craft 10 potions et bien au final dans mon inventaire j'aurais 10 potions 0 herbe 0 champi et j'aimerais regler ce problème mais je ne sais pas trop utiliser les scripts
|
terzarok -
posté le 21/07/2015 à 19:21:59 (345 messages postés)
| | Je n'y connais que couic en script, moi aussi ^^'
Du coup, si on continue "basiquement" avec des variables (je ne sais pas dans les scripts comment on peut limiter une quantité d'objets), tu peux mettre la condition au moment où tu es censé rajouter ta potion :
Dans mon p'tit exemple, ce serait à placer juste avant le retrait/ajout des objets, dans la "dernière condition.
1
2
3
4
5
6
7
| Variable NombreRessources= nombre objet "Potion"
Si NombreRessources < 10
Alors ...
----- (création de la potion)
Sinon
----- Message : "Vous avez atteint la limite de "Potion" dans votre inventaire"
Fin Condition |
C'est la solution basique et facile, mais au moins elle fonctionne ^^'
Par contre, si tu gagnes des potions via un combat, je ne sais pas comment faire pour garder la limite à 10.
A part éventuellement faire une correction post-combat du genre
1
2
3
4
5
6
| Variable NombreRessources= nombre objet "Potion"
Si NombreRessources > 10
Alors
----- Variable Correction= NombreRessources -10 (pour enlever l'excès)
----- Retirer objet "Potion" : valeur Correction
Fin Condition |
|
Il y a des gens qui passeraient des heures à expliquer qu'ils sont débordés. Moi sur Deviantart |
arttroy -
posté le 22/07/2015 à 10:33:56 (2394 messages postés)
| Just working | ouep faut juste définir que si le nombre d'item max est atteint l'opération ne se fasse pas.
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
| def on_item_ok
if @item_window.item.item_number < @item_window.item.max_item
# Because it is active;
# The player HAS enough money
# The player HAS enough of the required items
# Remove the gold
$game_party.lose_gold(@item_window.item.synth_cost)
# Remove the items required
@item_window.item.synth_materials.each do |remove_item|
case remove_item.itype
when "W"
item_name = $data_weapons[remove_item.index]
when "A"
item_name = $data_armors[remove_item.index]
when "I"
item_name = $data_items[remove_item.index]
end
$game_party.lose_item(item_name, 1)
# Removed the gold cost AND removed the items required...
# Add the created item
end
$game_party.gain_item(@item_window.item, 1)
@item_window.refresh
@info_window.refresh(@item_window.item)
@item_window.activate
end
end |
Ça devrait fonctionner comme ça. Au final les scripts ça à l'air compliqué comme ça mais une fois que tu as des bases solides, ça reviens plus ou moins au même système que les events ('fin une version plus juste des choses reviendrait à dire que le système d'event fonctionne comme celui des scripts et pour cause c'est les scripts qui définissent le fonctionnement des event ^^).
Si je peux me permettre un conseil, fais attention aux scripts que tu utilises, si tu comprend pas trop leur fonctionnement, le jour où tu vas tomber sur une erreur tu sauras pas d'où ça vient... Alors quand ça arrive au début du projet ça va mais si c'est après avoir bossé pendant 3 mois dessus...
Si toutefois tu cherches des scripts je te conseille la master script list, c'est un peu le cirque pour s'y retrouver vu que tout est en anglais au début mais c'est assez complet....
|
Anti-inconstructivité / Pétition pour que le mot making soit inscrit dans le dictionnaire ? |
Keroberus -
posté le 25/07/2015 à 21:03:24 (9 messages postés)
| | Ah voila j'ai trouvé un super script sur master script encore merci à vous 2 ^^
mais voila sur ce script j'ai toujours le même soucis la limite d'objet, je voudrai que si dons mon game_party max_item c'est full alors qu'il ne craft pas, parce que la même si je suis full il continue a consommer les objets pour le craft voici le scipt si quelqu'u peut m'aider merci beaucoup
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
|
#==============================================================================
# Crafting System
# Version 1.9
# By Szyu
#
# About:
# Craft items, weapons and armors.
#
# Instructions:
# - Place below "? Materials" but above "? Main Process".
# - Call global Crafting List by "SceneManager.call(Scene_Crafting)" or
# "SceneManager.call(Scene_Crafting, -1)".
# For categorized Crafting Lists use "SceneManager.call(Scene_Crafting, x)"
#
# How to Use:
# - "<ingredients> content </ingredients>" marks the area for ingredients
# example:
# <ingredients>
# i: 3x 5 => 3 items of item_id 5
# w: 2x 7 => 2 weapons of weapon_id 7
# a: 1x 2 => 1 armor of armor_id 2
# </ingredients>
#
# - "<recipe book>" marks the item as a recipe book, able to hold recipes
# - "<category: x>" marks a recipe book as category x. You can call seperate
# category crafting lists by SceneManager.call(Scene_Crafting, x)
#
# - "<recipes> content </recipes>" marks the area for recipes if the
# item is a crafting book
# example:
# <recipes>
# i: 5 => ability to craft the item with id 5
# w: 7 => ability to craft the weapon with id 7
# a: 2 - 20 => ability to craft armors from id 2 to id 20
# </recipes>
#
# - "$data_items[book_id].add_recipe("i/w/a: id")" adds a new recipe to a book
# - "$data_items[book_id].add_recipe("i/w/a: id1 - id2")" adds a new recipe to a book
# - "$data_items[book_id].remove_recipe("i/w/a: id")" removes a recipe from a book
# - "$data_items[book_id].remove_recipe("i/w/a: id1 - id2")" removes a recipe from a book
#
# Requires:
# - RPG Maker VX Ace
#
# Terms of Use:
# - Free for commercal and non-commercial use. Please list me
# in the credits to support my work.
#
# Pastebin:
# http://pastebin.com/CxB8F8T5
#
#==============================================================
# * Configuration
#==============================================================
# Term used for crafting from recipe books
INGREDIENTS_TERM = "Ingredientes"
CR_WEAPON_TYPE_TERM = "Clase de arma"
CR_ARMOR_TYPE_TERM = "Clase de armadura"
CRAFTING_CATEGORIES = ["Alchemy","Blacksmithing"]
# Custom crafting sounds by category
CUSTOM_CRAFT_SOUNDS_BY_CAT = ["Saint5", "Bell2"]
# Custom crafting sounds for RPG::Item, RPG::Weapon, RPG::Armor if no special cat
CUSTOM_CRAFT_SOUNDS_BY_TYPE = ["Saint5", "Bell2", "Bell3"]
# If you want to use crafting from the menu, set this to true, else false
CRAFTING_IN_MENU = true
MENU_CRAFTING_VOCAB = "Crafting"
# Vocabs used in status section for crafted items
CRAFTING_ITEM_STATUS ={
:empty => "-", # Text used when nothing is shown.
:hp_recover => "HP", # Text used for HP Recovery.
:mp_recover => "MP", # Text used for MP Recovery.
:tp_recover => "TP", # Text used for TP Recovery.
:tp_gain => "TP gain", # Text used for TP Gain.
:applies => "applies", # Text used for applied states and buffs.
:removes => "removes", # Text used for removed states and buffs.
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#==============================================================
# * Scene_Crafting
#==============================================================
class Scene_Crafting < Scene_ItemBase
def initialize()
@cr_category = SceneManager.scene_param[0] ? SceneManager.scene_param[0] : -1
end
def start
super
create_help_window
create_category_window
create_ingredients_window
create_item_window
end
def create_category_window
@category_window = Window_CraftingCategory.new
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.y = @help_window.height
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:return_scene))
end
def create_ingredients_window
wx = 240
wy = @category_window.y + @category_window.height
ww = Graphics.width - wx
wh = Graphics.height - wy
@ingredients_window = Window_CraftingIngredients.new(wx,wy,ww,wh)
@ingredients_window.viewport = @viewport
end
def create_item_window
wy = @category_window.y + @category_window.height
wh = Graphics.height - wy
@item_window = Window_CraftingItemList.new(0, wy, 240, wh)
@item_window.cr_category = @cr_category
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
@item_window.set_handler(:right, method(:ingredients_show_stats))
@item_window.set_handler(:left, method(:ingredients_show_ingredients))
@item_window.ingredients_window = @ingredients_window
@category_window.item_window = @item_window
end
def on_category_ok
@item_window.activate
@item_window.select_last
end
def on_item_ok
determine_crafting
end
def on_item_cancel
@item_window.unselect
@category_window.activate
end
def determine_crafting
craft_item if @item_window.item.match_ingredients?
end
def craft_item
item = @item_window.item
item.ingredients.each do |ing|
if ing[0].is_a?(RPG::BaseItem)
$game_party.lose_item(ing[0],ing[1])
else
$game_party.lose_gold(ing[1])
end
end
$game_party.gain_item(item,1)
if @cr_category != -1
csf = CUSTOM_CRAFT_SOUNDS_BY_CAT[@cr_category]
else
if item.is_a?(RPG::Item)
csf = CUSTOM_CRAFT_SOUNDS_BY_TYPE[0]
elsif item.is_a?(RPG::Weapon)
csf = CUSTOM_CRAFT_SOUNDS_BY_TYPE[1]
elsif item.is_a?(RPG::Armor)
csf = CUSTOM_CRAFT_SOUNDS_BY_TYPE[2]
end
end
RPG::SE.new(csf, 100, 50).play
@item_window.refresh
@item_window.activate
end
def ingredients_show_ingredients
@ingredients_window.showtype = 0
end
def ingredients_show_stats
@ingredients_window.showtype = 1
end
end
#==============================================================
# * Scene_Menu
#==============================================================
class Scene_Menu < Scene_MenuBase
alias add_crafting_menu_entry create_command_window
def create_command_window
add_crafting_menu_entry
@command_window.set_handler(:crafting, method(:open_crafting)) if CRAFTING_IN_MENU
end
def open_crafting
SceneManager.call(Scene_Crafting, 0)
end
end
#==============================================================
# * Window_CraftingCategory
#==============================================================
class Window_CraftingCategory < Window_HorzCommand
attr_reader :item_window
def initialize
super(0, 0)
end
def window_width
Graphics.width
end
def col_max
return 3
end
def update
super
@item_window.category = current_symbol if @item_window
end
def make_command_list
add_command(Vocab::item, :item)
add_command(Vocab::weapon, :weapon)
add_command(Vocab::armor, :armor)
end
def item_window=(item_window)
@item_window = item_window
update
end
end
#==============================================================
# * Window_CraftingCategory
#==============================================================
class Window_CraftingItemList < Window_Selectable
attr_reader :ingredients_window
attr_accessor :cr_category
def initialize(x, y, width, height)
super
@category = :none
@data = []
end
def category=(category)
return if @category == category
@category = category
refresh
self.oy = 0
end
def col_max
return 1
end
def item_max
@data ? @data.size : 1
end
def item
@data && index >= 0 ? @data[index] : nil
end
def current_item_enabled?
return false unless @data[index]
@data[index].match_ingredients?
end
def include?(item)
case @category
when :item
item.is_a?(RPG::Item)
when :weapon
item.is_a?(RPG::Weapon)
when :armor
item.is_a?(RPG::Armor)
else
false
end
end
def enable?(item)
$game_party.usable?(item)
end
def make_item_list
rbooks = $game_party.all_items.select {|item| item.recipe_book}
rbooks.delete_if {|x| x.cr_category != @cr_category} if @cr_category != -1
@data = []
rbooks.each do |book|
sdata = book.recipes.select {|recipe| include?(recipe) }
@data.concat sdata
end
@data.push(nil) if include?(nil)
end
def select_last
select(@data.index($game_party.last_item.object) || 0)
end
def draw_item(index)
item = @data[index]
if item
rect = item_rect(index)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, item.match_ingredients?, width-70)
draw_item_number(rect, item)
end
end
def draw_item_number(rect, item)
draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
end
def update_help
@help_window.set_item(item)
@ingredients_window.item = item if @ingredients_window
end
def refresh
make_item_list
create_contents
draw_all_items
end
def ingredients_window=(ingredients_window)
@ingredients_window = ingredients_window
update
end
def process_ok
if current_item_enabled?
Input.update
deactivate
call_ok_handler
else
Sound.play_buzzer
end
end
alias cr_us_win unselect
def unselect
cr_us_win
@ingredients_window.contents.clear
end
end
#==============================================================
# * Window_MenuCraftingList
#==============================================================
class Window_MenuCraftingList < Window_Selectable
attr_reader :ingredients_window
attr_reader :book
alias cr_ing_help call_update_help
alias cr_ing_hide hide
def initialize(book,y)
@book = book
super(0,y, 240, Graphics.height-y)
self.visible = false
refresh
end
def window_height
Graphics.height-self.y
end
def item_max
@book.recipes.size
end
def item_height
line_height+4
end
def draw_item(index)
recipe = @book.recipes[index]
rect = item_rect(index)
draw_icon(recipe.icon_index, rect.x+2, rect.y+2)
draw_text(rect.x+30,rect.y+2,width-75, line_height, recipe.name)
draw_text(rect.x-30,rect.y+2,width, line_height, sprintf(":%2d", $game_party.item_number(@item)), 2)
end
def process_ok
super
$game_party.menu_actor = $game_party.members[index]
end
def select_last
select($game_party.menu_actor.index || 0)
end
def select_for_item(item)
select(0)
@book = item
end
def ingredients_window=(ingredients_window)
@ingredients_window = ingredients_window
update
end
def call_update_help
cr_ing_help
@ingredients_window.item = @book.recipes[@index] if @ingredients_window && @index >= 0
end
def hide
cr_ing_hide
@ingredients_window.hide.deactivate
end
end
#==============================================================
# * Window_CraftingIngredients
#==============================================================
class Window_CraftingIngredients < Window_Selectable
def initialize(x,y,w,h)
super(x,y,w,h)
@item = nil
@showtype=0
end
def item=(item)
@item = item
refresh
end
def refresh
contents.clear
return if !@item
case @showtype
when 1
#draw_stats_item if @item.is_a?(RPG::Item)
draw_stats
else
draw_ingredients
end
end
def draw_ingredients
change_color(system_color)
draw_text(0,line_height*0,width,line_height, INGREDIENTS_TERM)
i = 1
@item.ingredients.each do |ing|
change_color(normal_color)
change_color(normal_color)
if ing[0].is_a?(String)
draw_icon(5312,0,line_height*i)
draw_text(24,line_height*i, width,line_height, ing[0])
inumber = $game_party.gold
else
draw_icon(ing[0].icon_index,0,line_height*i)
draw_text(24,line_height*i, width,line_height, ing[0].name)
inumber = $game_party.item_number(ing[0])
end
change_color(crisis_color) if inumber < ing[1]
change_color(hp_gauge_color1) if inumber == 0
change_color(tp_gauge_color2) if inumber >= ing[1]
txt = sprintf("%d/%d",inumber, ing[1])
draw_text(-24,line_height*i,width-4,line_height,txt,2)
i += 1
end
change_color(normal_color)
end
def draw_stats
draw_item_stats
draw_item_effects
end
def showtype=(st)
@showtype = st
refresh
end
def draw_background_box(dx, dy, dw)
colour = Color.new(0, 0, 0, translucent_alpha/2)
rect = Rect.new(dx+1, dy+1, dw-2, line_height-2)
contents.fill_rect(rect, colour)
end
def draw_item_stats
return unless @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
dx = 0; dy = 0
dw = (contents.width) / 2
for i in 0...8
draw_equip_param(i, dx, dy, dw)
dx = dx >= dw ? 0 : dw
dy += line_height if dx == 0
end
end
def draw_equip_param(param_id, dx, dy, dw)
draw_background_box(dx, dy, dw)
change_color(system_color)
draw_text(dx+4, dy, dw-8, line_height, Vocab::param(param_id))
draw_set_param(param_id, dx, dy, dw)
end
def draw_set_param(param_id, dx, dy, dw)
value = @item.params[param_id]
change_color(param_change_color(value), value != 0)
text = value.to_s
text = "+" + text if value > 0
draw_text(dx+4, dy, dw-8, line_height, text, 2)
return text
end
def draw_percent_param(param_id, dx, dy, dw)
value = @item.per_params[param_id]
change_color(param_change_color(value))
text = (@item.per_params[param_id] * 100).to_i.to_s + "%"
text = "+" + text if @item.per_params[param_id] > 0
draw_text(dx+4, dy, dw-8, line_height, text, 2)
return text
end
def draw_item_effects
return unless @item.is_a?(RPG::Item)
dx = 0; dy = 0
dw = (contents.width) / 2
draw_hp_recover(dx, dy + line_height * 0, dw)
draw_mp_recover(dx, dy + line_height * 1, dw)
draw_tp_recover(dx + dw, dy + line_height * 0, dw)
draw_tp_gain(dx + dw, dy + line_height * 1, dw)
dw = contents.width
draw_applies(dx, dy + line_height * 2, dw)
draw_removes(dx, dy + line_height * 3, dw)
end
def draw_hp_recover(dx, dy, dw)
draw_background_box(dx, dy, dw)
change_color(system_color)
draw_text(dx+4, dy, dw-8, line_height, CRAFTING_ITEM_STATUS[:hp_recover])
per = 0
set = 0
for effect in @item.effects
next unless effect.code == 11
per += (effect.value1 * 100).to_i
set += effect.value2.to_i
end
if per != 0 && set != 0
change_color(param_change_color(set))
text = set > 0 ? sprintf("+%s", set.to_s) : set.to_s
draw_text(dx+4, dy, dw-8, line_height, text, 2)
dw -= text_size(text).width
change_color(param_change_color(per))
text = per > 0 ? sprintf("+%s%%", per.to_s) : sprintf("%s%%", per.to_s)
draw_text(dx+4, dy, dw-8, line_height, text, 2)
return
elsif per != 0
change_color(param_change_color(per))
text = per > 0 ? sprintf("+%s%%", per.to_s) : sprintf("%s%%", per.to_s)
elsif set != 0
change_color(param_change_color(set))
text = set > 0 ? sprintf("+%s", set.to_s) : set.to_s
else
change_color(normal_color, false)
text = CRAFTING_ITEM_STATUS[:empty]
end
draw_text(dx+4, dy, dw-8, line_height, text, 2)
end
def draw_mp_recover(dx, dy, dw)
draw_background_box(dx, dy, dw)
change_color(system_color)
draw_text(dx+4, dy, dw-8, line_height, CRAFTING_ITEM_STATUS[:mp_recover])
per = 0
set = 0
for effect in @item.effects
next unless effect.code == 12
per += (effect.value1 * 100).to_i
set += effect.value2.to_i
end
if per != 0 && set != 0
change_color(param_change_color(set))
text = set > 0 ? sprintf("+%s", set.to_s) : set.to_s
draw_text(dx+4, dy, dw-8, line_height, text, 2)
dw -= text_size(text).width
change_color(param_change_color(per))
text = per > 0 ? sprintf("+%s%%", per.to_s) : sprintf("%s%%", per.to_s)
draw_text(dx+4, dy, dw-8, line_height, text, 2)
return
elsif per != 0
change_color(param_change_color(per))
text = per > 0 ? sprintf("+%s%%", per.to_s) : sprintf("%s%%", per.to_s)
elsif set != 0
change_color(param_change_color(set))
text = set > 0 ? sprintf("+%s", set.to_s) : set.to_s
else
change_color(normal_color, false)
text = CRAFTING_ITEM_STATUS[:empty]
end
draw_text(dx+4, dy, dw-8, line_height, text, 2)
end
def draw_tp_recover(dx, dy, dw)
draw_background_box(dx, dy, dw)
change_color(system_color)
draw_text(dx+4, dy, dw-8, line_height, CRAFTING_ITEM_STATUS[:tp_recover])
set = 0
for effect in @item.effects
next unless effect.code == 13
set += effect.value1.to_i
end
if set != 0
change_color(param_change_color(set))
text = set > 0 ? sprintf("+%s", set.to_s) : set.to_s
else
change_color(normal_color, false)
text = CRAFTING_ITEM_STATUS[:empty]
end
draw_text(dx+4, dy, dw-8, line_height, text, 2)
end
def draw_tp_gain(dx, dy, dw)
draw_background_box(dx, dy, dw)
change_color(system_color)
draw_text(dx+4, dy, dw-8, line_height, CRAFTING_ITEM_STATUS[:tp_gain])
set = @item.tp_gain
if set != 0
change_color(param_change_color(set))
text = set > 0 ? sprintf("+%s", set.to_s) : set.to_s
else
change_color(normal_color, false)
text = CRAFTING_ITEM_STATUS[:empty]
end
draw_text(dx+4, dy, dw-8, line_height, text, 2)
end
def draw_applies(dx, dy, dw)
draw_background_box(dx, dy, dw)
change_color(system_color)
draw_text(dx+4, dy, dw-8, line_height, CRAFTING_ITEM_STATUS[:applies])
icons = []
for effect in @item.effects
case effect.code
when 21
next unless effect.value1 > 0
next if $data_states[effect.value1].nil?
icons.push($data_states[effect.data_id].icon_index)
when 31
icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
when 32
icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
end
icons.delete(0)
break if icons.size >= 10
end
draw_icons(dx, dy, dw, icons)
end
def draw_removes(dx, dy, dw)
draw_background_box(dx, dy, dw)
change_color(system_color)
draw_text(dx+4, dy, dw-8, line_height, CRAFTING_ITEM_STATUS[:removes])
icons = []
for effect in @item.effects
case effect.code
when 22
next unless effect.value1 > 0
next if $data_states[effect.value1].nil?
icons.push($data_states[effect.data_id].icon_index)
when 33
icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
when 34
icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
end
icons.delete(0)
break if icons.size >= 10
end
draw_icons(dx, dy, dw, icons)
end
def draw_icons(dx, dy, dw, icons)
dx += dw - 4
dx -= icons.size * 24
for icon_id in icons
draw_icon(icon_id, dx, dy)
dx += 24
end
if icons.size == 0
change_color(normal_color, false)
text = CRAFTING_ITEM_STATUS[:empty]
draw_text(4, dy, contents.width-8, line_height, text, 2)
end
end
end
#==============================================================
# * Window_MenuCommand
#==============================================================
class Window_MenuCommand < Window_Command
alias add_crafting_menu_entry add_main_commands
def add_main_commands
add_crafting_menu_entry
add_command(MENU_CRAFTING_VOCAB, :crafting) if CRAFTING_IN_MENU
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#==============================================================
# * Initialize BaseItems
#==============================================================
module DataManager
class << self
alias load_db_sz_crafting load_database
alias save_crafting_recipe_books make_save_contents
alias load_crafting_recipe_books extract_save_contents
end
def self.load_database
load_db_sz_crafting
load_crafting_item_notetags
end
def self.load_crafting_item_notetags
groups = [$data_items, $data_weapons, $data_armors]
for group in groups
for obj in group
next if obj.nil?
obj.load_crafting_notetags_sz
end
end
end
def self.make_save_contents
contents = save_crafting_recipe_books
recipe_books = {}
for item in $data_items
next if item.nil?
next if not item.recipe_book
recipe_books[item.id] = item.recipes
end
contents[:recipe_books] = recipe_books
contents
end
def self.extract_save_contents(contents)
load_crafting_recipe_books(contents)
recipe_books = contents[:recipe_books]
recipe_books.each do |id, recipes|
$data_items[id].recipes = recipes
end
end
end
#==============================================================
# * Call Scene with Parameters
#==============================================================
class << SceneManager
alias call_scene_crafting call
attr_accessor :scene_param
def call(scene_class, *param)
@scene_param = param
call_scene_crafting(scene_class)
end
end
#==============================================================
# * List Recipes of a Book
#==============================================================
class Scene_Item < Scene_ItemBase
alias sz_crafting_determitem determine_item
def determine_item
if item.recipe_book
create_crafting_item_window
show_crafting_sub_window(@crafting_item_window)
else
sz_crafting_determitem
end
end
def create_crafting_item_window
wy = @help_window.height+@category_window.height
@crafting_item_window = Window_MenuCraftingList.new(item,wy)
@crafting_item_window.set_handler(:cancel, method(:on_sz_item_cancel))
@crafting_item_window.set_handler(:left, method(:ingredients_show_ingredients))
@crafting_item_window.set_handler(:right, method(:ingredients_show_stats))
ww = Graphics.width - @crafting_item_window.width
wh = Graphics.height - wy
@ingredients_window = Window_CraftingIngredients.new(240, wy,ww,wh)
@ingredients_window.viewport
@crafting_item_window.ingredients_window = @ingredients_window
end
def on_sz_item_cancel
hide_crafting_sub_window(@crafting_item_window)
end
def show_crafting_sub_window(window)
height_remain = @help_window.height+@category_window.height
@viewport.rect.height = height_remain
window.show.activate
end
def hide_crafting_sub_window(window)
@viewport.rect.y = @viewport.oy = 0
@viewport.rect.height = Graphics.height
window.hide.deactivate
activate_item_window
end
def ingredients_show_ingredients
@ingredients_window.showtype = 0
end
def ingredients_show_stats
@ingredients_window.showtype = 1
end
end
class Window_Selectable < Window_Base
alias :sz_cr_input_handler_process_handling :process_handling
def process_handling
return unless open? && active
sz_cr_input_handler_process_handling
return call_handler(:left) if handle?(:left) && Input.trigger?(:LEFT)
return call_handler(:right) if handle?(:right) && Input.trigger?(:RIGHT)
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#==============================================================
# * Content of Crafting Items
#==============================================================
class RPG::BaseItem
attr_accessor :ingredients
attr_accessor :recipe_book
attr_accessor :recipes
attr_accessor :cr_category
def load_crafting_notetags_sz
@ingredients = []
@recipe_book = false
@recipes = []
@cr_category = -1
@scan_ingredients = false
@scan_recipes = false
self.note.split(/[\r\n]+/).each do |line|
case line.downcase
# Ingredients
when /<(?:ingredients?)>/i
@scan_ingredients = true
when /<\/(?:ingredients?)>/i
@scan_ingredients = false
# Recipes
when /<(?:recipes?)>/i
@scan_recipes = true
when /<\/(?:recipes?)>/i
@scan_recipes = false
# Crafting Book
when /<(?:recipe book)>/i
@recipe_book = true
@itype_id = 2
when /<category:\s*?(\d+)>/i
@cr_category = $1.to_i if @recipe_book
else
scan_ingredients(line) if @scan_ingredients
scan_recipes(line) if @scan_recipes
end
end
end
def scan_ingredients(line)
return if @crafting_book
return unless line =~ /(\w+):\s*?(\d+)[x]?\s*(\d+)?/i ? true : false
case $1
when "c"
@ingredients.push([Vocab::currency_unit,$2.to_i])
when "i"
@ingredients.push([$data_items[$3.to_i], $2.to_i])
when "w"
@ingredients.push([$data_weapons[$3.to_i], $2.to_i])
when "a"
@ingredients.push([$data_armors[$3.to_i], $2.to_i])
end
end
def scan_recipes(line)
return unless line =~ /(\w+):\s*(\d+)\s*-?\s*(\d+)?/i ? true : false
from = $2.to_i
if $3 == nil
til = from
else
til = $3.to_i
end
for i in from..til
case $1
when "i"
@recipes.push($data_items[i])
when "w"
@recipes.push($data_weapons[i])
when "a"
@recipes.push($data_armors[i])
end
end
@recipes = @recipes.sort_by {|x| [x.class.to_s, x.id]}
end
def match_ingredients?
@ingredients.each do |ing|
icount = ing[0].is_a?(RPG::BaseItem) ? $game_party.item_number(ing[0]) : $game_party.gold
return false if icount < ing[1]
end
return true
end
def add_recipe(type)
return unless @recipe_book
return unless type =~ /(\w+):\s*(\d+)\s*-?\s*(\d+)?/i ? true : false
from = $2.to_i
if $3 == nil
til = from
else
til = $3.to_i
end
for i in from..til
case $1
when "i"
return if @recipes.include?($data_items[i])
@recipes.push($data_items[i])
when "w"
return if @recipes.include?($data_weapons[i])
@recipes.push($data_weapons[i])
when "a"
return if @recipes.include?($data_armors[i])
@recipes.push($data_armors[i])
end
end
@recipes = @recipes.sort_by {|x| [x.class.to_s, x.id]}
end
def remove_recipe(type)
return unless @recipe_book
return unless type =~ /(\w+):\s*(\d+)\s*-?\s*(\d+)?/i ? true : false
from = $2.to_i
if $3 == nil
til = from
else
til = $3.to_i
end
for i in from..til
case $1
when "i"
return if not @recipes.include?($data_items[i])
@recipes.delete($data_items[i])
when "w"
return if not @recipes.include?($data_weapons[i])
@recipes.delete($data_weapons[i])
when "a"
return if not @recipes.include?($data_armors[i])
@recipes.delete($data_armors[i])
end
end
@recipes = @recipes.sort_by {|x| [x.class.to_s, x.id]}
end
end
|
|
arttroy -
posté le 01/08/2015 à 02:55:07 (2394 messages postés)
| Just working | Remplace ta method def craft_item ligne 159 par ça, ça devrait fonctionner.
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
| def craft_item
item = @item_window.item
if item.item_number < item.max_item_number
item.ingredients.each do |ing|
if ing[0].is_a?(RPG::BaseItem)
$game_party.lose_item(ing[0],ing[1])
else
$game_party.lose_gold(ing[1])
end
end
$game_party.gain_item(item,1)
if @cr_category != -1
csf = CUSTOM_CRAFT_SOUNDS_BY_CAT[@cr_category]
else
if item.is_a?(RPG::Item)
csf = CUSTOM_CRAFT_SOUNDS_BY_TYPE[0]
elsif item.is_a?(RPG::Weapon)
csf = CUSTOM_CRAFT_SOUNDS_BY_TYPE[1]
elsif item.is_a?(RPG::Armor)
csf = CUSTOM_CRAFT_SOUNDS_BY_TYPE[2]
end
end
RPG::SE.new(csf, 100, 50).play
else
Sound.play_buzzer
end
@item_window.refresh
@item_window.activate
end |
|
Anti-inconstructivité / Pétition pour que le mot making soit inscrit dans le dictionnaire ? |
Keroberus -
posté le 02/08/2015 à 22:26:52 (9 messages postés)
| | Bonsoir merci pour ton aide, mais il y a un soucis a la ligne 3 du nouveau script que tu m'as envoyé, voila le message d'erreur
et je ne sais pas comment le changer
|
arttroy -
posté le 02/08/2015 à 22:31:58 (2394 messages postés)
| Just working |
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
| def craft_item
item = @item_window.item
if $game_party.item_number(item) < $game_party.max_item_number(item)
item.ingredients.each do |ing|
if ing[0].is_a?(RPG::BaseItem)
$game_party.lose_item(ing[0],ing[1])
else
$game_party.lose_gold(ing[1])
end
end
$game_party.gain_item(item,1)
if @cr_category != -1
csf = CUSTOM_CRAFT_SOUNDS_BY_CAT[@cr_category]
else
if item.is_a?(RPG::Item)
csf = CUSTOM_CRAFT_SOUNDS_BY_TYPE[0]
elsif item.is_a?(RPG::Weapon)
csf = CUSTOM_CRAFT_SOUNDS_BY_TYPE[1]
elsif item.is_a?(RPG::Armor)
csf = CUSTOM_CRAFT_SOUNDS_BY_TYPE[2]
end
end
RPG::SE.new(csf, 100, 50).play
else
Sound.play_buzzer
end
@item_window.refresh
@item_window.activate
end |
Ca devrait être mieux désolé ^^.
|
Anti-inconstructivité / Pétition pour que le mot making soit inscrit dans le dictionnaire ? |
Keroberus -
posté le 03/08/2015 à 19:52:53 (9 messages postés)
| | WOUHOUH la classe merci infiniment t'es trop fort c'est super gentil de ta part encore un grand merci ^^
|
arttroy -
posté le 03/08/2015 à 20:53:46 (2394 messages postés)
| Just working | C'était vraiment rien t'inquiètes ^^ Content que ça fonctionne
|
Anti-inconstructivité / Pétition pour que le mot making soit inscrit dans le dictionnaire ? | Index du forum > Entraide > [RPG MAKER VX ACE] Limite d'objet sur le crafting
|
|
|