Jump to content

Little help making a script?


Daisuke_aurora

Recommended Posts

Im trying to make a PHP battle script for my SMF site, but I have a few holdups:

 

-How do I make the script find info from the SMF DB?

-How do I make the script Change a person's membergroup when their HP reaches 0?

-How do I make the script give SMF shop items / Increase in posts to the winner?

-How do I make the script post as me in a thread?

 

Here's what I have so far (the variables are the stats from you or your opponent). I think it's right, and when I tested it with the variables I have set, it worked.

 

$A = 8; //Attacker's ATK

$D = 5; //Defender's DEF

$S = 8; //Attacker's SPD

$R = 7; //Defender's R. SPD

$HP = 50; //Defender's HP

$N1 = mt_rand(1, 10);

$N2 = mt_rand(1, 10);

$A1 = $N1 + $S;

$A2 = $A1 + $A;

$D1 = $N2 + $R;

$D2 = $D1 + $D;

 

 

//Defense v.s. attack?

If ($A - $D > 0)

{

                        $DA = $A-$D;

}

//Defense v.s. attack?

If ($A - $D < 0)

{

                        $DA = 0;

}

//Defense v.s. attack?

If ($A - $D = 0)

{

                        $DA = 0;

}

//Did we power-hit?

If ($A1 > $D2)

{

                        echo 'You smashed your opponent for ' .($A + $A). ' damage!';

SET $HP = ($HP - $A - $A)

}

else

//Did we hit?

If ($A2 > $D2)

{

                        echo 'You hit your opponent for ' .($A). ' damage!';

SET $HP = ($HP - $A)

}

else

//Did they dodge?

If ($A2 < $D1)

{

                        echo 'Your opponent dodged and took no damage!';

}

else

//Did they dodge?

If ($A2 = $D1)

{

                        echo 'Your opponent dodged and took no damage!';

}

else

//Did they block?

If ($A2 < $D2)

{

                        echo 'Your opponent blocked, taking only ' .($DA + 1). ' damage!';

SET $HP = ($HP - $DA - 1)

}

else

//Did they block?

If ($A2 = $D2)

{

                        echo 'Your opponent blocked, taking only ' .($DA + 1). ' damage!';

SET $HP = ($HP - $DA - 1)

}

 

That's just the PHP-box demo I made, to determine battle results. Now, I want to integrate it with SMF, but I am bad at PHP.

Link to comment
https://forums.phpfreaks.com/topic/123315-little-help-making-a-script/
Share on other sites

Bump.

 

And I replaced

//Defense v.s. attack?

If ($A - $D > 0)

{

                        $DA = $A-$D;

}

//Defense v.s. attack?

If ($A - $D < 0)

{

                        $DA = 0;

}

//Defense v.s. attack?

If ($A - $D = 0)

{

                        $DA = 0;

}

With

//Defense v.s. attack?

If ($A - $D > 0)

{

                        $DA = $A-$D;

}

Else

{

                        $DA = 0;

}

It should work the same, right?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.