Jump to content
Ozborn

Gift Box

Recommended Posts

Is there a script that could make an item generate a random  item. For example, an item dropped by a boss called "Hade's Gift Box" and when the party uses the box it generates a random item. so more or less its a surprize pack. oh how i loved surprize packages when i was a kid. 

Share this post


Link to post
Share on other sites

It depends upon the scale of randomisation you want - if it's like 1 out of 5 items you can common event this using the random variable.

 

There is also some random loot scripts - Galv made one ages for chests 

Share this post


Link to post
Share on other sites

Yes, there is such an item. The easiest approach here is to install this script:

module GiftBox
  # List of Item IDs for that would be contained by the gift box.
  Items_to_Give = [1, 2, 3, 4, 5]
  # Amount of Items to Give from the Gift Box
  Amount = 1
  # Tag Note of the Gift Box Items
  GiftRegEx = /<giftbox>/i
  # What should be the message if the item generates another item?
  Message = "You gained an item from the Gift Box!"
  #--------------------------------------------------------------------------
  # * Gain Item From Box
  #--------------------------------------------------------------------------  
  def self.gain_item_from_box
    puts $game_party.gain_item($data_items[GiftBox::Items_to_Give[rand(GiftBox::Items_to_Give.size)]], GiftBox::Amount, false)
    RPG::SE.new("Item1",100,100).play
    $game_message.add(GiftBox::Message)
  end

end

class Game_Battler < Game_BattlerBase
  alias :giftbox_item_apply                                       :item_apply
  #--------------------------------------------------------------------------
  # * Apply Effect of Skill/Item
  #--------------------------------------------------------------------------
  def item_apply(user, item)
    giftbox_item_apply(user, item)
    if $data_items[item.id].note =~ GiftBox::GiftRegEx
      GiftBox.gain_item_from_box
    end
  end
end

You have to use the note tag <giftbox> in your item for the script to consider your item as a gift box. Configuration of other things are inside the script. Tell me if this is the thing you want, as I did this in the simplest way, such as not bothering to add a GUI in it.

Share this post


Link to post
Share on other sites

A suggestion would be the message to say you got x item - x being the id of the item.

 

Would get more complex if wanted weapons / armours

Share this post


Link to post
Share on other sites

Easy. Make a counter that creates one for items, weapons, and armors. Get their name and display them as strings. Here is a full script for that:

module GiftBox
  # List of Item IDs for that would be contained by the gift box.
  Items_to_Give = [1, 2, 3, 4, 5]
  # List of Armor IDs for that would be contained by the gift box.
  Armors_to_Give = [1, 2, 3, 4, 5]
  # List of Weapon IDs for that would be contained by the gift box.
  Weapons_to_Give = [1, 2, 3, 4, 5]
  # Amount of Items to Give from the Gift Box
  Amount = 1
  # Tag Note of the Gift Box Items
  GiftRegEx = /<giftbox>/i
  # What should be the message if the item generates another item?
  #--------------------------------------------------------------------------
  # * Gain Item From Box
  #--------------------------------------------------------------------------  
end

class Game_Battler < Game_BattlerBase
  alias :giftbox_item_apply                                       :item_apply
  attr_accessor :given_item
  attr_accessor :give_item
  attr_accessor :give_weapon
  attr_accessor :give_armor
  #--------------------------------------------------------------------------
  # * Apply Effect of Skill/Item
  #--------------------------------------------------------------------------
  def item_apply(user, item)
    @given_item = $data_items[GiftBox::Items_to_Give[rand(GiftBox::Items_to_Give.size)]]
    @given_armor = $data_armors[GiftBox::Armors_to_Give[rand(GiftBox::Items_to_Give.size)]]
    @given_weapons = $data_weapons[GiftBox::Weapons_to_Give[rand(GiftBox::Items_to_Give.size)]]
    RPG::SE.new("Item1",100,100).play    
    giftbox_item_apply(user, item)
    SceneManager.goto(Scene_Map)
    counter = rand(3) + 1
    @give_item = true if counter == 1
    @give_weapon = true if counter == 2
    @give_armor = true if counter == 3
    if $data_items[item.id].note =~ GiftBox::GiftRegEx
      $game_party.gain_item(@given_item, GiftBox::Amount, false) if @give_item
      $game_party.gain_item(@given_armor, GiftBox::Amount, false) if @give_armor
      $game_party.gain_item(@given_weapons, GiftBox::Amount, false) if @give_weapon
      $game_message.add("You got " + $data_items[@given_item.id].name.to_s + " from the Gift Box!") if @give_item
      $game_message.add("You got " + $data_weapons[@given_weapons.id].name.to_s + " from the Gift Box!") if @give_weapon
      $game_message.add("You got " + $data_armors[@given_armor.id].name.to_s + " from the Gift Box!") if @give_armor
      @give_item = false
      @give_weapon = false
      @give_armor = false
    end
  end
end

You have to use the note tag <giftbox> in your item for the script to consider your item as a gift box. Configuration of other things are inside the script. Tell me if this is the thing you want, as I did this in the simplest way, such as not bothering to add a GUI in it.

Edited by SoulpourVII
  • Like 1

Share this post


Link to post
Share on other sites

Just by looking at this i think it will work as i need. but will there be an item in my invitory called Gift box ? cause what i would like is the enemy drops a gift box. so you hunt and save up 7 of them and open them all and get 7 random items, equipment, what ever.

Share this post


Link to post
Share on other sites

Yes. Any item tagged with the notetag <giftbox> is a giftbox.

  • Like 1

Share this post


Link to post
Share on other sites

Can I make a suggestion for this script?

 

How about making it so you can specify what items you can receive per gift box.

 

For example, I'd want a simple "level 1 " box to have 1 small healing item or a dagger.   Where a gift bag I won thru an event or difficult challenge being a "level 5" box might have 2 different high level swords or an elixir.

 

Also, is there a way to make a selection of gold be among the gifts?

 

So maybe making it so you can tag a giftbag:

 

<giftbox>

i1, i1, i3, w1, a3, g300

<\giftbox>

 

Something like that.

 

Thanks

Share this post


Link to post
Share on other sites

i cant seem to get this gift box to work. can you screen shot what i need to set the item called gift box up like? and i will check that other script out. right now i am using my ps vita to msg this

  • Like 1

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted