se7enet purgatorio

Page 1 of 1 1
Topic Options
Rate This Topic
#18503 - 10/16/08 10:28 AM Heal spell not working in a fight
gamefreak888
Rice Krispies


Registered: 09/06/07
Posts: 215

Offline
For some reason, heal spells won't work.
I've tried it as well in an unmodded version of Scourge but I still got the same problem.
My character is level 15 and has the "Heal 2" spell. When I'm exploring and click on "Heal" it works, but when I'm fighting and select the Heal spell I do get the message "basleijser casts Heal 2 and gets 10 HP" but my HP is not updated.

It's about this piece of code:

In spells.php:
 Code:
function heal($id) {
    
    global $userrow, $spells;
    
    $failed = 0;
    if ($userrow["currentmp"] < $spells[$id]["mp"]) { $return = "<span class=\"red\"><b>Failed to cast spell:</b> not enough MP!</span><br />"; $failed = 1; }
    
    if ($failed == 0) { 
        $userrow["currenthp"] += $spells[$id]["value"];
        $userrow["currentmp"] -= $spells[$id]["mp"];
        if ($userrow["currenthp"] > $userrow["maxhp"]) { $userrow["currenthp"] = $userrow["maxhp"]; }
		$return = $userrow["charname"] . " casts " . $spells[$id]["name"] . " and gains " . $spells[$id]["value"] . " HP.<br />";
    }
	
	
    
    return($return);
    
}


In fight.php:
 Code:
} elseif (isset($_POST["spell"])) {
    
        if (! is_numeric($_POST["spellid"])) { err("Wrong input."); }
        $isavailable = 0;
        for ($i = 1; $i < 11; $i++) {
            if ($userrow["spell".$i."id"] == $_POST["spellid"]) { $isavailable = 1; }
        }
        if ($isavailable == 0) { err("You don't have that spell!"); }
        
        include("spells.php");
        $castspell = $spells[$_POST["spellid"]]["fname"]($_POST["spellid"]);
        $userrow["currentmonsterhp"] -= ($fightrow["playerphysdamage"] + $fightrow["playermagicdamage"] + $fightrow["playerfiredamage"] + $fightrow["playerlightdamage"]);
        if ($userrow["currentmonsterhp"] <= 0) { youwin(); }
        monsterturn();
        if ($userrow["currenthp"] <= 0) { youlose(); }
        updateuserrow();
        
        $pagerow = array(
            "message"=>$castspell,
            "monstername"=>$monsterrow["name"],
            "monsterhp"=>$userrow["currentmonsterhp"],
            "playerphysdamage"=>$fightrow["playerphysdamage"],
            "playermagicdamage"=>$fightrow["playermagicdamage"],
            "playerfiredamage"=>$fightrow["playerfiredamage"],
            "playerlightdamage"=>$fightrow["playerlightdamage"],
            "monsterphysdamage"=>$fightrow["monsterphysdamage"],
            "monstermagicdamage"=>$fightrow["monstermagicdamage"],
            "monsterfiredamage"=>$fightrow["monsterfiredamage"],
            "monsterlightdamage"=>$fightrow["monsterlightdamage"],
            "track"=>$fightrow["track"]);
        $pagerow["spells"] = dospellslist();
        display("Fighting",parsetemplate(gettemplate("fight_turn"),$pagerow));


Thanks in advance.


Edited by basleijser (10/16/08 10:29 AM)

Top
#18507 - 10/16/08 11:52 AM Re: Heal spell not working in a fight [Re: gamefreak888]
Fayt
Crunchberries
***

Registered: 11/08/05
Posts: 1131
Loc: My Computer, USA

Offline
I don't use DS but I will attempt to resolve this.


You are saying, if the spell fails, then cast it??

if ($failed == 0) {
$userrow["currenthp"] += $spells[$id]["value"];
$userrow["currentmp"] -= $spells[$id]["mp"];
if ($userrow["currenthp"] > $userrow["maxhp"]) { $userrow["currenthp"] = $userrow["maxhp"]; }
$return = $userrow["charname"] . " casts " . $spells[$id]["name"] . " and gains " . $spells[$id]["value"] . " HP.<br />";
}

-----------------------------------------------------

Maybe change it to this



if ($failed != 0) {
$userrow["currenthp"] += $spells[$id]["value"];
$userrow["currentmp"] -= $spells[$id]["mp"];
if ($userrow["currenthp"] > $userrow["maxhp"]) { $userrow["currenthp"] = $userrow["maxhp"]; }
$return = $userrow["charname"] . " casts " . $spells[$id]["name"] . " and gains " . $spells[$id]["value"] . " HP.<br />";
}
_________________________
MasterFayt - Amara 5 - Manas - Banar

Top
#18509 - 10/16/08 12:00 PM Re: Heal spell not working in a fight [Re: Fayt]
gamefreak888
Rice Krispies


Registered: 09/06/07
Posts: 215

Offline
No you haven't read carefully through the code.

if ($userrow["currentmp"] < $spells[$id]["mp"])

If ^ that is the case:
$failed = 1;

And then comes:

if ($failed == 0) {

But a good try :P

Top
#18512 - 10/16/08 06:35 PM Re: Heal spell not working in a fight [Re: gamefreak888]
Fayt
Crunchberries
***

Registered: 11/08/05
Posts: 1131
Loc: My Computer, USA

Offline
I don't know what this $spells [$id] ["mp"] crap is
_________________________
MasterFayt - Amara 5 - Manas - Banar

Top
#18513 - 10/16/08 08:55 PM Re: Heal spell not working in a fight [Re: Fayt]
AnmanIndustries
Cookie Crisp
*****

Registered: 03/21/05
Posts: 2876
Loc: Planet Stupid, AKA Earth

Offline
Then you shouldnt be trying to help.

Im pretty sure this has come up before.

Common internet ettiquet is you SEARCH for you problem first, before you ask the question. Got that?

SEARCH FIRST!

http://se7enet.com/forums/ubbthreads.php...=true#Post17280
_________________________
If you want me to punch you in the nuts go to:
http://www.AnmanIndustries.com

I'll do it for free too. Enjoy.

Top
#18515 - 10/16/08 09:30 PM Re: Heal spell not working in a fight [Re: AnmanIndustries]
Fayt
Crunchberries
***

Registered: 11/08/05
Posts: 1131
Loc: My Computer, USA

Offline
But mommy I am allowed to attempt to fix it
_________________________
MasterFayt - Amara 5 - Manas - Banar

Top
#18516 - 10/17/08 03:36 AM Re: Heal spell not working in a fight [Re: AnmanIndustries]
gamefreak888
Rice Krispies


Registered: 09/06/07
Posts: 215

Offline
 Originally Posted By: AnmanIndustries
Then you shouldnt be trying to help.

Im pretty sure this has come up before.

Common internet ettiquet is you SEARCH for you problem first, before you ask the question. Got that?

SEARCH FIRST!

http://se7enet.com/forums/ubbthreads.php...=true#Post17280


I DID SEARCH FIRST!
I even read that entire topic before I started this one.

But that topic is about PvP and not about a fight against a monster and the updateuserrow() thing didn't worked out for me.

Top
#18531 - 10/19/08 07:52 PM Re: Heal spell not working in a fight [Re: gamefreak888]
AnmanIndustries
Cookie Crisp
*****

Registered: 03/21/05
Posts: 2876
Loc: Planet Stupid, AKA Earth

Offline
Then youve screwed your game.
_________________________
If you want me to punch you in the nuts go to:
http://www.AnmanIndustries.com

I'll do it for free too. Enjoy.

Top
Page 1 of 1 1


Hop to:

se7enet

Barack Obama Logo