Advertisement
Dekita

$D13x Core 1.3

Mar 27th, 2013
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.93 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # ☆ $D13x - CORE
  4. # -- Author : Dekita
  5. # -- Version : 1.3
  6. # -- Level : Easy
  7. # -- Requires : N/A
  8. # -- Engine : RPG Maker VX Ace.
  9. #
  10. #===============================================================================
  11. # ☆ Import
  12. #-------------------------------------------------------------------------------
  13. $D13x={}if$D13x==nil
  14. $D13x[:CORE] = true
  15. #===============================================================================
  16. # ☆ Updates
  17. #-------------------------------------------------------------------------------
  18. # D /M /Y
  19. # 27/o3/2o13 - Added Keyboard Control,
  20. # 26/o3/2o13 - Compatibility, (Status Scene)
  21. # - Update, (Icons w/Hue)
  22. # 18/03/2013 - Compatibility, (Skill Scene)
  23. # 23/o2/2o13 - Started, Finished,
  24. #
  25. #===============================================================================
  26. # ☆ Introduction
  27. #-------------------------------------------------------------------------------
  28. # This script simply holds some information and methods used by some other
  29. # scripts in the $D13x system, things like fonts, color, vocab..
  30. #
  31. # Place above all other $D13x Scripts.
  32. #
  33. #===============================================================================
  34. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  35. #===============================================================================
  36. # 1. You MUST give credit to "Dekita" !!
  37. # 2. You are NOT allowed to repost this script.(or modified versions)
  38. # 3. You are NOT allowed to convert this script.
  39. # 4. You are NOT allowed to use this script for Commercial games.
  40. # 5. ENJOY!
  41. #
  42. # "FINE PRINT"
  43. # By using this script you hereby agree to the above terms and conditions,
  44. # if any violation of the above terms occurs "legal action" may be taken.
  45. # Not understanding the above terms and conditions does NOT mean that
  46. # they do not apply to you.
  47. # If you wish to discuss the terms and conditions in further detail you can
  48. # contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  49. #
  50. #===============================================================================
  51. # ☆ Instructions
  52. #-------------------------------------------------------------------------------
  53. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  54. # Place Above ALL Other $D13x Scripts.
  55. #
  56. #===============================================================================
  57. # ☆ Notetags
  58. #-------------------------------------------------------------------------------
  59. # <tcol: red, grn, blu>
  60. # use this notetag to change the color of the text shown in some of my
  61. # scenes.
  62. #
  63. #===============================================================================
  64. module Text_Color
  65. #===============================================================================
  66.  
  67. # White's
  68. Pure_White = Color.new(255,255,255)
  69. White = Color.new(222,222,222)
  70. Grey = Color.new(111,111,111)
  71. # Yellow's
  72. Yellow = Color.new(255,255,0)
  73. Gold = Color.new(212,212,64)
  74. Orange = Color.new(255,182,0)
  75. Deep_Orange = Color.new(212,64,0)
  76. Dirt_Orange = Color.new(182,64,0)
  77. Brown = Color.new(128,32,0)
  78. # Red's
  79. Red = Color.new(251,111,111)
  80. Deep_Red = Color.new(222,60,60)
  81. Pure_Red = Color.new(255,0,0)
  82. Pink = Color.new(255,0,255)
  83. Dark_Pink = Color.new(182,0,156)
  84. # Blue's
  85. Sky_Blue = Color.new(0,182,255)
  86. Light_Blue = Color.new(64,128,255)
  87. Dark_Blue = Color.new(32,64,255)
  88. Purple = Color.new(182,64,255)
  89. Magenta = Color.new(156,156,255)
  90. # Green's
  91. Green = Color.new(111,251,111)
  92. Candy_Green = Color.new(0,255,0)
  93. Dirty_Green = Color.new(128,182,0)
  94. Khaki_Green = Color.new(111,156,64)
  95. Turquoise = Color.new(0,255,182)
  96.  
  97. Default_Equip_Color = White
  98.  
  99. end
  100.  
  101. #==============================================================================
  102. module General
  103. #==============================================================================
  104.  
  105. Fonts = ["VL Gothic"]
  106. Font_Size = 18
  107. Font_Bold = false
  108.  
  109.  
  110. # Gauge = [ Color 1 , Color 2 ]
  111. Hp_Colors = [ Text_Color::Dirt_Orange , Text_Color::Gold ]
  112. Mp_Colors = [ Text_Color::Dark_Blue , Text_Color::Sky_Blue ]
  113. Tp_Colors = [ Text_Color::Grey , Text_Color::Pure_Red ]
  114. Exp_Color = [ Text_Color::Deep_Red , Text_Color::Dark_Pink ]
  115.  
  116. # Show TP as a percentage ?
  117. # Only works in scripts i have written :p
  118. Show_Tp_As_Perc = false
  119.  
  120. end
  121.  
  122. #==============================================================================
  123. module Vocab
  124. #==============================================================================
  125.  
  126. # Parameters ( overwrite )
  127. def self.param(param_id)
  128. case param_id
  129. when 0 then "Max HP" # "Health"
  130. when 1 then "Max MP" # "Will"
  131. when 2 then "Physical Attack" # "Attack"
  132. when 3 then "Physical Resist" # "Defence"
  133. when 4 then "Magical Attack" # "Magic"
  134. when 5 then "Magical Resist" # "Aura"
  135. when 6 then "Agility" # "Speed"
  136. when 7 then "Luck" # "Luck"
  137. end
  138. end
  139.  
  140. Tp = "Rage"
  141.  
  142. # X - Parameters ( new )
  143. def self.x_param(x_param_id)
  144. case x_param_id
  145. when 0 then "Accuracy"
  146. when 1 then "Evasion"
  147. when 2 then "Critical"
  148. when 3 then "Crit Eva"
  149. when 4 then "Mag Eva"
  150. when 5 then "Mag Ref"
  151. when 6 then "Counter"
  152. when 7 then "HP Regen"
  153. when 8 then "MP Regen"
  154. when 9 then "TP Regen"
  155. end
  156. end
  157.  
  158. # S - Parameters ( new )
  159. def self.s_param(s_param_id)
  160. case s_param_id
  161. when 0 then "Aggro"
  162. when 1 then "Guard"
  163. when 2 then "Recovery"
  164. when 3 then "Medicine"#Pharmacology
  165. when 4 then "MP Cost"
  166. when 5 then "TP Charge"
  167. when 6 then "P DMG Taken"
  168. when 7 then "M DMG Taken"
  169. when 8 then "Floor DMG"
  170. when 9 then "Exp Rate"
  171. end
  172. end
  173.  
  174. Attack_Speed = "Atk Speed"
  175.  
  176. Attack_Times = "Atks Per Turn"#"APT"
  177.  
  178. Skill_Type = "Skillset"
  179.  
  180. Skill = "Skills"
  181.  
  182. Equip_Type = "Equipable"
  183.  
  184. Action_Times = "Action Time"
  185.  
  186. # Specials ( new )
  187. def self.specials(id)
  188. case id
  189. when 0 then "Auto-Fight"
  190. when 1 then "Guard"
  191. when 2 then "Substitue"
  192. when 3 then "Preserve TP"
  193. end
  194. end
  195.  
  196. # Collapse Type ( new )
  197. def self.collapse_type(id)
  198. case id
  199. when 0 then "Boss"
  200. when 1 then "Instant"
  201. when 2 then "No Vanish"
  202. end
  203. end
  204.  
  205. # Party Ability ( new )
  206. def self.party_ability(id)
  207. case id
  208. when 0 then "Encounter ½"
  209. when 1 then "Encounter NA"
  210. when 2 then "No Surprise"
  211. when 3 then "Pre-Emptive +"
  212. when 4 then "Gold Double"
  213. when 5 then "Double Drops"
  214. end
  215. end
  216.  
  217. Fixed = "Fixed "
  218. Sealed = "Sealed "
  219. Slot_Type = "Slot Type"
  220. Dual_Slot = "Dual Wield"
  221. One__Slot = "Single"
  222.  
  223. # Vocab for Statistic Control Script
  224. LevelDown = "%s has fell back to %s %s!"
  225. ForgetSkill = "%s's requirements are no longer met!"
  226.  
  227. #####################
  228. # CUSTOMISATION END #
  229. end #####################
  230. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  231. # #
  232. # http://dekitarpg.wordpress.com/ #
  233. # #
  234. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  235. # The following code is protected under the 2013 Dekita Data Protection Act. #
  236. # Ie. The “Do Not Fucking Look” Law. #
  237. # Breaking This One And Only Rule May Result In The Following Side Effects : #
  238. # Eyes Bleeding, Nightmares, Severe Head Ache's AND A Scratch On Your Knee :p #
  239. # That is all ! #
  240. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  241. #===============================================================================#
  242. module Keys
  243. #===============================================================================
  244. Key_Status = Win32API.new("user32", "GetKeyState", ["i"], "i")
  245. AKey_State = Win32API.new("user32", "GetAsyncKeyState", ["i"], "i")
  246. #---------------------------------------------------------------------------
  247. # Key Settings
  248. #---------------------------------------------------------------------------
  249. Key={
  250. # Letters
  251. :A => 0x41,:B => 0x42,:C => 0x43,:D => 0x44,:E => 0x45,:F => 0x46,:G => 0x47,
  252. :H => 0x48,:I => 0x49,:J => 0x4A,:K => 0x4B,:L => 0x4C,:M => 0x4D,:N => 0x4E,
  253. :O => 0x4F,:P => 0x50,:Q => 0x51,:R => 0x52,:S => 0x53,:T => 0x54,:U => 0x55,
  254. :V => 0x56,:W => 0x57,:X => 0x58,:Y => 0x59,:Z => 0x5A,
  255. # Numbers
  256. :_0 => 0x30,:_1 => 0x31,:_2 => 0x32,:_3 => 0x33,:_4 => 0x34,
  257. :_5 => 0x35,:_6 => 0x36,:_7 => 0x37,:_8 => 0x38,:_9 => 0x39,
  258. # Other
  259. :SHIFT => 0x10,:LSHIFT => 0xa0,:RSHIFT => 0xa1, :TAB => 0x09,
  260. :LEFT => 0x25,:RIGHT => 0x27,:UP => 0x26, :DOWN => 0x28,
  261. :PAUSE => 0x13,
  262. } # << End Key {}
  263.  
  264. #---------------------------------------------------------------------------
  265. # Key Got Triggered?
  266. #---------------------------------------------------------------------------
  267. def self.trigger?(key)
  268. return if key.nil?
  269. return true if AKey_State.call(key) != 0
  270. end
  271. #---------------------------------------------------------------------------
  272. # Key Being Pressed Currently ?
  273. #---------------------------------------------------------------------------
  274. def self.press?(key)
  275. return if key.nil?
  276. result = Key_Status.call(key)
  277. return true if result == -127
  278. return true if result == -128
  279. end
  280. #---------------------------------------------------------------------------
  281. # Key Being Held Down?
  282. #---------------------------------------------------------------------------
  283. def self.repeat?(key)
  284. return if key.nil?
  285. return true if Key_Status.call(key) == 1
  286. end
  287.  
  288. end
  289.  
  290. #==============================================================================
  291. #module Input
  292. #==============================================================================
  293. #---------------------------------------------------------------------------
  294. # Alias List
  295. #---------------------------------------------------------------------------
  296. # class << self
  297. # alias :update_input :update
  298. # end
  299. #---------------------------------------------------------------------------
  300. # Update
  301. #---------------------------------------------------------------------------
  302. # def self.update(*args)
  303. # update_input(*args)
  304. # Keys.update
  305. # end
  306.  
  307. #end
  308.  
  309. #===============================================================================
  310. class Object
  311. #===============================================================================
  312. #-------------------------------------------------------------------------
  313. # rand_between
  314. #-------------------------------------------------------------------------
  315. def rand_between(min, max)
  316. min + rand(max - min + 1)
  317. end
  318.  
  319. end
  320.  
  321. #===============================================================================
  322. class Numeric
  323. #===============================================================================
  324. #---------------------------------------------------------------------------
  325. # To Float (with limited digits after decimal point)
  326. #---------------------------------------------------------------------------
  327. def to_flim(limit = 5, saftey = "0")
  328. str = self.to_f.to_s + saftey
  329. new_str = ""
  330. limit.times do |i|
  331. break if new_str =~ /[0-9].[0-9][0-9]/
  332. break if str[i] == nil
  333. new_str += str[i]
  334. end
  335. return new_str
  336. end
  337. #---------------------------------------------------------------------------
  338. # To A Percentage Of (num)
  339. #---------------------------------------------------------------------------
  340. def perc_of(num)
  341. self.to_f / num.to_f * 100.0
  342. end
  343. #---------------------------------------------------------------------------
  344. # Even ?
  345. #---------------------------------------------------------------------------
  346. def even?
  347. e = self.to_s
  348. e[e.size] == ("0"||"2"||"4"||"6"||"8")
  349. end
  350. #---------------------------------------------------------------------------
  351. # 0dd?
  352. #---------------------------------------------------------------------------
  353. def odd?
  354. o = self.to_s
  355. o[o.size] == ("1"||"3"||"5"||"7"||"9")
  356. end
  357.  
  358. end
  359. #===============================================================================
  360. module Cache
  361. #===============================================================================
  362. #--------------------------------------------------------------------------
  363. # * Get System Graphic
  364. #--------------------------------------------------------------------------
  365. def self.icon(filename = "IconSet", hue = 0)
  366. load_bitmap("Graphics/System/", filename, hue)
  367. end
  368.  
  369. end
  370.  
  371. #===============================================================================
  372. module DataManager
  373. #===============================================================================
  374. #---------------------------------------------------------------------------
  375. # Alias List
  376. #---------------------------------------------------------------------------
  377. class << self
  378. alias :lbd_unique_shits :load_database
  379. end
  380. #---------------------------------------------------------------------------
  381. # Load Database (alias)
  382. #---------------------------------------------------------------------------
  383. def self.load_database
  384. lbd_unique_shits
  385. loa_unique_shits
  386. end
  387. #---------------------------------------------------------------------------
  388. # Load Unique Shit
  389. #---------------------------------------------------------------------------
  390. def self.loa_unique_shits
  391. classes = [$data_weapons, $data_armors , $data_items , $data_skills ,
  392. $data_actors , $data_classes, $data_enemies, $data_states ]
  393. for g in classes
  394. for o in g
  395. next if o == nil
  396. o.load_unique_shit
  397. end
  398. end
  399. end
  400.  
  401. end # << DataManager
  402.  
  403. #===============================================================================
  404. class RPG::BaseItem
  405. #===============================================================================
  406. #--------------------------------------------------------------------------
  407. # Pi Variables
  408. #--------------------------------------------------------------------------
  409. attr_accessor :item_disp_color
  410. #--------------------------------------------------------------------------
  411. # Loads Unique Shit
  412. #--------------------------------------------------------------------------
  413. def load_unique_shit
  414. load_item_color
  415. # << For use in Child Classes
  416. end
  417. #---------------------------------------------------------------------------
  418. # Load Item Text Color
  419. #---------------------------------------------------------------------------
  420. def load_item_color
  421. @item_disp_color = Text_Color::Default_Equip_Color
  422. if self.note.match(/<tcol:(.*),(.*),(.*)>/i)
  423. @item_disp_color = Color.new($1.to_i,$2.to_i,$3.to_i)
  424. end
  425. end
  426. #--------------------------------------------------------------------------
  427. # Returns features for item filtered by code (credits Tsukihime)
  428. #--------------------------------------------------------------------------
  429. def feature_val(code)
  430. self.features.select {|ft| ft.code == code}
  431. end
  432. #--------------------------------------------------------------------------
  433. # Returns features for item filtered by code and data ID (credits Tsukihime)
  434. #--------------------------------------------------------------------------
  435. def feature_val_with_id(code, data_id)
  436. self.features.select {|ft| ft.code == code && ft.data_id == data_id}
  437. end
  438. #--------------------------------------------------------------------------
  439. # Returns sum of all features for item, by code and data ID (credits Tsukihime)
  440. #--------------------------------------------------------------------------
  441. def features_sum(code, data_id)
  442. feature_val_with_id(code, data_id).inject(0.0) {|r, ft| r += ft.value }
  443. end
  444. #--------------------------------------------------------------------------
  445. # Returns features pi
  446. #--------------------------------------------------------------------------
  447. def features_pi(code, data_id)
  448. feature_val_with_id(code, data_id).inject(1.0) {|r, ft| r *= ft.value }
  449. end
  450. #--------------------------------------------------------------------------
  451. # Calculate Set Sum of Features
  452. #--------------------------------------------------------------------------
  453. def features_set(code)
  454. feature_val(code).inject([]) {|r, ft| r |= [ft.data_id] }
  455. end
  456.  
  457. end # << RPG::BaseItem
  458.  
  459. #==============================================================================
  460. class Window_Base < Window
  461. #==============================================================================
  462. #--------------------------------------------------------------------------
  463. # Draw Gauge (w/height)
  464. #--------------------------------------------------------------------------
  465. def draw_deki_gauge(gx, gy, gw, gh, rate, color1, color2)
  466. empty_gauge_color = Color.new(0,0,0,128)
  467. fill_w = [(gw * rate).to_i, gw].min
  468. gauge_h = gh
  469. gauge_y = gy + line_height - 2 - gauge_h
  470. contents.fill_rect(gx, gauge_y, gw, gauge_h, empty_gauge_color)
  471. contents.gradient_fill_rect(gx, gauge_y, fill_w, gauge_h, color1, color2)
  472. end
  473. #--------------------------------------------------------------------------
  474. # Draw Hp
  475. #--------------------------------------------------------------------------
  476. def draw_de_hp(x, y, wid = nil)
  477. wid = self.width/2 - (standard_padding*2) if wid == nil
  478. rate = @actor.hp_rate
  479. color1 = General::Hp_Colors[0]
  480. color2 = General::Hp_Colors[1]
  481. draw_deki_gauge(x, y, wid-x-2, 2, rate, color1, color2)
  482. draw_text(x, y, wid, line_height, Vocab::param(0))
  483. draw_text(x, y, wid-x-2, line_height, "#{@actor.hp}/#{@actor.mhp}",2)
  484. end
  485. #--------------------------------------------------------------------------
  486. # Draw Mp
  487. #--------------------------------------------------------------------------
  488. def draw_de_mp(x, y, wid = nil)
  489. wid = self.width/2 - (standard_padding*2) if wid == nil
  490. rate = @actor.mp_rate
  491. color1 = General::Mp_Colors[0]
  492. color2 = General::Mp_Colors[1]
  493. draw_deki_gauge(x, y, wid-x-2, 2, rate, color1, color2)
  494. draw_text(x, y, wid, line_height, Vocab::param(1))
  495. draw_text(x, y, wid-x-2, line_height, "#{@actor.mp}/#{@actor.mmp}",2)
  496. end
  497. #--------------------------------------------------------------------------
  498. # Draw Tp
  499. #--------------------------------------------------------------------------
  500. def draw_de_tp(x, y, wid = nil)
  501. wid = self.width/2 - (standard_padding*2) if wid == nil
  502. rate = @actor.tp / 100
  503. color1 = General::Tp_Colors[0]
  504. color2 = General::Tp_Colors[1]
  505. draw_deki_gauge(x, y, wid-x-2, 2, rate, color1, color2)
  506. draw_text(x, y, wid, line_height, Vocab::Tp)
  507. text = "#{(@actor.tp).to_i}/100"
  508. text = "#{(@actor.tp.perc_of(100)).to_flim}%" if General::Show_Tp_As_Perc
  509. draw_text(x, y, wid-x-2, line_height, text,2)
  510. end
  511. #--------------------------------------------------------------------------
  512. # Draw Exp (w/gauge)
  513. #--------------------------------------------------------------------------
  514. def draw_de_xp(x, y, gauge = true)
  515. s1 = @actor.current_level_exp
  516. s2 = @actor.next_level_exp
  517. s1_g = @actor.exp - @actor.current_level_exp
  518. s2_g = @actor.next_level_exp - @actor.current_level_exp
  519. wid = self.width/2 - (standard_padding*2)
  520. wid_b = self.width/2 - (standard_padding)
  521. rate = (s1_g).to_f / (s2_g)
  522. color1 = General::Exp_Color[0]
  523. color2 = General::Exp_Color[1]
  524. draw_deki_gauge(wid_b, y, wid-x-2, 2, rate, color1, color2) if gauge
  525. draw_text(wid_b, y, wid, line_height, "Exp:")
  526. draw_text(wid_b, y, wid-x-2, line_height, "#{s1}/#{s2}",2)
  527. end
  528. #--------------------------------------------------------------------------
  529. # Draw Icon (w/Hue)
  530. #--------------------------------------------------------------------------
  531. def draw_de_icon(icon_index, x, y, hue = 0, enabled = true)
  532. bitmap = Cache.icon("IconSet",hue)
  533. rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  534. contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  535. end
  536.  
  537. end
  538.  
  539. #==============================================================================
  540. class Deki_Help < Window_Base
  541. #==============================================================================
  542. #--------------------------------------------------------------------------
  543. # Object Initialization
  544. #--------------------------------------------------------------------------
  545. def initialize(line_number = 2)
  546. super(0, 0, Graphics.width/4*3, fitting_height(line_number))
  547. @item = nil
  548. end
  549. #--------------------------------------------------------------------------
  550. # Set Text
  551. #--------------------------------------------------------------------------
  552. def set_text(text)
  553. if text != @text
  554. @text = text
  555. refresh
  556. end
  557. end
  558. #--------------------------------------------------------------------------
  559. # Clear
  560. #--------------------------------------------------------------------------
  561. def clear
  562. set_text("")
  563. end
  564. #--------------------------------------------------------------------------
  565. # Set Item , item : Skills and items etc.
  566. #--------------------------------------------------------------------------
  567. def set_item(item)
  568. return if @item == item
  569. @item = item
  570. refresh
  571. set_text(item ? item.description : "")
  572. end
  573. #--------------------------------------------------------------------------
  574. # Refresh
  575. #--------------------------------------------------------------------------
  576. def refresh
  577. contents.clear
  578. draw_text_ex(4, 0, @text)
  579. end
  580. #--------------------------------------------------------------------------
  581. # Reset Font Settings
  582. #--------------------------------------------------------------------------
  583. def reset_font_settings
  584. change_color(normal_color)
  585. self.contents.font.name = General::Fonts
  586. self.contents.font.size = General::Font_Size
  587. self.contents.font.bold = General::Font_Bold
  588. end
  589.  
  590. end
  591.  
  592. #==============================================================================#
  593. # http://dekitarpg.wordpress.com/ #
  594. #==============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement