Customizing SMF > SMF Coding Discussion

Stat Battle / RPG Mod

(1/26) > >>

Daisuke_aurora:
I need some help writing a Mod. Basically I want the following:

-A button like the quote button called "attack" that, when clicked, will run a file (attack.php most likely) that will input your stats and the chosen member's stats into a formula that determines whether your attack hit, missed, watever, and then after that it posts the results of the attack in the thread as an admin and updates the attacked person's HP stat to reflect any damage he may have taken.

I'm not exactly good at this, but I figure it would have to edit the files that show the quote button to add this button, and I'd need to make the file attack.php and put it in Sources.

I assume the Attack.php file would look like a much MUCH better version of this general idea:

-Find who you are.
-Find who you "attacked."
-Find your stats "A" and "S" and set them to variables \$A and  \$S (They are in the Themes table, and are called CP3 and CP5.)
-Find your opponents stats "HP" "D" and "R" and set them to variables \$HP, \$D and  \$R (They are in the Themes table, and are called CP1, CP4 and CP6.)
-Set \$N1 and \$N2 (random numbers between 1 and 10)

The "battle" part

-\$A1=\$N1+\$S.
-\$D1=\$R+\$N2.
-\$A2=\$A1+\$A.
-\$D2=\$D1+\$D.

-If \$A1>\$D2, then update \$HP stat: \$HP - (\$Ax2). And Print "(You) smashed (opponent) for \$Ax2 damage!" As a post in the topic where you attacked him

-Else if \$A2>\$D2, then update \$HP stat: \$HP - \$A. And Print "(You) hit (opponent) for \$A damage!" As a post in the topic where you attacked him.

-Else if \$A2<\$D2, then update \$HP stat: \$HP - (\$A-\$D ). A-D can't be lower than 0. Then subtract another 1 from their HP. And Print "(You) attacked (Opponent), but they blocked, only taking (\$A-\$D)+1 damage!" As a post in the topic where he attacked him.

-If \$A2<\$D1, then Print "(You) attacked (Opponent), but they dodged it!" As a post in the topic where he attacked him.

Also, when a member has 0 HP, they get put into a group called Defeated.

And lastly, permissions for the Attack button that allow me to set which groups can use the attack button.
I know this looks daunting, but I really would love the help, as I am unable to figure out PHP enough to do it by myself.

[SiNaN]:
It looks interesting. I whish I had some time to code this. If you want, I can move this to the Mod Requests board.

matasanos:
yes...i am interested!!

Daisuke_aurora:

--- Quote from: [SiNaN] on September 04, 2008, 04:27:28 PM ---It looks interesting. I whish I had some time to code this. If you want, I can move this to the Mod Requests board.

--- End quote ---

Sure, thank you.

I'd love to get this done, simply because I've seen so many people who want to make RP boards that use stats like this. I already had help and made items that affect the stats, a system for using them (basically the coding above but done IRL by an Admin) and am working on some other things to make the system full automated. Maybe one day soon it'll be one big Mod called Stats or something.

--- Quote from: matasanos on September 04, 2008, 04:39:25 PM ---yes...i am interested!!

--- End quote ---

Daisuke_aurora:
Anybody else interested in helping me? I partially coded it, but as of now it has to have numeric input, and it only does the formula, not the posting, HP adjusting, or membergroup changing.

--- Quote ---\$A = 8;
\$D = 5;
\$S = 8;
\$R = 7;
\$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!';
}
else
//Did we hit?
If (\$A2 > \$D2)
{
echo 'You hit your opponent for ' .(\$A). ' damage!';
}
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!';
}
else
//Did they block?
If (\$A2 = \$D2)
{
echo 'Your opponent blocked, taking only ' .(\$DA + 1). ' damage!';
}
--- End quote ---

It's currently set to run in a phpbox in my portal on my homepage, so we can use it to determine the results, but it needs work obviously...