Jump to content

Recommended Posts

Loosing some words about first:

It's me again... I think I should finally work on at my project but browsing the forums and find some little challenges seems to be more fun at the moment. Today I saw someone who mentioned that making a random equip script would be incredible hard or even impossible. I wanted to know and this is my result :)

 

Features:

â— Creates Random Weapons or Armors based upon a template

â— Supports pre- and suffixes

â— Bind fix values to properties or make them random

â— Properties also support traits, but there's nothing random at the moment about this and it

â— Support for Notes, so you can use notetags from other scripts

â— Choose if a property is for armors or weapons.

â— Properties have a quality weight

 

Screenshot

Erm.. I don't think that one's needed. But here are some example names wit a 'Sword' as template:

â— Sword of Luck

â— Very sharp Sword

â— Very sharp Lucky Sword of a Thief

 

How to use

You can find detailed instructions in the script or better: check the manual.

 

Manual

Urm well...I thought it may be needed and so here you go:

Manual.pdf

 

Known Problems

â— I could not find any nice solution to save the Items in another way then to the database itself. While for players this won't be a problem it will be one for the dev. When you save your project you will overwrite the random items. Same problem as with the Trial work-around about scripting. I thought about saving a copy of the files I need and overwrite the originals with them but then you could not add anymore weapon or armors :rolleyes: So I'm still thinking about a appropriate solution.

 

Script

 

#==============================================================================
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# â–  DMO - RANDOM EQUIP SCRIPT
#   â— Version:  1.1
#   â— Author:   DasMoony
#   â— Date:	 January 15th, 2012
#   â— Credits:  DasMoony
#   â— LastEdit: January 16th, 2012
#
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# â–  Features (or 6 reasons why to use this one):
#   â— Creates Random Weapons or Armors based upon a template
#   â— Supports Pre- and Suffixes
#   â— Bind fix values to pre- and suffixes OR make them random
#   â— Also supports traits but they can't determined by random
#   â— Supports Notetags, so most scripts based upon them should be compatible
#   â— Random properties are bound to armor or weapon only
#
#==============================================================================
# â–  Description
#   A Script that adds a new EquipItem to the Inventory of the player and return
#   the ID of the Item.
#
#==============================================================================
# â–  Credits and Terms of use
#   â— Credits:
#	 DasMoony
#   â— This script is made for free use in commercial and non-commercial
#	 projects but credits are required
#   â— Do not post direct links to the download file, instead link the page that
#	 contains it
#   â— You're not allowed without the authors permission to distribute this
#	 script. Of course you're allowed to distribute the script within your
#	 project.
#   â— If you're allowed to distribute the script you can't require any rights
#	 about the script
#   â— If this script is used in commercial projects, I demand a free copy of
#	 it. Contact me for the details.
#
#==============================================================================
# â–  Instructions
#   â— Plug the script in
#	 Put this script to the Materials-Section.
#   â— Configurations
#	 You can configure some stuff if you scroll down to the Options (Or search
#	 for OPTIONS)
#	 â— MAX_SPECIAL_VALUE
#	   Max default quality of item
#	 â— PRICING_SPECIAL_MOD
#	   Influences the price by quality and this modifier
#	   Note: Somehow I feel like it doesn't work like I wanted...
#	 â— PRICING_VARIATION
#	   +/- this vlaue to end price
#	 â— WEAPON_FEAT_INFO/ARMOR_FEAT_INFO
#	   This is the part you want to edit. I tried to make a step-by-step
#	   instruction there. If you got any questions, please ask so I may
#	   explain it a better way.
#	 â— DON'T TOUCH-Section
#	   There's a part in the options you should not touch or you'll mess up
#	   the script. The values of the entries should count from 0 to 7 in case
#	   you did touch this part...
#   â— Call Generation
#	 Use dmo_gen_weapon or dmo_gen_armor in any script or script call. It will
#	 add the item and return his ID.
#	 There are some parameters you could call with
#	 â— template
#	   ID of the template item
#	 â— special_value
#	   A number to determine the quality. If set to 0 it will be random
#	 â— random_value
#	   If set true the item will be random quality regardless of special_value.
#	   Instead special_value will serve as min quality
#	 â— max_special_value
#	   Set the max quality of item if quality is random
#
#==============================================================================
# â–  IMPORTANT
#   The random property picker is not polished yet and so I recommend to follow
#   these guidelines about the properties.
#   â— NEVER try to generate an item with a quality over the total quality sum
#	 of possible properties. The Script will hang up.
#   â— Make sure to have several properties with a quality of 1. They can always
#	 be added to the item unless they already are.
#   â— Also for better performance I recommend to keep the property qualities
#	 in relation. The script will have a pretty hard time if you only had one
#	 quality 1 property but a dozen of quality 4 properties...it even may won't
#	 run and hang up.
#     
#==============================================================================
# â–  FAQ
#   â— The game hangs up or has a immense lag upon generation of an item
#	 Please read the instructions careful. Especially the part called
#	 IMPORTANT
#   â— After loading my save I lost my items, they lost their attributes, the
#	 amount of them is out of control,they changed, etc...
#	 If you save your project you'll overwrite the data storing your random
#	 equip. I'm already thinking about a solution to this, but maybe it'll
#	 help you to know it's a 'bug' which only occurs during development.
#
#==============================================================================
# â–  Support
#   â— Currently this script is supported on rpgmakervxace.net
#
#==============================================================================
# â–  Technical Aspects (this section is thought for other scripters)
#   â— Complete own module (DMO)
#   â— New methods
#	 â— Game_Interpreter:
#	   â— dmo_create_weapon
#	   â— dmo_create_armor
#
#==============================================================================
# â–  Contact Information
#   â— Email:
#	 sid.dasmoony@gmail.com
#
#==============================================================================
#==============================================================================

module DMO
 module OPTIONS
   module RAND_EQUIP
  # MAX_SPECIAL_VALUE
  # The max default quality
  MAX_SPECIAL_VALUE = 10

  # PRICING_SPECIAL_MOD
  # Influences the price by quality and this modifier
  PRICING_SPECIAL_MOD = 100

  # PRICING_VARIATION
  # Price of Item can variate +/- this value
  PRICING_VARIATION = 25

  ###################################
  ##You should NOT touch this part!##
  ###################################
  MAX_HP  = 0					 ###
  MAX_MP  = 1					 ###
  ATTACK  = 2					 ###
  DEFENSE = 3					 ###
  MAGIC   = 4					 ###
  MAGIC_DEFENSE = 5			   ###
  AGILITY = 6					 ###
  LUCK    = 7					 ###
								  ###
  PREFIX  = -1				    ###
  SUFFIX  = 1					 ###
  ###################################

  # The Pre/Suffix for weapons and armors and their properties
  #
  # This looks pretty complicated, so step-by-step:
  # â— COST
  #   Insert here the quality cost of the property
  # â— [[PARAM,[VALUE]],..]
  #   Here you can insert the parameters to manipulate
  #   by the pattern [PARAM,VALUE]. If you want to determine a random value
  #   insert instead of a fix number [min,max] for VALUE.
  # â— PRE/SUF
  #   Insert PREFIX or SUFFIX. Adds the following STRING in front or at end
  #   of the Item name. Note that there's no length cap.
  # â— STRING
  #   The name addition to the item
  # â— PRICING
  #   Change the Item base price by this value
  # â— [[FEAT_CODE,FEAT_DATA,FEAT_VALUE]]
  #   Here you can make a list of traits. Use a feat-reference for this.
  #   Note:I haven't made a reference for this nor can I recommend any. I may
  #   do one in the near future but I can't promise.
  # â— [NOTES,...]
  #   A Collection of your notetags. Use a string for each line.
  #
  # [COST, [[PARAM,[VALUE]],..], PRE/SUF?,STRING,PRICING,[[FEAT_CODE,FEAT_DATA,FEAT_VALUE]],[NOTES,..]]
  WEAPON_FEAT_INFO	  = [
			  [2,[[ATTACK,[5,10]]],PREFIX,"Sharpened",15,[],[]], #random attack(0-10)
			  [1,[[ATTACK,[0,5]]],PREFIX,"",15,[],[]], #random attack(0-5)
			  [1,[[ATTACK,[0,5]]],PREFIX,"",15,[],[]], #random attack(0-5)

			  [2,[[ATTACK,[25]]],PREFIX,"Very Sharp",30,[],[]],  #attack +15
			  [1,[[LUCK,[5]]], SUFFIX,"of Luck",10,[],[]],  #Luck +5
			  [3,[[AGILITY,[5]],[ATTACK,[10]]], SUFFIX,"of a thief",10,[],["<NOTETAG>","<NOTETAG>"]]
					  ]
  ARMOR_FEAT_INFO	  = [
			  [1,[[LUCK,[10]]],PREFIX,"Lucky",15,[],[]],
			  [2,[[LUCK,[25]]],SUFFIX,"of Luck",30,[],[]],
			  [1,[[LUCK,[5]]], PREFIX,"Charmful",10,[],[]]
					  ]
   end
 end
#==============================================================================
# â–  End of OPTIONS.
#   It's recommended not to change anything behind this point. If you're still
#   do, it's your pretty own risk.
#==============================================================================
 module STAT #static module
   module RAND_EQUIP
  #Interface
  def self.generate_weapon(template = 0, special_value = 1, rand_value = false,
    max_special_value = OPTIONS::RAND_EQUIP::MAX_SPECIAL_VALUE)
    return generate_equip(true,template,special_value,rand_value,max_special_value)
  end
  def self.generate_armor(template = 0, special_value = 1, rand_value = false,
    max_special_value = OPTIONS::RAND_EQUIP::MAX_SPECIAL_VALUE)
    return generate_equip(false,template,special_value,rand_value,max_special_value)
  end
  #Generator
  def self.generate_equip(weapon=true,template = 0, special_value = 1,
    rand_value = false,max_special_value = OPTIONS::RAND_EQUIP::MAX_SPECIAL_VALUE)
    if special_value == 0 || rand_value
	  special_value += Random.rand(max_special_value)
    end
    feats = []
    picked_feats = []
    feat = nil
    cost = 0
    for i in 1..special_value
	  feat = nil
	  if weapon
	    size = OPTIONS::RAND_EQUIP::WEAPON_FEAT_INFO.size
	  else
	    size = OPTIONS::RAND_EQUIP::ARMOR_FEAT_INFO.size
	  end
	  while(feat == nil || picked_feats.include?(feat) || (cost + feat[0]) > special_value)
	    if weapon
		  feat = OPTIONS::RAND_EQUIP::WEAPON_FEAT_INFO[Random.rand(size)]
	    else
		  feat = OPTIONS::RAND_EQUIP::ARMOR_FEAT_INFO[Random.rand(size)]
	    end
	  end
	  picked_feats.push(feat)
	  cost += feat[0]
	  break if cost == special_value
    end
    if weapon
	  t_equip = get_weapon(template)
    else
	  t_equip = get_armor(template)
    end
    name = t_equip.name
    picked_feats.each{|feat|
	  feat[1].each{|param|
	    t_equip.params[param[0]] += param[1][0]
	    if param[1].size > 1
		  t_equip.params[param[0]] += Random.rand(param[1][1])
	    end
	  }
	  feat[5].each{|trait|
	    t_equip.features.push(RPG::BaseItem::Feature.new(trait[0],trait[1],trait[2]))
	  }
	  if feat[2] < 0
	    name = feat[3] + " " + name
	  else
	    name += " " + feat[3]
	  end
	  t_equip.price += feat[4]
	  feat[6].each{|note|
	    t_equip.note += note.to_s + '\n'
	  }
    }
    t_equip.name = name
    t_equip.price += OPTIONS::RAND_EQUIP::PRICING_SPECIAL_MOD*special_value
    t_equip.price += Random.rand(2*OPTIONS::RAND_EQUIP::PRICING_VARIATION)+ 1 - OPTIONS::RAND_EQUIP::PRICING_VARIATION

    if weapon
	  $data_weapons.push(t_equip)
	  File.open("Data/Weapons.rvdata2","wb") do |file|
	    Marshal.dump($data_weapons,file)
	  end
    else
	  $data_armors.push(t_equip)
	  File.open("Data/Armors.rvdata2","wb") do |file|
	    Marshal.dump($data_armors,file)
	  end
    end
    $game_party.gain_item(t_equip,1)
    return t_equip.id
  end
  def self.get_weapon(id)
    ret = RPG::Weapon.new
    ret.id = $data_weapons.size
    if id != 0
	  ret.name = $data_weapons[id].name
	  ret.icon_index = $data_weapons[id].icon_index
	  ret.description = $data_weapons[id].description
	  ret.features = $data_weapons[id].features.dup
	  ret.note = $data_weapons[id].note
	  ret.price = $data_weapons[id].price
	  ret.etype_id = $data_weapons[id].etype_id
	  ret.params = $data_weapons[id].params.dup
	  ret.wtype_id = $data_weapons[id].wtype_id
	  ret.animation_id = $data_weapons[id].animation_id
    end
    return ret
  end
  def self.get_armor(id)
    ret = RPG::Armor.new
    ret.id = $data_armors.size
    if id!= 0
	  ret.name = $data_armors[id].name
	  ret.icon_index = $data_armors[id].icon_index
	  ret.description = $data_armors[id].description
	  ret.features = $data_armors[id].features.dup
	  ret.note = $data_armors[id].note
	  ret.price = $data_armors[id].price
	  ret.etype_id = $data_armors[id].etype_id
	  ret.params = $data_armors[id].params.dup
	  ret.atype_id = $data_armors[id].atype_id
    end
    return ret
  end
   end
 end
end
#==============================================================================
# â–  Game_Interpreter
#==============================================================================
class Game_Interpreter
 #------------------------------------------------------------------------
 # â— dmo_create_weapon
 #	 gives your party a random weapon
 #	 (template		 : ID of template weapon)
 #	 (special_value    : 'special value' - if 0 it determine random quality)
 #	 (rand_value	   :  random quality?)
 #	 (max_special_value: max value of random quality
 #
 #	 returns :ID of new weapon
 #------------------------------------------------------------------------
 def dmo_gen_weapon(template=0,special_value=0,rand_value=false,max_special_value=nil)
   return DMO::STAT::RAND_EQUIP.generate_weapon(template,special_value,rand_value,max_special_value)
 end
 #------------------------------------------------------------------------
 # â— dmo_create_armor
 #	 gives your party a random armor
 #	 (template		 : ID of template armor)
 #	 (special_value    : 'special value' - if 0 it determine random quality)
 #	 (rand_value	   :  random quality?)
 #	 (max_special_value: max value of random quality
 #
 #	 returns :ID of new armor
 #------------------------------------------------------------------------
 def dmo_gen_armor(template=0,special_value=0,rand_value=false,max_special_value=nil)
   return DMO::STAT::RAND_EQUIP.generate_armor(template,special_value,rand_value,max_special_value)
 end
end

 

 

Credits & Terms of use

â— Credits: DasMoony

â— This script is made for free use in commercial and non-commercial projects but credits are required

â— Do not post direct links to the download file, instead link the page that contains it

â— You're not allowed without the authors permission to distribute this script. Of course you're allowed to distribute the script within your project.

â— If you're allowed to distribute the script you can't require any rights about the script

â— If this script is used in commercial projects, I demand a free copy of

it. Contact me for the details. For this, look at contact informations or send me a pm on the forum

 

About Support, Redistribution, etc.

This is what this thread is for :) At the moment this script is exclusive shared at rpgmakervxace.net and that's my full intention until I set up a script section on my own homepage. So, if you see it somewhereelse please inform me. Thanks in advance for this.

 

Future Intentions to this Script

The scripts runs fine at the time and I'm happy about that. If you find any bugs or encounter any problems, I'd be happy for your hint. Also I plan to implement a acceptable solution for the save problem of the database.

Edited by DasMoony

Share this post


Link to post
Share on other sites

@Jacob:

 

the properties also define the pre or suffix at this part (you can find it in OPTIONS)

