Advertisement
Dekita

unieqp1.0

Mar 29th, 2014
854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.75 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Unique Equipment
  5. # -- Author : Dekita
  6. # -- Version : 1.0
  7. # -- Level : N/A
  8. # -- Requires : $D13x - CORE
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:UniEquip] = true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # o1/o4/2o13 - Update for release,(v1.0)
  21. # 23/o2/2o13 - Started, Finished,
  22. #
  23. #===============================================================================
  24. # ☆ Introduction
  25. #-------------------------------------------------------------------------------
  26. # This script is what makes every item unique, without this the Equipment
  27. # part of the $D13x system would be FULL of errors, faults and glitches !!
  28. # This script has 0 customisation options.
  29. #
  30. # NOTE :
  31. # I HIGHLY Reccommend you to NOT have any actor wearing any equipment at
  32. # the beggining of the game, if needbe, create all items after starting the game
  33. # and add them to the actor via script calls.
  34. # This will likley avoid glitches with multiple save files and potential errors.
  35. #
  36. #===============================================================================
  37. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  38. #===============================================================================
  39. # 1. You MUST give credit to "Dekita" !!
  40. # 2. You are NOT allowed to repost this script.(or modified versions)
  41. # 3. You are NOT allowed to convert this script.
  42. # 4. You are NOT allowed to use this script for Commercial games.
  43. # 5. ENJOY!
  44. #
  45. # "FINE PRINT"
  46. # By using this script you hereby agree to the above terms and conditions,
  47. # if any violation of the above terms occurs "legal action" may be taken.
  48. # Not understanding the above terms and conditions does NOT mean that
  49. # they do not apply to you.
  50. # If you wish to discuss the terms and conditions in further detail you can
  51. # contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  52. #
  53. #===============================================================================
  54. # ☆ Instructions
  55. #-------------------------------------------------------------------------------
  56. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  57. # Place Below $D13x Core Script.
  58. # Place Above ALL Other $D13x Equipment Related Scripts.
  59. #
  60. #===============================================================================
  61. # ☆ Script Calls
  62. #-------------------------------------------------------------------------------
  63. # make_weapon(id)
  64. # This script call will create a cloned weapon and add it to the party.
  65. #
  66. # make_armor(id)
  67. # This script call will create a cloned armor and add it to the party
  68. #
  69. # actor_has_weapon?(actor_id, weapon id)
  70. # This script call will check if actor_id has weapon_id equipped
  71. # it will return true if yes and false if no, should be used for things like
  72. # conditional branch checks as the default checks wont work.
  73. #
  74. # actor_has_armor?(actor_id, armor id)
  75. # Same as above but for armors
  76. #
  77. # party_has_weapon?(weapon id)
  78. # party_has_armor?(armor_id)
  79. # Similar to the above script calls but checks if the item exists within the
  80. # party, ie includes inventory.
  81. #
  82. # change_eqp_to_this(actor_id, slot_id, item_id)
  83. # use the following script call to change an actors equipment to a specific
  84. # item. (if the party has the item)
  85. #
  86. # $game_actors[ID].has_any_equip?
  87. # will return true if actor ID is wearing at least 1 piece of equipment.
  88. # retusn false otherwise.
  89. #
  90. #===============================================================================#
  91. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  92. # #
  93. # http://dekitarpg.wordpress.com/ #
  94. # #
  95. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  96. #===============================================================================#
  97. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  98. # YES?\.\. #
  99. # OMG, REALLY? \| #
  100. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  101. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  102. #===============================================================================#
  103. module Weapons
  104. #===============================================================================
  105. ID=[]
  106. Data = load_data("Data/Weapons.rvdata2")
  107. Data.size.times{|i|ID[i]={:teir_chances=>[]}}
  108. end
  109.  
  110. #===============================================================================
  111. module Armors
  112. #===============================================================================
  113. ID=[]
  114. Data = load_data("Data/Armors.rvdata2")
  115. Data.size.times{|i|ID[i]={:teir_chances=>[]}}
  116. end
  117.  
  118. #===============================================================================
  119. module Cloning_101 # A.K.A ~ Cloning for Dummies
  120. #===============================================================================
  121. #---------------------------------------------------------------------------
  122. # Initializes cloning process
  123. #---------------------------------------------------------------------------
  124. def self.start_clone(type, id, set_teir = nil, need_ret = false)
  125. case type
  126. when :weapon
  127. vi = $data_weapons ; vii = $deki_weaps ; mod = Weapons
  128. when :armor
  129. vi = $data_armors ; vii = $deki_armrs ; mod = Armors
  130. end
  131. new = make_clone(vi,vii,id)
  132. teir = get_random_teir(mod, id, new, set_teir)
  133. new = get_unique_stats(new, mod, vi, id, teir)
  134. vi.push(new) ; vii.push(new)
  135. item = vi[new.id]
  136. new.uni_feats.sort_by!{|i| i[1] }
  137. $game_party.gain_item(item, 1)
  138. if $D13x[:Equip_Durability]
  139. new.durability = (new.max_durability/2).to_f
  140. end
  141. return new if need_ret
  142. end
  143. #---------------------------------------------------------------------------
  144. # removes clone from database
  145. #---------------------------------------------------------------------------
  146. def self.delete_clone(type, id, inc_equip = false)
  147. case type
  148. when :weapon then vi = $data_weapons ; vii = $deki_weaps
  149. when :armor then vi = $data_armors ; vii = $deki_armrs
  150. end
  151. return if vi[id] == nil
  152. $game_party.gain_item(vi[id], -1, inc_equip)
  153. end
  154. #---------------------------------------------------------------------------
  155. # Create complete clone
  156. #---------------------------------------------------------------------------
  157. def self.make_clone(vi,vii, id)
  158. new = vi[id].clone
  159. new.features = vi[id].features.clone
  160. vi[id].instance_variables.each do |var|
  161. val = vi[id].instance_variable_get(var).is_a?(Numeric) ?
  162. vi[id].instance_variable_get(var) :
  163. vi[id].instance_variable_get(var) == nil ? nil :
  164. vi[id].instance_variable_get(var) == true ? true :
  165. vi[id].instance_variable_get(var) == false ? false :
  166. vi[id].instance_variable_get(var).clone
  167. new.instance_variable_set(var, val)
  168. end
  169. new.params = vi[id].params.clone
  170. new.id = vi.size
  171. return new
  172. end
  173. #---------------------------------------------------------------------------
  174. # get teir
  175. #---------------------------------------------------------------------------
  176. def self.get_random_teir(mod, id, new, set_teir)
  177. return 0 unless $D13x[:Equip_Randomize]
  178. end
  179. #---------------------------------------------------------------------------
  180. # Make item unique
  181. #---------------------------------------------------------------------------
  182. def self.get_unique_stats(new, mod, vi, id, teir)
  183. return new unless $D13x[:Equip_Randomize]
  184. return new if mod == nil
  185. end
  186.  
  187. end # end Cloning_101
  188.  
  189. #===============================================================================
  190. module DataManager
  191. #===============================================================================
  192. #---------------------------------------------------------------------------
  193. # Alias List
  194. #---------------------------------------------------------------------------
  195. class << self
  196. alias :cgo_unique_items :create_game_objects
  197. alias :msc_unique_items :make_save_contents
  198. alias :esc_unique_items :extract_save_contents
  199. end
  200. #---------------------------------------------------------------------------
  201. # Create Game Objects (alias)
  202. #---------------------------------------------------------------------------
  203. def self.create_game_objects
  204. cgo_unique_items
  205. $deki_weaps = []
  206. $deki_armrs = []
  207. end
  208. #---------------------------------------------------------------------------
  209. # make save contents (alias)
  210. #---------------------------------------------------------------------------
  211. def self.make_save_contents
  212. contents = msc_unique_items
  213. contents[:deki_weaps] = $deki_weaps
  214. contents[:deki_armrs] = $deki_armrs
  215. contents
  216. end
  217. #---------------------------------------------------------------------------
  218. # extract save contents (alias)
  219. #---------------------------------------------------------------------------
  220. def self.extract_save_contents(contents)
  221. esc_unique_items(contents)
  222. get_unique_contents(contents)
  223. end
  224. #---------------------------------------------------------------------------
  225. # Get Unique Contents
  226. #---------------------------------------------------------------------------
  227. def self.get_unique_contents(conts)
  228. $deki_weaps = conts[:deki_weaps]
  229. $deki_weaps.each do |w|
  230. next unless w != nil
  231. $data_weapons << w
  232. end
  233. $deki_armrs = conts[:deki_armrs]
  234. $deki_armrs.each do |a|
  235. next unless a != nil
  236. $data_armors << a
  237. end
  238. end
  239.  
  240. end # DataManager
  241.  
  242. #===============================================================================
  243. class RPG::EquipItem < RPG::BaseItem
  244. #===============================================================================
  245. #---------------------------------------------------------------------------
  246. # Pi Variables
  247. #---------------------------------------------------------------------------
  248. attr_accessor :uni_feats
  249. attr_accessor :teir
  250. #---------------------------------------------------------------------------
  251. # load unique shit
  252. #---------------------------------------------------------------------------
  253. def load_dekita_core
  254. super
  255. load_unique_equip
  256. end
  257. #---------------------------------------------------------------------------
  258. # load unique shit
  259. #---------------------------------------------------------------------------
  260. def load_unique_equip
  261. @uni_feats = []
  262. @teir = 0
  263. end
  264.  
  265. end # RPG::EquipItem
  266.  
  267. #===============================================================================
  268. class Game_Actor < Game_Battler
  269. #===============================================================================
  270. #--------------------------------------------------------------------------
  271. # Change Equipment ( overwrite )
  272. # slot_id = Equipment slot ID && item_id = Weapons/armor ID
  273. #--------------------------------------------------------------------------
  274. def change_equip_by_id(slot_id, item_id)
  275. item = nil
  276. if equip_slots[slot_id] == 0
  277. $game_party.weapons.each do |weap|
  278. item = weap if weap.database_id == item_id && item == nil
  279. end
  280. else
  281. $game_party.armors.each do |arms|
  282. item = arms if arms.database_id == item_id && item == nil
  283. end
  284. change_equip(slot_id, item) if item != nil
  285. end
  286. end
  287. #--------------------------------------------------------------------------
  288. # Actor Is Wearing Any Equipment ?
  289. #--------------------------------------------------------------------------
  290. def has_any_equip?
  291. equips.each {|e| return true if e != nil}
  292. return false
  293. end
  294.  
  295. end
  296.  
  297. #===============================================================================
  298. class Game_Interpreter
  299. #===============================================================================
  300. #--------------------------------------------------------------------------
  301. # Change Weapons (overwrite)
  302. #--------------------------------------------------------------------------
  303. def command_127
  304. value = operate_value(@params[1], @params[2], @params[3])
  305. if value > 0
  306. value.times do
  307. @params[0] = Cloning_101.start_clone(:weapon,@params[0],0,true).id
  308. end
  309. elsif value < 0
  310. $game_party.weapons.each do |weap|
  311. break if value >= 0
  312. if weap.database_id == @params[0]
  313. Cloning_101.delete_clone(:weapon, weap.id, @params[4])
  314. value += 1
  315. end
  316. end
  317. end
  318. end
  319. #--------------------------------------------------------------------------
  320. # Change Armor (overwrite)
  321. #--------------------------------------------------------------------------
  322. def command_128
  323. value = operate_value(@params[1], @params[2], @params[3])
  324. if value > 0
  325. value.times do
  326. @params[0] = Cloning_101.start_clone(:armor,@params[0],0,true).id
  327. end
  328. elsif value < 0
  329. $game_party.armors.each do |arm|
  330. break if value >= 0
  331. if arm.database_id == @params[0]
  332. Cloning_101.delete_clone(:armor, arm.id, @params[4])
  333. value += 1
  334. end
  335. end
  336. end
  337. end
  338. #---------------------------------------------------------------------------
  339. # Creates A Cloned Weapon
  340. #---------------------------------------------------------------------------
  341. def make_weapon(id, teir = nil)
  342. return if id == ( nil || 0 )
  343. id = Cloning_101.start_clone(:weapon, id, teir, true).id
  344. make_popup(:weapon,id,1) if $D13x[:Item_Pops]
  345. end
  346. #---------------------------------------------------------------------------
  347. # Creates A Cloned Armor
  348. #---------------------------------------------------------------------------
  349. def make_armor(id, teir = nil)
  350. return if id == ( nil || 0 )
  351. id = Cloning_101.start_clone(:armor, id, teir, true).id
  352. make_popup(:armor,id,1) if $D13x[:Item_Pops]
  353. end
  354. #---------------------------------------------------------------------------
  355. # Checks if actor has weapon equipped
  356. #---------------------------------------------------------------------------
  357. def actor_has_weapon?(aid, wid)
  358. bool = false
  359. $game_actors[aid].weapons.each do |wep|
  360. bool = true if $data_weapons[wep.id].database_id == wid
  361. end
  362. return bool
  363. end
  364. #---------------------------------------------------------------------------
  365. # Checks if actor has armor equipped
  366. #---------------------------------------------------------------------------
  367. def actor_has_armor?(aid, wid)
  368. bool = false
  369. $game_actors[aid].armors.each do |wep|
  370. bool = true if $data_armors[wep.id].database_id == wid
  371. end
  372. return bool
  373. end
  374. #---------------------------------------------------------------------------
  375. # Checks if party has weapon
  376. #---------------------------------------------------------------------------
  377. def party_has_weapon?(wid)
  378. bool = false
  379. $game_party.weapons.each do |wep|
  380. bool = true if $data_weapons[wep.id].database_id == wid
  381. end
  382. return bool
  383. end
  384. #---------------------------------------------------------------------------
  385. # Checks if party has armor
  386. #---------------------------------------------------------------------------
  387. def party_has_armor?(wid)
  388. bool = false
  389. $game_party.armors.each do |wep|
  390. bool = true if $data_armors[wep.id].database_id == wid
  391. end
  392. return bool
  393. end
  394. #---------------------------------------------------------------------------
  395. # Changes an actors equipment to X with X teir
  396. #---------------------------------------------------------------------------
  397. def change_eqp_to_this(actor_id, slot_id, item_id, teir = 0)
  398. return if actor_id == (nil || 0)
  399. $game_actors[actor_id].change_equip_by_id_and_teir(slot_id, item_id, teir)
  400. end
  401.  
  402. end
  403.  
  404. #===============================================================================
  405. module BattleManager
  406. #===============================================================================
  407. #--------------------------------------------------------------------------
  408. # Dropped Item Acquisition and Display
  409. #--------------------------------------------------------------------------
  410. def self.gain_drop_items
  411. $game_troop.make_drop_items.each do |item|
  412. if item.is_a?(RPG::Item)
  413. $game_party.gain_item(item, 1)
  414. else
  415. type = item.is_a?(RPG::Weapon) ? :weapon : :armor
  416. item = Cloning_101.start_clone(type,item.id,nil,true)
  417. end
  418. $game_message.add(sprintf(Vocab::ObtainItem, item.name))
  419. end
  420. wait_for_message
  421. end
  422.  
  423. end # end Battle Manager
  424.  
  425. #===============================================================================
  426. class Scene_Shop < Scene_MenuBase
  427. #===============================================================================
  428. #--------------------------------------------------------------------------
  429. # Execute Purchase
  430. #--------------------------------------------------------------------------
  431. def do_buy(number)
  432. $game_party.lose_gold(number * buying_price)
  433. if @item.is_a?(RPG::EquipItem)
  434. number.times do
  435. Cloning_101.start_clone(:weapon,@item.id, 0) if @item.is_a?(RPG::Weapon)
  436. Cloning_101.start_clone(:armor, @item.id, 0) if @item.is_a?(RPG::Armor)
  437. end
  438. else
  439. $game_party.gain_item(@item, number)
  440. end
  441. end
  442. #--------------------------------------------------------------------------
  443. # Execute Sale
  444. #--------------------------------------------------------------------------
  445. def do_sell(number)
  446. $game_party.gain_gold(number * selling_price)
  447. if @item.is_a?(RPG::EquipItem)
  448. Cloning_101.delete_clone(:weapon,@item.id) if @item.is_a?(RPG::Weapon)
  449. Cloning_101.delete_clone(:armor, @item.id) if @item.is_a?(RPG::Armor)
  450. else
  451. $game_party.lose_item(@item, number)
  452. end
  453. end
  454.  
  455. end # end Scene_Shop
  456.  
  457.  
  458. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement