Charas-Project

  • Home
  • Help
  • Search
  • Calendar
  • Login
  • Register
*
Please login or register.

Login with username, password and session length
 

News:

Click here to join us on IRC (#charas on irc.freenode.net)!



  • Charas-Project »
  • Game Creation »
  • Requests »
  • Tutorials »
  • Increase/Decrease chances of getting an item
« previous next »
  • Print
Pages: [1]

Author Topic: Increase/Decrease chances of getting an item  (Read 3007 times)

Offline AsakuraHao2004


  • RAM-TORTOISE!!
  • Exemplar
  • *
  • Posts: 1,623
  • AIM: dakutenshisdemon YIM: desimodontidae
Increase/Decrease chances of getting an item
« on: June 01, 2005, 11:07:25 PM »
This idea just occured to me, so I thought I'd share it. First off, all you need is a pretty basic understanding of variables.

Lets say you have a CBS, and theres a monster that drops an item, however, the chances of getting this item is very rare. So what we could do is

<> Set Variable "Rare Item Drop" to a random number between 1-5
<> Branch if variable "Drop Item" is 1
      <> Add item "Rare Item" +1
      <> wait 0.1 sec
      <> Set Variable "Rare Item Drop" to 0
<> Else Case>

<> End

(The wait and Set Variable to 0 will set it so that you can use the variable again)

Now, there's a 1-in-5 chance of dropping that item will occur. For even higher rarity, you can set the random number range to even higher levels. I don't reccomend going over 20. Also, instead of making an else case, you could do this:

<> Set Variable "Item Drop" to a random number between 1-10
<> Branch if variable "Drop Item" is 1
      <> Add item "Rare Item" +1
      <> wait 0.1 sec
      <> Set Variable "Rare Item Drop" to 0
<> End

<> Set Variable "Item Drop" to a random number between 1-10
<> Branch if variable "Drop Item" is 2
      <> Add item "NON-Rare Item" +1
      <> wait 0.1 sec
      <> Set Variable "Rare Item Drop" to 0
<> End

And so on. This will make it so that a monster usually drops a regular item, but might drop a rarer item occasionally. You can also put in different items several times over (to increase chances of getting it), or leave a few blank.

A good way to set up, would be to have about 10 numbers set. make 5-6 numbers blank (so the monster wont drop anything sometimes), have 3-4 of the numbers with a "normal" item (the same, or different ones), and only have the rare item assigned to 1 number. This is a good range that will probably provide fair item span.

Hope this helps  :)
Logged
AKA Desimodontidae. If you're seeing this profile, Im probably at school.

If i were a clown, would you hold me when I'm down?/I wish I had someone to make me drown/So many people don't know that it's so damn hard to be a clown/I am the clown with the giant frown/My heart is in a state of being upside down...

Offline WarxePB

  • Action Sue
  • Royal
  • *
  • Posts: 3,601
  • What killed the dinosaurs?
    • The Gigaverse
(No subject)
« Reply #1 on: June 02, 2005, 01:45:46 AM »
Hmm. Concievably, this could also be applied to the DBS using the same code; you'd just need to activate it by the monster having no HP. I think I'll play around with that.

Nice tutorial, well-written and understandable. The only thing is, if you had a CBS, you'd probably already know how to code an item drop system ;)
Logged
Blog: The Gigaverse
Twitter: Initial Chaos

Offline SaiKar

  • KOFFING!
  • Staff
  • Royal
  • *
  • Posts: 4,082
(No subject)
« Reply #2 on: June 02, 2005, 01:52:37 AM »
Your code is kinda screwy. You would not need to re-randomize the number when dealing with the non-rare stuff.

Here is another way to do it probably involves less code:

<> Variable Operation [001: Item Drop] Set, Rnd 1-10
<> Branch if Var [001: Item Drop] is 5 less
<>  Branch if Var [001: Item Drop] is 1
<> Change Items: Rare Item +1
<>
<> Else Handler
<> Change Items: Non-rare Item +1
<>
:  End
<>
:  End
<>

The "inside" branch has the else condition. After seeing if the items drop is less then 5 (1-5 means that something will drop) we see if it exactly 1. If it is, we give the rare item. If not, we give the non-rare item.

Avoids having to copy a bunch of code a lot of times.

Nice idea, though you would need a CMS for it. In the DBS after the last enemy dies the battle ends, so there is no time for custom code.
Logged

Offline AsakuraHao2004


  • RAM-TORTOISE!!
  • Exemplar
  • *
  • Posts: 1,623
  • AIM: dakutenshisdemon YIM: desimodontidae
(No subject)
« Reply #3 on: June 02, 2005, 02:11:51 AM »
Worked for me.

I'm kinda weary of using your method, because I used a smiliar one for something else, which caused massive problems. And that method would really limit custimization, although it is effective for decreasing/increasing chances.
Logged
AKA Desimodontidae. If you're seeing this profile, Im probably at school.

If i were a clown, would you hold me when I'm down?/I wish I had someone to make me drown/So many people don't know that it's so damn hard to be a clown/I am the clown with the giant frown/My heart is in a state of being upside down...

  • Print
Pages: [1]
« previous next »
  • Charas-Project »
  • Game Creation »
  • Requests »
  • Tutorials »
  • Increase/Decrease chances of getting an item
 

  • SMF 2.0.10 | SMF © 2015, Simple Machines
  • XHTML
  • 2O11
  • RSS
  • WAP2
  • Simple Machines Forum