nb Core Community
February 09, 2012, 09:38:51 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] 2
  Print  
Author Topic: Error on dragon fight ...  (Read 3560 times)
Alchemion
Guest
« on: February 15, 2009, 10:57:16 pm »

restarted some server testing and when I came back from shadows I got this poping up...

http://www.bn-core.net/dragon.php?nointro=1&c=324-214730

and the error message :

+++++++++++++++++++
PHP Warning: "Invalid argument supplied for foreach()"
in /mounted-storage/home113a/sub007/sc41001-XJFO/bn-core.net/battle.php at 100.
Call Stack:
2: require_once("/mounted-storage/home113a...") called from /mounted-storage/home113a/sub007/sc41001-XJFO/bn-core.net/dragon.php on line 272
surprises you and gets the first round of attack!

PHP Warning: "Invalid argument supplied for foreach()"
in /mounted-storage/home113a/sub007/sc41001-XJFO/bn-core.net/battle.php at 171.
Call Stack:
2: require_once("/mounted-storage/home113a...") called from /mounted-storage/home113a/sub007/sc41001-XJFO/bn-core.net/dragon.php on line 272
With a mighty final blow, lets out a tremendous bellow and falls at your feet, dead at last.

+++++++++++++++++++++++

some related with the nointro dragon fight occurance...

any hints or code repairings?...

thank you very much...


Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #1 on: February 16, 2009, 09:40:06 am »

core version would be nice to know without having to visit your page ^^

foreach ($enemies as $index=>$enemy) {


that's my line 100, and I assume you have an old module that overwrites $enemies .... if it, for instance, messes with the $session['user']['badguy'].

My guess would be an obsolete module (DP Editions before 1.1.1) that tries to rename the dragon. =)
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: February 16, 2009, 02:53:56 pm »

I thought we are talking here abot nb core 1.2 + ... more precisely the 1.2.2 ... not needing to remention it...

I guess also it has to do with the dragonattack module... wich is rather old... will try to uninstall it and see what happens... or maybe with the peerpresure module...

I will get back with results...

thank you for your quick hint.
« Last Edit: February 17, 2009, 03:46:15 pm by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #3 on: February 16, 2009, 04:43:10 pm »

the "more precisely" would be nice.

As you use a version that bases on daily snapshots, you might get a not-working-version.

Also update your source code.

You need to understand that if I stop working on a wicked problem on Monday evening, the build gets assembled at 11pm and if you download at 11:30 pm, you have a borked version.

-_- there is a reason why I declare some things final and some "in dev" or "don't install on a live server".

There might be a chance I worked on the dragon.php and you have a borked version, too.
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: February 19, 2009, 11:08:44 am »

The nb source (1.2.2+) is downloaded a couple of days ago...

The module in discussion is peerpressure.

Here is the code :

Code:
<?php
// translator ready
// addnews ready
// mail ready

function peerpressure_getmoduleinfo(){
$info = array(
"name"=>"Peer Pressure",
"version"=>"1.1",
"author"=>"`\$Red Yates",
"category"=>"Village Specials",
"download"=>"core_module",
"settings"=>array(
"Peer Pressure Settings,title",
"daysfree"=>"Days until player is a potential victim,int|2",
),
"prefs"=>array(
"Peer Pressure Preferences,title",
"dayspast"=>"Days since user hit level 15,int|0",
),
);
return $info;
}

function 
peerpressure_victimtest(){
global $session;
if ($session['user']['level'] != 15) return 0;
if (get_module_pref("dayspast""peerpressure") <
get_module_setting("daysfree""peerpressure")) return 0;
return 100;
}


function 
peerpressure_install(){
module_addeventhook("village""require_once(\"modules/peerpressure.php\"); return peerpressure_victimtest();");
module_addhook("newday");
module_addhook("battle-defeat");
return true;
}

function 
peerpressure_uninstall(){
return true;
}

function 
peerpressure_dohook($hookname,$args){
global $session;
switch($hookname){
case "newday":
$dayspast=get_module_pref("dayspast");
$dayspast++;
set_module_pref("dayspast",
($session['user']['level']==15?$dayspast:0));
break;
case "battle-defeat":
// If they have a special inc set for the dragon and they just
// lost, reset it so they don't keep coming back here!
global $options;
if ($session['user']['specialinc'] == "module:peerpressure" && $options['type'] == "dragon") {
$session['user']['specialinc'] = "";
}
break;
}
return $args;
}

function 
peerpressure_runevent($type)
{
global $session;
$session['user']['specialinc']="module:peerpressure";
// For translation reasons, you cannot really substitute in his/her
// since the gender can change other things
if ($session['user']['sex']) {
addnews("`&%s`7 heroically decided to seek out `@The Green Dragon`7 with cheers of encouragement from her peers ringing in her ears.",$session['user']['name']);
} else {
addnews("`&%s`7 heroically decided to seek out `@The Green Dragon`7 with cheers of encouragement from his peers ringing in his ears.",$session['user']['name']);
}
output("`2Wandering the village, going about your business, you are suddenly surrounded by a group of villagers.");
output("They wonder why such an experienced adventurer as yourself hasn't slain a dragon yet.");
output("You mutter some embarrassed excuses but they aren't listening.");
output("They crowd around you closer, and lift you up on their shoulders.");
$isforest 0;
$vloc modulehook('validforestloc', array());
foreach($vloc as $i=>$l) {
if ($session['user']['location'] == $l) {
$isforest 1;
break;
}
}
if ($isforest || count($vloc)==0) {
output("`n`nCheering your name the whole way, they carry you into the forest, and right to the mouth of a cave outside the town!`n`n");
} else {
$key array_rand($vloc);
output("`n`nCheering your name the whole way, they carry you far into the forest, and right to the mouth of a cave outside the town of %s!`n`n"$key);
$session['user']['location'] = $key;
}
output("Still cheering your name, they put you down and eagerly wait for you to enter and slay that dragon.`n`n");
output("You know that you'd never live it down if you tried to back out now.");
output("Swallowing your fear as best you can, you enter the cave.");
if (is_module_active("dragonplace")) {
addnav("Enter the cave""runmodule.php?module=dragonplace&op=cave");
} else {
addnav("Enter the cave""dragon.php?nointro=1");
}
$session['user']['specialinc']="";
checkday(); //increment buffs, newday buffs, and heal... and probably throw people off in general
$session['user']['specialinc']="module:peerpressure";
apply_buff('peerpressure', array(
"name"=>"`2Heroic Valor",
"rounds"=>20,
"atkmod"=>(1+(get_module_pref("dayspast")/100)),
"defmod"=>(1+(get_module_pref("dayspast")/100)),
"startmsg"=>"`2You fight bravely, considering the pressure you're under.",
"wearoff"=>"`@The Green Dragon`2 has beaten and burnt the bravery out of you.",
"schema"=>"module-peerpressure",
)
);
}

function 
peerpressure_run(){
}
?>


i find this module useful so it would be good to have it working with the nb-core engine...

where would be the problem and how could it be solved ?...

Thank you very much.
« Last Edit: February 19, 2009, 11:10:59 am by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #5 on: February 19, 2009, 11:45:13 am »

You need debug skills Wink


debug() is such a nice function.


try a
        debug($options);

after
   global $options;

And see if you find an array key type - and if that type is dragon.

But really, I don't think this module breaks the dragon fight, it does not write to $enemies nor $badguy.
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 #6 on: February 20, 2009, 12:58:09 pm »

Thanks for the sugestion...

You know I have an issue with this "debug" function...

Not that I don't like it, just I didn't understand how to make it run...

So, I have added the debug code as you said, but no different code (than the one reported above) shows in the running module...

What else, beside the added code in the module, should I set in some game settings in order to see the output code I am interested in changing, as I intend ?...

Note that, before adding the sugested code, I had set the gamesettings to run in debug mode and also to show any php notice output...

...

