nb Core Community
May 22, 2012, 04:50:08 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: 1.2.3 +nb is now final and released

@new registrations. I will not allow any new registrations here as there are more (real person) spambots here than ever.... captcha proved to be ineffective.

After your registration, mail me at ( admin AT shinobilegends.com ) from the mail address you want to register. Provide some text about you and possibly your game.
 
   Home   Help Search Calendar Downloads Login Register  
Pages: [1]
  Print  
Author Topic: Modifying modules from DP to fit into +NB core  (Read 1295 times)
Alchemion
Guest
« on: October 13, 2008, 08:18:39 am »

Hi,

I have an issue with a module from DragonPrime, The Balrog... balrog.php...

The balrog stats are settable from admin area, but, even if I set the creature's attack and defense to 2 * player's stats and even 4*player's coresponding stats, the Balrog does not do to me ANY damage ... if he basicly is a multiplyer of "me", how come that a 4 times bigger me does not hurt me at all ?...

Is there some code to modify or insert to this one ? :

Code:
$badguy = array(
"creaturename"=>"Balrog",
"creatureweapon"=>"Flaming Whip",
"creaturelevel"=>$session['user']['level']+1,
"creatureattack"=>round($session['user']['attack']*$atk),
"creaturedefense"=>round($session['user']['defense']*$def),
"creaturehealth"=>round($session['user']['maxhitpoints']*$hp),
"diddamage"=>0,);

where $atk = get_module_setting("atk");
    $def = get_module_setting("def");

or maybe somewhere else within the module ??


balrog.php :
Code:
<?php

function balrog_getmoduleinfo(){
$info = array(
"name"=>"The Balrog",
"author"=>"John M",
//based on Mad Monk by Ges;
"version"=>"1.5",
"category"=>"Forest Specials",
"download"=>"http://dragonprime.net/users/ges/balrog.zip",
"settings"=>array(
"Balrogs Settings,title",
"mindk"=>"How many DK's before a player encounters the Balrog?,int|10",

"atk"=>"Multiplier of attacker's attack to get Creature Attack,floatrange,0,2,.02|1.3",
"def"=>"Multiplier of attacker's defense to get Creature Defense,floatrange,0,2,.02|1.3",
"hp"=>"Multiplier of attacker's max HP to get Creature Hitpoints,floatrange,0,2,.02|1.2",
), 
);
return $info;
}
function 
balrog_install(){
module_addeventhook("forest","return 15;");
return true;
}
function 
balrog_uninstall(){
return true;
}

function 
balrog_runevent($type){
global $session;
require_once("lib/increment_specialty.php");
$op "";
$op httpget('op');
$page httpget('page');

$atk get_module_setting("atk");
$def get_module_setting("def");
$hp get_module_setting("hp");
$aug get_module_setting("aug");
$mxs get_module_setting("mxs");
$rdm get_module_setting("rdm");
$mindk=get_module_setting("mindk");
if ($session['user']['dragonkills'] <=$mindk)
{
                          
output("You sense an unearthly presence, and feel a cold chill down your spine, but nothing bad happens.");
                          
output("You're not sure why, but you feel as if you've narrowly escaped death.");

return;
}

$session['user']['specialinc'] = "module:balrog";
if ($op == "" || $op == "search")
{
output("`) As you are exploring the forest just outside of %s, your keen senses become aware of the smell of smoke.",($session['user']['location']));
output(" `n`n Looking around, you see an orange glow in the distance.");
                        
output("You ears pick up the sounds of something crashing through the trees, and wonder if the fire has created a stampede.");
output("`n`nA frightened adventurer comes running from the direction of the fire. ");
                        
output("His eyes are wide and his face is pale, he runs up to you and grabs you by the collar...");
output("`n`n`^\"RUN! We must RUN! It's the BALROG!!!\"`) He cries.");
output(" `n`nThe crashing sounds grow closer, you wonder if the panicky adventurer is correct.");
                        
output("If so, then you are the only protection %s has from one of the fiercest monsters ever known.",($session['user']['location']));
output("`n`n`)You see a large tree snap into pieces, as a growing aura of flame comes into view.");
                                
output("In the heart of the flames, is a being about twenty feet tall, and at least nine feet wide at the shoulders.");
                                
output("The aura of flames around it's body makes it hard for you to perceive it's full form, but it's demonic wings, and powerful whip are easily visible as it approaches.`n");
addnav("The Balrog");
addnav("Stand","forest.php?op=stand");
addnav("Flee","forest.php?op=withdraw");
$battle false;

}
elseif ($op == "stand")
{

output("`)You draw your `!%s, `)and stand fast.",translate_inline($session['user']['weapon']));

$badguy = array(
"creaturename"=>"Balrog",
"creatureweapon"=>"Flaming Whip",
"creaturelevel"=>$session['user']['level']+1,
"creatureattack"=>round($session['user']['attack']*$atk),
"creaturedefense"=>round($session['user']['defense']*$def),
"creaturehealth"=>round($session['user']['maxhitpoints']*$hp), 
"diddamage"=>0,);

apply_buff('balaura', array(
"startmsg"=>"`4As you move towards the Balrog, you feel the heat of its flaming aura.",
"name"=>"`4Flaming Aura",
"rounds"=>15,
"minioncount"=>1,
"wearoff"=>"You've weakened the vile beast enough to extinguish it's flames.",
"mingoodguydamage"=>0,
                                                
"maxgoodguydamage"=>round(($session['user']['maxhitpoints']/4)),

                                                
"effectmsg"=>"`4You are toasted by the searing heat of the Balrog for`Q {damage} `4points!",
                                                  
"effectnodmgmsg"=>"You strike quickly and jump back before the heat can affect you.",
"schema"=>"module-balrog",));
$session['user']['badguy'] = createstring($badguy);
$op "fight";
httpset('op',$op);
}
elseif ($op == "withdraw")
{
$session['user']['specialinc'] = "";
output("`)You realize that despite being the only hope the town has, you have to look out for your own skin first. You swallow your pride and join the panicked adventurer in fleeing the scene.");
output("`n`nYou feel deeply ashamed for fleeing and leaving all those innocent townspeople to certain deaths. You lose `!5 charm points`) for your cowardice!");
$session ['user']['charm']-=5;
addnews("%s fled like a coward, leaving the city of %s helpless before the Balrog.",$session['user']['name'],$session['user']['location']);
                                
addnews("The city of %s was attacked by the Balrog, many innocents were killed and much of the town has been destroyed.");
$battle false;
}

if ($op == "fight")
{
                          
output("`)The panicked adventurer realizes that you're not joining him and screams...");
switch (e_rand(1,5))
{
case 1:

output("`c`i`@We're all going to die!`i`c");

break;
case 2:

output("`c`i`@You're my HERO! (You push him away before he can kiss you.)`i`c");

break;
case 3:

output("`c`i`@Are you MAD! It will snap you like a twig!`i`c");

break;
case 4:

output("`c`i`@Don't be a FOOL! We must run for our lives!!?!`i`c");

break;
case 5:

output("`c`i`@Your so BRAVE! I'm such a coward!`i`c");

break;
}
$battle true;
}

if ($battle)
{
include("battle.php");

if ($victory)
{
$session['user']['specialinc'] = "";
$expgain=$session['user']['experience']*.15;
if ($session['user']['level'] > 9$expgain *= 0.8;
if ($session['user']['level'] < 6$expgain *= 1.2;
if ($session['user']['level'] == 1$expgain += 20;
$expgain=round($expgain);
                          
//exp formula by Chris Vorndran from tatmonster.php
$session['user']['experience']+=$expgain;
                                
strip_buff('balaura');
output("`)The Balrog screams, and shrinks in size. A beautiful white glow appears around your`! %s, `)and a circular vortex opens directly behind the unholy beast.",$session['user']['weapon']);
output("`n`n Instinctively, you push forward, your glowing weapon forces him back into the vortex and out of this reality.");
output(" `n`n`c`&The white glow surrounds your entire body, and you feel your wounds being healed.`c`n");
                               
output("`n`c`b`)You gained `^$expgain `)experience from the battle.`b`c");
$session['user']['hitpoints']=$session['user']['maxhitpoints'];
$gold=($session['user']['maxhitpoints']*3)+123;
output("`)`n`n`cAs the energy fades, you find`^ %s gold `)on the ground in front of you.`c",translate_inline($gold));
output("`n`n`cYour heroic actions make you feel very `!charming!`c");
$session['user']['gold']+=$gold;
$session['user']['charm']+=5;

addnews("%s has saved the city of %s from the horrors of the Balrog.",$session['user']['name'],$session['user']['location']);

if ($session['user']['charm'] <=10)
{
output("`)As you put out the brush fires started by the Balrog, a beautiful Dryad steps out from one of the trees.");
output("`&\"Thank you for saving my tree, and my life.\"` She says, kissing you lightly on the cheek.");
output("`n`n`cYou feel even more `!charming!`)`c");
$session['user']['charm']=10;
$session['user']['specialinc']="";
return;
}


if ($session['user']['charm'] >=100)
{   $giftgems= (rand(13)+3);
    output("`)The citizens of %s come out to put out the forest fire.",$session['user']['location']);
    output("When they learn of your heroism, they decide to throw a celebration in your honor!");
    output("`n`nYou are carried back to town on their shoulders, and right up the steps to City Hall.");
    output("The local chefs bring their finest foods, and the barkeeps break out barrels of fresh ale!");
    output("You receive several marriage proposals, and the Mayor gives you the keys to the city.");
    output("`n`nYou are given an extra`! %s gems `)as a reward for your services!",translate_inline($giftgems));
                                            
$session['user']['gems']+=$giftgems;

    debuglog("received $giftgems gems from the grateful townspeople.");
    return;
}
else {   







{

}



};

}
elseif($defeat)
{
$session['user']['specialinc'] = "";
$exploss round($session['user']['experience']*.05);
output("`c`n`n`)`bThe Balrog's whip catches you in the head, knocking you unconscious.");
output("`)The Balrog finishes you off effortlessly.");
output ("`n`nThe panicked adventurer shouts `^\"I told you so!\"`) as he runs away (taking your gold with him).");
output("`n`nYou lose `^$exploss `)experience.`b`c`0");
$session['user']['experience']-=$exploss;
$session['user']['alive'] = false;
$session['user']['hitpoints'] = 0;
$session['user']['gold'] = 0;
strip_buff('balaura');
debuglog("lost $exploss experience to the Balrog.");
addnews("%s died heroically trying to save the city of %s from the Balrog.",$session['user']['name'],$session['user']['location']);
addnav("Return");
addnav("Return to the Shades","shades.php");
}
else
{
fightnav(true,false);



}
}
}

?>




I guess it is something related to the new playerfunctions lib, cause I met this issue repeated with others modules, too.

Thank you very much.

« Last Edit: October 13, 2008, 08:25:24 am by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 307



View Profile WWW
« Reply #1 on: October 13, 2008, 08:22:12 am »

$session['user']['attack']

I don't use them for normal attack values - only for BONUS values (like weapondamage)

The attack should be acquired by the get_player_attack(); function in lib/playerfunctions.php

as always, a simple debug($badguy); would have helped you in the balrog.php -> showing you the creature stats.

Please learn to debug =)
Logged

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
« Reply #2 on: October 13, 2008, 08:31:51 am »

this
Quote
debug($badguy);
you always tell me about seems to do allday miracles...

where do I insert this line ?... at the begining of, at the end, between, nearby ?... is there a generic location for this line  as for
Quote
debug($xyz);
should be insert immediatly under or above the first or last line where $xyz occurs ?... if so, i may not bother you at all on this matter...


ref :

Quote
I don't use them for normal attack values - only for BONUS values (like weapondamage)

you're saying that in fact the code works but takes into consideration the weapon's stat not the user's stat, or, in this case, does not work at all ?...


thanks.
« Last Edit: October 13, 2008, 08:43:01 am by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 307



View Profile WWW
« Reply #3 on: October 14, 2008, 07:17:39 am »

I have not run the code into my brain-compiler Smiley so I cannot say it works.

but if you use $session['user']['attack'] and are NOT level 1, it should be >0 as value.
However, if you are level 1 and have not had any special event -> it is 0.

In DP Editions ALL attack related stuff gets stored in here. My attribute system works different, however.

@debug

Ask yourself the important debugging question:
Quote
When has my variable what value in that program?

And you see what I mean. You currently have no clue - you code it to your best knowledge, fire it in and then if it does not work try to fix "by guessing" where it breaks.

You need to narrow down WHERE it breaks, hence you need to "debug", means first of all to know what your code REALLY produces instead of "it does not work".

after having SET the badguy, if it is NOT working, it is imperative to add a debug($badguy) and see what values our badguy gets...

believe me, 90% of your questions can be solved by simply reviewing what happens where.
Logged

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
« Reply #4 on: October 14, 2008, 07:38:28 am »

I understood that... but you didn't clarifiy where do I insert the
Quote
debug($xyz);
  Huh? before, after, in between.......

I guess I'll have to test it on my own...
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 307



View Profile WWW
« Reply #5 on: October 14, 2008, 10:41:02 am »

Please, this is your 3rd (I believe) post where you need to debug =)

Understand what you do -> debug() is to display variables and/or text at for your convenient locations in your script to your browser... so you can SEE what happens. =) not just get the final result.

A var_dump() does the same, but not as nicely formatted.
Logged

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
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!