Jump to content
  • 0
Sign in to follow this  
ShadowLight

Saving Mob ID for Daily/Weekly Quest

Question

Hi all,

 

I have an event where players have to hunt a range of different mobs. Players will be rewarded with zeny for killing the mob the first time. Nothing will happen the following time he/she kills the mob if he already killed it in the last 6 days. After 7 days, the player can claim the reward again by killing the same mob(s).

 

Instead of having a ton of variable storing for each mobs, is there a better way of storing and using this information?

 

Thanks,

ShadowLight 

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

@@ShadowLight

 

You could use setd and getd to atleast save yourself from using a extra var for the mob.

 

It might require you to iterate trough all your mobs to reset the mobs to kill for one player but performance wise to have to performe that once in a while is a lot better than having more player variables that have to be constantly saved by the map server as long as the player is online.

 

I imagine something like this could be what you are searching for:

Adding of a mob to kill to the player:setd( "mob2kill" + .@mobid ), 1;Check if mob got killed etc.OnNPCKillEvent:	// Get last time mob got killed.	.@mob2kill = getd( "mob2kill" + killedrid );	// If the mob2kill is set and the last time the mob got killed was 7 days ago...	if( .@mob2kill && ( .@mob2kill < gettimetick( 2 ) ) ) {		// Hand out reward or whatever.				// Save the cool down time till the mob can be killed again.		setd( "mob2kill" + killedrid, gettimetick( 2 ) + 604800 );	}	Removing a mob from the player:setd( "mob2kill" + .@mobid ), 0;
Edited by Winterfox

Share this post


Link to post
Share on other sites
  • 0

for monster hunting quest, I do suggest you use the Quest System. Basically it fix all your issue and help to solve everything, all you need is just assign the quest and check for which quest is available for that particular weeks.

 

@@Winterfox

your method does save a from using extra variable to store the kill count, but your attempt end up wasting resources.

Imagine the server have 100 monsters only, if that characters everything hunt all the 100 monsters, basically that characters generated 100 variables.

1 account consist 9 characters or more, end up become >=  900 variables per accounts.

imagine the resources that need to spent to store all these data...

 

A checking on mob id is a must.

Share this post


Link to post
Share on other sites
  • 0

for monster hunting quest, I do suggest you use the Quest System. Basically it fix all your issue and help to solve everything, all you need is just assign the quest and check for which quest is available for that particular weeks.

 

@@Winterfox

your method does save a from using extra variable to store the kill count, but your attempt end up wasting resources.

Imagine the server have 100 monsters only, if that characters everything hunt all the 100 monsters, basically that characters generated 100 variables.

1 account consist 9 characters or more, end up become >=  900 variables per accounts.

imagine the resources that need to spent to store all these data...

 

A checking on mob id is a must.

Your example is pretty unrealistic.

 

I highly doubt, that for the event mentioned above you will have more than 10 mobs per character. That still makes 90 per account if someone really goes up to 9 characters.

 

But you have to consider that you can only be online with 1 character per account and only the online characters variables get saved on the update cycle.

Also the quest hunting system can only cover kill x of y.

 

The problem with that approach is, it has the opposit problem my approach has. You have to create a quest for every single mob to set it on cd if you wan't to reward for every single mob every week while in mine it would be hard to make it synchronized to get one single reward for all killed mobs.

 

At the end it depends on what you wan't to achieve and how many trade offs you want to make performance wise for it.

Share this post


Link to post
Share on other sites
  • 0

Honestly, both options are completely fine. As far as resources go, Hercules can handle well over a measly 90-900 variables, it could easily handle a whopping 90,000 variables in all honesty. The important thing is which type of variable is being used. If it is a permanent variable (those that dont get reset upon logout or done talking to an NPC / server restart) then it'll be a little resource heavy, but for this script I'd recommend using player variables (as Winterfox suggested in her example).

 

The only thing I would do different from Winterfox's example though, would be to store the information in a custom sql_table. You'd only update the sql-db upon the player logging out or completing the quest, and resetting the quest.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.