Not in the least, I have observed that neither other debug code do not show in this newer nb version I test now... I refer to the modified avatar module, that I use to show images in battles and pvp... the code you thaught me about showing "is the image on the server ?.." does also not showing anything, respectively I cannot learn the name of the "monsters" in order to set the correspondent image name... :|

the code for debugging the images in my modified avatar module (that worked fine on previous 1.2.1 version) is:

Code:
case "battle":
global $options;
                                if ($options['type']=='pvp') break;
if (get_module_pref("validated")==1 && get_module_pref("user_seeavatar")==1) {
$image="<img src='".get_module_pref("avatar")."' ALT='You!' width='100%'>";                        
} else {
$image=translate_inline("Avatar not validated yet");
}
foreach ($args as $creature) {
if ($creature['image']!='') {
$name=$creature['image'];
$pic=true;
} else {
$name="modules/addmonsterpics/".$creature['creaturename'].".jpg";
                                                        debug("assigned name $name to the creature pic");
$pic=file_exists($name);
                                                        debug("is the picture file there: ".$pic);
}
if ($pic==true) $pics.="<IMG SRC=\"$name\" ALT='$name' width='100%'>";                                             
}
rawoutput("
<table width='330' height='150' border='4' align='center'>
  <tr align='center'>
    <td width='150'>$image</td>
    <td width='30'>VS.</td>
    <td width='150'>$pics</td>
  </tr>
</table>
");
break;


Thank you very much...
« Last Edit: February 20, 2009, 01:05:02 pm by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #7 on: February 20, 2009, 06:17:22 pm »

You need to think like a programmer.

You run through the program with your eyes like a parser... debug() will give you nothing as it is called here in the "else" condition - what if there is no "else" ever touched ?

debug() is just a function as any other. If the part of the code does not run - it won't give you output.

debug() just prints to the screen in a nice way text, a variable or an array.

If you have no clue about a function, see where it is and read through it - they are in the /lib folder.
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 #8 on: February 20, 2009, 06:30:44 pm »

The "else" condition is "touched" and I did thought about "it"... as I don't have pictures on the server for the monsters... and as I said and confirmed, the debug worked indeed nice on the previous nb instalation... i haven't changed anything to that avatar module, since...
 Huh? Roll Eyes

Beside the debug(), must i activate some extra settings in the game ?...

Thank you.
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #9 on: February 20, 2009, 10:37:12 pm »

No.

If you get an output, you can now start "debugging" where it breaks.

Means debug-outputting variables, see what their value is, and so on.

To find the bad thing. =)

That's what I can do for you, point the way to go.

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 #10 on: February 21, 2009, 10:38:49 am »

you suggest i should try debugging with the previous working version ?
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #11 on: February 23, 2009, 10:23:03 am »

No.

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 #12 on: February 24, 2009, 11:01:48 pm »

I was at a couple of inches away from shutting down the nb version...

why ?... cause the debug output refused to show after following the indications as stated above...

well ?... I allowed myself the unbelief that everything's all right and I searched a little more... I found that the Admin User hadn't set in the grotto, from User Editor, the permission to see the debug output...

I changed it and everything return to normal...

Conclusion: let's not state as imuable the untested information...

Nevertheless, the peerpresure module still is not working on the nb engine...  Cry

Greets !
« Last Edit: February 24, 2009, 11:24:42 pm by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #13 on: February 25, 2009, 12:54:19 pm »

 Grin sorry, I always have debug output on - switched it on 3 years ago...

Maybe I make it even mandatory for the first admin char created... it is helpful and necessary.
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 #14 on: February 25, 2009, 02:31:16 pm »

"it is helpful and necessary"... indeed... you can set it on by default and announce in some last installation step that the admin can unset it with the User Editor...

regarding the peerpressure module : it takes only 2-3 minutes to install and give it a test... maybe you'll have the time to see what's wrong with it... and have a greater number of compatible DP-NB modules... thus creating a stronger bridge for an easy movement from one LOTGD version to another ...

thank you.
Logged
Pages: [1] 2
  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!