Advertisement
AlliedG

Kread-Ex Traits Namer

Jan 15th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.28 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # ▼ Traits Namer
  3. # Author: Kread-EX
  4. # Version: 1.02
  5. # Release date: 11/03/2012
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  7.  
  8. #------------------------------------------------------------------------------
  9. # ▼ UPDATES
  10. #------------------------------------------------------------------------------
  11. # # 03/02/2012. Bug fixes.
  12. # # 24/03/2012. Added methods used by Alchemic Synthesis.
  13. # # 23/03/2012. Version 1.0, now help window generation is included.
  14. #------------------------------------------------------------------------------
  15. # ▼ TERMS OF USAGE
  16. #------------------------------------------------------------------------------
  17. # # You are free to adapt this work to suit your needs.
  18. # # You can use this work for commercial purposes if you like it.
  19. # # Credit is appreciated.
  20. # #
  21. # # For support:
  22. # # grimoirecastle.wordpress.com
  23. # # rpgmakerweb.com
  24. #------------------------------------------------------------------------------
  25. # ▼ INTRODUCTION
  26. #------------------------------------------------------------------------------
  27. # # This is a core script. By itself, it doesn't do anything but it used by
  28. # # Runic Enchantment and Alchemic Synthesis. The purpose of this script
  29. # # is to provide an automated way to name traits: the script retrieve the traits
  30. # # data and generates a name based on a customizable template.
  31. #------------------------------------------------------------------------------
  32.  
  33. $imported = {} if $imported.nil?
  34. $imported['KRX-TraitsNamer'] = true
  35.  
  36. puts 'Load: Traits Namer v1.02 by Kread-EX'
  37.  
  38. module KRX
  39. module TraitsNamer
  40. #===========================================================================
  41. # ■ CONFIGURATION
  42. #===========================================================================
  43.  
  44. X_PARAMETERS = [
  45.  
  46. 'Accuracy',
  47. 'Evasion',
  48. 'Critical rate',
  49. 'Critical eva. rate',
  50. 'M. Evasion',
  51. 'Magic reflection',
  52. 'Counter rate',
  53. 'HP Regen',
  54. 'MP Regen',
  55. 'TP Regen'
  56.  
  57. ]
  58.  
  59. S_PARAMETERS = [
  60.  
  61. 'Aggro effect',
  62. 'Guard effect',
  63. 'Recovery rate',
  64. 'Pharmacology',
  65. 'MP cost',
  66. 'TP charge rate',
  67. 'Physical damage',
  68. 'Magical damage',
  69. 'Floor damage',
  70. 'EXP rate'
  71.  
  72. ]
  73.  
  74. SPECIAL_FLAGS = [
  75.  
  76. 'Autobattle',
  77. 'Guard',
  78. 'Cover',
  79. 'TP Saver'
  80.  
  81. ]
  82.  
  83. PARTY_ABILITY = [
  84.  
  85. 'Half Encounter',
  86. 'No Encounter',
  87. 'No surprise attacks',
  88. 'No preemptive attacks',
  89. 'Gold x2',
  90. 'Item Drops x2'
  91.  
  92. ]
  93.  
  94. CODENAMES = {
  95.  
  96. 11 => '%s resist: %d%%' , # Element rate
  97. 12 => '%s debuff rate: %d%%' , # Debuff rate
  98. 13 => '%s resist: %d%%' , # State rate
  99. 14 => 'Immunity: %s' , # State immunity
  100. 21 => '%s: %d%%' , # Parameter rate
  101. 22 => '%s: %d%%' , # Additional parameter rate
  102. 23 => '%s: %d%%' , # Special parameter rate
  103. 31 => 'Attack %s' , # Physical attack attribute
  104. 32 => 'Attack %s %d%%' , # Physical attack state
  105. 33 => 'Attack speed %d' , # Attack speed correction
  106. 34 => 'Attack x%d' , # Additional attacks
  107. 41 => 'Command: %s' , # Add skill type
  108. 42 => 'Seal: %s' , # Seal skill type
  109. 43 => 'Skill: %s' , # Add skill
  110. 44 => 'Skill Seal: %s' , # Seal skill
  111. 51 => 'Can equip: %s' , # Add equip type (weapon)
  112. 52 => 'Can equip: %s' , # Add equip type (armor)
  113. 53 => 'Fix equip: %s' , # Fix equip slot
  114. 54 => 'Seal equip: %s' , # Seal equip slot
  115. 55 => 'Dual Wielding' , # Dual Wield
  116. 61 => 'Bonus Actions: +%d%%' , # Bonus actions
  117. 62 => '%s' , # Special flag
  118. 63 => 'Collapse type' , # Collapse type (will never be used, I think)
  119. 64 => '%s' , # Party ability
  120.  
  121. }
  122.  
  123. CODEHELP = {
  124.  
  125. # Element rate
  126. 11 => 'Raises %s resistance by %d%%.',
  127. # Debuff rate
  128. 12 => 'Raises %s resistance by %d%%.',
  129. # State rate
  130. 13 => 'Raises %s resistance by %d%%.',
  131. # State immunity
  132. 14 => 'Grants immunity to %s.',
  133. # Parameter rate
  134. 21 => 'Raises %s by %d%%.',
  135. # Additional parameter rate
  136. 22 => 'Raises %s by %d%%.',
  137. # Special parameter rate
  138. 23 => 'Grants a %d% modifier to %s.',
  139. # Physical attack attribute
  140. 31 => 'Adds %s element to normal attacks.',
  141. # Physical attack state
  142. 32 => 'Adds %s to normal attacks (%d%% accuracy).',
  143. # Attack speed correction (bonus)
  144. 33 => ['Raises attack speed by %d.',
  145. # Attack speed correction (malus)
  146. 'Reduces attack speed by %d.'],
  147. # Additional attacks
  148. 34 => 'Grants %d additional attacks.',
  149. # Add skill type
  150. 41 => 'Enables the %s battle command.',
  151. # Seal skill type
  152. 42 => 'Seals the %s battle command.',
  153. # Add skill
  154. 43 => 'Allows the use of the %s skill',
  155. # Seal skill
  156. 44 => 'Seals the %s skill.',
  157. # Add equip type (weapon)
  158. 51 => 'Allows %s to be equipped.',
  159. # Add equip type (armor)
  160. 52 => 'Allows %s to be equipped.',
  161. # Fix equip slot
  162. 53 => 'Fixes the %s equipment slot.',
  163. # Seal equip slot
  164. 54 => 'Seals the %s equipment slot.',
  165. # Dual Wield
  166. 55 => 'Allows to use two weapons as the same time.',
  167. # Bonus actions
  168. 61 => 'Raises the action rate by %d%%.',
  169. # Autobattle
  170. 62 => ['The character will act on his/her own in battle.',
  171. # Guard
  172. 'The character will permanently defend.',
  173. # Cover
  174. 'The character will take hits for his/her wounded comrades.',
  175. # TP Saver
  176. 'TP are kept after battles.'],
  177. # Collapse type (no need to use it but meh)
  178. 63 => 'Alters the collapse animation.',
  179. # Half encounter
  180. 64 => ['Halves the random encounter rate.',
  181. # No encounter
  182. 'Disables random encounters.',
  183. # No surprise attacks
  184. 'Disables surprise attacks.',
  185. # No preemptive attacks
  186. 'Disables preemptive attacks.',
  187. # Gold x2
  188. 'Doubles the money obtained after a battle.',
  189. # Item Drops x2
  190. 'Doubles the drop rate of items.']
  191.  
  192. }
  193.  
  194. EFFECTS_CODENAMES = {
  195.  
  196. 11 => 'HP Recovery' , # HP Recovery
  197. 12 => 'MP Recovery' , # MP Recovery
  198. 13 => 'TP Recovery' , # TP Gain
  199. 21 => 'Add %s' , # Add State
  200. 22 => 'Cleanse %s' , # Remove State
  201. 31 => '%s+' , # Add buff
  202. 32 => '%s-' , # Add debuff
  203. 33 => 'Dispel %s+' , # Remove buff
  204. 34 => 'Cancel %s-' , # Remove debuff
  205. 41 => 'Escape' , # Escape
  206. 42 => '%s Bonus' , # Permanent stat growth
  207. 43 => 'Learn %s' , # Permanent skill learning
  208. 44 => 'Common Event' , # Common event
  209.  
  210. }
  211.  
  212. EFFECTS_CODEHELP = {
  213.  
  214. # HP Recovery (static)
  215. 11 => ['Restores %d HP.',
  216. # HP Recovery (dynamic)
  217. 'Restores %d%% of maximum HP.'],
  218. # MP Recovery (static)
  219. 12 => ['Restores %d MP.',
  220. # MP Recovery (dynamic)
  221. 'Restores %d%% of maximum MP.'],
  222. # TP Gain
  223. 13 => 'Restores %d%% TP.',
  224. # Add State
  225. 21 => 'Inflicts %s (%d%% chance).',
  226. # Remove State
  227. 22 => 'Cancels %s.',
  228. # Add buff
  229. 31 => 'Increases %s for %d turns.',
  230. # Add debuff
  231. 32 => 'Decreases %s for %d turns.',
  232. # Remove buff
  233. 33 => 'Cancels a previously applied %s buff.',
  234. # Remove debuff
  235. 34 => 'Dispels an active %s debuff.',
  236. # Escape
  237. 41 => 'Automatically escape from battle.',
  238. # Permanent stat growth
  239. 42 => 'Boosts %d by %d permanently.',
  240. # Permanent skill learning
  241. 43 => 'Teaches the %s skill permanently.',
  242. # Common Event
  243. 44 => 'Calls a common event.'
  244.  
  245. }
  246.  
  247. #===========================================================================
  248. # ■ CUSTOM TRAITS/EFFECTS CONFIGURATION
  249. #===========================================================================
  250.  
  251. # INSTRUCTIONS
  252. # Here you can define custom traits names and descriptions.
  253. #
  254. # Syntax:
  255. # [type, code, data_id, value 1, value2] => [name, description]
  256. #
  257. # type: 0 (for equipment), 1 (for usables)
  258. #
  259. # code: the code number. Refer to default naming to know what is what.
  260. #
  261. # data_id: the number of the option you've choosen in the trait droplist.
  262. #
  263. # value1: what you typed in the first field where you can write numbers.
  264. # For equipment this is the only one.
  265. #
  266. # value2: usable items only. What you typed in the second field.
  267. #
  268. # description: If you want to also use a custom description. If you only
  269. # want the custom name, set this to nil.
  270.  
  271. CUSTOM_TRAITS = {
  272.  
  273. [0, 32, 2, 50] => ['Poisonous', nil],
  274. [0, 32, 2, 100] => ['Venomous', nil],
  275. [0, 31, 3, 100] => ['Firestrike', nil],
  276. [0, 31, 5, 100] => ['Lightningstrike', nil],
  277. [0, 31, 6, 100] => ['Waterstrike', nil],
  278. [0, 31, 4, 100] => ['Bug Damage +50%', nil],
  279. [0, 31, 7, 100] => ['Reptile Damage +50%', nil],
  280. [0, 31, 8, 100] => ['Bird Damage +50%', nil],
  281. [0, 31, 9, 100] => ['Undead Damage +50%', nil],
  282. [0, 31, 10, 100] => ['Demon Damage +50%', nil],
  283. [0, 11, 3, 75] => ['Fire Resistance +25%', nil],
  284. [0, 11, 3, 50] => ['Fire Resistance +50%', nil],
  285. [0, 11, 5, 75] => ['Lighting Resistance +25%', nil],
  286. [0, 11, 5, 50] => ['Lighting Resistance +50%', nil],
  287. [0, 11, 6, 75] => ['Water Resistance +25%', nil],
  288. [0, 11, 6, 50] => ['Water Resistance +50%', nil],
  289. [0, 14, 1, 0] => ['Death Immunity', nil],
  290. [0, 21, 2, 125] => ['ATK +25%', nil],
  291. [0, 21, 2, 150] => ['ATK +50%', nil],
  292. [0, 21, 2, 200] => ['ATK +100%', nil],
  293. [0, 21, 4, 125] => ['MAT +25%', nil],
  294. [0, 21, 4, 150] => ['MAT +50%', nil],
  295. [0, 21, 4, 200] => ['MAT +100%', nil],
  296. [0, 21, 3, 150] => ['DEF +50%', nil],
  297. [0, 21, 3, 200] => ['DEF +100%', nil],
  298. [0, 21, 5, 150] => ['MDF +50%', nil],
  299. [0, 21, 5, 200] => ['MDF +100%', nil],
  300. [0, 21, 6, 150] => ['AGI +50%', nil],
  301. [0, 21, 6, 200] => ['AGI +100%', nil],
  302. [0, 21, 0, 150] => ['Maximum HP +50%', nil],
  303. [0, 21, 0, 200] => ['Maximum HP +100%', nil],
  304. [0, 22, 7, 10] => ['HP Regeneration +10%', nil],
  305. [0, 22, 8, 10] => ['MP Regeneration +10%', nil],
  306. [0, 23, 4, 200] => ['MP Cost +100%', nil],
  307. [0, 23, 6, 200] => ['Physical Resistance -100%', nil],
  308.  
  309. [1, 11, 0, 0, 10] => ['HP Recovery XS', nil],
  310. [1, 11, 0, 0, 25] => ['HP Recovery S', nil],
  311. [1, 11, 0, 0, 50] => ['HP Recovery M', nil],
  312. [1, 11, 0, 0, 75] => ['HP Recovery L', nil],
  313. [1, 11, 0, 0, 100] => ['HP Recovery XL', 'Restores all HP!'],
  314. [1, 12, 0, 0, 10] => ['MP Recovery XS', nil],
  315. [1, 12, 0, 0, 25] => ['MP Recovery S', nil],
  316. [1, 12, 0, 0, 50] => ['MP Recovery M', nil],
  317. [1, 12, 0, 0, 75] => ['MP Recovery L', nil],
  318. [1, 12, 0, 0, 100] => ['MP Recovery XL', 'Restores all MP!'],
  319. [1, 13, 0, 2, 0] => ['TP Recovery XS', nil],
  320. [1, 13, 0, 5, 0] => ['TP Recovery S', nil],
  321. [1, 13, 0, 10, 0] => ['TP Recovery M', nil],
  322. [1, 13, 0, 16, 0] => ['TP Recovery L', nil],
  323. [1, 13, 0, 20, 0] => ['TP Recovery XL', nil],
  324.  
  325. }
  326.  
  327. #===========================================================================
  328. # ■ CONFIGURATION ENDS HERE
  329. #===========================================================================
  330. #--------------------------------------------------------------------------
  331. # ● Generates traits name
  332. #--------------------------------------------------------------------------
  333. def self.feature_name(code, data_id, value)
  334. custom = CUSTOM_TRAITS[[0, code, data_id, self.convert_value(code, value)]]
  335. return custom[0] unless custom.nil? || custom[0].nil?
  336. base_name = CODENAMES[code]
  337. data_name = case code
  338. when 11, 31
  339. $data_system.elements[data_id]
  340. when 12, 21
  341. Vocab.param(data_id)
  342. when 13, 14, 32
  343. $data_states[data_id].name
  344. when 22
  345. X_PARAMETERS[data_id]
  346. when 23
  347. S_PARAMETERS[data_id]
  348. when 41, 42
  349. $data_system.skill_types[data_id]
  350. when 43, 44
  351. $data_skills[data_id].name
  352. when 51
  353. $data_system.weapon_types[data_id]
  354. when 52
  355. $data_system.armor_types[data_id]
  356. when 53, 54
  357. Vocab.etype(data_id)
  358. when 62
  359. SPECIAL_FLAGS[data_id]
  360. when 64
  361. PARTY_ABILITY[data_id]
  362. end
  363. final_value = case code
  364. when 11, 13
  365. 100 - (value * 100)
  366. when 33, 34
  367. value
  368. else
  369. value * 100
  370. end
  371. if data_name.nil?
  372. name = sprintf(base_name, final_value)
  373. else
  374. name = sprintf(base_name, data_name, final_value)
  375. end
  376. name
  377. end
  378. #--------------------------------------------------------------------------
  379. # ● Generates traits description
  380. #--------------------------------------------------------------------------
  381. def self.feature_description(code, data_id, value)
  382. custom = CUSTOM_TRAITS[[0, code, data_id, self.convert_value(code, value)]]
  383. return custom[1] unless custom.nil? || custom[1].nil?
  384. if CODEHELP[code].is_a?(Array)
  385. base_help = CODEHELP[code][data_id]
  386. else
  387. base_help = CODEHELP[code]
  388. end
  389. data_name = case code
  390. when 11, 31
  391. $data_system.elements[data_id]
  392. when 12, 21
  393. Vocab.param(data_id)
  394. when 13, 14, 32
  395. $data_states[data_id].name
  396. when 22
  397. X_PARAMETERS[data_id]
  398. when 23
  399. S_PARAMETERS[data_id]
  400. when 41, 42
  401. $data_system.skill_types[data_id]
  402. when 43, 44
  403. $data_skills[data_id].name
  404. when 51
  405. $data_system.weapon_types[data_id]
  406. when 52
  407. $data_system.armor_types[data_id]
  408. when 53, 54
  409. Vocab.etype(data_id)
  410. when 62
  411. SPECIAL_FLAGS[data_id]
  412. when 64
  413. PARTY_ABILITY[data_id]
  414. end
  415. final_value = case code
  416. when 11, 13
  417. 100 - (value * 100)
  418. when 33, 34
  419. value
  420. else
  421. value * 100
  422. end
  423. if data_name.nil?
  424. name = sprintf(base_help, final_value)
  425. else
  426. name = sprintf(base_help, data_name, final_value)
  427. end
  428. name
  429. end
  430. #--------------------------------------------------------------------------
  431. # ● Generates effects name
  432. #--------------------------------------------------------------------------
  433. def self.effect_name(code, data_id, value1, value2)
  434. custom = CUSTOM_TRAITS[[1, code, data_id,
  435. self.convert_value(code, value1, false),
  436. self.convert_value(code, value2, false)]]
  437. return custom[0] unless custom.nil? || custom[0].nil?
  438. base_name = EFFECTS_CODENAMES[code]
  439. data_name = case code
  440. when 21, 22
  441. $data_states[data_id].name
  442. when 31, 32, 33, 34, 42
  443. Vocab.param(data_id)
  444. when 43
  445. $data_skills[data_id]
  446. end
  447. if data_name.nil?
  448. name = sprintf(base_name, value1, value2)
  449. else
  450. name = sprintf(base_name, data_name, value1, value2)
  451. end
  452. name
  453. end
  454. #--------------------------------------------------------------------------
  455. # ● Generates effects description
  456. #--------------------------------------------------------------------------
  457. def self.effect_description(code, data_id, value1, value2)
  458. custom = CUSTOM_TRAITS[[1, code, data_id,
  459. self.convert_value(code, value1, false),
  460. self.convert_value(code, value2, false)]]
  461. return custom[1] unless custom.nil? || custom[1].nil?
  462. if EFFECTS_CODEHELP[code].is_a?(Array)
  463. base_help = value2 > 0 ? EFFECTS_CODEHELP[code][0] :
  464. EFFECTS_CODEHELP[code][1]
  465. else
  466. base_help = EFFECTS_CODEHELP[code]
  467. end
  468. data_name = case code
  469. when 21, 22
  470. $data_states[data_id].name
  471. when 31, 32, 33, 34, 42
  472. Vocab.param(data_id)
  473. when 43
  474. $data_skills[data_id]
  475. end
  476. value1 = self.convert_value(code, value1, false)
  477. value2 = self.convert_value(code, value2, false)
  478. value1 = value2 if value1 == 0
  479. if data_name.nil?
  480. name = sprintf(base_help, value1, value2)
  481. else
  482. name = sprintf(base_help, data_name, value1, value2)
  483. end
  484. name
  485. end
  486. #--------------------------------------------------------------------------
  487. # ● Converts the real value to the one entered in the editor
  488. #--------------------------------------------------------------------------
  489. def self.convert_value(code, value, feature = true)
  490. if feature && [33, 34].include?(code)
  491. return value.to_i
  492. elsif feature && [31, 32, 21, 22, 23].include?(code)
  493. return (value.to_f * 100).to_i
  494. elsif [11, 12].include?(code) && value <= 1
  495. return (value.to_f * 100).to_i
  496. else
  497. value.to_i
  498. end
  499. end
  500. #--------------------------------------------------------------------------
  501. # ● Points towards either feature name or effect name
  502. #--------------------------------------------------------------------------
  503. def self.trait_name(trait)
  504. if trait.is_a?(RPG::BaseItem::Feature)
  505. return self.feature_name(trait.code, trait.data_id, trait.value)
  506. end
  507. self.effect_name(trait.code, trait.data_id, trait.value1, trait.value2)
  508. end
  509. #--------------------------------------------------------------------------
  510. # ● Points towards either feature description or effect description
  511. #--------------------------------------------------------------------------
  512. def self.trait_description(trait)
  513. if trait.is_a?(RPG::BaseItem::Feature)
  514. return self.feature_description(trait.code, trait.data_id, trait.value)
  515. end
  516. self.effect_description(trait.code, trait.data_id, trait.value1,
  517. trait.value2)
  518. end
  519. end
  520. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement