Author Topic: Forest search countdown  (Read 15315 times)

Alchemion

  • Guest
Forest search countdown
« on: August 11, 2008, 03:47:24 pm »
Thank you, Nightborn, for sharing your work and efforts here on nb-core.org ...

I just hope to be of any use to this community, as I for sure shall test and probably use your codes...

I have an issue for some time with the DP LOTGD sources: there is nowhere a setting in the core or a module that will disallow access to the forest search, based on a countdown timer... For my themed game, I need this kind of feature and as far as my efforts could manage, I have only succeeded a partial solution : I get prevention of access to forest search, but FOR ALL USERS... the same countdown is appliable to all users and I couldn't get it working for each player in particular...

Please help with this issue... I understand the notion of time... if the code will not be shared and made public, I am willing to deal for a reasonable coding time...

Thanks again for making this site available to public.

Iori

  • Guest
Re: Forest search countdown
« Reply #1 on: August 11, 2008, 04:26:10 pm »
Thank you, Nightborn, for sharing your work and efforts here on nb-core.org ...

I just hope to be of any use to this community, as I for sure shall test and probably use your codes...

I have an issue for some time with the DP LOTGD sources: there is nowhere a setting in the core or a module that will disallow access to the forest search, based on a countdown timer... For my themed game, I need this kind of feature and as far as my efforts could manage, I have only succeeded a partial solution : I get prevention of access to forest search, but FOR ALL USERS... the same countdown is appliable to all users and I couldn't get it working for each player in particular...

Please help with this issue... I understand the notion of time... if the code will not be shared and made public, I am willing to deal for a reasonable coding time...

Thanks again for making this site available to public.

Make a "lastgrant" module pref that stores the time that the player was last made ineligible for fighting, and evey time the player is on the forest page, check whether the amount of time has passed between the value stored in "lastgrant" and the current time is greater than the minimum "cooldown" time. If it is, allow access, else block access and show how much time is left before access is granted. The "lastgrant" pref can be updated at the completion of each forest fight (doing so will start the cooldown at the end of each battle).

Note: Please move this thread to a more appropriate board.
« Last Edit: August 11, 2008, 04:31:23 pm by Iori »

Alchemion

  • Guest
Re: Forest search countdown
« Reply #2 on: August 11, 2008, 05:43:43 pm »
Thank you, Iori, for your answer.

Where do I insert this "lastgrant" setting , in configuration.php ?... should this also be reffered in forest.php, user.php and lib/saveuser.php ?...

The changes I made to forest.php consisted from my part only in idea and method, the coding has been made strictly by a friend that does not fully understands the mechanics of DP/NB LOTGD sources... I have to admit that my friend and I don't have the stomach for this kind of immersion into full bit by bit mechanics of these sources.... 

I have also considered a similar to "laston" setting, as you suggested the "lastgrant" setting, but I couldn't manage to fit it in the core files, needless to say in a dedicated module...

I see, Iori, you have perceived the scope of the forest access countdown, please, please, please.... provide some quick working hints to fit some code directly in the core files needed to be updated, for quick intervention and testing, or maybe a special module that would do the trick ...

Looking forward to your help...

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: Forest search countdown
« Reply #3 on: August 11, 2008, 07:57:46 pm »
Alchemion, slow down.

Not all you wish is something that HAS to be a core hack or core feature.

I could replace ALL modules with settings, which would make the configuration file a mile long, and 1000 settings to load for each player is not fine, either.

What you can do is relatively simple, but I don't get *on what* the counter is based.

Make a module
>hook into village and newday
>in the do_hook check for village like
Code: [Select]
if (get_module_pref('playercounter')>=get_module_setting('maxcounter')) blocknav("forest.php");>in the newday
Code: [Select]
set_module_pref('playercounter',0);>and whereever you increase that counter, just use
Code: [Select]
increment_module_pref('playercounter',1);
    >you have to add the setting and the pref to your module _info section, of course. But I assume you know how to do modules, right.

    You need to do such easy things by module. I know that hooking to village is high load, but I know *no* other themed game that has some kind of counter for the forest, if it would need one, we can argue hours about WHAT to count.
It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Iori

  • Guest
Re: Forest search countdown
« Reply #4 on: August 11, 2008, 11:13:33 pm »
Thank you, Iori, for your answer.

Where do I insert this "lastgrant" setting , in configuration.php ?... should this also be reffered in forest.php, user.php and lib/saveuser.php ?...

The changes I made to forest.php consisted from my part only in idea and method, the coding has been made strictly by a friend that does not fully understands the mechanics of DP/NB LOTGD sources... I have to admit that my friend and I don't have the stomach for this kind of immersion into full bit by bit mechanics of these sources.... 

