DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • September 05, 2010, 07:35:47 PM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1] 2 3   Go Down
  Print  
Author Topic: Portable Potions for 0.9.8  (Read 3170 times)
0 Members and 1 Guest are viewing this topic.
lonnyl
Guest
« on: October 09, 2004, 07:48:00 AM »

Here is the portable potions mod for 0.9.8....

Comes with hearler patch for pre-release 8....
pre-release 9 should not need it when it comes out.
Patch is in unified diff format (YES I finally got a diff util on my machine)

Includes forest special for potions etc.....

Take along healing potions in place of healer in forest.... moves healer to villages.. and is multiple city compat....

http://www.pqcomp.com/modules/mydownloads/visit.php?cid=3&lid=12
« Last Edit: February 01, 2005, 06:41:35 AM by lonnyl » Logged
Kendaer
Global Moderator
Mod God
*****
Offline Offline

Posts: 1806


Once a dragon, always a dragon


View Profile WWW
« Reply #1 on: October 09, 2004, 09:37:01 AM »

* Kendaer takes a look since he figures it's time to give people feedback on modules again.

Code:
               $city = getsetting("villagename", LOCATION_FIELDS);
                $capital = $session['user']['location']==$city;
                $sqlpq="SELECT active FROM modules WHERE modulename='cities'";
                $resultpq = db_query($sqlpq) or die(db_error(LINK));
                $rowpq = db_fetch_assoc($resultpq);
                if ($rowpq['active'] == 1 and $capital){
                }else{
                tlschema($args['schemas']['fightnav']);
                addnav($args['fightnav']);
                tlschema();
                addnav("H?Healer's Hut","healer.php?return=village.php");
                }
could be much better written as
Code:
               $city = getsetting("villagename", LOCATION_FIELDS);
                if ($session['user']['location'] == $city) {
                     // no healer in the capital since it's already added there by the
                     // multicity module, and shouldn't be there in single city.
                } else {
                    tlschema($args['schemas']['fightnav']);
                    addnav($args['fightnav']);
                    tlschema();
                    addnav("H?Healer's Hut","healer.php?return=village.php");
                }
There is no need for that extra SQL call there since the village hook will only be called for active villages.

You have some work to do for translation readyness.
Code:
output("`3Healing Potion`7 costs `6".round(100*$potioncost/100,0)." gold`7. You can carry up to 5 with you to heal yourself.`n`n");
should be
Code:
output("`3Healing Potion`7 costs `6%s gold`7. You can carry up to 5 with you to heal yourself.`n`n", round(100*$potioncost/100, 0));

Lastly, you do the following
Code:
function potions_runevent($type)
{
        global $session;
                                                                               
        $upotion  = get_module_pref("potion");
        if ($upotion<5 and $session['user']['dragonkills']<10){
                output("Lucky Day! You find a healing potion!");
                set_module_pref('potion', ++$upotion);
                debuglog("found 1 Healing Potion in the forest");
        }else{
                redirect("forest.php?op=search");
        }
}

While this would work, it would be *better* to make the event not fire at all if it wasn't legal, so instead, what you should do is modify the         module_addeventhook("forest", "return 100;");
call as follows
Code:
module_addeventhook("forest", "require_once(\"modules/potions.php\"); return potions_chance();");
and then modify the code as follows
Code:
function potions_chance()
{
    global $session;
    // we need the modulename in the get here because we aren't in a
    // module context at the time we call the event hooks for evaluation.
    $upotion = get_module_pref("potion", "potions");
     if ($upotion >= 5 || $session['user']['dragonkills'] >= 10)
         return 0;
     return 100;
}

function potions_runevent($type)
{
        $upotion  = get_module_pref("potion");
        output("Lucky Day! You find a healing potion!");
        set_module_pref('potion', ++$upotion);
        debuglog("found 1 Healing Potion in the forest");
}

This is actually better because it doesn't require an extra page load which the redirect does require making it actually faster on a loaded server.
« Last Edit: October 09, 2004, 09:38:04 AM by Kendaer » Logged

Ex co-developer of LotGD
lonnyl
Guest
« Reply #2 on: October 09, 2004, 09:42:44 AM »

you wanna submit that in a diff file???  Tongue  Grin
Logged
lonnyl
Guest
« Reply #3 on: October 09, 2004, 09:45:19 AM »

Oh and yes there are propably some strange instances there that I haven't caught.... this was one of the mods that was converted by someone else, and I really haven't done more than bug fixes and getting in some missing features.... as far as translation ready... well I don't think I have looked too deeply but the line you show looks interesting... I will have to look at the mods... my next step with them was to be db prefix compatiblity.... then I will have to figure out this whole language thing.
Logged
lonnyl
Guest
« Reply #4 on: October 10, 2004, 06:28:18 AM »

Code:
output("`3Healing Potion`7 costs `6%s gold`7. You can carry up to 5 with you to heal yourself.`n`n", round(100*$potioncost/100, 0));

ok... short of pulling the output function apart and figuring this out.... please enlighten me a bit as to how/why this works.   I guess a good understanding of this may help me with future language compatibility and to get the other modules up to par as far as the translation part goes....

As far as some of the other edits go... I have implemented them (or variations of them) into the code and am uploading as soon as I get this message posted.  Also added the download link that I previously had forgotten...  (ver 1.3)
« Last Edit: October 10, 2004, 06:29:48 AM by lonnyl » Logged
Booger
Captain of the Guard
***
Offline Offline

Posts: 126


I'm a llama!


View Profile
« Reply #5 on: October 10, 2004, 08:17:41 AM »

like Kendaer said in the sticky:

Quote
The reason the first is bad here is that every single 'amount' would result in a different string to be translated, whereas the second would correctly allow the base string to get translated and substitute the parameter in at the correct place.  You can use multiple substitution parameters, etc.
Logged
lonnyl
Guest
« Reply #6 on: October 10, 2004, 10:03:41 AM »

Yes.... I was actually looking for why the %s part works...
Logged
Kendaer
Global Moderator
Mod God
*****
Offline Offline

Posts: 1806


Once a dragon, always a dragon


View Profile WWW
« Reply #7 on: October 10, 2004, 01:13:25 PM »

The %s works because we call sprintf() down inside the output function Smiley

No other way to explain it honestly Smiley
Logged

Ex co-developer of LotGD
SaucyWench
Mod God
*****
Offline Offline

Posts: 2238


I'm a good girl.


View Profile WWW
« Reply #8 on: October 10, 2004, 10:31:36 PM »

You can also use more than one.

From the new city I am writing now:

      addnews("`4%s`3 defeated `4%s`3 in fair combat near the campfire in %s.", $session['user']['name'],$args['badguy']['creaturename'], $args['badguy']['location']);

Goddess SaucyWench defeated Farmie RandomName in fair combat near the campfire in NewVillageName.

(which is basically just a PvP message ripped straight out of the core, with the text changed slightly.)
« Last Edit: October 10, 2004, 10:33:56 PM by SaucyWench » Logged

SaucyWench
Owner of GemDust.com and Darton City proudly hosted by LunarPages
Boofo
Guest
« Reply #9 on: October 17, 2004, 12:45:36 PM »

Here is the portable potions mod for 0.9.8....

Comes with hearler patch for pre-release 8....
pre-release 9 should not need it when it comes out.
Patch is in unified diff format (YES I finally got a diff util on my machine)

How do we use the healer patch? Or does it automatically do it when we install this mod? Sorry to sound like a newbie, but I guess I am. Wink
Logged
lonnyl
Guest
« Reply #10 on: October 17, 2004, 06:49:04 PM »

The patch is in the unix diff format... Using it... well my best suggestion is a bit of research at your favorite search engine.
Logged
AndyMC
Guest
« Reply #11 on: October 18, 2004, 12:01:24 AM »

basically the patch file changes line 78 of healer.php from this:
Code:
}else{
into this:
Code:
}elseif ($op=="buy"){

I noticed this module doesn't let you click the potions at all times.  I can understand why you can't use a potion while in a battle, but it also doesn't let you use the potion while using the World Map module journeying out in the world.  Can support for this module be added somehow?  or is that up to the creator of the World Map mod?
Logged
Boofo
Guest
« Reply #12 on: October 18, 2004, 05:01:46 AM »

I've checked out Google and they tell you how to make the patch, but not how to run it. Is there a command line for running the patch?
Logged
lonnyl
Guest
« Reply #13 on: October 18, 2004, 06:15:56 AM »

I noticed this module doesn't let you click the potions at all times.  I can understand why you can't use a potion while in a battle, but it also doesn't let you use the potion while using the World Map module journeying out in the world.  Can support for this module be added somehow?  or is that up to the creator of the World Map mod?

Yes... at this point it blocks runmodule.php so it will not work from a module....
The reason being is that I have not come up with a suitable return routine from a module....
That and not being able to control every module out there... it also could be used to cheat... say your module rewards gold... well... the player gets their reward... then they click on a potion (or chow) and get returned to the module to get rewarded again.  Or vise versa, could be used to avoid death, such as healing when you have a continue to shades nav.   Hence I don't know if I can deal with each and every module situation with any all purpose code for doing this....  (I know I can check if user is alive to stop the healing on death).  Not to mention that my experiments with $MOSTRECENTMODULE do not always seem to return the actual most recent module.  It is a very grey area dealing with returning to modules, not to mention that if one were 5 steps into a module (to prevent cheating) the potions (and chow) would have to return them to the module with no options (which in itself opens up another avenue for cheating).  

To summarize I have not come up with an ACCEPTABLE way of dealing with using a potion from a module, hence they are blocked from usage all together.
Logged
Matt
Guest
« Reply #14 on: October 24, 2004, 05:48:49 PM »

Could you add something where we can change the price of the potions in the settings menu, and maybe an option to use them in the middle of a fight using up a turn.
Thanks!!
Logged
Pages: [1] 2 3   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Who's Online
30 Guests, 3 Users
KaosKaizer, Rawr_mel, Cory2
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search