In-game Weapon Creator ver. 2.0
by Haki
Introduction:
This script allows to create weapons inside the game. Weapon parts must be given inside the script.
Script:
Please follow the instructions inside the script. If there's anything you don't get please download the demo.
Download:
http://www.megaupload.com/?d=HJL6LR46
Other Notes:
If you use this script credit me (Haki). The script hasn't been tested with any other scripts so if you find any compatibility issues post them in this topic or e-mail me at ivica.hakstok@du.t-com.hr
by Haki
Introduction:
This script allows to create weapons inside the game. Weapon parts must be given inside the script.
Script:
Please follow the instructions inside the script. If there's anything you don't get please download the demo.
Code:
#=================================================================================
#In-game Weapon Creator ver 2.0 by Haki
#=================================================================================
#
# Version 2.0 updates:
# -each part can now be used only once
# -added gold display
# -fixed the problem when using two same parts
#
# How to use:
# -Inside the game, call "$scene = Scene_Weapon_Select.new" to open
# the weapon creator window.
# -All weapon parts must be edited and created inside this script inside
# the "Weapons" module. Instructions on how to do that are in the module.
# -To enable parts call "Weapons::AVAILABLE_PARTS.push(part_id)".
# To disable them call "Weapons::AVAILABLE_PARTS.delete(part_id)"
#
# Compatibility:
# -The script hasn't been tested with other scripts but it should be
# compatible.
#
# Bug report:
# -If you find any bugs, e-mail me at ivica.hakstok@du.t-com.hr
#
#=================================================================================
module Weapons
WEAPON_TYPE = {1 => "Sword", 2 => "Spear"} #types used when creating a new weapon
CLASS_WEAPON = {1 => 1, 2 =>2} #set which class can hold which type of weapon - class_id => type
WEAPON_PARTS = {1 => [1,"Simple Handle",30,0,100], 2 =>[1,"Simple Blade",120,0,100], 3 => [2,"Simple Stick",20,1,100], 4 =>[2,"Simple Spike",100,3,100], 5 =>[2,"Mega Attack Booster!!!",200,12,200]} #part => [type, name, atk, dex_plus,cost]
AVAILABLE_PARTS = [1,2,5] #parts of WEAPON_PARTS that are available. Add new ones using event's "Script..." command "Weapons::AVAILABLE_PARTS.push(part_id)"
NEW_WEAPON = {[1,2] => ["Simple Sword","A simple sword.",7], [3,4] => ["Simple Spear","A simple spear.",8], [3,4,5] => ["Super Duper Spear","A super duper spear!!!",8]} #weapon_parts => new weapon name, weapon description, animation_id
DEFAULT_ICON = {1=>"001-Weapon01",2=>"002-Weapon02"} #type => id of the icon which represents the type
end
class Window_Command < Window_Selectable
attr_accessor :commands
end
class Game_Party
attr_accessor :gold
end
class Scene_Weapon_Select
attr_accessor :type
def main
@spriteset = Spriteset_Map.new
@weapon_type_window = Window_Command.new(160, Weapons::WEAPON_TYPE.values)
@weapon_type_window.index = 0
@weapon_type_window.x = 320 - @weapon_type_window.width / 2
@weapon_type_window.y = 240 - @weapon_type_window.height / 2
@weapon_type_window.opacity = 155
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
@weapon_type_window.dispose
@spriteset.dispose
end
def update
@weapon_type_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
Graphics.update
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
self.type = @weapon_type_window.index + 1
$game_system.se_play($data_system.decision_se)
$scene = Scene_Weapon_Main.new(self.type)
end
end
end
class Scene_Weapon_Main
attr_accessor :type
def initialize(type)
self.type = type
end
def main
@spriteset = Spriteset_Map.new
@parts = []
@parts_selected = []
@leftover_parts = []
@leftover_check = []
@cost = 0
@str = 0
@dex = 0
clean(Weapons::AVAILABLE_PARTS)
for i in Weapons::AVAILABLE_PARTS
if Weapons::WEAPON_PARTS[i] != nil
case Weapons::WEAPON_PARTS[i][0]
when type
@parts.push(Weapons::WEAPON_PARTS[i][1] + " " + Weapons::WEAPON_PARTS[i][4].to_s)
end
end
end
@parts.push("Done")
@weapon_part1_window = Window_Command.new(480, @parts)
@weapon_part1_window.index = 0
@weapon_part1_window.x = 0
@weapon_part1_window.y = 240 - @weapon_part1_window.height / 2
@result_window = Window_Base.new(0,416,640,64)
@result_window.contents = Bitmap.new(608,32)
@info_window = Window_Base.new(0,0,640,64)
@info_window.contents = Bitmap.new(608,32)
@info_window.opacity = 155
@weapon_part1_window.opacity = 155
@result_window.opacity = 155
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
@weapon_part1_window.dispose
@result_window.dispose
@spriteset.dispose
@info_window.dispose
end
def clean(array) #this method will remove double parts
a = []
for i in 0...array.size
for j in i+1...array.size
if array[i] == array[j]
a.push(array[i])
end
end
end
for i in a
array.delete(i)
array.push(i)
end
end
def update
@weapon_part1_window.update
@result_window.update
@info_window.update
@info_window.contents.clear
@info_window.contents.draw_text(0,0,368,32,"Select the parts you want to use.")
@info_window.contents.draw_text(400,0,208,32,"You have " + $game_party.gold.to_s + " " + $data_system.words.gold)
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
Graphics.update
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
i = @parts[@weapon_part1_window.index]
for j in Weapons::WEAPON_PARTS.keys
if i.sub(/\s+\S+\Z/){""} == Weapons::WEAPON_PARTS[j][1]
id = j
end
end
if @weapon_part1_window.index == @weapon_part1_window.commands.size - 1
$scene = Scene_Map.new if @parts_selected == []
for i in @parts_selected
@cost += Weapons::WEAPON_PARTS[i][4].to_i
end
if @cost <= $game_party.gold
for i in 0...Weapons::NEW_WEAPON.keys.size
@leftover_parts = @parts_selected - Weapons::NEW_WEAPON.keys[i]
@leftover_check = Weapons::NEW_WEAPON.keys[i] - @parts_selected
if @leftover_parts == @leftover_check and @leftover_check == [] and @leftover_parts == []
@result_window.contents.clear
@result_window.contents.draw_text(0,0,608,32,"Created " + Weapons::NEW_WEAPON[Weapons::NEW_WEAPON.keys[i]][0])
@result_window.update
$game_party.gold -= @cost
for part in Weapons::NEW_WEAPON.keys[i]
@str += Weapons::WEAPON_PARTS[part][2]
@dex += Weapons::WEAPON_PARTS[part][3]
end
weapon = RPG::Weapon.new
weapon.name = Weapons::NEW_WEAPON[Weapons::NEW_WEAPON.keys[i]][0]
weapon.icon_name = Weapons::DEFAULT_ICON[type]
weapon.atk = @str
weapon.dex_plus = @dex
weapon.animation2_id = Weapons::NEW_WEAPON[Weapons::NEW_WEAPON.keys[i]][2]
weapon.description = Weapons::NEW_WEAPON[Weapons::NEW_WEAPON.keys[i]][1]
for j in 1...$data_weapons.size
if $data_weapons[j].name == weapon.name
$game_system.se_play($data_system.equip_se)
$game_party.gain_weapon($data_weapons[j].id,1)
return
end
if $data_weapons[j].name == ""
$game_system.se_play($data_system.equip_se)
weapon.id = $data_weapons[j].id
$data_weapons[j] = weapon
$data_classes[type].weapon_set.push(weapon.id)
$game_party.gain_weapon(weapon.id,1)
break
end
end
for x in @parts_selected
Weapons::AVAILABLE_PARTS.delete(x)
end
@parts_selected = []
Graphics.freeze
$scene = Scene_Weapon_Select.new
Graphics.transition(40)
else
@result_window.contents.clear
@result_window.contents.draw_text(0,0,608,32,"Nothing created")
@result_window.update
end
end
else
@result_window.contents.clear
@result_window.contents.draw_text(0,0,608,32,"Not enough money to do this.")
@result_window.update
$game_system.se_play($data_system.buzzer_se)
end
elsif @parts_selected.include?(id) == true
$game_system.se_play($data_system.cancel_se)
@weapon_part1_window.draw_item(@weapon_part1_window.index,Color.new(255,255,255,255))
@parts_selected.delete(id)
elsif @parts_selected.include?(id) == false
$game_system.se_play($data_system.decision_se)
@weapon_part1_window.draw_item(@weapon_part1_window.index,Color.new(255,255,255,127))
@parts_selected.push(id)
end
end
end
end
Download:
http://www.megaupload.com/?d=HJL6LR46
Other Notes:
If you use this script credit me (Haki). The script hasn't been tested with any other scripts so if you find any compatibility issues post them in this topic or e-mail me at ivica.hakstok@du.t-com.hr