I have also considered a similar to "laston" setting, as you suggested the "lastgrant" setting, but I couldn't manage to fit it in the core files, needless to say in a dedicated module...

I see, Iori, you have perceived the scope of the forest access countdown, please, please, please.... provide some quick working hints to fit some code directly in the core files needed to be updated, for quick intervention and testing, or maybe a special module that would do the trick ...

Looking forward to your help...

I did say that lastgrant is a module pref - hence you will need to make a module to do that. I suggest you familiarise yourself with how modules work before you continue (Core hacks are NOT suitable most of the time). This whole thing does not require a single change in core code to achieve.

Personally, it is not something I would do to my game (make a minimum of x time pass after the previous battle before user can battle again), but the code to achieve that is simple enough. I'll reiterate what I said in my first post in a clearer manner.

Make a module with
- a cooldown setting (this could also be hardcoded if you like)
- a modulepref "lastgrant"

the module hooks onto forest
- checks if (lastgrant + cooldown) is less than current time
- if it is, allow players to search normally
- otherwise, block the search nav and inform the player the amount of time left before they can battle again

the module also hooks onto battle-victory
- if the battle type is "forest", set the "lastgrant" modulepref to the current time string

Alchemion

  • Guest
Re: Forest search countdown
« Reply #5 on: August 13, 2008, 12:18:19 pm »
Iori...

Please, please... take a couple of minutes of your valuable time, on a beer, a coffee or whatever you like serving when you concentrate on a job...

You are confident it's easy job, for me it's hell of a job...

Please add my YM ID ( spiritofword ) for further communication on this matter...

Nightborn, the countdown reffers to time out of the forest... based on similar process like the user expired time session.. only reffered to user expired forest search access...

For my game, this feature is very useful, as it encourages time out of the forest and time into different activities like other gaming areas, forum conversations, communication...

Please, any mastercoder, help ...

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: Forest search countdown
« Reply #6 on: August 13, 2008, 02:54:26 pm »
Wait - do you want assistance or somebody who modifies your game for you ;)

the latter is not found here, I am afraid.

So you want to have simply say.... 8h game days, but a player can only fight ...say, once he logs in for 1h? and then the rest of the day he cannot enter the forest.... ?

Well, your intent is fine, but you should just limit the forest fights - or lenghten the game days. Same effect, less complex for players to understand.
(hey, even I did not understand what you wanted to have)

Iori wrote a good outline for what you want.

you can reproduce that in a module relatively easy. you can almost copy+paste the code from the timeout function and just use your own prefs to check that. roughly 50 lines of effective code in the module =) if not less.
It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: Forest search countdown
« Reply #7 on: August 13, 2008, 03:34:58 pm »
I have tried the copy/paste mixing functions and ideas... couldn't get it work, but for preventing all players to access forest search... the correct thing: for each player, didn't get well...

I don't want people to stay out of forest for x hours... just 3 or 5 minutes... they can enter forest, to go to outhouse, mine or other hooked stuff there, but not to search the forest... after a "search", a user session counter registers the time passed between 180 seconds (ie) and the seconds the player returned to search option in the forest... if the result is positive, they are prevented and informed that have still y seconds till they will be allowed... if the result is negative, they are allowed to search...

I am able to copy/paste... :) just give me "what" to paste  ::)

Thanks, Nightborn, for your reply.

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: Forest search countdown
« Reply #8 on: August 14, 2008, 09:30:03 am »
^^ if you put unknown ingredients into a bowl, mix it, this is what happens.

first, you have to understand *how* to do the cake you want. then you can get the ingredients.

why did you not say that you want a delay between forest forest ? Oo so nobody can click through fast.
that would be soooooo much easier to understand.

make a module
have a pref "lastforestsearch"
hook into "forestsearch"
 ---> there just
Code: [Select]
set_module_pref("lastforestsearch",strtotime("now"));hook into "forest"
 ---> there just do
Code: [Select]
if (get_module_pref("lastforestsearch")>strtotime("- 3 minutes")) blocknav("forest.php?op=search");
that does what you want in a few lines, and you may now add your own setting instead of 3 minutes, or display "you can search again in ..." or so ....
It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: Forest search countdown
« Reply #9 on: August 14, 2008, 02:07:28 pm »
I will try this evening to play with the copy/paste insight given by you...

What a bliss would have been, Nightborn, to just attach this easy module to this topic ...  :)

Hope to get it working...

Thank you, Oliver.

I'll get back with the results :)

Alchemion

  • Guest
Re: Forest search countdown
« Reply #10 on: August 14, 2008, 10:56:20 pm »
I have done as pointed out by you, Nightborn :

code:

////////

Code: [Select]
<?php
function forestsearch_timeout_getmoduleinfo(){
$info = array(
"name"=>"Forest search time out",
"author"=>"`%Oliver Brendel`0 & `%Alchemion`0",
"download"=>"....",
"description"=>"forest search time out",
"settings"=>array(
"Forest search time out - Settings,title",
"lastforestsearch"=>"How long to stay out (minutes)?,int|3"
),

"category"=>"General",
"version"=>"1.0"
);
return $info;
}
function 
forestsearch_timeout_install(){
module_addhook("forest");
module_addhook("forestsearch");

return true;
}
function 
forestsearch_timeout_uninstall(){
return true;
}
function 
forestsearch_timeout_dohook($where,$args){
global $session;
if (get_module_pref("lastforestsearch")>strtotime("- 3 minutes")) blocknav("forest.php?op=search");
switch($where){
case "forestsearch":
set_module_pref("lastforestsearch",strtotime("now"));
break;


}
return $args;
}
function 
forestsearch_timeout_run(){}
?>

////


While tested, apparently the code works, but creates some delay in loading the forest.php page... or my server was a litlle bit laisy at the time...

Yet, I don't know if I haven't put too extra useless code in the module (please check, as I think i mixed too much from the carryover_ticker.php module...)...

Anyway there is an issue : The module prevents only access to "Look for something to kill"... the rest "Go slumming" and "Go thrillseeking" are still available for players to (search &) click...

Please help...

Thank you, Nightborn for the easy hints.
« Last Edit: August 20, 2008, 09:56:48 pm by Alchemion »

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: Forest search countdown
« Reply #11 on: August 15, 2008, 07:12:43 am »
Code: [Select]
   if (get_module_pref("lastforestsearch")>strtotime("- 3 minutes")) blocknav("forest.php?op=search");
put this in the switch, in the "forest".

and make yourself author, please...

I did not want to ask, because I assumed (this is a +nb forum) you use 1.1..1.2 +nb Edition.
I heavily except you use 1.1.0 DP Edition, right? Then just block all navs you don't want, check out what they are named.
It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: Forest search countdown
« Reply #12 on: August 15, 2008, 01:05:29 pm »
Thank you very much, Nightborn, for your suggestions...

They work very smooth... I am testing it on Version: 1.2.0 +nb Edition.

Anyone interested in seeing this module at work can download it from:

http://www.xevolution.ro/lotgd/forestsearch_timeout.tar

the timeout is set to 3 minutes and can be adjusted ... it also informs you of the remaining amount of time (in seconds), till new search & adventures become available... quite neat... :)

As for the real feature, please Nightborn, lend me a hand on making this forest search time out available in the Donators Lodge... so that users could buy the "Forest Search speed up recovery dust", which will help them reduce the amount of forest time out from 3, 5 or other setting to 2 or 1 minute...

This is a real challenge... :)

Thank you again, Nightborn, High Spirits Bless !
« Last Edit: August 15, 2008, 02:32:09 pm by Alchemion »

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: Forest search countdown
« Reply #13 on: August 15, 2008, 01:13:58 pm »
on 1.2.0 (note: this is a *development version that has almost daily changes, no guarantee working(!)*) it should block out all navs, including autofight (untested).

You may simply copy+paste the other ops required into a blocknav()

if you want to make a  module to buy a personal timelifter...

well, a three-liner.

use a "buy-stuff-from-lodge" module like .. say, fairydust.
it has most of the stuff you need.

now, you only need to put the "activate fairydust" navigation to the forest, not to battle or whatever it is on right now to the "forest" hook.

then when activate just to a
Code: [Select]
increment_module_pref("lastforestsearch',-(get_module_setting('reduceminutes')*60));which will make it appear the player searched an amount of minutes earlier than he actually did, crediting him 'reduceminutes' (setting in the module!) to his lastforestsearch timestamp.
It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: Forest search countdown
« Reply #14 on: August 15, 2008, 01:24:31 pm »
Wow!!!... when you speak, you make it look so simple....

Please keep in mind that I am a fully novice here and I don't want to get higher grade in this matter...

In the module (updated last post) I managed (thanks to your hints) blocking all fighting navs in the forest, also puting an informing timer...

I told you that I could manage copy/pasting... on condition that the stuff mixed should be quality stuff... :)

I will try this evening your new hints and codes on converting this to a lodge module or building a separate lodge module... hope to succeed again....

Thank you, Nightborn.