Rpg²S Forum uses cookies. Read the Privacy Policy for more info. To remove this message, please click the button to the right:    I accept the use of cookies

Vai al contenuto

Rpg²S Forum uses cookies. Read the Privacy Policy for more info. To remove this message, please click the button to the right:    I accept the use of cookies

Screen Contest #90

Kamikun






  • Si prega di effettuare il log in prima di rispondere
-Support System FF9 - - - - -

    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#1 Inviato 28 August 2010 - 21:30 PM

Support System FF9


Descrizione

Questo script emula il sistema di supporto delle abilità passive presente in FF9. In pratica si possono attivare varie abilità passive con delle pietre magiche che si ottengono attraverso il level up. Molte abilità presenti in FF9 sono state implementate nel sistema più qualche extra.


Autore
Avon Valentino (Io)


Allegati
Script:
CODE -> ruby
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
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
#-------------------------------Support System FF9--------------------------
 
#script creato da Valentino Avon
#Queste sono solo alcune delle possibili abilità, per personalizzarlo rivolgetevi
#pure a me su rpg2s forum.net
#Se usate questo script per favore creditatemi ;)
 
#------------------------------CONFIGURAZIONE---------------------------------
module Pietre
#pietre iniziali per ogni personaggio
#devono essere stabilite per ogni personaggio  o darà errore.
#Il costo delle abilità in pietre viene semplicemente dato dal costo in Mp
#della abilità passiva.
 
# ID EROE => N° PIETRE,
PIETRE_INIZIALI = {
1 => 18, 2 => 15, 3 => 13, 4 => 16, 5 => 19, 6 => 10, 7 => 13, 8 => 15
}
end
 
 
PIETRA_ATTIVA = "Sfera" #pictures della pietra attiva
PIETRA_NONATTIVA = "Sfera_dis"#pictures della pietra inattiva
 
#Livelli nei quali si aquisirà una pietra.
PIETRE_LV = [3,5,8,10,13,15,18,20,23,25,28,30,33,35,38,40,43,45,48,50,53,55,58,
60,63,65,68,70,73,75,78,80,83,85,88,90,93,95,98,100]
 
#numero pietre prese raggiunto il lv di PIETRE_LV
N_PIETRE = 1
 
#Id armature che al lv di PIETRE_LV permettono l'aquisizione del doppio di pietre
ARMATURA_PIETRE = [1,5]
 
 
#id di tutte le skill passive
SKILL_PASSIVE = [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]
 
#di delle skill passive che conferiscono elementi (fuoco, ghiaccio, besticida...)
ELMNT = [81,82,83,84,85,86,87,88]
 
#Id della skill autoprotect
AUTO_PROTECT = 89
PROTECT_STATE_ID = 14 #Id dello status protect
 
#Id della skill autoshell
AUTO_SHELL = 90
SHELL_STATE_ID = 15 #ID dello status Shell
 
#ID della skill per salire piu velocemente di livello
LEVEL_UP = 91
LEVEL_UP_FATTORE = 1.5 #esperienza ottenuta moltiplicata per 2
 
#ID della skill di contrattacco
CONTRATTACCO = 92
 
#ID della skill di occhio x occhio
OCCHI_X_OCCHI = 93
 
#ID della skill di HP + 10%
HP_10 = 94
 
#ID della skill di HP + 20%
HP_20 = 95
 
#ID della skill di HP + 30%
HP_30 = 96
 
#ID della skill di HP + 40%
HP_40 = 97
 
#ID della skill di MP + 10%
SP_10 = 98
 
#ID della skill di MP + 20%
SP_20 = 99
 
#ID della skill di MP + 30%
SP_30 = 100
 
#ID della skill di MP + 40%
SP_40 = 101
 
#ID della skill Siero (protegge dal veleno)
SIERO = 102
VELENO_STATE_ID = 3 #Id dello status veleno
 
#ID della skill Megafono (protegge dal mutismo)
MEGAFONO = 103
MUTISMO_STATE_ID = 5 #Id dello status mutismo
 
#ID della skill Anti-Caos (protegge dal caos)
ANTI_CAOS = 104
CAOS_STATE_ID = 6 #Id dello status caos
 
#ID della skill Insonnia (protegge dal sonno)
INSONNIA = 105
SONNO_STATE_ID = 7 #Id dello status sonno
 
#ID della skill Distenebra (protegge dalla cecità)
DISTENEBRA = 106
CECITA_STATE_ID = 10 #Id dello status cecità
 
#ID della skill Provvidenza (Auto-risveglio)
PROVVIDENZA = 107
RISVEGLIO_STATE_ID = 17 #Id dello status risveglio
RISVEGLIO_ANIM = 25 #Id animazione risveglio
 
#ID della skill auto-rigene (recupero hp costante)
AUTO_RIGENE = 108
RIGENE_STATE_ID = 18 #Id dello status rigene
RIGENE_FATTORE = 30 #ogni turno viene recuperato un trentesimo di vita.
 
#ID della skill auto-levita (si evitano colpi di terra)
AUTO_LEVITA = 109
LEVITA_STATE_ID = 19 #Id dello status levita
TERRA = 5 #id elemento Terra
 
#ID della skill auto-reflex (si riflettono le magie)
AUTO_REFLEX = 110
REFLEX_STATE_ID = 20 #id status reflex
REFLEX_ANIM = 65 #animazione di reflex
#id skill possibili da riflettere
REFLEX_SKILL = [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]
 
#ID della skill Licenza Medica (Raddoppia effetto medicine)
LICENZA_MEDICA = 111
 
#ID della skill 50% MP (consumo mp dimezzato)
MP_DIMEZZA = 112
 
#Id della skill auto-haste (aumenta velocità d'azione)
AUTO_HASTE = 113
HASTE_STATE_ID = 21#id status Haste
 
#Id della skill applicazione (aumenta effetto magie)
APPLICAZIONE = 114
#id skill potenziate
APPLICAZIONE_SKILL = [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]
APPLICAZIONE_FORZA = 2 #danno moltiplicato per 2
 
#Id skill WILHELM_TELL (aumenta la destrezza)
WILHELM_TELL = 115
WILHELM_TELL_FATTORE = 10  #percentuale della destrezza di base che viene aggiunta
 
#Id della skill MP x Attacco (usa mp per potenziare l'attacco)
MP_X_ATTACCO = 116
MP_X_ATTACCO_FATTORE = 10 #percentuale del danno effettuato che verrà sottratta agli MP
ATK_FATTORE = 20 #Aumenta l'attacco in percentuale
 
#Id della skill Auto-pozione (usa pozione appena colpiti)
AUTO_POZIONE = 117
POZIONE_ID = 1 #id pozione e megapozione
MEGAPOZIONE_ID = 2
 
#Id della skill contramagia (contrattacca se colpito da una magia dannosa)
CONTRAMAGIA = 118
 
#id delle magie che verranno contrattaccate
#Inserire solo magie che colpiscono 1 eroe.
CONTRAMAGIA_SKILL = [7,8,10,11,13,14,16,17,19,20,22,23,25,26,28,29,31,32]
 
#id skill sinergia (abilita i cambi di status delle armi)
SINERGIA = 119
 
#id della skill MP = 1 (consuma 1 mp)
MP_1 = 120
 
#id della skill assorbire (attaccando si recupera vita)
ASSORBIRE = 121
#cosi il danno sara assorbito per un ventesimo, a valori piu grandi corrisponde
#un assorbimento minore. con 1 il danno verrà assorbito interamente.
ASSORBIRE_FATTORE = 20
 
#id della skill DANNO MP (il danno viene ridotto a metà ma vengono colpiti anche
#gli Mp)
DANNO_MP = 122
DANNO_MP_FATTORE = 20 #danno in proporzione agli mp (1 ventesimo default)
 
#id della skill doppio colpo (attacca due volte il nemico)
DOPPIO_COLPO = 123
DOPPIO_COLPO_FATTORE = 2 #Toglie la metà per ogni attacco.
 
#id della skill critico(aumenta la possibilità di fare un colpo critico)
CRITICO = 124
 
#percentuale che aumenta la probabilità del colpo critico.
#normalmente viene preso un numero a caso tra 1 e cento e viene comparato
#con la destrezza di chi attacca e la agilità di chi subisce. Se il numero a caso
#è minore della destrezza * 4 / l'agilità, avviene il colpo critico.
#questo numero viene sottratto al numero massimo che viene scelto a caso, cosi
#come default se è 10, invece che scegliere un numero tra 1 e 100 verrà scelto
#tra 1 e 90 rendendo più facile il colpo critico.
CRITICO_FATTORE = 10
 
#id della skill potenziamento critico (se esegue un colpo critico esso
#infligge ancora più danni.)
CRITICO_POT = 125
CRITICO_POT_FATTORE = 2.5 #fattore che moltiplica la potenza del colpo critico.
#il colpo critico infliggerà due volte e mezzo i danni di un attacco normale.
 
 
#id della skill assorbire (attaccando si recupera vita)
ASSORBIRE_MP = 126
#cosi il danno sara assorbito per un ventesimo, a valori piu grandi corrisponde
#un assorbimento minore. con 1 il danno verrà assorbito interamente.
ASSORBIRE_FATTORE_MP = 30
 
#Id della skill Incontri 0
INCONTRI_0 = 127
 
#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
#  This window class contains cursor movement and scroll functions.
#==============================================================================
 
class Window_Selectable_Passive < Window_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :index                    # cursor position
  attr_reader   :help_window              # help window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x      : window x-coordinate
  #     y      : window y-coordinate
  #     width  : window width
  #     height : window height
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @item_max = 1
    @column_max = 1
    @index = -1
  end
  #--------------------------------------------------------------------------
  # * Set Cursor Position
  #     index : new cursor position
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    # Update Help Text (update_help is defined by the subclasses)
    if self.active and @help_window != nil
      update_help
    end
    # Update cursor rectangle
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # * Get Row Count
  #--------------------------------------------------------------------------
  def row_max
    # Compute rows from number of items and columns
    return (@item_max + @column_max - 1) / @column_max
  end
  #--------------------------------------------------------------------------
  # * Get Top Row
  #--------------------------------------------------------------------------
  def top_row
    # Divide y-coordinate of window contents transfer origin by 1 row
    # height of 32
    return self.oy / 32
  end
  #--------------------------------------------------------------------------
  # * Set Top Row
  #     row : row shown on top
  #--------------------------------------------------------------------------
  def top_row=(row)
    # If row is less than 0, change it to 0
    if row < 0
      row = 0
    end
    # If row exceeds row_max - 1, change it to row_max - 1
    if row > row_max - 1
      row = row_max - 1
    end
    # Multiply 1 row height by 32 for y-coordinate of window contents
    # transfer origin
    self.oy = row * 32
  end
  #--------------------------------------------------------------------------
  # * Get Number of Rows Displayable on 1 Page
  #--------------------------------------------------------------------------
  def page_row_max
    # Subtract a frame height of 32 from the window height, and divide it by
    # 1 row height of 32
    return (self.height - 32) / 32
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items Displayable on 1 Page
  #--------------------------------------------------------------------------
  def page_item_max
    # Multiply row count (page_row_max) times column count (@column_max)
    return page_row_max * @column_max
  end
  #--------------------------------------------------------------------------
  # * Set Help Window
  #     help_window : new help window
  #--------------------------------------------------------------------------
  def help_window=(help_window)
    @help_window = help_window
    # Update help text (update_help is defined by the subclasses)
    if self.active and @help_window != nil
      update_help
    end
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # If cursor position is less than 0
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # Get current row
    row = @index / @column_max
    # If current row is before top row
    if row < self.top_row
      # Scroll so that current row becomes top row
      self.top_row = row
    end
    # If current row is more to back than back row
    if row > self.top_row + (self.page_row_max - 1)
      # Scroll so that current row becomes back row
      self.top_row = row - (self.page_row_max - 1)
    end
    # Calculate cursor width
    cursor_width = self.width / @column_max - 32
    # Calculate cursor coordinates
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    # Update cursor rectangle
    self.cursor_rect.set(x, y, cursor_width, 32)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # If cursor is movable
    if self.active and @item_max > 0 and @index >= 0
      # If pressing down on the directional buttons
      if Input.repeat?(Input::DOWN)
        # If column count is 1 and directional button was pressed down with no
        # repeat, or if cursor position is more to the front than
        # (item count - column count)
        if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
           @index < @item_max - @column_max
          # Move cursor down
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
        end
      end
      # If the up directional button was pressed
      if Input.repeat?(Input::UP)
        # If column count is 1 and directional button was pressed up with no
        # repeat, or if cursor position is more to the back than column count
        if (@column_max == 1 and Input.trigger?(Input::UP)) or
           @index >= @column_max
          # Move cursor up
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
        end
      end
      # If the right directional button was pressed
      if Input.repeat?(Input::RIGHT)
        # If column count is 2 or more, and cursor position is closer to front
        # than (item count -1)
        if @column_max >= 2 and @index < @item_max - 1
          # Move cursor right
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      # If the left directional button was pressed
      if Input.repeat?(Input::LEFT)
        # If column count is 2 or more, and cursor position is more back than 0
        if @column_max >= 2 and @index > 0
          # Move cursor left
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      # If R button was pressed
    end
    # Update help text (update_help is defined by the subclasses)
    if self.active and @help_window != nil
      update_help
    end
    # Update cursor rectangle
    update_cursor_rect
  end
end
 
 
#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
#  This window displays usable skills on the skill and battle screens.
#==============================================================================
 
class Window_Skill < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills[i]]
      if skill != nil
        unless SKILL_PASSIVE.include?(skill.id)
        @data.push(skill)
      end
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    if $game_temp.in_battle
      if @actor.skill_learn?(MP_DIMEZZA)
        sp_2 = skill.sp_cost / 2
    self.contents.draw_text(x + 232, y, 48, 32, sp_2.to_s, 2)
  elsif @actor.skill_learn?(MP_1)
   self.contents.draw_text(x + 232, y, 48, 32, "1", 2)
   else
    self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  end
else
  self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  end
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  end
end
 
 
#==============================================================================
# ** Window_Passive
#------------------------------------------------------------------------------
#  This window displays passive skills on the skill and battle screens.
#==============================================================================
 
class Window_Pass < Window_Selectable_Passive
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 128, 640, 352)
    @actor = actor
    @column_max = 2
    refresh
    self.index = 0
    # If in battle, move window to center of screen
    # and make it semi-transparent
  end
  #--------------------------------------------------------------------------
  # * Acquiring Skill
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...$data_skills.size
      skill = $data_skills[i]
      if SKILL_PASSIVE.include?(skill.id) and @actor.passive.include?(skill.id)
 
        @data.push(skill)
      end
      end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    self.contents.font.color = normal_color
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(PIETRA_ATTIVA) if @actor.skill_learn?(skill.id)
    bitmap = RPG::Cache.icon(PIETRA_NONATTIVA) unless @actor.skill_learn?(skill.id)
    if skill.id == OCCHI_X_OCCHI and @actor.contrattacco == false
       self.contents.font.color = disabled_color
       end
 
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  end
end
 
 
#==============================================================================
# ** Game_Battler (part 2)
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================
 
class Game_Battler
  attr_accessor :damage_mp
  attr_accessor :damage_pop_mp
 
  alias battler_initialize initialize
  def initialize
    @damage_mp = nil
    @damage_pop_mp = false
    battler_initialize
    end
  #--------------------------------------------------------------------------
  # * State Change (+) Application
  #     plus_state_set  : State Change (+)
  #--------------------------------------------------------------------------
  def states_plus(plus_state_set)
    # Clear effective flag
    effective = false
    # Loop (added state)
    for i in plus_state_set
      if self.is_a?(Game_Actor)
      for skill in $data_skills
       if skill_learn?(skill.id)
         stato = $data_states[i]
 
    if skill.id == SIERO and stato.id == VELENO_STATE_ID
    @state_changed = false
    @protezione = true
  end
 
    if skill.id == MEGAFONO and stato.id == MUTISMO_STATE_ID
    @state_changed = false
    @protezione = true
  end
 
    if skill.id == ANTI_CAOS and stato.id == CAOS_STATE_ID
    @state_changed = false
    @protezione = true
  end
 
    if skill.id == INSONNIA and stato.id == SONNO_STATE_ID
    @state_changed = false
    @protezione = true
  end
 
  if skill.id == DISTENEBRA and stato.id == CECITA_STATE_ID
    @state_changed = false
    @protezione = true
  end
 
  end
end
end
  unless @protezione
      # If this state is not guarded
      unless self.state_guard?(i)
        # Set effective flag if this state is not full
        effective |= self.state_full?(i) == false
        # If states offer [no resistance]
        if $data_states[i].nonresistance
          # Set state change flag
          @state_changed = true
          # Add a state
          add_state(i)
        # If this state is not full
        elsif self.state_full?(i) == false
          # Convert state effectiveness to probability,
          # compare to random numbers
          if rand(100) < [0,100,80,60,40,20,0][self.state_ranks[i]]
            # Set state change flag
            @state_changed = true
            # Add a state
            add_state(i)
          end
        end
      end
    end
    # End Method
    return effective
  end
  end
  #--------------------------------------------------------------------------
  # * Applying Normal Attack Effects
  #     attacker : battler
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # Clear critical flag
    self.critical = false
    # First hit detection
    hit_result = (rand(100) < attacker.hit)
    # If hit occurs
    if hit_result == true
      # Calculate basic damage
      atk = [attacker.atk - self.pdef / 2, 0].max
      #MP per attacco
      if attacker.is_a?(Game_Actor) and attacker.skill_learn?(MP_X_ATTACCO) and attacker.sp > 0
          atk += (attacker.atk * ATK_FATTORE) / 100
          end
      self.damage = atk * (20 + attacker.str) / 20
      # Element correction
      self.damage *= elements_correct(attacker.element_set)
 
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Critical correction
        if attacker.is_a?(Game_Actor) and attacker.skill_learn?(CRITICO)
          numero = 100 - CRITICO_FATTORE
          if rand(numero) < 4 * attacker.dex / self.agi
            self.damage *= 2 unless attacker.skill_learn?(CRITICO_POT)
            self.damage *= CRITICO_POT_FATTORE if attacker.skill_learn?(CRITICO_POT)
          self.critical = true
          self.damage = self.damage.to_i
        end
 
      else #se non ha imparato la skill CRITICO verifica normalmente
 
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2 unless attacker.skill_learn?(CRITICO_POT)
          self.damage *= CRITICO_POT_FATTORE if attacker.skill_learn?(CRITICO_POT)
          self.critical = true
          self.damage = self.damage.to_i
        end
 
        end
        #Mp per attacco
        if attacker.is_a?(Game_Actor) and attacker.skill_learn?(MP_X_ATTACCO) and attacker.sp > 0
          attacker.sp -= (self.damage*MP_X_ATTACCO_FATTORE)/ 100
          end
 
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
       if attacker.is_a?(Game_Actor) and attacker.skill_learn?(DOPPIO_COLPO)
        self.damage /= DOPPIO_COLPO_FATTORE unless $contra
        end
      end
      # Dispersion
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    # If hit occurs
    if hit_result == true
      # State Removed by Shock
      remove_states_shock
      # Substract damage from HP
       if attacker.is_a?(Game_Actor)  
    unless attacker.skill_learn?(DANNO_MP)
      self.hp -= self.damage
    else
      self.hp -= self.damage/2
      self.hp -= self.damage
     # self.damage_mp = self.damage/DANNO_MP_FATTORE
      self.sp -= self.damage/DANNO_MP_FATTORE
    end
  else
    self.hp -= self.damage
  end
 
      # State change
      @state_changed = false
      @protezione = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # When missing
    else
      # Set damage to "Miss"
      self.damage = "Mancato!"
 
      # Clear critical flag
      self.critical = false
    end
    self.damage = "Guardia!" if @protezione #se si è immuni allo status
    # End Method
 
    return true
  end
  #--------------------------------------------------------------------------
  # * Apply Skill Effects
  #     user  : the one using skills (battler)
  #     skill : skill
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # Clear critical flag
    self.critical = false
    # If skill scope is for ally with 1 or more HP, and your own HP = 0,
    # or skill scope is for ally with 0, and your own HP = 1 or more
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      # End Method
      return false
    end
    # Clear effective flag
    effective = false
    # Set effective flag if common ID is effective
    effective |= skill.common_event_id > 0
    # First hit detection
    hit = skill.hit
    if skill.atk_f > 0
      hit *= user.hit / 100
    end
    hit_result = (rand(100) < hit)
    # Set effective flag if skill is uncertain
    effective |= hit < 100
    # If hit occurs
    if hit_result == true
      # Calculate power
      power = skill.power + user.atk * skill.atk_f / 100
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0].max
      end
      # Calculate rate
      rate = 20
      rate += (user.str * skill.str_f / 100)
      rate += (user.dex * skill.dex_f / 100)
      rate += (user.agi * skill.agi_f / 100)
      rate += (user.int * skill.int_f / 100)
      # Calculate basic damage
      self.damage = power * rate / 20
      # Element correction
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      if skill.variance > 0 and self.damage.abs > 0
        amp = [self.damage.abs * skill.variance / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / user.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
      # Set effective flag if skill is uncertain
      effective |= hit < 100
    end
    # If hit occurs
    if hit_result == true
      # If physical attack has power other than 0
      if skill.power != 0 and skill.atk_f > 0
        # State Removed by Shock
        remove_states_shock
        # Set to effective flag
        effective = true
      end
      if self.is_a?(Game_Actor)
for abilities in $data_skills
   #Se auto levita rende immuni agli attacchi di terra
  if abilities.id == AUTO_LEVITA and self.skill_learn?(abilities.id) and skill.element_set.include?(TERRA)
        @levita = true
       end
     end
   end
   if user.is_a?(Game_Actor)
     #Se applicazione è attiva aumenta il danno delle abilità
      if user.skill_learn?(APPLICAZIONE) and APPLICAZIONE_SKILL.include?(skill.id)
         self.damage *= APPLICAZIONE_FORZA
         self.damage = self.damage_to.i
       end
       end
      # Substract damage from HP
      last_hp = self.hp
            if user.is_a?(Game_Actor)
    unless user.skill_learn?(DANNO_MP)
      self.hp -= self.damage unless @levita
    else
      self.hp -= self.damage/2 unless @levita
     # self.damage_mp = self.damage/DANNO_MP_FATTORE
      self.sp -= self.damage/DANNO_MP_FATTORE unless @levita
    end
  else
 
  self.hp -= self.damage unless @levita
  end
     # self.hp -= self.damage/2 unless @levita
     # self.sp -= self.damage/DANNO_MP_FATTORE unless @levita
     # self.damage_mp = self.damage/DANNO_MP_FATTORE unless @levita
      @levita = false
      effective |= self.hp != last_hp
      # State change
      @state_changed = false
      @protezione = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # If power is 0
      if skill.power == 0
        # Set damage to an empty string
        self.damage = ""
        # If state is unchanged
        unless @state_changed
          # Set damage to "Miss"
          self.damage = "Mancato!"
        end
      end
    # If miss occurs
    else
      # Set damage to "Miss"
      self.damage = "Mancato!"
    end
    # If not in battle
    unless $game_temp.in_battle
      # Set damage to nil
      self.damage = nil
    end
   self.damage = "Guardia!" if @protezione #se immuni allo status
 
    if self.is_a?(Game_Actor)
   for abilities in $data_skills
     #Se auto levita rende immuni agli attacchi di terra
  if abilities.id == AUTO_LEVITA and self.skill_learn?(abilities.id) and skill.element_set.include?(TERRA)
 
         self.damage = "Immune"
       end
       end
     end
    # End Method
    return effective
  end
  #--------------------------------------------------------------------------
  # * Application of Item Effects
  #     item : item
  #--------------------------------------------------------------------------
  def item_effect(item, user)
    # Clear critical flag
    self.critical = false
    # If item scope is for ally with 1 or more HP, and your own HP = 0,
    # or item scope is for ally with 0 HP, and your own HP = 1 or more
    if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
       ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
      # End Method
      return false
    end
    # Clear effective flag
    effective = false
    # Set effective flag if common ID is effective
    effective |= item.common_event_id > 0
    # Determine hit
    hit_result = (rand(100) < item.hit)
    # Set effective flag is skill is uncertain
    effective |= item.hit < 100
    # If hit occurs
    if hit_result == true
      # Calculate amount of recovery
      recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
      recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
      if recover_hp < 0
        recover_hp += self.pdef * item.pdef_f / 20
        recover_hp += self.mdef * item.mdef_f / 20
        recover_hp = [recover_hp, 0].min
      end
      # Element correction
      recover_hp *= elements_correct(item.element_set)
      recover_hp /= 100
      recover_sp *= elements_correct(item.element_set)
      recover_sp /= 100
      # Dispersion
      if item.variance > 0 and recover_hp.abs > 0
        amp = [recover_hp.abs * item.variance / 100, 1].max
        recover_hp += rand(amp+1) + rand(amp+1) - amp
      end
      if item.variance > 0 and recover_sp.abs > 0
        amp = [recover_sp.abs * item.variance / 100, 1].max
        recover_sp += rand(amp+1) + rand(amp+1) - amp
      end
      # If recovery code is negative
      if recover_hp < 0
        # Guard correction
        if self.guarding?
          recover_hp /= 2
        end
      end
      # Set damage value and reverse HP recovery amount
 
      # HP and SP recovery
      last_hp = self.hp
      last_sp = self.sp
 
      #se licenza medica è attiva raddoppia gli effetti delle medicine
if user.skill_learn?(LICENZA_MEDICA)
   recover_hp *= 2 if recover_hp > 0
   recover_sp *= 2 if recover_sp > 0
 
end
self.damage = -recover_hp
      self.hp += recover_hp
      self.sp += recover_sp
      effective |= self.hp != last_hp
      effective |= self.sp != last_sp
      # State change
      @state_changed = false
      @protezione = false
      effective |= states_plus(item.plus_state_set)
      effective |= states_minus(item.minus_state_set)
      # If parameter value increase is effective
      if item.parameter_type > 0 and item.parameter_points != 0
        # Branch by parameter
        case item.parameter_type
        when 1  # Max HP
          @maxhp_plus += item.parameter_points
        when 2  # Max SP
          @maxsp_plus += item.parameter_points
        when 3  # Strength
          @str_plus += item.parameter_points
        when 4  # Dexterity
          @dex_plus += item.parameter_points
        when 5  # Agility
          @agi_plus += item.parameter_points
        when 6  # Intelligence
          @int_plus += item.parameter_points
        end
        # Set to effective flag
        effective = true
      end
      # If HP recovery rate and recovery amount are 0
      if item.recover_hp_rate == 0 and item.recover_hp == 0
        # Set damage to empty string
        self.damage = ""
        # If SP recovery rate / recovery amount are 0, and parameter increase
        # value is ineffective.
        if item.recover_sp_rate == 0 and item.recover_sp == 0 and
           (item.parameter_type == 0 or item.parameter_points == 0)
          # If state is unchanged
          unless @state_changed
            # Set damage to "Miss"
            self.damage = "Mancato!"
          end
        end
      end
    # If miss occurs
    else
      # Set damage to "Miss"
      self.damage = "Mancato!"
    end
    # If not in battle
    unless $game_temp.in_battle
      # Set damage to nil
      self.damage = nil
    end
    # End Method
     self.damage = "Guardia!" if @protezione
    return effective
  end
end
 
 
#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
#  This class handles enemies. It's used within the Game_Troop class
#  ($game_troop).
#==============================================================================
 
class Game_Enemy < Game_Battler
  attr_accessor :contrattacco
   attr_accessor :random
   attr_accessor :occhio
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     troop_id     : troop ID
  #     member_index : troop member index
  #--------------------------------------------------------------------------
  def initialize(troop_id, member_index)
    super()
    @troop_id = troop_id
    @member_index = member_index
    troop = $data_troops[@troop_id]
    @enemy_id = troop.members[@member_index].enemy_id
    enemy = $data_enemies[@enemy_id]
    @battler_name = enemy.battler_name
    @battler_hue = enemy.battler_hue
    @hp = maxhp
    @sp = maxsp
    @hidden = troop.members[@member_index].hidden
    @immortal = troop.members[@member_index].immortal
    @contrattacco = false
    @random = false
    @occhio = false
  end
end
 
 
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
 
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :name                     # name
  attr_reader   :character_name           # character file name
  attr_reader   :character_hue            # character hue
  attr_reader   :class_id                 # class ID
  attr_reader   :weapon_id                # weapon ID
  attr_reader   :armor1_id                # shield ID
  attr_reader   :armor2_id                # helmet ID
  attr_reader   :armor3_id                # body armor ID
  attr_reader   :armor4_id                # accessory ID
  attr_reader   :level                    # level
  attr_reader   :exp                      # EXP
  attr_reader   :skills                   # skills
  attr_accessor :passive
  attr_accessor :pietre
  attr_accessor :pietre_usate
  attr_accessor :pietre_disp
  attr_accessor :contrattacco
  attr_accessor :random
  attr_accessor :occhio
  attr_accessor :danno
  attr_accessor :pozione
  attr_accessor :megapozione
  attr_accessor :contramagia
  attr_accessor :danno_magia
  attr_accessor :sinergia
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def initialize(actor_id)
    super()
    setup(actor_id)
  end
  #--------------------------------------------------------------------------
  # * Setup
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def setup(actor_id)
    @danno = false
    @occhio = false
    @random = false
    @pozione = false
    @megapozione = false
    @contramagia = false
    @danno_magia = false
    @sinergia = false
    @pietre = Pietre::PIETRE_INIZIALI[actor_id]
    @pietre_usate = 0
    @pietre_disp = @pietre - @pietre_usate
    @contrattacco = false
    @passive = []
    actor = $data_actors[actor_id]
    @actor_id = actor_id
    @name = actor.name
    @character_name = actor.character_name
    @character_hue = actor.character_hue
    @battler_name = actor.battler_name
    @battler_hue = actor.battler_hue
    @class_id = actor.class_id
    @weapon_id = actor.weapon_id
    @armor1_id = actor.armor1_id
    @armor2_id = actor.armor2_id
    @armor3_id = actor.armor3_id
    @armor4_id = actor.armor4_id
    @level = actor.initial_level
    @exp_list = Array.new(101)
    make_exp_list
    @exp = @exp_list[@level]
    @skills = []
    @hp = maxhp
    @sp = maxsp
    @states = []
    @states_turn = {}
    @maxhp_plus = 0
    @maxsp_plus = 0
    @str_plus = 0
    @dex_plus = 0
    @agi_plus = 0
    @int_plus = 0
    # Learn skill
    for i in 1..@level
      for j in $data_classes[@class_id].learnings
        if j.level == i
          unless SKILL_PASSIVE.include?(j.skill_id)
          learn_skill(j.skill_id)
        else
          self.passive.push(j.skill_id)
          end
        end
      end
    end
    # Update auto state
    update_auto_state(nil, $data_armors[@armor1_id])
    update_auto_state(nil, $data_armors[@armor2_id])
    update_auto_state(nil, $data_armors[@armor3_id])
    update_auto_state(nil, $data_armors[@armor4_id])
  end
  #--------------------------------------------------------------------------
  # * Get Normal Attack Element
  #--------------------------------------------------------------------------
  def element_set
    for skill in $data_skills
       if ELMNT.include?(skill.id) and skill_learn?(skill.id)
         return skill != nil ? skill.element_set : []
       end
     end
 
     weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.element_set : []
  end
 
  #--------------------status-------------
  def plus_state_set
    weapon = $data_weapons[@weapon_id]
    if self.sinergia
    return weapon != nil ? weapon.plus_state_set : []
  else
    return []
    end
  end
 
  #--------------------------------------------------------------------------
  # * Get Maximum HP
  #--------------------------------------------------------------------------
  def maxhp
    n = [[base_maxhp + @maxhp_plus, 1].max, 9999].min
    for i in @states
      n *= $data_states[i].maxhp_rate / 100.0
    end
     for skill in $data_skills
       if skill_learn?(skill.id)
      n += (base_maxhp*10)/100 if skill.id == HP_10
      n += (base_maxhp*20)/100 if skill.id == HP_20
      n += (base_maxhp*30)/100 if skill.id == HP_30
      n += (base_maxhp*40)/100 if skill.id == HP_40
      end
      end
    n = [[Integer(n), 1].max, 9999].min
    return n
  end
 
  def maxsp
    n = [[base_maxsp + @maxsp_plus, 0].max, 9999].min
    for i in @states
      n *= $data_states[i].maxsp_rate / 100.0
    end
    for skill in $data_skills
       if skill_learn?(skill.id)
      n += (base_maxsp*10)/100 if skill.id == SP_10
      n += (base_maxsp*20)/100 if skill.id == SP_20
      n += (base_maxsp*30)/100 if skill.id == SP_30
      n += (base_maxsp*40)/100 if skill.id == SP_40
      end
      end
    n = [[Integer(n), 0].max, 9999].min
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Dexterity
  #--------------------------------------------------------------------------
  def base_dex
    n = $data_actors[@actor_id].parameters[3, @level]
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
      if self.skill_learn?(WILHELM_TELL)
     n += (n* WILHELM_TELL_FATTORE)/100
    end
    n += weapon != nil ? weapon.dex_plus : 0
    n += armor1 != nil ? armor1.dex_plus : 0
    n += armor2 != nil ? armor2.dex_plus : 0
    n += armor3 != nil ? armor3.dex_plus : 0
    n += armor4 != nil ? armor4.dex_plus : 0
    return [[n, 1].max, 999].min
  end
  #--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
           if PIETRE_LV.include?(@level)
            self.pietre += N_PIETRE
            if ARMATURA_PIETRE.include?(@armor1_id) or ARMATURA_PIETRE.include?(@armor2_id) or ARMATURA_PIETRE.include?(@armor3_id) or ARMATURA_PIETRE.include?(@armor4_id)
            self.pietre += N_PIETRE
          end
            end
      # Learn skill
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          unless SKILL_PASSIVE.include?(j.skill_id)
          learn_skill(j.skill_id)
        else
          self.passive.push(j.skill_id)
          end
        end
      end
    end
    # Level down
    while @exp < @exp_list[@level]
      @level -= 1
      if PIETRE_LV.include?(@level)
            self.pietre -= N_PIETRE
      end
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
end
 
 
#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
#  This class performs skill screen processing.
#==============================================================================
 
class Scene_Passiva
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make help window, status window, and skill window
    @help_window = Window_Help.new
    @status_window = Window_Passive_Status.new(@actor)
    @skill_window = Window_Pass.new(@actor)#Skill.new(@actor)
    # Associate help window
    @skill_window.help_window = @help_window
    # Make target window (set to invisible / inactive)
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @status_window.dispose
    @skill_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @status_window.update
    @skill_window.update
    # If skill window is active: call update_skill
    if @skill_window.active
      update_skill
      return
    end
    # If skill target is active: call update_target
  end
  #--------------------------------------------------------------------------
  # * Frame Update (if skill window is active)
  #--------------------------------------------------------------------------
  def update_skill
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(1)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      actor = $game_party.actors[@actor_index]
      @actor.pietre_disp = @actor.pietre - @actor.pietre_usate
      # Get currently selected data on the skill window
      @skill = @skill_window.skill
      # If unable to use
      if @skill == nil
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
 
 
      # If effect scope is ally
     if actor.skill_learn?(@skill.id)
       $game_system.se_play($data_system.decision_se)
        actor.forget_skill(@skill.id)
       # @actor.pietre_disp =+ @skill.sp_cost
      @actor.pietre_usate -= @skill.sp_cost
     @actor.contramagia = false if @skill.id == CONTRAMAGIA #contramagia
 
 
      if @skill.id == CONTRATTACCO #disabilita occhi per occhi se contrattacco = false
        occhi = $data_skills[OCCHI_X_OCCHI]
        @actor.pietre_usate -= occhi.sp_cost if @actor.occhio
      @actor.contrattacco = false
      @actor.occhio = false
      actor.forget_skill(OCCHI_X_OCCHI)
      end
    @actor.occhio = false if @skill.id == OCCHI_X_OCCHI #occhi per occhi
    @actor.sinergia = false if @skill.id == SINERGIA #sinergia
      @actor.pietre_disp = @actor.pietre - @actor.pietre_usate
    elsif not actor.skill_learn?(@skill.id)
        if @actor.pietre_disp >= @skill.sp_cost
       # @actor.pietre_disp =- @skill.sp_cost
      @actor.contrattacco = true if @skill.id == CONTRATTACCO # contrattacco
      if @skill.id == OCCHI_X_OCCHI #abilita solo se contrattacco = true
        if @actor.contrattacco
       @actor.occhio = true
      else
        $game_system.se_play($data_system.buzzer_se)
        return
      end
    end
    @actor.contramagia = true if @skill.id == CONTRAMAGIA
    @actor.sinergia = true if @skill.id == SINERGIA
    $game_system.se_play($data_system.decision_se)
      @actor.pietre_usate += @skill.sp_cost
      @actor.pietre_disp = @actor.pietre - @actor.pietre_usate
        actor.learn_skill(@skill.id)
      else
        $game_system.se_play($data_system.buzzer_se)
        return
        end
      end
 
       @status_window.refresh
     @skill_window.refresh
     end
    # If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different skill screen
      $scene = Scene_Passiva.new(@actor_index)
      return
    end
    # If L button was pressed
    if Input.trigger?(Input::L)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different skill screen
      $scene = Scene_Passiva.new(@actor_index)
      return
    end
  end
end
 
 
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================
 
class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x      : window x-coordinate
  #     y      : window y-coordinate
  #     width  : window width
  #     height : window height
  #--------------------------------------------------------------------------
 
  #--------------------------------------------------------------------------
  # * Draw Name
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_pietre(actor, x, y, width = 144)
    # Draw "SP" text string
    # Calculate if there is draw space for MaxHP
    # Draw SP
     rect = Rect.new(x, y, 144, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(PIETRA_ATTIVA)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x+20, y, 48, 32, actor.pietre_usate.to_s, 2)
    # Draw MaxSP
      self.contents.draw_text(x+ 68, y, 12, 32, "/", 1)
      self.contents.draw_text(x + 80, y, 48, 32, actor.pietre.to_s)
  end
  #--------------------------------------------------------------------------
  # * Draw Class
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
end
 
 
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  This window displays party member status on the menu screen.
#==============================================================================
 
class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 480, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 64
      y = i * 116
      actor = $game_party.actors[i]
      draw_actor_graphic(actor, x - 40, y + 80)
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x + 144, y)
      draw_actor_level(actor, x, y + 32)
      draw_actor_state(actor, x + 90, y + 32)
      draw_actor_exp(actor, x, y + 64)
      draw_actor_hp(actor, x + 236, y + 32)
      draw_actor_sp(actor, x + 236, y + 64)
      draw_actor_pietre(actor, x+ 236, y)
    end
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
    end
  end
end
 
 
#==============================================================================
# ** Window_SkillStatus
#------------------------------------------------------------------------------
#  This window displays the skill user's status on the skill screen.
#==============================================================================
 
class Window_Passive_Status < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 64, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_name(@actor, 4, 0)
    draw_actor_hp(@actor, 140, 0)
    draw_actor_sp(@actor, 284, 0)
    draw_actor_pietre(@actor, 460, 0)
  end
end
 
 
#==============================================================================
# ** Scene_Battle (part 1)
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================
 
class Scene_Battle
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Initialize each kind of temporary battle data
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    # Initialize battle event interpreter
    $game_system.battle_interpreter.setup(nil, 0)
    # Prepare troop
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    # Make actor command window
    for actor in $game_party.actors
     for skill in $data_skills
       if skill.id == AUTO_PROTECT and actor.skill_learn?(skill.id)
         actor.add_state(PROTECT_STATE_ID, true)
        elsif skill.id == AUTO_SHELL and actor.skill_learn?(skill.id)
         actor.add_state(SHELL_STATE_ID, true)
      elsif skill.id == PROVVIDENZA and actor.skill_learn?(skill.id)
         actor.add_state(RISVEGLIO_STATE_ID, true)
     elsif skill.id == AUTO_RIGENE and actor.skill_learn?(skill.id)
         actor.add_state(RIGENE_STATE_ID, true)    
     elsif skill.id == AUTO_LEVITA and actor.skill_learn?(skill.id)
         actor.add_state(LEVITA_STATE_ID, true)
      elsif skill.id == AUTO_REFLEX and actor.skill_learn?(skill.id)
         actor.add_state(REFLEX_STATE_ID, true)    
      elsif skill.id == AUTO_HASTE and actor.skill_learn?(skill.id)
         actor.add_state(HASTE_STATE_ID, true)    
         end
     end
   end
   $fase = false
   $fase_4_2 = false
   $fase_5_2 = false
   $contra = false
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # Make other windows
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @message_window = Window_Message.new
    # Make sprite set
    @spriteset = Spriteset_Battle.new
    # Initialize wait count
    @wait_count = 0
    # Execute transition
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
        $data_system.battle_transition)
    end
    # Start pre-battle phase
    start_phase1
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Refresh map
    $game_map.refresh
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @actor_command_window.dispose
    @party_command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    # Dispose of sprite set
    @spriteset.dispose
    # If switching to title screen
    if $scene.is_a?(Scene_Title)
      # Fade out screen
      Graphics.transition
      Graphics.freeze
    end
    # If switching from battle test to any screen other than game over screen
    if $BTEST and not $scene.is_a?(Scene_Gameover)
      $scene = nil
    end
  end
 
  #--------------------------------------------------------------------------
  # * Determine Battle Win/Loss Results
  #--------------------------------------------------------------------------
  def judge
    # If all dead determinant is true, or number of members in party is 0
    if $game_party.all_dead? or $game_party.actors.size == 0
      # If possible to lose
      if $game_temp.battle_can_lose
        # Return to BGM before battle starts
        $game_system.bgm_play($game_temp.map_bgm)
        # Battle ends
        battle_end(2)
        # Return true
        return true
      end
      # Set game over flag
      $game_temp.gameover = true
      # Return true
      return true
    end
    # Return false if even 1 enemy exists
    for enemy in $game_troop.enemies
      if enemy.exist?
        return false
      end
    end
    # Start after battle phase (win)
    start_phase5
    # Return true
    return true
  end
  #--------------------------------------------------------------------------
  # * Battle Ends
  #     result : results (0:win 1:lose 2:escape)
  #--------------------------------------------------------------------------
  def battle_end(result)
    # Clear in battle flag
    $game_temp.in_battle = false
    # Clear entire party actions flag
    $game_party.clear_actions
    # Remove battle states
    for actor in $game_party.actors
      actor.remove_states_battle
    end
    # Clear enemies
    $game_troop.enemies.clear
    # Call battle callback
    if $game_temp.battle_proc != nil
      $game_temp.battle_proc.call(result)
      $game_temp.battle_proc = nil
    end
    for actor in $game_party.actors
 
     for skill in $data_skills
       if skill.id == AUTO_PROTECT and actor.skill_learn?(skill.id)
         actor.remove_state(PROTECT_STATE_ID, true)
       elsif skill.id == AUTO_SHELL and actor.skill_learn?(skill.id)
         actor.remove_state(SHELL_STATE_ID, true)
       elsif skill.id == PROVVIDENZA and actor.skill_learn?(skill.id)
         actor.remove_state(RISVEGLIO_STATE_ID, true)
      elsif skill.id == AUTO_RIGENE and actor.skill_learn?(skill.id)
         actor.remove_state(RIGENE_STATE_ID, true)
        elsif skill.id == AUTO_LEVITA and actor.skill_learn?(skill.id)
         actor.remove_state(LEVITA_STATE_ID, true)  
         elsif skill.id == AUTO_REFLEX and actor.skill_learn?(skill.id)
         actor.remove_state(REFLEX_STATE_ID, true)    
      elsif skill.id == AUTO_HASTE and actor.skill_learn?(skill.id)
         actor.remove_state(HASTE_STATE_ID, true)    
         end
     end
     end
    # Switch to map screen
    $scene = Scene_Map.new
  end
 
 
 
  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  def start_phase5
    # Shift to phase 5
    @phase = 5
    # Play battle end ME
    $game_system.me_play($game_system.battle_end_me)
    # Return to BGM before battle started
    $game_system.bgm_play($game_temp.map_bgm)
    # Initialize EXP, amount of gold, and treasure
    exp = 0
    gold = 0
    treasures = []
    # Loop
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP and amount of gold obtained
        exp += enemy.exp
        gold += enemy.gold
        # Determine if treasure appears
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    # Treasure is limited to a maximum of 6 items
    treasures = treasures[0..5]
    # Obtaining EXP
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    for actor in $game_party.actors
      for skill in $data_skills
       if skill.id == LEVEL_UP and actor.skill_learn?(skill.id)
         actor.exp += (exp * LEVEL_UP_FATTORE).to_i
         actor.exp -= exp
       end
     end
     end
    # Obtaining gold
    $game_party.gain_gold(gold)
    # Obtaining treasure
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    # Make battle result window
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    # Set wait count
    @phase5_wait_count = 100
  end
end
 
 
#==============================================================================
# ** Scene_Battle (part 4)
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================
 
class Scene_Battle
 
  #--------------------------------------------------------------------------
  # * Frame Update (main phase)
  #--------------------------------------------------------------------------
  def update_phase4
    case @phase4_step
    when 1
      update_phase4_step1
    when 2
      update_phase4_step2
    when 3
      update_phase4_step3
    when 4
      update_phase4_step4
    when 4.1
      update_phase4_step4_2
    when 4.2
      update_phase4_step4_3    
    when 5
      update_phase4_step5
    when 5.1
      update_phase4_step5_2  
    when 5.2
      update_phase4_step5_3  
    when 6
      update_phase4_step6
    when 7
      update_phase4_step7
    when 8
      update_phase4_step8  
    when 9
      update_phase4_step9
    when 10
      update_phase4_step10
    when 11
      update_phase4_step11  
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 1 : action preparation)
  #--------------------------------------------------------------------------
  def update_phase4_step1
    # Hide help window
    @help_window.visible = false
    # Determine win/loss
    if judge
      # If won, or if lost : end method
      return
    end
    # If an action forcing battler doesn't exist
    if $game_temp.forcing_battler == nil
      # Set up battle event
      setup_battle_event
      # If battle event is running
      if $game_system.battle_interpreter.running?
        return
      end
    end
    # If an action forcing battler exists
    if $game_temp.forcing_battler != nil
      # Add to head, or move
      @action_battlers.delete($game_temp.forcing_battler)
      @action_battlers.unshift($game_temp.forcing_battler)
    end
    # If no actionless battlers exist (all have performed an action)
    if @action_battlers.size == 0
      # Start party command phase
      for actor in $game_party.actors
        #se rigene è attivo recupera un 30esimo di vita
     if actor.states.include?(RIGENE_STATE_ID) and actor.hp < actor.maxhp
       #actor.animation_id = 15
        actor.damage_pop = true
        actor.damage = - actor.maxhp/RIGENE_FATTORE
      actor.hp += actor.maxhp/RIGENE_FATTORE
      @status_window.refresh
    end
    end
      start_phase2
      return
    end
    # Initialize animation ID and common event ID
    @animation1_id = 0
    @animation2_id = 0
    @common_event_id = 0
    # Shift from head of actionless battlers
    @active_battler = @action_battlers.shift
    # If already removed from battle
    if @active_battler.index == nil
      return
    end
    # Slip damage
    if @active_battler.hp > 0 and @active_battler.slip_damage?
      @active_battler.slip_damage_effect
      @active_battler.damage_pop = true
    end
    # Natural removal of states
    @active_battler.remove_states_auto
    # Refresh status window
    @status_window.refresh
    # Shift to step 2
    @phase4_step = 2
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 2 : start action)
  #--------------------------------------------------------------------------
  def update_phase4_step2
    # If not a forcing action
    unless @active_battler.current_action.forcing
      # If restriction is [normal attack enemy] or [normal attack ally]
      if @active_battler.restriction == 2 or @active_battler.restriction == 3
        # Set attack as an action
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
      end
      # If restriction is [cannot perform action]
      if @active_battler.restriction == 4
        # Clear battler being forced into action
        $game_temp.forcing_battler = nil
        # Shift to step 1
        @phase4_step = 1
        return
      end
    end
    # Clear target battlers
    @target_battlers = []
    @target_rimasti = []
    @target_reflex = []
    # Branch according to each action
    case @active_battler.current_action.kind
    when 0  # basic
      make_basic_action_result
    when 1  # skill
      make_skill_action_result
    when 2  # item
      make_item_action_result
    end
    # Shift to step 3
    if @phase4_step == 2
      @phase4_step = 3
    end
  end
  #--------------------------------------------------------------------------
  # * Make Basic Action Results
  #--------------------------------------------------------------------------
  def make_basic_action_result
    # If attack
    if @active_battler.current_action.basic == 0
      # Set anaimation ID
      @help_window.set_text(@active_battler.name + " attacca!",1)
      @animation1_id = @active_battler.animation1_id
      @animation2_id = @active_battler.animation2_id
      # If action battler is enemy
      if @active_battler.is_a?(Game_Enemy)
        if @active_battler.restriction == 3
          target = $game_troop.random_target_enemy
        elsif @active_battler.restriction == 2
          target = $game_party.random_target_actor
        else
          index = @active_battler.current_action.target_index
          target = $game_party.smooth_target_actor(index)
        end
      end
      # If action battler is actor
      if @active_battler.is_a?(Game_Actor)
        if @active_battler.restriction == 3
          target = $game_party.random_target_actor
        elsif @active_battler.restriction == 2
          target = $game_troop.random_target_enemy
        else
          index = @active_battler.current_action.target_index
          target = $game_troop.smooth_target_enemy(index)
        end
      end
      # Set array of targeted battlers
      @target_battlers = [target]
      # Apply normal attack results
      for target in @target_battlers
        target.attack_effect(@active_battler)
      end
 
      return unless target.contrattacco
    end
    # If guard
    if @active_battler.current_action.basic == 1
      # Display "Guard" in help window
      @help_window.set_text($data_system.words.guard, 1)
      return
    end
    # If escape
    if @active_battler.is_a?(Game_Enemy) and
       @active_battler.current_action.basic == 2
      # Display "Escape" in help window
      @help_window.set_text("Escape", 1)
      # Escape
      @active_battler.escape
      return
    end
    # If doing nothing
    if @active_battler.current_action.basic == 3
      # Clear battler being forced into action
      $game_temp.forcing_battler = nil
      # Shift to step 1
      @phase4_step = 1
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Make Skill Action Results
  #--------------------------------------------------------------------------
  def make_skill_action_result
    # Get skill
    @skill = $data_skills[@active_battler.current_action.skill_id]
    # If not a forcing action
    unless @active_battler.current_action.forcing
      # If unable to use due to SP running out
      unless @active_battler.skill_can_use?(@skill.id)
        # Clear battler being forced into action
        $game_temp.forcing_battler = nil
        # Shift to step 1
        @phase4_step = 1
        return
      end
    end
    # Use up SP
    if @active_battler.is_a?(Game_Actor)
    if @active_battler.skill_learn?(MP_DIMEZZA) #dimezza il costo se Salva 50% Mp
      @active_battler.sp -= @skill.sp_cost / 2
      elsif  @active_battler.skill_learn?(MP_1) #riduce a 1 il consumo
    @active_battler.sp -= 1
  else
    @active_battler.sp -= @skill.sp_cost
    end
  end
    # Refresh status window
    @status_window.refresh
    # Show skill name on help window
    @help_window.set_text(@skill.name, 1)
    # Set animation ID
    @animation1_id = @skill.animation1_id
    @animation2_id = @skill.animation2_id
    # Set command event ID
    @common_event_id = @skill.common_event_id
    # Set target battlers
    set_target_battlers(@skill.scope)
    # Apply skill effect
    for target in @target_battlers
      @target_rimasti.push(target)
      end
        for target in @target_battlers
      #se reflex il bersaglio diventa il nemico che ha lanciato la magia
      if target.is_a?(Game_Actor) and target.skill_learn?(AUTO_REFLEX) and REFLEX_SKILL.include?(@skill.id)
        if @skill.scope == 1
           @target_reflex.push(@active_battler)
            @target_battlers.delete(target)
          end
        if @skill.scope == 2
          for actor in $game_party.actors
            @target_battlers.delete(actor) if actor.skill_learn?(AUTO_REFLEX) and REFLEX_SKILL.include?(@skill.id)
            end
            for enemy in $game_troop.enemies
        @target_reflex.push(enemy)
      end
    end
    if @skill.scope == 3
      num = rand($game_troop.enemies.size)
      @target_reflex.push($game_troop.enemies[num])
    end
 
      end
      end
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
    end
 
  end
 
 
  def make_item_action_result
    # Get item
    @item = $data_items[@active_battler.current_action.item_id]
    # If unable to use due to items running out
    unless $game_party.item_can_use?(@item.id)
      # Shift to step 1
      @phase4_step = 1
      return
    end
    # If consumable
    if @item.consumable
      # Decrease used item by 1
      $game_party.lose_item(@item.id, 1)
    end
    # Display item name on help window
    @help_window.set_text(@item.name, 1)
    # Set animation ID
    @animation1_id = @item.animation1_id
    @animation2_id = @item.animation2_id
    # Set common event ID
    @common_event_id = @item.common_event_id
    # Decide on target
    index = @active_battler.current_action.target_index
    target = $game_party.smooth_target_actor(index)
    # Set targeted battlers
    set_target_battlers(@item.scope)
    # Apply item effect
    for target in @target_battlers
      target.item_effect(@item, @active_battler)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 3 : animation for action performer)
  #--------------------------------------------------------------------------
  def update_phase4_step3
 
    # Animation for action performer (if ID is 0, then white flash)
    if @animation1_id == 0
      @active_battler.white_flash = true
    else
      @active_battler.animation_id = @animation1_id
      @active_battler.animation_hit = true
    end
    for actor in @target_rimasti
      #mostra l'animazione di reflex
    if actor.is_a?(Game_Actor) and actor.skill_learn?(AUTO_REFLEX) and REFLEX_SKILL.include?(@skill.id)
    $fase = true
        actor.animation_id = REFLEX_ANIM
        actor.damage = "Reflex"
        actor.damage_pop = true
      end
      end
    # Shift to step 4
    @phase4_step = 4
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 4 : animation for target)
  #--------------------------------------------------------------------------
  def update_phase4_step4
 
    # Animation for target
    for target in @target_battlers
      target.animation_id = @animation2_id
      target.animation_hit = (target.damage != "Miss")
    end
    # Animation has at least 8 frames, regardless of its length
    @wait_count = 8
    # Shift to step 5
    @phase4_step = 4.1 if @target_reflex.size != 0
    @phase4_step = 5 unless @target_reflex.size != 0
    @phase4_step = 5 if @target_reflex == nil
  end
  #----------------------------------------
  def update_phase4_step4_2
    # Animation for target
    $fase_4_2 = true
    for target in @target_battlers
      target.damage_pop = true
    end
    @status_window.refresh
    # Shift to step 5
    @phase4_step = 4.2
  end
 
    def update_phase4_step4_3
    for target in @target_reflex
      target.animation_id = @animation2_id
      target.animation_hit = (target.damage != "Miss")
    end
    @wait_count = 8
    # Shift to step 5
    @phase4_step = 5
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 5 : damage display)
  #--------------------------------------------------------------------------
  def update_phase4_step5
    # Hide help window
    @help_window.visible = false
    # Refresh status window
    # Display damage
    for target in @target_reflex
      target.skill_effect(@active_battler, @skill)
      target.damage_pop = true
    end
    @status_window.refresh
 
    for target in @target_battlers
      if target.damage != nil
         if target.is_a?(Game_Actor) and target.damage.is_a?(Numeric) and target.damage > 0
           target.danno = true
         end
         if @active_battler.current_action.kind == 1
         if target.is_a?(Game_Actor) and target.damage.is_a?(Numeric) and target.damage > 0 and CONTRAMAGIA_SKILL.include?(@skill.id)
           target.danno_magia = true
         end
       end
       unless $fase_4_2
        target.damage_pop = true
         if @active_battler.is_a?(Game_Actor) and @active_battler.skill_learn?(DOPPIO_COLPO)
            $fase_5_2 = true
 
          end
         end
      end
      if @active_battler.is_a?(Game_Actor) and @active_battler.skill_learn?(ASSORBIRE) and @active_battler.current_action.kind == 0 and target.damage.is_a?(Numeric)
        @active_battler.damage = -target.damage / ASSORBIRE_FATTORE
        @danno = @active_battler.damage
        if @danno < 0
        @active_battler.hp -= @danno
        @status_window.refresh
        @active_battler.damage_pop = true
        end
      end
      if @active_battler.is_a?(Game_Actor) and @active_battler.skill_learn?(ASSORBIRE_MP) and @active_battler.current_action.kind == 0 and target.damage.is_a?(Numeric)
        @active_battler.damage = -target.damage / ASSORBIRE_FATTORE_MP
        @danno = @active_battler.damage
        if @danno < 0
        @active_battler.sp -= @danno
        @status_window.refresh
        end
      end
    end
    $fase_4_2 = false
    # Shift to step 6
    @phase4_step = 6 unless $fase_5_2
    @phase4_step = 5.1 if $fase_5_2
  end
 
 
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 5 : damage display)
  #--------------------------------------------------------------------------
  def update_phase4_step5_2
    # Hide help window
    @help_window.set_text(@active_battler.name + " colpisce ancora!",1) unless judge
    # Refresh status window
    # Display damage
    for target in @target_battlers
      target.animation_id = @animation2_id
      target.animation_hit = (target.damage != "Miss")
    end
    @wait_count = 8
    # Shift to step 6
    $fase_5_2 = false
    @phase4_step = 5.2
  end
 
  def update_phase4_step5_3
    # Hide help window
 
    # Refresh status window
    # Display damage
    for target in @target_battlers
      target.attack_effect(@active_battler)
      if target.damage != nil
        target.damage_pop = true
      end
      if @active_battler.is_a?(Game_Actor) and @active_battler.skill_learn?(ASSORBIRE) and @active_battler.current_action.kind == 0 and target.damage.is_a?(Numeric)
        @active_battler.damage = -target.damage / ASSORBIRE_FATTORE
        @danno = @active_battler.damage
        if @danno < 0
        @active_battler.hp -= @danno
        @status_window.refresh
        @active_battler.damage_pop = true
        end
      end
      if @active_battler.is_a?(Game_Actor) and @active_battler.skill_learn?(ASSORBIRE_MP) and @active_battler.current_action.kind == 0 and target.damage.is_a?(Numeric)
        @active_battler.damage = -target.damage / ASSORBIRE_FATTORE_MP
        @danno = @active_battler.damage
        if @danno < 0
        @active_battler.sp -= @danno
        @status_window.refresh
        end
      end
    end
    @phase4_step = 6
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 6 : refresh)
  #--------------------------------------------------------------------------
  def update_phase4_step6
       @help_window.visible = false
 
    # Clear battler being forced into action
    $game_temp.forcing_battler = nil
    for target in @target_battlers
    #  target.damage_pop_mp = true if target.damage_mp != nil
      #probabilità di contrattacco
      target.random = true if rand(100) > 60 and target.occhio == false
      target.random = true if rand(100) > 30 and target.occhio
      if CONTRAMAGIA_SKILL.include?(@skill.id) and target.is_a?(Game_Actor)
      target.random = true if rand(100) > 50 and target.contramagia
      end
      #contrattacca se attaccato e se l'eroe non è addormentato
     if target.is_a?(Game_Actor) and target.contrattacco and target.random and target.hp > 0 and @active_battler.current_action.kind == 0
       unless target.states.include?(SONNO_STATE_ID)
       @help_window.set_text("Contrattacco!",1)
       $contra = true
       target.white_flash = true
       $fase = true
     end
   end
   if target.is_a?(Game_Actor) and target.contramagia and target.random and target.hp > 0 and target.danno_magia #and CONTRAMAGIA_SKILL.include?(@skill.id)
       unless target.states.include?(SONNO_STATE_ID)
       @help_window.set_text("Contramagia!",1)
       $contra = true
       target.white_flash = true
       $fase = true
     end
   end
   end
    # If common event ID is valid
    @phase4_step = 7
    unless $fase
    @phase4_step = 8
    end
  end
 
def update_phase4_step7
    for target in @target_battlers
      #animazione contrattacco
     if target.is_a?(Game_Actor) and target.contrattacco and target.random and target.hp > 0 and @active_battler.current_action.kind == 0
       unless target.states.include?(SONNO_STATE_ID)
            if target.weapon_id != nil
              @active_battler.animation_hit = true
            weapon = $data_weapons[target.weapon_id]
           @active_battler.animation_id = weapon.animation2_id
         end
         end
       end
            if target.is_a?(Game_Actor) and target.contramagia and target.random and target.hp > 0 and target.danno_magia #and CONTRAMAGIA_SKILL.include?(@skill.id)
       unless target.states.include?(SONNO_STATE_ID)
            if target.weapon_id != nil
              @active_battler.animation_hit = true
            weapon = $data_weapons[target.weapon_id]
           @active_battler.animation_id = weapon.animation2_id
         end
         end
       end
       end
    @phase4_step = 8
  end
 
 
  def update_phase4_step8
    for target in @target_battlers
      #danno contrattacco
     if target.is_a?(Game_Actor) and target.contrattacco and target.random and target.hp > 0 and @active_battler.current_action.kind == 0
       unless target.states.include?(SONNO_STATE_ID)
          @active_battler.attack_effect(target)
           @active_battler.damage_pop = true
           target.random = false
         end
       end
       if target.is_a?(Game_Actor) and target.contramagia and target.random and target.hp > 0 and target.danno_magia #and CONTRAMAGIA_SKILL.include?(@skill.id)
       unless target.states.include?(SONNO_STATE_ID)
          @active_battler.attack_effect(target)
           @active_battler.damage_pop = true
           target.random = false
         end
         end
     end
     for actor in $game_party.actors
       #Se auto-risveglio è attivo resuscita se KO
        if actor.states.include?(RISVEGLIO_STATE_ID) and actor.states.include?(1)
          actor.states.delete(1)
          actor.damage = "Risveglio"
          actor.damage_pop = true
          actor.hp += actor.maxhp/4
      actor.animation_id = RISVEGLIO_ANIM
 
      actor.states.delete(RISVEGLIO_STATE_ID)
    end
  end
  $fase = false
@phase4_step = 9
end
 
def update_phase4_step9
   for actor in $game_party.actors
     #se attaccato usa una pozione
    if actor.skill_learn?(AUTO_POZIONE) and $game_party.item_can_use?(POZIONE_ID) and actor.danno
      unless $game_party.item_can_use?(MEGAPOZIONE_ID)
      @help_window.set_text("Autopozione",1)
      $fase = true
      $game_party.gain_item(POZIONE_ID, -1)
      actor.pozione = true
      actor.animation_id = $data_items[POZIONE_ID].animation1_id
    end
  end
    if actor.skill_learn?(AUTO_POZIONE) and actor.danno
        if $game_party.item_can_use?(MEGAPOZIONE_ID)
      @help_window.set_text("Autopozione",1)
      $game_party.gain_item(MEGAPOZIONE_ID, -1)
      $fase = true
      actor.megapozione = true
      actor.animation_id = $data_items[MEGAPOZIONE_ID].animation1_id
    end
  end
end
  @phase4_step = 10 if $fase
  @phase4_step = 11 unless $fase
end
 
  def update_phase4_step10
    #animazione autopozione
   for actor in $game_party.actors
    if actor.pozione and actor.danno
      unless actor.megapozione
      actor.animation_id = $data_items[POZIONE_ID].animation2_id
    end
  end
    if actor.megapozione and actor.danno
      actor.animation_id = $data_items[MEGAPOZIONE_ID].animation2_id
    end
  @status_window.refresh
end
@phase4_step = 11
end
 
def update_phase4_step11
  #animazione autopozione
   for actor in $game_party.actors
    if actor.pozione and actor.danno
      unless actor.megapozione
      actor.hp += $data_items[POZIONE_ID].recover_hp
      actor.damage = -$data_items[POZIONE_ID].recover_hp  
      actor.damage_pop = true
    end
  end
    if actor.megapozione and actor.danno
      actor.hp += $data_items[MEGAPOZIONE_ID].recover_hp
      actor.damage = -$data_items[MEGAPOZIONE_ID].recover_hp  
      actor.damage_pop = true
  end
  @status_window.refresh
  actor.danno = false
  actor.pozione = false
  actor.megapozione = false
  actor.danno_magia = false
  $contra = false
end
 
     if @common_event_id > 0
      # Set up event
      common_event = $data_common_events[@common_event_id]
      $game_system.battle_interpreter.setup(common_event.list, 0)
    end
    $fase = false
    # Shift to step 1
    @phase4_step = 1
end
end
 
 
 
 
 
 
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================
 
class Scene_Map
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Loop
    loop do
      # Update map, interpreter, and player order
      # (this update order is important for when conditions are fulfilled
      # to run any event, and the player isn't provided the opportunity to
      # move in an instant)
      $game_map.update
      $game_system.map_interpreter.update
      $game_player.update
      # Update system (timer), screen
      $game_system.update
      $game_screen.update
      # Abort loop if player isn't place moving
      unless $game_temp.player_transferring
        break
      end
      # Run place move
      transfer_player
      # Abort loop if transition processing
      if $game_temp.transition_processing
        break
      end
    end
    # Update sprite set
    @spriteset.update
    # Update message window
    @message_window.update
    # If game over
    if $game_temp.gameover
      # Switch to game over screen
      $scene = Scene_Gameover.new
      return
    end
    # If returning to title screen
    if $game_temp.to_title
      # Change to title screen
      $scene = Scene_Title.new
      return
    end
    # If transition processing
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # If showing message window
    if $game_temp.message_window_showing
      return
    end
    $incontri = false
    # If encounter list isn't empty, and encounter count is 0
    for actor in $game_party.actors
      if actor.skill_learn?(INCONTRI_0)
        $incontri = true
      end
      end
    if $game_player.encounter_count == 0 and $game_map.encounter_list != [] and $incontri == false
      # If event is running or encounter is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        # Confirm troop
        n = rand($game_map.encounter_list.size)
        troop_id = $game_map.encounter_list[n]
        # If troop is valid
        if $data_troops[troop_id] != nil
          # Set battle calling flag
          $game_temp.battle_calling = true
          $game_temp.battle_troop_id = troop_id
          $game_temp.battle_can_escape = true
          $game_temp.battle_can_lose = false
          $game_temp.battle_proc = nil
        end
      end
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # If event is running, or menu is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # Set menu calling flag or beep flag
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
    # If debug mode is ON and F9 key was pressed
    if $DEBUG and Input.press?(Input::F9)
      # Set debug calling flag
      $game_temp.debug_calling = true
    end
    # If player is not moving
    unless $game_player.moving?
      # Run calling of each screen
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
  end
end
Parsed in 0.578 seconds at 151.15 KB/s, using GeSHi 1.0.8.3


Demo Link

Versione aggiornata più compatibile
EDIT: aggiunte nuove abilità, migliorate le animazioni e risolti alcuni bug.
http://www.mediafire...uu57mz7gxff1r52

Screenshot






Istruzioni per l'uso
Dovrebbero essere tutte all'interno della demo e dello script.
Per qualsiasi cosa rivolgetevi a me.

Bugs e Conflitti Noti
Se trovate qualche bugs, avvertitemi e aggiornerò lo script con i bug eliminati (se riesco XD)


Altri Dettagli
Per aggiungere altre abilità bisogna sapere un po' di RGSS quindi chiedetemi pure e farò quello che volete :D
Comunque sono state implementate molte abilità come ad esempio l'auto-risveglio, auto-reflex, auto-protect, auto.pozione, contrattacco e tante altre... vedrete tutto all'interno della demo :D
Se dovete inserire lo script nel menu e non sapete come fare chiedetemi e posterò una versione con il menu.

Modificato da Valentino, 06 September 2010 - 18:03 PM.


    Guardian of Irael
  • Coniglietto Rosso

  • Rpg²S Admin
  • Rens: 195
  • 19
  • StellettaStellettaStellettaStellettaStellettaStelletta
  • 58424 messaggi
  • Sesso:Maschio
  • Provenienza:Bagnaia (Viterbo)
  • Abilità:Apprendista


#2 Inviato 28 August 2010 - 22:31 PM

Interessante soprattutto per le abilità già implementate! :3
Bel lavoro! ^ ^

(\_/)
(^ ^) <----coniglietto rosso, me!     
(> <)

 
Il mio Tumblr dove seguire i miei progetti, i progetti della Reverie : : Project ^ ^
 
KdUDtQt.png disponibile su Google Play, qui i dettagli! ^ ^
 
FwnGMI3.png completo! Giocabile online, qui i dettagli! ^ ^  
 
REVERIE : : RENDEZVOUS (In allenamento per apprendere le buone arti prima di cominciarlo per bene ^ ^) Trovate i dettagli qui insieme alla mia intervista (non utilizzerò più rpgmaker) ^ ^

Spoiler


    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#3 Inviato 28 August 2010 - 22:45 PM

Grazie mille :biggrin: Se qualcuno ha qualche idea su altre abilità da inserire me lo faccia sapere!

    charlie
  • Utente occasionale

  • Utenti
  • Rens: 0
  • 0
  • StellettaStelletta
  • 169 messaggi
  • Sesso:Maschio
  • Abilità:Esperto

#4 Inviato 29 August 2010 - 06:05 AM

Uno script apprezzabile, tuttavia la formattazione del codice a me risulta completamente sballata ed è un po' difficile orientarsi all'interno e vedere cosa hai fatto. Inoltre vedo che non usi gli alias, ma non sempre si può d'altra parte, però mi sembra di vedere che ci sono tanti metodi ricopiati che sono identici a quelli originali. Se non li hai modificati li dovresti togliere, sia per chiarezza che per aumentare la compatibilità con altri script.

Immagine inserita
Immagine inserita Immagine inserita Immagine inserita Immagine inserita Immagine inserita


    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#5 Inviato 29 August 2010 - 08:44 AM

Sì lo so avrei dovuto toglierli ma ci ho lavorato parecchio e non ne avevo tutta questa voglia XD
Comunque avevo avvertito che per modificare lo script a proprio piacimento servisse un po di RGSS, comunque adesso provvedo subito alla modifica del codice.
Per quanto riguarda gli alias non so usarli benissimo e quindi non volevo incorrere in errori che non sapevo risolvere.
Grazie per il commento :D

EDIT: aggiunta una versione più compatibile.

Modificato da Valentino, 29 August 2010 - 09:06 AM.


    abadon92
  • Utente avanzato

  • Utenti
  • Rens: 52
  • 0
  • StellettaStellettaStelletta
  • 478 messaggi
  • Sesso:Maschio
  • Provenienza:Verona
  • Abilità:Apprendista

#6 Inviato 29 August 2010 - 10:08 AM

Complimenti, gran bello script (:

Ps. l'abilità "Level Up" in Final Fantasy 9 non fa accumulare il doppio dell'esperienza, ma la moltiplica per 1.5 (:

Coming Soon



Immagine inserita




"...non hai bisogno di cercare, è tutto dentro di te..."


Contest
Immagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inserita



Immagine inserita


    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#7 Inviato 29 August 2010 - 10:11 AM

Complimenti, gran bello script (:

Ps. l'abilità "Level Up" in Final Fantasy 9 non fa accumulare il doppio dell'esperienza, ma la moltiplica per 1.5 (:



Grazie! Per me è stato un traguardo riuscire a creare un sistema cosi :biggrin:
Comunque ho messo che raddoppia ma nella configurazione è possibile inserire un qualsiasi numero che andrà a moltiplicare all'esperienza ^^
Vi ringrazio per tutti questi commenti XD non ci speravo :tongue:

Piuttosto sai per caso come veniva gestita la crescita delle pietre col level up?
Ho cercato in internet e dicono che se ne aquista una ogni volta che si raggiunge un livello che termina con una cifra tra : 0,3,5,7,8 ma provando così ho confrontato il pg con gidan e alla fine gidan aveva almeno una trentina di pietre in piu XD quindi ho deciso di rendere personalizzabili i livelli e il numero di pietre aquistabili ma sarebbe più bello riuscire a renderlo simile a ff 9 XD

Modificato da Valentino, 29 August 2010 - 10:14 AM.


    abadon92
  • Utente avanzato

  • Utenti
  • Rens: 52
  • 0
  • StellettaStellettaStelletta
  • 478 messaggi
  • Sesso:Maschio
  • Provenienza:Verona
  • Abilità:Apprendista

#8 Inviato 29 August 2010 - 10:17 AM

Ho cercato in internet e dicono che se ne aquista una ogni volta che si raggiunge un livello che termina con una cifra tra : 0,3,5,7,8

Si si, ogni volta che un personaggio arriva al livello con la corrispondente cifra alle unità le pietre aumentano di 1 (:

Coming Soon



Immagine inserita




"...non hai bisogno di cercare, è tutto dentro di te..."


Contest
Immagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inserita



Immagine inserita


    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#9 Inviato 29 August 2010 - 10:38 AM

Si si, ogni volta che un personaggio arriva al livello con la corrispondente cifra alle unità le pietre aumentano di 1 (:



Eppure ho controllato, cioè:
Al livello uno Gidan ha 18 pietre e al lv 67 ne ha 54
Il pg che ho creato al livello uno ho messo che possiede anche lui 18 pietre, ma salendo di livello al 67 ne ha 44!
Qualcosa non torna. Boh! :biggrin:

    abadon92
  • Utente avanzato

  • Utenti
  • Rens: 52
  • 0
  • StellettaStellettaStelletta
  • 478 messaggi
  • Sesso:Maschio
  • Provenienza:Verona
  • Abilità:Apprendista

#10 Inviato 29 August 2010 - 11:02 AM

Ho fatto un po' di calcoli, ma non mi trovo u.u
Se a ogni livello che termina con 0,3,5,7,8 si aumenta di uno a me risulta che Gidan al livello 67 dovrebbe averne 51 O.o
Ho letto in vece che si aumentano di 1 quando il livello termina con 0,3,5,8 (e non sette) e la somma è proprio 44 u.u

Boh, non saprei però ):

Coming Soon



Immagine inserita




"...non hai bisogno di cercare, è tutto dentro di te..."


Contest
Immagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inserita



Immagine inserita


    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#11 Inviato 29 August 2010 - 11:07 AM

Ah si scusami! Ho sbagliato a scrivere prima! Le pietre si prendono solo a 0,3,5,8 almeno cosi dicono in internet.
Avevo messo sette perchè lo avevo provato come soluzione ma senza risultato XD
Infatti ne avanzano ancora.

    abadon92
  • Utente avanzato

  • Utenti
  • Rens: 52
  • 0
  • StellettaStellettaStelletta
  • 478 messaggi
  • Sesso:Maschio
  • Provenienza:Verona
  • Abilità:Apprendista

#12 Inviato 29 August 2010 - 11:42 AM

Mmm, mi sembra di ricordare che, comunque, se si indossano particolari oggetti allo scattare di questi livelli si aumentino i parametri di forza, difesa, ecc..
Magari avendo un particolare equip. si aumentano di 2 le pietre, boh xD

Secondo me è proprio cosi u.u
Con alcuni accessori o equipaggiamenti magari invece che aumentare di 1 pietra si aumenta di 2 (:

Modificato da abadon92, 29 August 2010 - 11:43 AM.

Coming Soon



Immagine inserita




"...non hai bisogno di cercare, è tutto dentro di te..."


Contest
Immagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inserita



Immagine inserita


    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#13 Inviato 29 August 2010 - 11:48 AM

Mmm... Se certi oggetti aumentano le pietre allora nel gioco non viene detto XD perchè non ho mai trovato oggetti che facessero aumentare le pietre, forse sono equip con effetti segreti. Bella idea comunque :)

    abadon92
  • Utente avanzato

  • Utenti
  • Rens: 52
  • 0
  • StellettaStellettaStelletta
  • 478 messaggi
  • Sesso:Maschio
  • Provenienza:Verona
  • Abilità:Apprendista

#14 Inviato 29 August 2010 - 21:36 PM

Io avevo letto che i parametri di forza difesa, ecc..(insomma i primi che ci sono) aumentano di 1 all'arrivo di quei livelli che abbiamo citato noi e con alcuni oggetti aumentano di 2.
Esempio, il "Cinturone" quando arrivi ad un livello che finisce con 0,3,5,8 aumenta la forza di chi lo indossa di 2 e non di uno come è normale che accada, non so se mi sono spiegato ben ) :
Comunque si, sono cose che non vengono dette, ma sono sicuro che sulla guida ce scritto ( :

Io sono sicuro di averlo letto ( :

Modificato da abadon92, 29 August 2010 - 21:36 PM.

Coming Soon



Immagine inserita




"...non hai bisogno di cercare, è tutto dentro di te..."


Contest
Immagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inseritaImmagine inserita



Immagine inserita


    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#15 Inviato 29 August 2010 - 23:26 PM

Io avevo letto che i parametri di forza difesa, ecc..(insomma i primi che ci sono) aumentano di 1 all'arrivo di quei livelli che abbiamo citato noi e con alcuni oggetti aumentano di 2.
Esempio, il "Cinturone" quando arrivi ad un livello che finisce con 0,3,5,8 aumenta la forza di chi lo indossa di 2 e non di uno come è normale che accada, non so se mi sono spiegato ben ) :
Comunque si, sono cose che non vengono dette, ma sono sicuro che sulla guida ce scritto ( :

Io sono sicuro di averlo letto ( :



Ah ecco! Comunque l'ho già implementato, ora ho inserito anche l'abilità di contramagia...
Quando avrò messo altre abilità pubblicherò una versione aggiornata.

    Squall_Leonheart
  • Alex (Rm2k)

  • Utenti
  • Rens: 92
  • 0
  • StellettaStellettaStellettaStellettaStelletta
  • 1388 messaggi
  • Sesso:Maschio
  • Provenienza:Salerno
  • Abilità:Maestro

#16 Inviato 30 August 2010 - 00:55 AM

Sapete se riscontra dei bug con l'RATB ?

Iscriviti sul mio canale youtube -

https://www.youtube....w_as=subscriber

Seguimi su Instagram -

https://www.instagra...stralguitarist/

---------------------------------------------------------------------------------------------------------------------------------------
Contest vinti
---------------------------------------------------------------------------------------------------------------------------------------

FACE CONTEST # 3
BANNER CONTEST #69


    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#17 Inviato 30 August 2010 - 01:04 AM

Eh dipende che script usi XD Comunque credo che si possa tranquillamente renderlo compatibile, ma che così normale sovvrascriva delle classi che andrebbero in conflitto.
Se vuoi te lo modifico io lo script.
Comunque ho scoperto che nella nuova versione ce un bug quando si usano gli oggetti perchè ho cancellato una cosa che non dovevo quindi devo sistemarlo, comunque è una boiata XD

EDIT: Ok sistemato il bug e aggiunto la versione fixata.

Modificato da Valentino, 30 August 2010 - 01:16 AM.


    Squall_Leonheart
  • Alex (Rm2k)

  • Utenti
  • Rens: 92
  • 0
  • StellettaStellettaStellettaStellettaStelletta
  • 1388 messaggi
  • Sesso:Maschio
  • Provenienza:Salerno
  • Abilità:Maestro

#18 Inviato 30 August 2010 - 01:22 AM

Appena posso provo,se ho problemi ri-posto

Iscriviti sul mio canale youtube -

https://www.youtube....w_as=subscriber

Seguimi su Instagram -

https://www.instagra...stralguitarist/

---------------------------------------------------------------------------------------------------------------------------------------
Contest vinti
---------------------------------------------------------------------------------------------------------------------------------------

FACE CONTEST # 3
BANNER CONTEST #69


    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#19 Inviato 30 August 2010 - 01:30 AM

D'accordo, intanto io adesso vado a dormire XD lascia pure scritto domani dovrei esserci. :tongue:

    Valentino
  • Utente avanzato

  • Utenti
  • Rens: 180
  • 0
  • StellettaStellettaStelletta
  • 464 messaggi
  • Sesso:Maschio
  • Provenienza:Maniago
  • Abilità:Esperto

#20 Inviato 02 September 2010 - 18:56 PM

Aggiunta una nuova versione:
include nuove abilità passive, animazioni migliori e la risoluzione di alcuni bug.




  • Feed RSS