Guest Access
Go to page : 1, 2, 3
EVENTALIST
EVENTALIST
EVENTALIST
profile
This script creates random weapons in game for the player to use. It's a lot like the game Border Lands.
WRWG Folder < Some starting graphics
Post any suggestions for future updates or any errors you may encounter here.
mr_wiggles
profile
Wiggles Random Weapon Generator
Version: 1.2
Author: Mr Wiggles
Date: June 26, 2013
Version History
Version: 1.2
Author: Mr Wiggles
Date: June 26, 2013
Version History
- Version 1.2 6/26/13 - XAS compatible + First item store glitch
- Version 1.0 4/30/11 - Original Release
Planned Future Versions
- More features and such, idk what...
Description
This script creates random weapons in game for the player to use. It's a lot like the game Border Lands.
Features
- Too many, look at the config module in the code box bellow.
Instructions
You'll have to paste the script above main and bellow the default scripts. Download and place the WRWG folder in your graphics folder.Script
- Code:
#==============================================================================
# ** Wiggles Random Weapon Generator **
#==============================================================================
# By: Mr_Wiggles
# Version 1.2
# 6/26/13
#==============================================================================
# Instructions:
# --------------------------------
# Make sure that the "WRWG" folder is in your Graphics directory.
#
# To give the player a random weapon create a script call in an event:
# "wrwg_gain_weapon(rare_per)"
#
# You can also ues the id tag for shops and change weapon event commands.
#
# rare_per = If not used in the call will use defualt. Changes the rarity per
# to allow for a higher or lower chance of a rare item.
#
#==============================================================================
module WRW_Generator
#==============================================================================
# ** Config
#==============================================================================
# ids of weapons in the database to transform into a random one.
RANDID = [17,18,19,20]
#-----------------------------------------------------------------------------
# These are teh types of weapons, These are also the base names for the icon
# IMGs in the "Graphics/WRWG/" folder.
TYPES = {
0 => "Sword",
1 => "Axe",
2 => "Bow",
3 => "Spear"
}
#-----------------------------------------------------------------------------
# This is the base tool for the above types. (Only if using with XAS)
XAS_3dot92 = true # Using XAS version 3.92 ?
TOOLBASE = {
0 => 1,
1 => 2,
2 => 3,
3 => 4
}
#-----------------------------------------------------------------------------
# This is the base attack for the above types.
STATBASE = { # use 0 for no base value.
# [atk, pdef, mdef, str, dex, agi, int]
0 => [130, 0 , 0 , 0 , 0 , 0 , 0 ],
1 => [310, 0 , 0 , 0 , 0 , 0 , 0 ],
2 => [120, 0 , 0 , 0 , 0 , 0 , 0 ],
3 => [145, 0 , 0 , 0 , 0 , 0 , 0 ]
}
#-----------------------------------------------------------------------------
# These are the materials list, this will be the follow up name that comes
# after the type in the "Graphics/WRWG/" folder.
# e.x. "Sword_Copper" or "Spear_Dragon"
# Materials are listed by most common to rarest.
MATERIAL = {
0 => "Copper",
1 => "Tin",
2 => "Bronze",
3 => "Iron",
4 => "Silver",
5 => "Mithril",
6 => "Dragon"
}
#-----------------------------------------------------------------------------
# This is the status bonus ranges for the above materials.
STATPLUS = { # use "" for no bonus.
# [ atk , pdef , mdef , str , dex , agi , int]
0 => [" 50 - 100", "" , "" , "" , "" , "1 - 10" , "" ],
1 => ["100 - 150", "" , "" , "" , "3 - 11" , "" , "" ],
2 => ["150 - 200", "" , "" , "" , "" , "" , "" ],
3 => ["200 - 250", "" , "" , "2 - 9" , "" , "" , "" ],
4 => ["250 - 300", "" , "" , "" , "" , "" , "" ],
5 => ["300 - 350", "5 - 10" , "" , "" , "" , "" , "" ],
6 => ["350 - 400", "" , "8 - 11" , "" , "" , "" , "" ]
}
#-----------------------------------------------------------------------------
# This is the chance of leveling up the material line. i.e.
# copper + (chance > rand %) = tin + (chance > rand %) = bronze + ... ect
# until the chain breaks. (%0.00 Percentage)
DEFMATPER = 25.67
#-----------------------------------------------------------------------------
# Price value eidts. Price is modfied by the weapons rarity, and
# other factors like effects. Feel free to experament with these values.
PRICEMUL = 10 # higher = cost more (max 50)
PRICEDIV = 0.63 # lower = cost more
#-----------------------------------------------------------------------------
# These are the special effect names. If a weapon has a special effect, this
# will be the follow up name that comes after the type in the
# "Graphics/WRWG/" folder. : e.x. "Sword_Quick" or "Spear_Master"
EFFNAME = {
0 => "Quick",
1 => "Powerfull",
2 => "Master",
3 => "Precision",
4 => "Poison"
}
#-----------------------------------------------------------------------------
# Chance of getting one or more of the above specials. (%0.00 Percentage)
EFFCHAN = {
0 => 5.50,
1 => 3.76,
2 => 0.99,
3 => 10.01,
4 => 3.85
}
#-----------------------------------------------------------------------------
# These are the effects for the above names. They go like so:
# ["type", value_range]
# "type" = type of effect boost
# Acceptable types: "atk", "pdef", "mdef", "str", "dex", "agi", "int"
#
# You can also use the following..
# ["argue", id]
# Acceptable argues: "add_state", "sub_state", "element"
# "add_state" = will add the state to the enemy when attacking.
# "sub_state" = will remove the state to the enemy when attacking.
# "element" = makes the weapon have an elemental tie.
# id = is the id in the database of argument.
#
EFFECT = {
0 => ["agi", "99 - 199"],
1 => ["atk", "25 - 99"],
# You can include more then one effect type.
2 => [["atk", "30 - 50"], ["agi", "99 - 199"], ["dex", "99 - 199"]],
3 => ["dex", "101 - 201"],
4 => [["add_state", 3], ["element", 8]]
}
#-----------------------------------------------------------------------------
# These are the descriptive words used in making weapon descriptions.
# Try to use words that flow down the line.
# e.x. "(type) made from (material), containing hidden powers." or
# "(type) created with (material), bestoing amazing strength."
# The description is made from the words in the arrays by random, more words,
# more the descriptions seem random and unique.
# --------------------------
# after: "Weapon Type"
MADE = ["made", "created", "forged", "formed"]
CONJUN = ["from", "with", "using"]
# after: "Material Name" - added if weapon has special effects.
JUNCT = ["containing", "bestowing", "including"]
SPECT = ["special", "hidden", "amazing", "foreign", "rare", "unique"]
POWRS = ["powers", "potency", "energy", "forces", "vitality"]
#-----------------------------------------------------------------------------
# This is for testing, it will print the stats of the created item.
# (good for making adjustments to the above values)
PSTATS = false # show weapon stats after completion
PRANKS = false # show material change while its happening
#==============================================================================
# ** End Config
#==============================================================================
end # Do not eddit below this line if what you see there looks confusing.
#==============================================================================
# ** Interpreter
#==============================================================================
class Interpreter
include WRW_Generator
#--------------------------------------------------------------------------
def wrwg_gain_weapon(chance = DEFMATPER)
weap_id = create_new_rwdata(chance)
$game_party.gain_weapon(weap_id, 1)
end
#--------------------------------------------------------------------------
def create_new_rwdata(chance = DEFMATPER)
wep_data = RPG::Weapon.new
# get material
mater_index = 0; price = 0
loop do
rper = (rand(10000) / 100.to_f); exit = (chance.to_f < rper)
string = "Chance % #{chance} < Random % #{rper}\n" +
"Material: #{MATERIAL[mater_index]} - Continue: #{!exit}"
print("#{string}") if PRANKS
break if mater_index >= MATERIAL.size - 1 or exit
mater_index += 1
end
material = MATERIAL[mater_index]
# get type
trand = rand(TYPES.size); type = TYPES[trand]; tool = TOOLBASE[trand]
wep_data.action_id = tool
# get effects
rand_eff = []
for id in 0..EFFNAME.size - 1
eff = EFFNAME[id]
schan = EFFCHAN[id]
if schan.to_f > (rand(10000) / 100.to_f)
rand_eff.push([eff, schan, id]) if rand_eff.size < 1
end
end
unless rand_eff.empty?
effect_name = "#{rand_eff[0][0]} " unless rand_eff[0].nil?
effect_name += "and #{rand_eff[1][0]} " unless rand_eff[1].nil?
end
# create base values
st = ["atk", "pdef", "mdef", "str_plus", "dex_plus", "agi_plus", "int_plus"]
for i in 0..6
b = 0
unless STATPLUS[trand][i] == ""
r = STATPLUS[trand][i].split(' - ')
b = r[0].to_i + rand(r[1].to_i - r[0].to_i)
end
eval("wep_data.#{st[i]} = STATBASE[trand][i] + b")
end
# create effects
wep_data.element_set = []
wep_data.plus_state_set = []
wep_data.minus_state_set = []
for i in 0..1
unless rand_eff[i].nil?
effects = EFFECT[rand_eff[i][2]]
effects = [effects] unless effects[0].is_a?(Array)
for eff in effects
if eff[1].is_a?(String)
range = eff[1].split(' - ')
value = rand(range[1].to_i)
value = range[0].to_i if value < range[0].to_i
end
if eff[0] == "add_state"
unless $data_states[eff[1]].nil?
wep_data.plus_state_set.push(eff[1])
end
elsif eff[0] == "sub_state"
unless $data_states[eff[1]].nil?
wep_data.minus_state_set.push(eff[1])
end
elsif eff[0] == "element"
wep_data.element_set.push(eff[1])
else
st.each{|s| eval("wep_data.#{s} += value") if eff[0] == s}
end
end
end
end
# create name
wep_data.name = "#{effect_name}#{material} #{type}"
# create icon
bases = Retrive_Files.get_files("#{type}")
im1 = bases[rand(bases.size)]
materials = Retrive_Files.get_files("#{type}_#{material}")
im2 = materials[rand(materials.size)]
unless rand_eff[0].nil?
unless rand_eff[0][0].nil?
effects1 = Retrive_Files.get_files("#{type}_#{rand_eff[0][0]}")
im3 = effects1[rand(effects1.size)]
end
end
unless rand_eff[1].nil?
unless rand_eff[1][0].nil?
effects2 = Retrive_Files.get_files("#{type}_#{rand_eff[1][0]}")
im4 = effects2[rand(effects2.size)]
end
end
wep_data.icon_name = "WRWG - #{im1} - #{im2} - #{im3} - #{im4}"
# create description
made = MADE; conj = CONJUN; spec = SPECT; pows = POWRS; junc = JUNCT
dr = "#{type} #{made[rand(made.size)]} #{conj[rand(conj.size)]} #{material}"
unless rand_eff.empty?
dr += ", #{junc[rand(junc.size)]} #{spec[rand(spec.size)]} " +
"#{pows[rand(pows.size)]}"
end; wep_data.description = dr + "."
# create price
div = PRICEDIV + 1; mul = PRICEMUL > 50 ? 50 : PRICEMUL
price += mul * (10000 - chance * (mater_index + 1)) / div
unless rand_eff.empty?
price += mul * (10000 - rand_eff[0][1].to_i) / div if !rand_eff[0].nil?
price += mul * (10000 - rand_eff[1][1].to_i) / div if !rand_eff[1].nil?
end
value = (price * (rand(100) / 100.to_f)) * mul / div
price += rand(1000) > 500 ? -value : value
price *= -1 if price < 0; wep_data.price = price.floor
# create id and data
wep_data.id = $game_party.last_rwid
$game_party.last_rwid += 1
$game_party.rand_wep_data[wep_data.id] = wep_data
$data_weapons[wep_data.id] = wep_data
$game_party.actors.each{|a| $data_classes[a.class_id
].weapon_set.push(wep_data.id)}
XAS_SKILL::WEAPON_ID_TOOL[wep_data.id] = tool if XAS_3dot92
$game_party.rweps_toolids[wep_data.id] = tool
# return id
string = "Name: #{wep_data.name} \t| id: #{wep_data.id} \t|" +
"Price: #{wep_data.price} \n" +
"atk: #{wep_data.atk} \t| pdef: #{wep_data.pdef} \t| " +
"mdef: #{wep_data.mdef} \t| str: #{wep_data.str_plus} \t| " +
"dex: #{wep_data.dex_plus} \t| " +
"agi: #{wep_data.agi_plus} \t| int: #{wep_data.int_plus} \n" +
"#{wep_data.description}"
print("#{string}") if PSTATS
return wep_data.id
end
#--------------------------------------------------------------------------
def command_302
$game_temp.battle_abort = true
$game_temp.shop_calling = true
type, id = @parameters
id = create_new_rwdata if type == 1 and RANDID.include?(id)
$game_temp.shop_goods = [[type, id]]
loop do
@index += 1
if @list[@index].code == 605
type, id = @list[@index].parameters
id = create_new_rwdata if type == 1 and RANDID.include?(id)
$game_temp.shop_goods.push([type, id])
else
return false
end
end
end
#--------------------------------------------------------------------------
def command_127
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
id = RANDID.include?(@parameters[0]) ? create_new_rwdata : @parameters[0]
$game_party.gain_weapon(id, value)
return true
end
end
#==============================================================================
# ** Game Party
#==============================================================================
class Game_Party
attr_accessor :rand_wep_data, :rweps_toolids, :last_rwid
#--------------------------------------------------------------------------
alias :wrwg_init :initialize
def initialize
wrwg_init
@rand_wep_data = {}
@last_rwid = $data_weapons.size
@rweps_toolids = {}
end
#--------------------------------------------------------------------------
alias :wrwg_ref :refresh
def refresh
wrwg_ref
if @rand_wep_data.nil?
@rand_wep_data = {}
@rweps_toolids = {}
end
for id in $data_weapons.size...($data_weapons.size + @rand_wep_data.size)
wep = @rand_wep_data[id]
$data_weapons[wep.id] = wep
for actor in @actors
$data_classes[actor.class_id].weapon_set.push(wep.id)
end
end
end
end
#==============================================================================
# ** Weapon Module
#==============================================================================
module RPG
class Weapon
attr_accessor :action_id
alias :wrwg_init :initialize
def initialize
wrwg_init
@action_id = 0
end
end
#=====================================================================
module Cache
#--------------------------------------------------------------------
def self.icon(filename, hue = 0)
if filename.include?("WRWG")
tag, im1, im2, im3, im4 = filename.split(' - ')
# create bitmap
bitmap = Bitmap.new(24, 24)
bit = self.wrwg(im4) rescue nil
bitmap.blt(0, 0, bit, Rect.new(0, 0, 24, 24), 150) unless bit.nil?
bit = self.wrwg(im3) rescue nil
bitmap.blt(0, 0, bit, Rect.new(0, 0, 24, 24), 150) unless bit.nil?
bit = self.wrwg(im2) rescue nil
bitmap.blt(0, 0, bit, Rect.new(0, 0, 24, 24)) unless bit.nil?
bit = self.wrwg(im1) rescue nil
bitmap.blt(0, 0, bit, Rect.new(0, 0, 24, 24)) unless bit.nil?
return bitmap
else
self.load_bitmap("Graphics/Icons/", filename, hue)
end
end
#--------------------------------------------------------------------
def self.wrwg(filename, hue = 0)
self.load_bitmap("Graphics/WRWG/", filename, hue)
end
end
end
#==============================================================================
# ** Retrive Files
#==============================================================================
module Retrive_Files
def self.get_files(name)
files = []
for file in Dir.entries("Graphics/WRWG/")
file = file.to_s
next unless file.include?(".png")
string = file.clone; string.sub!(/([0-9]+)-/, ""); string.sub!(".png", "")
files.push(file) if string == "#{name}"
end
return files
end
end
#==============================================================================
# ** XAS Patch
#==============================================================================
if WRW_Generator::XAS_3dot92
class Scene_Load < Scene_File
alias :rwxas_patch :read_save_data
def read_save_data(file)
rwxas_patch(file)
$game_party.rweps_toolids.each{|w, t|
if $game_party.weapon_number(w) <= 0
$game_party.rweps_toolids.delete(w)
next
end
XAS_SKILL::WEAPON_ID_TOOL[w] = t
}
end
end
end
WRWG Folder < Some starting graphics
Support
Post any suggestions for future updates or any errors you may encounter here.
Known Compatibility Issues
none that i know of.Restrictions
DO NOT post this on any other forum with out my permission, you are free to edit this in anyway for YOUR use only. EVENTALIST
Show Signature
EVENTALIST
C.O.R.N.
C.O.R.N.
C.O.R.N.
profile
BluE
profile
Impressive! Border Lands is what I thought when I saw the title. Nice job!
Is there a randomizer for ammo types required for ranged weapons?
Is there a randomizer for ammo types required for ranged weapons?
C.O.R.N.
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
no, it just uses the base tools requirements in the XAS SKILL config menu.
You could make multiples of the types but with different links that use different ammo types.
like "Bow", "Bow", "Bow"
but the toll bases are 1, 2, 3
You could make multiples of the types but with different links that use different ammo types.
like "Bow", "Bow", "Bow"
but the toll bases are 1, 2, 3
EVENTALIST
Show Signature
EVENTALIST
||||||||||
||||||||||
||||||||||
profile
supercow
profile
i didnt play border lands but its kindda like diablo right? because it looks like for me
tried it and it looks great :p (kindda confused at the pricing range though)
i especialy love using it in shop going in and out looking for the best equip
now just need to make shop that sell ??? wep/armor kindda like gambling shop
kindda stumped at first with the script:wrwg_gain_weapon(rare_per) didnt know have to change the (rare_per) into %number
randomizer for ammo types? just mask the ammo with armor (make the armor increase atk ,etc)
tried it and it looks great :p (kindda confused at the pricing range though)
i especialy love using it in shop going in and out looking for the best equip
now just need to make shop that sell ??? wep/armor kindda like gambling shop
kindda stumped at first with the script:wrwg_gain_weapon(rare_per) didnt know have to change the (rare_per) into %number
randomizer for ammo types? just mask the ammo with armor (make the armor increase atk ,etc)
||||||||||
Show Signature
||||||||||
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
Yea the config can be a little complex, but i tried to explain everything the best i could.
EVENTALIST
Show Signature
EVENTALIST
ACTIVATED
ACTIVATED
ACTIVATED
profile
mchallin
profile
Hey Mr Wiggles, realllly liking this script!
I seem to be having one problem though...
When I load up a saved game (after totally quiting rpgxp), the tool in my game doesnt activate anymore, and so the weapon doesnt work...
the tool works still if I only quit to the main game menu and reload from there
im using XAS 3.91 by the way
I seem to be having one problem though...
When I load up a saved game (after totally quiting rpgxp), the tool in my game doesnt activate anymore, and so the weapon doesnt work...
the tool works still if I only quit to the main game menu and reload from there
im using XAS 3.91 by the way
ACTIVATED
Show Signature
ACTIVATED
ACTIVATED
ACTIVATED
ACTIVATED
profile
mchallin
profile
# update: I've just noticed when it occurs;
if a normal weapon is equipped after a random generated weapon, and the game is saved with a normal weapon equipped...then the game is reloaded...the tool for the random gen weapon doesnt seem to work anymore...
hope this makes sense!
if a normal weapon is equipped after a random generated weapon, and the game is saved with a normal weapon equipped...then the game is reloaded...the tool for the random gen weapon doesnt seem to work anymore...
hope this makes sense!
ACTIVATED
Show Signature
ACTIVATED
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
So you have a random weapon, then swap for a normal weapon. save, then on reload swap back to the random weapon and try to use it.
And this causes XAS's tool id link and break the system?
And this causes XAS's tool id link and break the system?
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
Yea i see the problem after reading the script.
This line, its editing the value of the module in its state. In order to fix it would need to write over the Game_Player section in XAS where that "WEP_ID_TOOL" is used and replace it with a new means of transportation of tool value with it.
A simple fix would be to simple add a variable "@weapon_tool" into Game_Player" class and have it store the data for the weapons information. But that wouldn't save all the random ones created sowould have to add a hash into "Game_Party" that would hold the weapon id and tool values in. Also would need to have a cleaner when weapons are added/removed so hash wont bloat.
- Code:
XAS_SKILL::WEP_ID_TOOL[wep_data.id] = tool
This line, its editing the value of the module in its state. In order to fix it would need to write over the Game_Player section in XAS where that "WEP_ID_TOOL" is used and replace it with a new means of transportation of tool value with it.
A simple fix would be to simple add a variable "@weapon_tool" into Game_Player" class and have it store the data for the weapons information. But that wouldn't save all the random ones created sowould have to add a hash into "Game_Party" that would hold the weapon id and tool values in. Also would need to have a cleaner when weapons are added/removed so hash wont bloat.
EVENTALIST
Show Signature
EVENTALIST
ACTIVATED
ACTIVATED
ACTIVATED
profile
mchallin
profile
Yeah that's what I meant! Appreciate the reply and taking a look for me.. cheers man
going to have a play and try to figure out how to fix it how you said. I'm still a learner with scripting so might have to bug you for some more info.. if I give up hope lol!
going to have a play and try to figure out how to fix it how you said. I'm still a learner with scripting so might have to bug you for some more info.. if I give up hope lol!
ACTIVATED
Show Signature
ACTIVATED
Go to page : 1, 2, 3