Multiple "Kill X amount of monsters" Quest Issue

Hello everyone,

This is my first post (I assume it will not be my last).  I have been able to find solutions to issues by searching the Forums before now. *By the way, this Community is spectacular with helping out with issues and helping others. 

Anyway. Here is my issue. I am thinking of Skyrim, and the Thieve's Guild where Vex and Delvin hand out a TON of different quests, each when completed you get paid and move on to another quest, but of the same genre and by the same NPCs.

I am trying to have Multiple "Kill X amount of Monsters" quests in the project I am working on. With the quests given by the same NPC. I am not having an issue with the first quest, "Kill 3 Jellyfish" come back to the NPC and she pays you. That works perfectly, using script and events, triggers and self-switches. The NPC recognizes I have killed 3 Jellyfish, pays me, then moves onto the next "Contract".

My issue has been with expanding the quest line. After the "Jellyfish Contract" has been completed, the second Contract is for a different monster entirely, I have evented, scripted, and triggered every thing that EXACT same way as the first Contract, but the NPC does not recognize that the correct number of monsters have been killed. I have tried using the same event as the first Contract, using self-switches and triggers and of course adding that specific monster's script, that did not work. I then created another event, with the same NPC handing out the second Contract. It works fine, but the NPC is not recognizing the "greater than or equal to" numbers. I am stumped and I am hoping to find a solution.

I am thinking I can only have one "Kill X amount of Monsters" script per game?

Any help would be greatly appreciated!

-Outrightsmile (Amy) 
Show us screenshots of your event.  If we can't see what you've done, we can't see where you went wrong.
The "Jellyfish Contract" Event Page 1

oWFs2Rn.png


"Jellyfish Contract" page 3 (Note:this certain Event DOES work perfectly, just setting the "mood")

gxJ1aGJ.png


The "Jellyfish Contract" Script (does work perfectly)

i2aFT19.png


Here is the "Contract" I am having issues with. It works perfectly, until the correct number of enemies have been killed, then the NPC does not recognize that the Player has killed enough of the "Skeletons". 

Page 1

hVKdW4k.png


Page 2 of the "Skeleton Contract"

nuxIUc2.png


Page 3 of the "Skeleton Contract"

8y2UcI5.png


The Script for the "Skeleton Contract" which does not produce any errors or anything like that.

Kf29Ctp.png


Apologies for not posting these sooner, I kept getting the "You may not post image links in this Community" error. Quick research determined to keep trying.
The problem is that the def die command is being overwritten each time you do that. You need to combine the two def die commands, or alias the first one, otherwise, only one of them will ever work in the game.

Edit: For more specifics. In Ruby, every time you add a function (with the def command), it overwrites the other one. You have the command def die 2x, so what the editor sees to do is to run only the newest version, which is the Jellyfish one. You will need to combine the two commands into one to do this, or add the following to your second one:

Try this code instead for your second contract, replacing what you have from Game_Enemy in your code with this (keep the module stuff above it though).

Game_Enemy < Game_Battler include Skeleton_Counter alias my_monster_counter_script_die die def die #The code for your counter $game_variables[Counter_Variable] += 1 if Skeleton.include? (enemy.id) #Call aliased function my_monster_counter_script_die endendNotice  you don't need the rest of the code, as the aliased function command will call your first contract, which takes care of the rest.

If you decide to make more contracts this way, you will need a new name for the aliased function every time. I'd recommend adding the name of the contract after it. Or, personally, I'd just combine all of these into one code as follows:

Spoiler
module Skeleton_Counter Skeleton_Counter_Variable = 15 Skeleton = [15]endmodule Jellyfish_Counter Jellyfish_Counter_Variable = 13 Jellyfish = [5]end#Add any future modules above this lineGame_Enemy < Game_Battler #Add all your includes here include Jellyfish_Counter include Skeleton_Counter #Create aliased function alias my_monster_counter_script_die die def die #Put all variable processing here $game_variables[Jellyfish_Counter_Variable] += 1 if Jellyfish.include (enemy_id) $game_variables[Skeleton_Counter_Variable] += 1 if Skeleton.include (enemy_id) #Call aliased function my_monster_counter_script_die endend
This way, you only have one script to edit. Just keep adding the modules as needed, and the game variables as needed.

Also notice I changed the variable name. That may or may not be a problem, not sure, but it is a bad idea to ever use two of the same name in a program, as it is hard to know what will happen then.
I will look into either Combining the two def die commands or alias the first one, thank you so much for the replies! I have been searching for a solution for this issue for a few days now, and I was unsure what really to search for..Event-wise or Script-wise.

I appreciate the help  🙂
I posted code as an edit for how to do both. You may need to read up on Ruby and how alias vs overwrite work later, but what I posted *should* work well enough for you to have both contracts working for now. Sure, it could be more elegant (I'm sure the advanced scripters will see this code and cringe), but it works.
This is amazing, I will try it and let you know the results!

Thank you so much, bgillisp, I greatly appreciate it!
Let me know how it works. I'm down with a cold so typos might have slipped in, but if it gives errors I'm sure one of us can fix it up.
Plugged it all in, but got a few errors. The first, easy fix (Too many "end" at the end). The next is this, and I have been trying to find a solution, but I'm unsure how to fix this.

TEyYRnx.png
That's because I forgot the word class in front of the Game_Enemy, without it, it thought it had too many ends. Once you deleted the ends, it couldn't find the die command.

Try this code, this one is tested and works in my project:

Code:
module Skeleton_Counter     Skeleton_Counter_Variable = 15     Skeleton = [15]endmodule Jellyfish_Counter         Jellyfish_Counter_Variable = 13    Jellyfish = [13]end#Add any future modules above this lineclass Game_Enemy < Game_Battler    #Add all your includes here    include Jellyfish_Counter    include Skeleton_Counter    #Create aliased function    alias my_monster_counter_script_die die    def die                #Put all variable processing here        $game_variables[Jellyfish_Counter_Variable] += 1 if Jellyfish.include? (enemy_id)        $game_variables[Skeleton_Counter_Variable] += 1 if Skeleton.include? (enemy_id)        #Call aliased function        my_monster_counter_script_die     endend
Just tested the new Code, and it works like a dream! Wow, what a relief, this issue has been a thorn in my side for days. Thank you SO MUCH for taking time out of your day to help me out, it's greatly appreciated!

Have a fantastic day!   🙂
Moving to RGSSx Script Support forum

Original thread: https://forums.rpgmakerweb.com/threads/multiple-kill-x-amount-of-monsters-quest-issue.45066/