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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.