ITEM DROPED BASED ON ANOTHER ITEM HOW?
Posts
i want to know how to make an item drop only if you have another item
example, you kill a wolf -> if you have a "skinning knife" -> you receive a "wolf skin". preferably without script
edit: i always forget that, i am using rpg maker VX ace
example, you kill a wolf -> if you have a "skinning knife" -> you receive a "wolf skin". preferably without script
edit: i always forget that, i am using rpg maker VX ace
If you have random encounters the answer will be more annoying. If you have on-touch encounters you can easily make a conditional branch to check if you have said item.
You can also do this in the battle events - make one check to see if x enemy is dead/has 0%HP, then check if you have the item in question and if so, add the item you want. Don't forget to add a message telling you you got the item.
You can also do this in the battle events - make one check to see if x enemy is dead/has 0%HP, then check if you have the item in question and if so, add the item you want. Don't forget to add a message telling you you got the item.
well its a random battle.
i used battle events, but for some unknown reason it dose not work, it seems battle event don't run if you end a battle,
if there was a condition "upon victory" :)
i used battle events, but for some unknown reason it dose not work, it seems battle event don't run if you end a battle,
if there was a condition "upon victory" :)
You could add a property to Game_Enemy called @item_prerequisite or something that stores the ID of an item that you need to get the item the enemy drops in the database, then write an overload of the method that checks and awards items that checks whether the party has the prerequisite before running the rest of the code.
well i find a solution (with use of google and some testing)
i must create a "death resist * 100%" status, then add this stat to the troops at the beginning of battle, as soon as enemy hp is 0% add "wolf skin" and remove "death resist".
hmm i think this can be a lot easier with scrip. ok drop rate is always 100%
dose this work? 0001 is a switch
i must create a "death resist * 100%" status, then add this stat to the troops at the beginning of battle, as soon as enemy hp is 0% add "wolf skin" and remove "death resist".
hmm i think this can be a lot easier with scrip. ok drop rate is always 100%
def make_drop_items
enemy.drop_items.inject([]) do |r, di|
if di.kind > 0 && @game_switch_data[0001] == true
r.push(item_object(di.kind, di.data_id))
else
r
end
end
end
Tell me which maker you're using and I'll write you a more efficient script.
hmm well i probably should post in write me a script i am using rpg maker Vx ace (RGSS3?)
thanks again man, i really owe you a lot. i hope i can repay you someday
edit: well i am new to this whole rpg maker thing but i think i can do testing if you have a particular game in testing phase i would gladly test it for you.
thanks again man, i really owe you a lot. i hope i can repay you someday
edit: well i am new to this whole rpg maker thing but i think i can do testing if you have a particular game in testing phase i would gladly test it for you.
Here you go. Not the most elegant script ever but it works:
To use it, just put <item_req: [item id]> in the notes box for your enemy. So if you had item 31 Skinning Knife, and wanted to require it to get a Wolf Pelt from a Wolf enemy, put <item_req: 31> in the notes box for Wolf. Note that the script will still take into account the drop chance of the item. If you wanted I could actually add another parameter to the notetag that adds to the drop chance, so you could have better skinning knives that make it more likely you'll get the pelt, but that might be more than you wanted so I kept things simple.
module TRI
module REGEX
ITEM_REQ = /<item_req:[ ]*(.+?)>/i
end
end
module DataManager
class << self
alias_method(:tri_load_database, :load_database)
end
def self.load_database
tri_load_database
load_prereq_notetags
end
def self.load_prereq_notetags
for obj in $data_enemies
next if obj.nil?
obj.load_prereq_notetags
end
puts "Read: Item prerequisite notetags"
end
end
class Game_Enemy < Game_Battler
def get_prereq(index)
if enemy.item_req[index]
enemy.item_req[index]
else
0
end
end
#--------------------------------------------------------------------------
# * Create Array of Dropped Items
#--------------------------------------------------------------------------
def make_drop_items
index = 0
enemy.drop_items.inject([]) do |r, di|
if di.kind > 0 && rand * di.denominator < drop_item_rate && (get_prereq(index) == 0 || $game_party.has_item?($data_items[get_prereq(index)]))
index += 1
r.push(item_object(di.kind, di.data_id))
else
index += 1
r
end
end
end
end
class RPG::Enemy < RPG::BaseItem
attr_accessor :item_req
def load_prereq_notetags
@note.split(/[\r\n]+/).each do |line|
case line
when TRI::REGEX::ITEM_REQ
@item_req = []
@item_req |= $1.scan(/\d+/).collect { |id| id.to_i }
end
end
end
end
To use it, just put <item_req: [item id]> in the notes box for your enemy. So if you had item 31 Skinning Knife, and wanted to require it to get a Wolf Pelt from a Wolf enemy, put <item_req: 31> in the notes box for Wolf. Note that the script will still take into account the drop chance of the item. If you wanted I could actually add another parameter to the notetag that adds to the drop chance, so you could have better skinning knives that make it more likely you'll get the pelt, but that might be more than you wanted so I kept things simple.
thanks again
hmm i want 1 more thing :P
what happen if i want 3 items?
example:
skinning knife: wolf skin. (item slot 1)
bone saw: claw (item slot 2).
jawchisel: teeth (item slot 3).
how can i add this?
hmm i want 1 more thing :P
what happen if i want 3 items?
example:
skinning knife: wolf skin. (item slot 1)
bone saw: claw (item slot 2).
jawchisel: teeth (item slot 3).
how can i add this?
Edited the script above to include that. Now the tag is <item_req: item1, item2, item3> where each parameter is the item ID of the prerequisite for that slot.
hmm, it does not work is this line correct? item_req should be an array now.
i hope i didn't make a fool of myself.
edit:
its a "no method" nil:Nilclass in this line,
in "class Game_Enemy < Game_Battler"
edit 2: i should have mentionend that, i am using your other script in this thread
http://rpgmaker.net/forums/topics/13376/ also i don't find any logical conflict btw them.
attr_accessor :item_req
edit:
its a "no method" nil:Nilclass in this line,
if enemy.item_req[index]
edit 2: i should have mentionend that, i am using your other script in this thread
http://rpgmaker.net/forums/topics/13376/ also i don't find any logical conflict btw them.
They won't actually be usable together because I use the same alias for the database loading method, so it'll cause a stack level error at the very least. I didn't write them with compatibility in mind. ;)
That said, you shouldn't be getting a no method error there either unless there's something wrong with the setup. Let me take a look and get back to you.
Edit: Can you tell me how you have your notetags set?
That said, you shouldn't be getting a no method error there either unless there's something wrong with the setup. Let me take a look and get back to you.
Edit: Can you tell me how you have your notetags set?
its one of the example:
<level: 10>
<item_req: 19, 22, 23>
i used this script in a new project, and only add <item_req: 16, 15, 14>
the game completely ignored the script.
<level: 10>
<item_req: 19, 22, 23>
i used this script in a new project, and only add <item_req: 16, 15, 14>
the game completely ignored the script.
Are you using any other custom scripts?
not at all, i didn't change anything, dose it work for you?
this mean's start a new project, copy and past your script in material section, adding items and note tage
this mean's start a new project, copy and past your script in material section, adding items and note tage
Yeah, it works fine for me.
Can you zip up your project and send it to me?
Can you zip up your project and send it to me?
Ah, I see what's wrong now, thanks.
Don't split up my script into separate entries, just keep it all in one script as I wrote it. The problem in your project is because you had the Game_Enemy changes before RPG::Enemy, so it was looking for a property of the class that hadn't been created yet.
Don't split up my script into separate entries, just keep it all in one script as I wrote it. The problem in your project is because you had the Game_Enemy changes before RPG::Enemy, so it was looking for a property of the class that hadn't been created yet.
it was a mistake from my part, i didn't know battle test from troops page, give 99 of every item to player. i am sorry that i wasted your time :S.
but how can i split them, you know i don't like using script without even understanding it.
thanks again for your help.
but how can i split them, you know i don't like using script without even understanding it.
thanks again for your help.
All you have to do is literally copy my entire script, exactly as I wrote it, and paste it into a blank spot above Main. Name it whatever you like, but all the code can be in one place.
for example, in this case i want to mix exp gain and item drop, if i don't split them i can't do it right?