WEAPON_FEAT_INFO	  = [
			  [2,[[ATTACK,[5,10]]],PREFIX,"Sharpened",15,[],[]], #random attack(0-10)
			  [1,[[ATTACK,[0,5]]],PREFIX,"",15,[],[]], #random attack(0-5)
			  [1,[[ATTACK,[0,5]]],PREFIX,"",15,[],[]], #random attack(0-5)

			  [2,[[ATTACK,[25]]],PREFIX,"Very Sharp",30,[],[]],  #attack +15
			  [1,[[LUCK,[5]]], SUFFIX,"of Luck",10,[],[]],  #Luck +5
			  [3,[[AGILITY,[5]],[ATTACK,[10]]], SUFFIX,"of a thief",10,[],["<NOTETAG>","<NOTETAG>"]]
					  ]

With this part are the prefixes 'Sharpened' and 'Very Sharp' possible, as the suffixes 'Luck' and 'of a thief'. Most confusing part is about the tons of '[' and ']', I guess. Generation of a weapon itself can be done via dmo_gen_weapon(template_id,quality) in any script or script call. Just make sure not to make a quality higher then 6 at weapons or 4 at armors if you haven't expanded the propertiy list yet.

 

But let's add another possible prefix for example:I want be able to create a 'Defenders Sword' based on the template of a sword(weapon id 1). Let's say the defenders-prefix should give +10 defense, have a quality weight of 2 and increases the base price about 20gold then you have to add this:

[2,[[DEFENSE,[10]]],PREFIX,"Defenders",20,[],[]]

The entries are seperated by a ',' so add a ',' at the end of the last entry:

[3,[[AGILITY,[5]],[ATTACK,[10]]], SUFFIX,"of a thief",10,[],["<NOTETAG>","<NOTETAG>"]],

Now in the Event where you want to add the item make a script call dmo_gen_weapon(1,quality) where quality should be at least 2 to have a chance for the defender's sword.

 

Hope this could help :)

Share this post


Link to post
Share on other sites

Well it's confusing the hell out of me, but (it seems) this is what I was after! :D If I keep getting my problems solved, my game will never get done.

Share this post


Link to post
Share on other sites

It starts to get confusing as soon as you mess with traits...still have to do the reference for this. I guess I start tomorrow with it. Also I start then a better and much more readable manual for this script, so stay tuned ;)

Share this post


Link to post
Share on other sites

So, I made a manual for this script with the reference for the trait-objects.

You can find the link in the first post ;) I hope it will let you understand the script a bit better, so you can do much better random weapons then you may think.

 

@Sapharan:

I thought it would make some people happy :)

Share this post


Link to post
Share on other sites

I am having problems, the Game_Interpreter is giving me an error. Could someone post (or send) me a demo, so that I can see it in use, pretty please?

Share this post


Link to post
Share on other sites

Nevermind, see what I ended up doing was pull my head out my butt, read FULLY everything that you wrote and then proceeded to do it as INSTRUCTED. Works, got it and I love you all the more for making this.

Share this post


Link to post
Share on other sites

My implementation of this idea uses the FP Inventory system which automatically provides individual equips that can generate stats, quality, prefixes and suffixes.

 

That way, I don't need to add stuff to the database.

Edited by Tsukihime

Share this post


Link to post
Share on other sites

Hey, anything that can help make the game more interesting. Playing the game for hours then finding something new makes you wonder, what else is there that I have missed? A little overlap is ok, I would think, just not straight biting someone elses work, which I do not think you would do.

Share this post


Link to post
Share on other sites

Whoa, basically the loot system of Diablo/Torchlight? Awesome! Would it be possible to add a "description" of sort to traits (just a string with a parameter in the trait configurations), that displays when viewing the equipment in the equip menu (such as "+X to Maximum MP")? Also, is limiting the number of name extensions possible? (To avoid "Sharp Spiky Heavy Fiery Sparkling Golden Broadsword of the thief of the supreme sage")

Share this post


Link to post
Share on other sites

I have only been able to get a single Prefix and Single Suffix, so I think it is built in. I was curious on how to make it show information as well

Share this post


Link to post
Share on other sites

Love this script. Totally works, and I have managed to work in some new properties. I have not managed to get traits to function, however.

[1,[[ATTACK,[0,5]]],PREFIX,"Flaming",15,[41,51,0],[]],

doesnt give the skill, i also tried, 32,22,1 with no effect. am I missing something simple? Could someone post a functioning trait property?

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted