BEST WAY TO HANDLE RANDOM LOOT IN CHESTS

Posts

Pages: first 12 next last
So I am making a dungeon crawler and as such random loot will play a big part. I was trying to set up a test but I can;t quiet think of how I will go about this.

My initial thought is to set up a common event with a list of items (probably have a few of these common events with different lists to better optimize what loot would be found at that particular part of the dungeon) but then I realize I would have to create an item for every possible enchantment or bonus I will be using.

Here is an example of the set up I am using
Enchantments
Elemental damage
Stat boost
HP regen
Bonus damage
ect

Curses
Life drain
Stat drain
Monster Bait
ect

Weapons (with Iron, Mythil, Adamantite, Dragon forged versions)
short sword
Long sword
Axe
Bow
Spear
Staff
Mace

Just from my example enchantments and curses there are a fair ammount of items I would have to create and there is still my armour and accessory list.
I'm not sure what system you are using for the enchantments, but I believe you can create a certain enchantment on an item using just the code?

If so...

Try the following: Everytime you open a chest, it generates a base item. Every base item has it's own number, the higher the number, the better the item is(which will require you to rearrange your itemlist in the database). Let's call this VarItem. Now, let's say that the range between item number 1 and item number 15 should be about the same in power, while 16 - 30 the "second" tier kinda item is. So we need another Variable to check what item Tier the item is.
Let's call this VarTier.

To see how good a random item is, just pick a random number between the first item and the last item using VarItem, and then let it check how powerful your item is using VarTier.
So..

Variable: "VarItem = 1 - maxItems"
Branch: "VarItem = same/below 15"
- Variable: "VarTier = 0"
Else:
- Branch: "VarItem = same/below 30"
- - Variable: "VarTier = 10"
- Else:
- - Branch: "VarItem = same/below 40"
- - - Variable: "VarTier = 20"

etc etc

As you can see, I'm using multiples of 10. That's because we also need to add enchantments to our gear.

I'm not sure what system you added, but I'm positive you can add enchantments by code, So, make another random Generator(varGen)generating a number between 1 and the max amount of enchantments you have. Next, we need another branch like above. Here, we state for every enchantment how powerful it is(varEnchant).
Ofcourse, You can have multiple enchantments, so let's just add that to this system while we are at it. We need twp vars for that one(varMultEnchant/varTreasureMultEnchant). varTreasureMultEnchant Is send by the chest to the common event, so you can easily monitor every's chest input.

So...

LOOP{
Variable: "varGen = 1 - maxEnchantments"
Branch: "varGen = same 1"
- Variable: "VarEnchant + 1"
Branch: "varGen = same 2"
- Variable: "VarEnchant + 1"
Branch: "varGen = same 3"
- Variable: "VarEnchant + 2"
Branch: "varGen = same 4"
- Variable: "VarEnchant + 1"

Variable: "varMultEnchant + 1"
Branch: "varMultEnchant = same varTreasureMultEnchant"
- BREAK LOOP}



Now the only thing we need is to see if the treasurechest actually can contain such an item. I mean, it would be weird if we got a godtier item in the level one dungeon. So.. we need a cap. And that is where the points get in handy. Simply add the points, and see if we can use this item with another variable(varCap/varChestcap).

Variable: "VarCap + VarTier"
Variable: "VarCap + VarEnchant"
Branch: "varCap = same or below varChestcap"
- Create item with those values.
Else: Repeat the event


So whenever you open a treasure chest, just make the chest send two nuumbers to the computer: varChestcap, containing how strong the item can be, and varTreasureMultEnchant, where you state how many enchants there can be, max on one item.

I hope this will help you, good luck!
I haven't got any kind of system or script. My system was just me using notepad to write a checklist of items with the enchantments and curses I would have to make

Iron sword
Iron sword of flame
Iron sword of might
Cursed Iron sword of leech
Cursed Iron sword of Monster bait
ect

I am not a scripter and I have not been able to find any kind of Item generation scripts.

Ideally I would use a Diablo/Borderlands set up

Weapon Type (chooses from a list of available weapon types
Material (Chooses from the mentioned materials, affects appearance)
Quality (Chooses from list of qualities which affect the base damage)
Magical effect (Chooses from a list of enchantments and curses, basically how suffix and prefix names work in diablo)

Open a chest, it uses that formula and bam you get
A cursed rusted Iron sword of bleeding.
Atk 5 (Normal Iron sword atk is 7)
Bleeding causes you to take damage when you attack

As an extra affect, The actual properties of the loot is not revealed until you either equip it or take it to an NPC to identify it, cursed items cannot be unequiped without visiting a special NPC or using a spell

So that Rusted iron sword of bleeding would probably just be recognized as
A rusted iron sword Until it is equipped or Identified.
Hmm, perhaps you should dig into this system: http://grimoirecastle.wordpress.com/2011/12/08/alchemic-synthesis-go-go-totori/

You'll need to download a few scripts for it, but it's all listed on the site: even without any knowledge of scripting, you should be able to install that.

It's a shop, but it does feature item traits, on top of normal items. I guess that comes the closest to what you want, as far as I've seen.

Good luck anyways!
author=noicreC
Hmm, perhaps you should dig into this system: http://grimoirecastle.wordpress.com/2011/12/08/alchemic-synthesis-go-go-totori/

You'll need to download a few scripts for it, but it's all listed on the site: even without any knowledge of scripting, you should be able to install that.

It's a shop, but it does feature item traits, on top of normal items. I guess that comes the closest to what you want, as far as I've seen.

Good luck anyways!


Bugger, That looks like it's for Ace. I use XP
Hi Argol,

What you desire doesn't sound as if it's necessary to use scripts. You can do the procedures listed above using simple events or common events. Simply make a variable that will search through your large database of items.

This may take some planning and organizing of your item database. For example, grouping all of your +1 enchantments and +2 enchantments together, but it is possible.

This could be the easiest way to do it in the end.
So I suppose that means there is no way of getting around having to manually enter every item into the database.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
If the items are not already in your database, then using a non-scripted system would require adding them all.

If you can find or make an RMXP script that lets you add random effects to pieces of equipment, your life will be a lot easier.

Making this yourself actually isn't too hard. The way I'd do it is to put the base items in your inventory with large gaps in between. If you have thirty possible enchantments, you'll need a gap of thirty empty spaces between each piece of equipment. (But you'll probably want to make the gap much bigger than the minimum you think you need, so you can add more enchantments as you keep making the game.) So let's say every hundredth item is a piece of boring, unenchanted equipment, and all the other slots in the database are empty.

Then find your Scene_Title script. Find the spot in it where it says:
$data_weapons       = load_data("Data/Weapons.rxdata")


And put a bunch of stuff after that line, to build the weapons data you want. Like so:
$data_weapons       = load_data("Data/Weapons.rxdata")
for weapon in $data_weapons
  $data_weapons[weapon.id] = $data_weapons[weapon.id - (weapon.id%100)]
  if weapon.id%100 == 1
    $data_weapons[weapon.id].str_plus = 10  # +10 strength
    $data_weapons[weapon.id].name += " of power"
  end
  if weapon.id%100 == 2
    $data_weapons[weapon.id].agi_plus = 10  # +10 agility
    $data_weapons[weapon.id].name += " of swiftness"
  end
  if weapon.id%100 == 3
    $data_weapons[weapon.id].dex_plus = 10  # +10 dexterity
    $data_weapons[weapon.id].name += " of nimbleness"
  end
  if weapon.id%100 == 4
    $data_weapons[weapon.id].int_plus = 10  # +10 intellect
    $data_weapons[weapon.id].name += " of magic"
  end
  if weapon.id%100 == 5
    $data_weapons[weapon.id].element_set = [1]  # Elemental attack is the 1st element in your game
    $data_weapons[weapon.id].name = "Blazing " + $data_weapons[weapon.id].name
  end
  if weapon.id%100 == 6
    $data_weapons[weapon.id].element_set = [2]  # Elemental attack is the 2nd element in your game
    $data_weapons[weapon.id].name = "Freezing " + $data_weapons[weapon.id].name
  end
end


etc. and so forth. Then do the same thing for armors.
so to clarify, I would change the on the first line of the below excerpt to to tell the rest of the script that the base weapon is the first weapon in the database?

$data_weapons = $data_weapons
if weapon.id%100 == 1
$data_weapons.str_plus = 10 # +10 strength
$data_weapons.name += " of power"

I am a newb to scripting and only half understand it sometimes. I can generally pick up on patterns but I have no idea how I would go about setting up for a simple test using your posted example.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
No, when I wrote weapon.id I meant it. That script isn't complete (it's only six bonuses, and presumably you want more than that, and also it's only for weapons and not armor), but nothing that's in it is a "placeholder" that you need to replace, except for the amount of each stat you want the bonuses to grant. Right now they grant +10. You can change that to +2 or +100 or whatever.

In other words if you just copy and paste my script in, it should work. If your database has weapons 100, 200, 300, and 400 in it, then this script should make weapons 101-106, 201-206, 301-306 and 401-406 work correctly if they're added to the player's inventory.

Unless I made it wrong. Which is always a distinct possibility, especially when I just start typing ruby code directly into the forums without actually trying it out in RPG Maker. Haha. If it doesn't work let me know, I'll try to fix it.
Well I was only going to use what you posted to start just to test, I will no doubt add to it if it works.

Edit: Ok so I pasted the script in, changed my maximum weapons to 406, added test sword to 100. made a chest to give me weapon 101 and 102. went to test and activated the chest and checked inventory. nothing appears except 2 blank weapons.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
Question, where were you pasting it in? I pasted it into a test project and it actually errored and wouldn't let me start the game. Make sure you are actually pasting into your existing Scene_Title script, not into a new script. It should go where the
$data_weapons       = load_data("Data/Weapons.rxdata")

line is in the default Scene_Title script.

Aside from the placement, like I said, it actually errored. This is because there's no weapon #0, and so it breaks when it tries to build weapons 1 through 99. I solved this by making it ignore weapons 1 through 99. So now, if you want any weapons to work as unique weapons and not get random stats, you can put them in the first 99 slots in the database.

Use this version:
$data_weapons       = load_data("Data/Weapons.rxdata")
    for weapon in $data_weapons
      if weapon.id > 100
        $data_weapons[weapon.id] = $data_weapons[weapon.id - (weapon.id%100)].clone
      end
      if weapon.id%100 == 1
        $data_weapons[weapon.id].str_plus = 10  # +10 strength
        $data_weapons[weapon.id].name += " of power"
      end
      if weapon.id%100 == 2
        $data_weapons[weapon.id].agi_plus = 10  # +10 agility
        $data_weapons[weapon.id].name += " of swiftness"
      end
      if weapon.id%100 == 3
        $data_weapons[weapon.id].dex_plus = 10  # +10 dexterity
        $data_weapons[weapon.id].name += " of nimbleness"
      end
      if weapon.id%100 == 4
        $data_weapons[weapon.id].int_plus = 10  # +10 intellect
        $data_weapons[weapon.id].name += " of magic"
      end
      if weapon.id%100 == 5
        $data_weapons[weapon.id].element_set = [1]  # Elemental attack is the 1st element in your game
        $data_weapons[weapon.id].name = "Blazing " + $data_weapons[weapon.id].name
      end
      if weapon.id%100 == 6
        $data_weapons[weapon.id].element_set = [2]  # Elemental attack is the 2nd element in your game
        $data_weapons[weapon.id].name = "Freezing " + $data_weapons[weapon.id].name
      end
    end


I tested it this time and it works. If you have questions on how to get it to do what you want, or can't get it to work, please ask. If you're having problems making it work, copying and pasting your entire script page here would be the most helpful thing you could do. Also, I don't require credit, just make a good game and I'll be happy. :)
well again my problem is how do I test this. Using an event to change weapon or by setting the weapon number as the default for the PC, results in getting blank weapon data, I have been putting it in the right spot.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
If you are adding the script correctly, using an event to change weapon should work fine. Can you paste your entire Scene_Title script page here so I can see it?

Also make sure you don't have another custom script that's overwriting Scene_Title. You can search all your scripts to make sure by right-clicking on the list of scripts on the left-hand and choosing Find, and then searching for "class Scene_Title" If it finds anything, you might need to add my script to your new version of Scene_Title isntead of to the default one.
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================

class Scene_Title
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# If battle test
if $BTEST
battle_test
return
end
# Load database
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
for weapon in $data_weapons
if weapon.id > 100
$data_weapons = $data_weapons.clone
end
if weapon.id%100 == 1
$data_weapons.str_plus = 10 # +10 strength
$data_weapons.name += " of power"
end
if weapon.id%100 == 2
$data_weapons.agi_plus = 10 # +10 agility
$data_weapons.name += " of swiftness"
end
if weapon.id%100 == 3
$data_weapons.dex_plus = 10 # +10 dexterity
$data_weapons.name += " of nimbleness"
end
if weapon.id%100 == 4
$data_weapons.int_plus = 10 # +10 intellect
$data_weapons.name += " of magic"
end
if weapon.id%100 == 5
$data_weapons.element_set = # Elemental attack is the 1st element in your game
$data_weapons.name = "Blazing " + $data_weapons.name
end
if weapon.id%100 == 6
$data_weapons.element_set = # Elemental attack is the 2nd element in your game
$data_weapons.name = "Freezing " + $data_weapons.name
end
end
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
# Make system object
$game_system = Game_System.new
# Make title graphic
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
# Make command window
s1 = "New Game"
s2 = "Continue"
s3 = "Shutdown"
@command_window = Window_Command.new(192, )
@command_window.back_opacity = 160
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 288
# Continue enabled determinant
# Check if at least one save file exists
# If enabled, make @continue_enabled true; if disabled, make it false
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
# If continue is enabled, move cursor to "Continue"
# If disabled, display "Continue" text in gray
if @continue_enabled
@command_window.index = 1
else
@command_window.disable_item(1)
end
# Play title BGM
$game_system.bgm_play($data_system.title_bgm)
# Stop playing ME and BGS
Audio.me_stop
Audio.bgs_stop
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of command window
@command_window.dispose
# Dispose of title graphic
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
@command_window.update
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # New game
command_new_game
when 1 # Continue
command_continue
when 2 # Shutdown
command_shutdown
end
end
end
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Command: Continue
#--------------------------------------------------------------------------
def command_continue
# If continue is disabled
unless @continue_enabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to load screen
$scene = Scene_Load.new
end
#--------------------------------------------------------------------------
# * Command: Shutdown
#--------------------------------------------------------------------------
def command_shutdown
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Fade out BGM, BGS, and ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# Shutdown
$scene = nil
end
#--------------------------------------------------------------------------
# * Battle Test
#--------------------------------------------------------------------------
def battle_test
# Load database (for battle test)
$data_actors = load_data("Data/BT_Actors.rxdata")
$data_classes = load_data("Data/BT_Classes.rxdata")
$data_skills = load_data("Data/BT_Skills.rxdata")
$data_items = load_data("Data/BT_Items.rxdata")
$data_weapons = load_data("Data/BT_Weapons.rxdata")
$data_armors = load_data("Data/BT_Armors.rxdata")
$data_enemies = load_data("Data/BT_Enemies.rxdata")
$data_troops = load_data("Data/BT_Troops.rxdata")
$data_states = load_data("Data/BT_States.rxdata")
$data_animations = load_data("Data/BT_Animations.rxdata")
$data_tilesets = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system = load_data("Data/BT_System.rxdata")
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up party for battle test
$game_party.setup_battle_test_members
# Set troop ID, can escape flag, and battleback
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play($game_system.battle_bgm)
# Switch to battle screen
$scene = Scene_Battle.new
end
end
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
Yeah, that looks right. (Next time use the [code] tag so people don't have to quote your post to be able to read it.)

You must have another custom script that's overwriting this one. It happens. Now we just need to find it.

You can search all your scripts by right-clicking on the list of scripts on the left-hand and choosing Find, and then searching for "class Scene_Title". If it finds anything, you might need to add my script to your new version of Scene_Title instead of to the default one.

You may want to also search for "Data/Weapons.rxdata" to see if any other scripts besides the title screen are resetting the weapons data. Let me know the results.
Ok found it and pasted the script in. it works, sort of.

If I start with the PC equiped with one of the enchented swors, they work. Once unequiped though it reverts to the base sword. if I add them via chest They can't be equiped and show no stat change via the stat display on the equip screen where as removing an enchanted sword does show the appropriate stat changes.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
The issue of not being able to equip them from the menu is probably just a matter of checking all the boxes in the Classes tab to let your characters equip all these items. Similarly, it won't show the stat changes because they're not equippable. That should fix both those problems.

The fact that it reverts to the base sword when you unequip it is bizarre! That sounds impossible to me, I guess another script is doing that? At this point, I'm interested enough in the problem that if you send me your game, I'll try to figure out how your other scripts are interacting with mine and fix it for you. Sorry this is ending up with so many problems.

Actually, I don't even need the whole game, just the Scripts.rxdata file, which is in the Data folder in your game. Send me a message or post it here. It should be small enough to put in your rpgmaker.net file locker.
yes I did make sure to have the actor/class able to equip it. I had to so I was able to set it as default equipment. Ok it is in my locker
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
OK, got it.

(80% sure this time.)

Use this version now:

$data_weapons       = load_data("Data/Weapons.rxdata")
    for weapon in $data_weapons
      if weapon.id > 100
        $data_weapons[weapon.id] = $data_weapons[weapon.id - (weapon.id%100)].clone
        $data_weapons[weapon.id].id = weapon.id
      end
      if weapon.id%100 == 1
        $data_weapons[weapon.id].str_plus = 10  # +10 strength
        $data_weapons[weapon.id].name += " of power"
      end
      if weapon.id%100 == 2
        $data_weapons[weapon.id].agi_plus = 10  # +10 agility
        $data_weapons[weapon.id].name += " of swiftness"
      end
      if weapon.id%100 == 3
        $data_weapons[weapon.id].dex_plus = 10  # +10 dexterity
        $data_weapons[weapon.id].name += " of nimbleness"
      end
      if weapon.id%100 == 4
        $data_weapons[weapon.id].int_plus = 10  # +10 intellect
        $data_weapons[weapon.id].name += " of magic"
      end
      if weapon.id%100 == 5
        $data_weapons[weapon.id].element_set = [1]  # Elemental attack is the 1st element in your game
        $data_weapons[weapon.id].name = "Blazing " + $data_weapons[weapon.id].name
      end
      if weapon.id%100 == 6
        $data_weapons[weapon.id].element_set = [2]  # Elemental attack is the 2nd element in your game
        $data_weapons[weapon.id].name = "Freezing " + $data_weapons[weapon.id].name
      end
    end
Pages: first 12 next last