Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Daisuke_aurora on September 04, 2008, 11:56:08 AM

Title: Stat Battle / RPG Mod
Post by: Daisuke_aurora on September 04, 2008, 11:56:08 AM
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.
Title: Re: Stat Battle Mod
Post by: [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 (http://www.simplemachines.org/community/index.php?board=79.0) board.
Title: Re: Stat Battle Mod
Post by: matasanos on September 04, 2008, 04:39:25 PM
yes...i am interested!!
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 05, 2008, 08:39:08 AM
It looks interesting. I whish I had some time to code this. If you want, I can move this to the Mod Requests (http://www.simplemachines.org/community/index.php?board=79.0) board.

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.

yes...i am interested!!

Then come on over to the Dojo (http://www.daisukesdojo.heliohost.org/forum)  and sign up.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 08, 2008, 10:35:49 AM
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!';
}

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...
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 09, 2008, 11:04:15 AM
Bump.

And I replaced
Quote
//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
Quote
//Defense v.s. attack?
If ($A - $D > 0)
{
                        $DA = $A-$D;
}
Else
{
                        $DA = 0;
}
It should work the same, right?
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 11, 2008, 10:53:16 AM
Yes, that would do that.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 11, 2008, 11:03:35 AM
Okay, then onto the next problem:

How do I pull information from the Database? I have this as the current Attack.php, but it won't work, I believe I messed up the part where it gets the stats from the DB:

Quote
<?php

if (!defined('SMF'))
   die('Hacking attempt...');

function Attack()
{
      global $db_prefix, $ID_MEMBER;

   checkSession('get');

$A = db_query("
      SELECT value FROM {$db_prefix}themes
      WHERE variable = 'CP3' && ID_MEMBER = {$ID_MEMBER},");

$D = 5;
$S = db_query("
      SELECT value FROM {$db_prefix}themes
      WHERE variable = 'CP7' && ID_MEMBER = {$ID_MEMBER},");
$R = 7;
$HP = 50;
$N1 = mt_rand(1, 10);
$N2 = mt_rand(1, 10);
$A1 = $N1 + $S;
$A2 = $A1 + $A;
$D1 = $N2 + $R;
$D2 = $D1 + $D;


//Is A-D positive?
If ($A - $D > 0)
{
                        $DA = $A-$D;
}
//If it's not...
Else
{
                        $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 block?
If ($A2 <= $D2)
{
                        echo 'Your opponent blocked, taking only ' .($DA + 1). ' damage!';
}
}
?>

Also, I took the "check session" and "If not SMF, die" things from another script because I figured they'd need to be put in eventually.
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 11, 2008, 02:01:05 PM
Find:

Code: [Select]
$A = db_query("
      SELECT value FROM {$db_prefix}themes
      WHERE variable = 'CP3' && ID_MEMBER = {$ID_MEMBER},");

$D = 5;
$S = db_query("
      SELECT value FROM {$db_prefix}themes
      WHERE variable = 'CP7' && ID_MEMBER = {$ID_MEMBER},");

Replace:

Code: [Select]
$request = db_query("
SELECT value
FROM {$db_prefix}themes
WHERE variable = 'CP3'
AND ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
list ($A) = mysql_fetch_row($request);
mysql_free_result($request);

$D = 5;

$request = db_query("
SELECT value
FROM {$db_prefix}themes
WHERE variable = 'CP7'
AND ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
list ($S) = mysql_fetch_row($request);
mysql_free_result($request);
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 11, 2008, 02:31:09 PM
You're awesome Sinan. Works perfectly. I have more I need help with, but I can't really do it piece by piece; I've posted it here somewhere, but I need a button next to "quote" called "attack" that'll run this script when clicked, but take the "attacked" member's D, R.S and HP from the DB and put it into the equation. And I'm sure this part is alot harder than just asking how to do requests for the user's info.
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 11, 2008, 02:37:03 PM
You want a button on every post?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 11, 2008, 02:49:03 PM
Yes, just like the quote button.

Also, i'm getting an error in this item I made:

Quote
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: IncreaseAtk.php 79 2007-01-18 08:26:55Z Daisuke                         $ *
* Software by:                Daisuke (http://www.daisukesdojo.heliohost.org/)    *
* Copyright 2005-2007 by:     Daisuke (http://www.daisukesdojo.heliohost.org/)    *
* Support, News, Updates at:  http://www.daisukesdojo.heliohost.org/              *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version of the license can always be found at                        *
* http://www.simplemachines.org.                                                  *
**********************************************************************************/

if (!defined('SMF'))
   die('Hacking attempt...');

class item_Potion extends itemTemplate
{
   function getItemDetails()
   {
      $this->authorName = 'Daisuke';
      $this->authorWeb = 'http://www.daisukesdojo.heliohost.org/';
      $this->authorEmail = 'Daisuke_aurora@hotmail.com';

      $this->name = 'Potion!';
      $this->desc = 'Restores 30 HP!';
      $this->price = 500;

      $this->require_input = false;
      $this->can_use_item = true;
      $this->addInput_editable = true;
   }
   
   // See 'AddToPostCount.php' for info on how this works
   function getAddInput()
   {
      global $user_info;
      if ($item_info[1] == 0) $item_info[1] = 1;
      return 'Amount to increase Current HP by: <input type="text" name="info1" value="' . $item_info[1] . '" />';
   }

   function onUse()
   {
      global $db_prefix, $ID_MEMBER, $item_info;

      $request = db_query("
      SELECT value
      FROM {$db_prefix}themes   
      WHERE variable = 'CP1'      
      AND ID_MEMBER = $ID_MEMBER   
   LIMIT 1", __FILE__, __LINE__);
list ($HP) = mysql_fetch_row($request);
mysql_free_result($request);


      $request = db_query("
      SELECT value
      FROM {$db_prefix}themes   
      WHERE variable = 'CP9'      
      AND ID_MEMBER = $ID_MEMBER   
   LIMIT 1", __FILE__, __LINE__);
list ($MAX) = mysql_fetch_row($request);
mysql_free_result($request);

If ($HP + 30 > $MAX)
   


      db_query("
         UPDATE {$db_prefix}themes
         SET value = $MAX
         WHERE variable = 'CP1' AND ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);      return 'Successfully increased your Attack by ' . $item_info[1] . '!';
   }
else
If ($HP + 30 <= $MAX)
{
      db_query("
         UPDATE {$db_prefix}themes
         SET value = value + {$item_info[1]}
         WHERE variable = 'CP1' AND ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);      return 'Successfully increased your Attack by ' . $item_info[1] . '!';
   }
}

?>

Basically, it's supposed to get your Current HP and Max HP, make sure that Current + 30 isn't over your max (If it is, it sets your current to your Max) or add 30 to your current. It says there's an error on line 90, unexpected Else?
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 11, 2008, 03:01:07 PM
About the first issue:

Save your codes  as Attack.php.

../index.php

Find:

Code: [Select]
'announce' => array('Post.php', 'AnnounceTopic'),
Replace:

Code: [Select]
'attack' => array('Attack.php', 'Attack'),
../Themes/your_theme/Display.template.php

Find:

Code: [Select]
// Show online and offline buttons?
Replace:

Code: [Select]
echo '<a href="' . $scripturl . '?action=attack;attacked=' . $message['member']['id'] . ';sesc=', $context['session_id'], '">[Attack]</a>';

// Show online and offline buttons?

Find:

Code: [Select]
   checkSession('get');
Replace:

Code: [Select]
   checkSession('get');

$attacked_id = !empty($_REQUEST['attacked']) ? (int) $_REQUEST['attacked'] : 0;

Then get the info as you did for the others. Just use $attacked_id instead of $ID_MEMBER.

For second;

You should try the SMF Shop support topic.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 11, 2008, 03:02:41 PM
Is there one here? I tried the SMF Shop forum at daniel15.com, but no one there is ever on.
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 11, 2008, 03:10:01 PM
It's here (http://www.simplemachines.org/community/index.php?topic=22396.0).
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 11, 2008, 03:19:12 PM
Okay, a few issues:

1. My forum now has huge letters and all the pictures are X's.

2. There is no attack button in any of the posts; going to the action attack action does nothing (I assume because there was no button, the opponents stats aren't there to use.)

3. I WAS supposed to put the checksession code in Attack.php right?

4. Was i supposed to completely erase the announce action?
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 11, 2008, 03:27:37 PM
1) Make sure you applied the edits correctly.

2) There should be in posts, in the profile area of a message, unless you add it in the wrong line.

3) Yes.

4) First edit should be "add after", I missed it. So announce stays there, but you add attack after that.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 11, 2008, 03:39:00 PM
I think this i swhy I have big text:

Quote
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 5
File: /home/daisuke/public_html/forum/Sources/Attack.php
Line: 27

The message I got when I attacked someone.

Quote
<?php

if (!defined('SMF'))
   die('Hacking attempt...');

checkSession('get');
   $attacked_id = !empty($_REQUEST['attacked']) ? (int) $_REQUEST['attacked'] : 0;

function Attack()
{
      global $db_prefix, $ID_MEMBER;

$request = db_query("
      SELECT value
      FROM {$db_prefix}themes   
      WHERE variable = 'CP3'      
      AND ID_MEMBER = $ID_MEMBER   
   LIMIT 1", __FILE__, __LINE__);
list ($A) = mysql_fetch_row($request);
mysql_free_result($request);

$request = db_query("
      SELECT value
      FROM {$db_prefix}themes   
      WHERE variable = 'CP4'      
      AND ID_MEMBER = $attacked_id   
   LIMIT 1", __FILE__, __LINE__);
list ($D) = mysql_fetch_row($request);
mysql_free_result($request);

$request = db_query("
      SELECT value
      FROM {$db_prefix}themes
      WHERE variable = 'CP7'
      AND ID_MEMBER = $ID_MEMBER
   LIMIT 1", __FILE__, __LINE__);
list ($S) = mysql_fetch_row($request);
mysql_free_result($request);


$request = db_query("
      SELECT value
      FROM {$db_prefix}themes   
      WHERE variable = 'CP8'      
      AND ID_MEMBER = $attacked_id   
   LIMIT 1", __FILE__, __LINE__);
list ($R) = mysql_fetch_row($request);
mysql_free_result($request);


$request = db_query("
      SELECT value
      FROM {$db_prefix}themes   
      WHERE variable = 'CP9'      
      AND ID_MEMBER = $attacked_id   
   LIMIT 1", __FILE__, __LINE__);
list ($HP) = mysql_fetch_row($request);
mysql_free_result($request);

$N1 = mt_rand(1, 10);
$N2 = mt_rand(1, 10);
$A1 = $N1 + $S;
$A2 = $A1 + $A;
$D1 = $N2 + $R;
$D2 = $D1 + $D;


//Is A-D positive?
If ($A - $D > 0)
{
                        $DA = $A-$D;
}
//If it's not...
Else
{
                        $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 block?
If ($A2 <= $D2)
{
                        echo 'Your opponent blocked, taking only ' .($DA + 1). ' damage!';
}
}
?>

My current Attack.php
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 11, 2008, 03:41:24 PM
You should put these

Code: [Select]
checkSession('get');
   $attacked_id = !empty($_REQUEST['attacked']) ? (int) $_REQUEST['attacked'] : 0;

codes after these

Code: [Select]
      global $db_prefix, $ID_MEMBER;
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 11, 2008, 03:43:13 PM
I got this error when I did that:

Quote
Unable to load the 'main' template.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 11, 2008, 04:30:35 PM
Oh, and the big text problem must be in the index.php; I removed it and the problem was fixed.

What did i do wrong :D

Quote
   // Here's the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function).
   $actionArray = array('rivals' => array ( 'rivals.php', 'rivals' ),
      'activate' => array('Register.php', 'Activate'),
      'admin' => array('Admin.php', 'Admin'),
      'announce' => array('Post.php','AnnounceTopic'),        'arcade' => array('Arcade.php','Arcade'),   'attack' => array('Attack.php','Attack'),
      'managegames' => array('ManageGames.php', 'GamesAdmin'),
      'arcadecategory' => array('ArcadeSettings.php', 'ArcadeCategory'),
      'arcadesettings' => array('ArcadeSettings.php', 'ArcadeSettings'),
      'ban' => array('ManageBans.php', 'Ban'),
      'boardrecount' => array('Admin.php', 'AdminBoardRecount'),
      'buddy' => array('Subs-Members.php', 'BuddyListToggle'),
      'calendar' => array('Calendar.php', 'CalendarMain'),
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 12, 2008, 04:25:20 PM
Can anyone tell me why my text gets so big? It's got to be something to do with Index.php
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 13, 2008, 05:54:05 AM
I got this error when I did that:

Quote
Unable to load the 'main' template.

That is you should have a template file to display something. What do you want it to do/show when somebody attacks another?

Can anyone tell me why my text gets so big? It's got to be something to do with Index.php

When does it get bigger? When you take the change back in index.php, does it show as usual?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 16, 2008, 10:01:36 AM
I wanted it to show the topic you attacked them in, but I wanted it to post a post in the topic under my name that says the result of the attack.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 16, 2008, 01:29:10 PM
Isn't there a few lines of code that I can put at the end that will basically do this:

-Get the topic you clicked the button in.
-Post the results of the attack under the user ID of an Admin (myself most likely.)
-Return the attacker to the topic.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 17, 2008, 12:53:53 PM
Okay, would it be possible to have someone help me with this part? I think if I take the Post and Post2 functions from Post.php, tweak them a little to skip the whole "Locked? Able to reply? quoting?" Etc. and just do the posting and returning to topic, then it'll work like I want it to. I'm going to back up my forum, put it all on my compy, and try it out on EasyPHP. But any advice as to what i need to keep, how to go about it, etc. would be appreciated.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 22, 2008, 11:23:11 AM
Any help? At all?
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 25, 2008, 08:24:51 AM
Use createPost() (http://support.simplemachines.org/function_db/index.php?action=view_function;id=323) function to create post.

Send the topic id with url and after doing all that, use redirectindex() (http://support.simplemachines.org/function_db/index.php?action=view_function;id=224) to take the user back to topic.

Example:

Url:

' . $scripturl . '?action=attack;attacked=' . $message['member']['id'] . ';topic=' . $context['current_topic'] . ';sesc=', $context['session_id'], '

Redirect:

$topic = empty($REQUEST['topic']) ? 0 : (int) $_REQUEST['topic'];
redirectexit('topic=' . $topic);
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 25, 2008, 09:27:06 AM
Like this?:

Code: [Select]
createPost()

' . $scripturl . '?action=attack;attacked=' . $message['member']['id'] . ';topic=' . $context['current_topic'] . ';sesc=', $context['session_id'], '

redirectindex()

$topic = empty($REQUEST['topic']) ? 0 : (int) $_REQUEST['topic'];
redirectexit('topic=' . $topic);


Do i put it into Attack.php?

And how do I set what gets posted? I want it to post the phrases I had it returning.
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 25, 2008, 09:32:00 AM
1) Check how you should use createPost() function here:

http://support.simplemachines.org/function_db/index.php?action=view_function;id=323

2) Use url code I gave for the url of button you add in Display.template.php that you made here:

http://www.simplemachines.org/community/index.php?topic=259616.msg1702666#msg1702666

3) Use the redirect codes I gave at the end of the Attack() function.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 25, 2008, 09:36:09 AM
Thanks again, I'll let you know how it turns out.

Is there anything I can do to thank you for your help? You've done more to help with my site than anyone else, and I remember you said you were busy, so I really appreciate the time you put into helping me.

Edit: Okay, I'm an idiot at PHP. I have no idea how to set this up... Sorry SiNaN, but can you (yet again) help me? The message to be posted is this:

Code: [Select]
You smashed your opponent for ' .($A + $A). ' damage!
Also, I need to be able to use this code for all 4 possible outcomes, so would I just have it in each outcome after the "If" check? like

Code: [Select]
If ($A1 > $D2)
{
                        <CODE HERE>
}

or something like that?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 26, 2008, 08:57:49 AM
Code: [Select]
function createPost(&$msgOptions, &$topicOptions, &$posterOptions)
{
global $db_prefix, $user_info, $ID_MEMBER, $txt, $modSettings;

// Set optional parameters to the default value.
$msgOptions['icon'] = empty($msgOptions['icon']) ? 'xx' : $msgOptions['icon'];
$msgOptions['smileys_enabled'] = !empty($msgOptions['smileys_enabled']);
$msgOptions['attachments'] = empty($msgOptions['attachments']) ? array() : $msgOptions['attachments'];
$topicOptions['id'] = empty($topicOptions['id']) ? 0 : (int) $topicOptions['id'];
$topicOptions['poll'] = isset($topicOptions['poll']) ? (int) $topicOptions['poll'] : null;
$topicOptions['lock_mode'] = isset($topicOptions['lock_mode']) ?  $topicOptions['lock_mode'] : null;
$topicOptions['sticky_mode'] = isset($topicOptions['sticky_mode']) ? $topicOptions['sticky_mode'] : null;
$posterOptions['id'] = empty($posterOptions['id']) ? 0 : (int) $posterOptions['id'];
$posterOptions['ip'] = empty($posterOptions['ip']) ? $user_info['ip2'] : $posterOptions['ip'];

// If nothing was filled in as name/e-mail address, try the member table.
if (!isset($posterOptions['name']) || $posterOptions['name'] == '' || (empty($posterOptions['email']) && !empty($posterOptions['id'])))
{
if (empty($posterOptions['id']))
{
$posterOptions['id'] = 0;
$posterOptions['name'] = $txt[28];
$posterOptions['email'] = '';
}
elseif ($posterOptions['id'] != $ID_MEMBER)
{
$request = db_query("
SELECT memberName, emailAddress
FROM {$db_prefix}members
WHERE ID_MEMBER = $posterOptions[id]
LIMIT 1", __FILE__, __LINE__);
// Couldn't find the current poster?
if (mysql_num_rows($request) == 0)
{
trigger_error('createPost(): Invalid member id ' . $posterOptions['id'], E_USER_NOTICE);
$posterOptions['id'] = 0;
$posterOptions['name'] = $txt[28];
$posterOptions['email'] = '';
}
else
list ($posterOptions['name'], $posterOptions['email']) = mysql_fetch_row($request);
mysql_free_result($request);
}
else
{
$posterOptions['name'] = $user_info['name'];
$posterOptions['email'] = $user_info['email'];
}

$posterOptions['email'] = addslashes($posterOptions['email']);
}

// It's do or die time: forget any user aborts!
$previous_ignore_user_abort = ignore_user_abort(true);

$new_topic = empty($topicOptions['id']);

// Insert the post.
db_query("
INSERT INTO {$db_prefix}messages
(ID_BOARD, ID_TOPIC, ID_MEMBER, subject, body, posterName, posterEmail, posterTime,
posterIP, smileysEnabled, modifiedName, icon)
VALUES ($topicOptions[board], $topicOptions[id], $posterOptions[id], SUBSTRING('$msgOptions[subject]', 1, 255), SUBSTRING('$msgOptions[body]', 1, 65534), SUBSTRING('$posterOptions[name]', 1, 255), SUBSTRING('$posterOptions[email]', 1, 255), " . time() . ",
SUBSTRING('$posterOptions[ip]', 1, 255), " . ($msgOptions['smileys_enabled'] ? '1' : '0') . ", '', SUBSTRING('$msgOptions[icon]', 1, 16))", __FILE__, __LINE__);
$msgOptions['id'] = db_insert_id();

// Something went wrong creating the message...
if (empty($msgOptions['id']))
return false;

// Fix the attachments.
if (!empty($msgOptions['attachments']))
db_query("
UPDATE {$db_prefix}attachments
SET ID_MSG = $msgOptions[id]
WHERE ID_ATTACH IN (" . implode(', ', $msgOptions['attachments']) . ')', __FILE__, __LINE__);

// Insert a new topic (if the topicID was left empty.
if ($new_topic)
{
db_query("
INSERT INTO {$db_prefix}topics
(ID_BOARD, ID_MEMBER_STARTED, ID_MEMBER_UPDATED, ID_FIRST_MSG, ID_LAST_MSG, locked, isSticky, numViews, ID_POLL)
VALUES ($topicOptions[board], $posterOptions[id], $posterOptions[id], $msgOptions[id], $msgOptions[id],
" . ($topicOptions['lock_mode'] === null ? '0' : $topicOptions['lock_mode']) . ', ' .
($topicOptions['sticky_mode'] === null ? '0' : $topicOptions['sticky_mode']) . ", 0, " . ($topicOptions['poll'] === null ? '0' : $topicOptions['poll']) . ')', __FILE__, __LINE__);
$topicOptions['id'] = db_insert_id();

// The topic couldn't be created for some reason.
if (empty($topicOptions['id']))
{
// We should delete the post that did work, though...
db_query("
DELETE FROM {$db_prefix}messages
WHERE ID_MSG = $msgOptions[id]
LIMIT 1", __FILE__, __LINE__);

return false;
}

// Fix the message with the topic.
db_query("
UPDATE {$db_prefix}messages
SET ID_TOPIC = $topicOptions[id]
WHERE ID_MSG = $msgOptions[id]
LIMIT 1", __FILE__, __LINE__);

// There's been a new topic AND a new post today.
trackStats(array('topics' => '+', 'posts' => '+'));

updateStats('topic', true);
updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
}
// The topic already exists, it only needs a little updating.
else
{
// Update the number of replies and the lock/sticky status.
db_query("
UPDATE {$db_prefix}topics
SET
ID_MEMBER_UPDATED = $posterOptions[id], ID_LAST_MSG = $msgOptions[id],
numReplies = numReplies + 1" . ($topicOptions['lock_mode'] === null ? '' : ",
locked = $topicOptions[lock_mode]") . ($topicOptions['sticky_mode'] === null ? '' : ",
isSticky = $topicOptions[sticky_mode]") . "
WHERE ID_TOPIC = $topicOptions[id]
LIMIT 1", __FILE__, __LINE__);

// One new post has been added today.
trackStats(array('posts' => '+'));
}

// Creating is modifying...in a way.
db_query("
UPDATE {$db_prefix}messages
SET ID_MSG_MODIFIED = $msgOptions[id]
WHERE ID_MSG = $msgOptions[id]", __FILE__, __LINE__);

// Increase the number of posts and topics on the board.
db_query("
UPDATE {$db_prefix}boards
SET numPosts = numPosts + 1" . ($new_topic ? ', numTopics = numTopics + 1' : '') . "
WHERE ID_BOARD = $topicOptions[board]
LIMIT 1", __FILE__, __LINE__);

// Mark inserted topic as read (only for the user calling this function).
if (!empty($topicOptions['mark_as_read']) && !$user_info['is_guest'])
{
// Since it's likely they *read* it before replying, let's try an UPDATE first.
if (!$new_topic)
{
db_query("
UPDATE {$db_prefix}log_topics
SET ID_MSG = $msgOptions[id] + 1
WHERE ID_MEMBER = $ID_MEMBER
AND ID_TOPIC = $topicOptions[id]
LIMIT 1", __FILE__, __LINE__);

$flag = db_affected_rows() != 0;
}

if (empty($flag))
db_query("
REPLACE INTO {$db_prefix}log_topics
(ID_TOPIC, ID_MEMBER, ID_MSG)
VALUES ($topicOptions[id], $ID_MEMBER, $msgOptions[id] + 1)", __FILE__, __LINE__);
}

// If there's a custom search index, it needs updating...
if (!empty($modSettings['search_custom_index_config']))
{
//$index_settings = unserialize($modSettings['search_custom_index_config']);

$inserts = '';
foreach (text2words(stripslashes($msgOptions['body']), 4, true) as $word)
$inserts .= "($word, $msgOptions[id]),\n";

if (!empty($inserts))
db_query("
INSERT IGNORE INTO {$db_prefix}log_search_words
(ID_WORD, ID_MSG)
VALUES
" . substr($inserts, 0, -2), __FILE__, __LINE__);
}

// Increase the post counter for the user that created the post.
if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']))
{
// Are you the one that happened to create this post?
if ($ID_MEMBER == $posterOptions['id'])
$user_info['posts']++;
updateMemberData($posterOptions['id'], array('posts' => '+'));
}

// They've posted, so they can make the view count go up one if they really want. (this is to keep views >= replies...)
$_SESSION['last_read_topic'] = 0;

// Better safe than sorry.
if (isset($_SESSION['topicseen_cache'][$topicOptions['board']]))
$_SESSION['topicseen_cache'][$topicOptions['board']]--;

// Update all the stats so everyone knows about this new topic and message.
updateStats('message', true, $msgOptions['id']);
updateLastMessages($topicOptions['board'], $msgOptions['id']);

// Alright, done now... we can abort now, I guess... at least this much is done.
ignore_user_abort($previous_ignore_user_abort);

// Success.
return true;
}

That's the normal Createpost, what needs to be changed?
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 28, 2008, 05:07:49 AM
Take all the changes back.

../index.php

Find:

Code: [Select]
'announce' => array('Post.php', 'AnnounceTopic'),
Replace:

Code: [Select]
'announce' => array('Post.php', 'AnnounceTopic'),
'attack' => array('StatBattle.php', 'Attack'),

../Themes/your_theme/Display.template.php

Find:

Code: [Select]
// Show online and offline buttons?
Replace:

Code: [Select]
// StatBattle
echo '<a href="', $scripturl, '?action=attack;attacked=', $message['member']['id'], ';country=', $context['current_board'], ';arena=', $context['current_topic'], ';sesc=', $context['session_id'], '">[Attack]</a><br />';

// Show online and offline buttons?

Then dowload the attached file and upload it to your Sources directory.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 28, 2008, 05:27:48 AM
I'll have to do it on Monday. Thanks so much! I can't believe it'll finally be done and working! I'll have to add in somewhere to have it reduce the person's HP but that should be easy enough.
Title: Re: Stat Battle Mod
Post by: Marcus Forsberg on September 28, 2008, 05:30:47 AM
I tested this on my forum and it works pretty godd :)
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 28, 2008, 05:31:19 AM
You did? You put in the custom profile mod and everything?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 29, 2008, 01:39:05 PM
Okay, nest question:

I added the HP part of the codes and the MP part, making the following:

Code: [Select]
<?php

if (!defined('SMF'))
die('Hacking attempt...');

function 
Physical()
{
global $db_prefix$sourcedir$ID_MEMBER;

$attacked_id = !empty($_REQUEST['attacked']) ? (int) $_REQUEST['attacked'] : 0;
$attacked_topic = !empty($_REQUEST['arena']) ? (int) $_REQUEST['arena'] : 0;
$attacked_board = !empty($_REQUEST['country']) ? (int) $_REQUEST['country'] : 0;

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP3'
AND ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($A) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP4'
AND ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($D) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes
WHERE variable = 'CP7'
AND ID_MEMBER = 
$ID_MEMBER
LIMIT 1"
__FILE____LINE__);
list ($S) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP8'
AND ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($R) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP9'
AND ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($HP) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT realname
FROM 
{$db_prefix}members   
WHERE ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($you) = mysql_fetch_row($request);
mysql_free_result($request);


$request db_query("
SELECT realname
FROM 
{$db_prefix}members   
WHERE ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($them) = mysql_fetch_row($request);
mysql_free_result($request);

$N1 mt_rand(110);
$N2 mt_rand(110);
$A1 $N1 $S;
$A2 $A1 $A;
$D1 $N2 $R;
$D2 $D1 $D;

if ($A1 $D2)
{
$damage $A $A;
$HP2 $HP $damage $HP $damage 0;
$msg '' .($you). ' smashed ' .($them). ' for ' .($damage). ' damage!';
}
elseif ($A2 $D2)
{
$HP2 $HP $A $HP $A 0;
$msg '' .($you). ' attacked ' .($them). ' for ' .($A). ' damage!';
}
elseif ($A2 <= $D1)
{
$msg '' .($them). ' dodged an attack by ' .($you). ' and took no damage!';
}
elseif ($A2 <= $D2)
{
$DA $A $D $A-$D 0;
$damage $DA 1;
$HP2 $HP $damage $HP $damage 0;
$msg '' .($them). ' blocked an attack by ' .($you). ', taking only ' .($damage). ' damage!';
}

db_query("
UPDATE 
{$db_prefix}themes
SET value = 
{$HP2}
WHERE variable = 'CP9' AND ID_MEMBER = 
{$attacked_id}"__FILE____LINE__);

$msgOptions = array(
'id' => 0,
'subject' => 'Physical Attack!',
'body' => $msg,
'icon' => 'xx',
'smileys_enabled' => 1,
'attachments' => array(),
);
$topicOptions = array(
'id' => $attacked_topic,
'board' => $attacked_board,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => $ID_MEMBER,
'update_post_count' => 1,
);

require_once($sourcedir '/Subs-Post.php');
createPost($msgOptions$topicOptions$posterOptions);

redirectexit('topic=' $attacked_topic);
}

function 
Magical()
{
global $db_prefix$sourcedir$ID_MEMBER;

$attacked_id = !empty($_REQUEST['attacked']) ? (int) $_REQUEST['attacked'] : 0;
$attacked_topic = !empty($_REQUEST['arena']) ? (int) $_REQUEST['arena'] : 0;
$attacked_board = !empty($_REQUEST['country']) ? (int) $_REQUEST['country'] : 0;

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP5'
AND ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($A) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP6'
AND ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($D) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes
WHERE variable = 'CP7'
AND ID_MEMBER = 
$ID_MEMBER
LIMIT 1"
__FILE____LINE__);
list ($S) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP8'
AND ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($R) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP9'
AND ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($HP) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP10'
AND ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($MP) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT realname
FROM 
{$db_prefix}members   
WHERE ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($you) = mysql_fetch_row($request);
mysql_free_result($request);


$request db_query("
SELECT realname
FROM 
{$db_prefix}members   
WHERE ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($them) = mysql_fetch_row($request);
mysql_free_result($request);

$N1 mt_rand(110);
$N2 mt_rand(110);
$A1 $N1 $S;
$A2 $A1 $A;
$D1 $N2 $R;
$D2 $D1 $D;
$MP2 $MP $A $MP $A 0

if ($A1 $D2)
{
$damage $A $A;
$HP2 $HP $damage $HP $damage 0;
$msg '' .($you). ' blasted ' .($them). ' for ' .($damage). ' damage!';
}
elseif ($A2 $D2)
{
$HP2 $HP $A $HP $A 0;
$msg '' .($you). ' attacked ' .($them). ' using Magic for ' .($A). ' damage!';
}
elseif ($A2 <= $D1)
{
$msg '' .($them). ' dodged a Magic attack from ' .($you). ' and took no damage!';
}
elseif ($A2 <= $D2)
{
$DA $A $D $A $D 0;
$damage $DA 1;
$HP2 $HP $damage $HP $damage 0;
$msg '' .($them). ' blocked a Magic attack from ' .($you). ', taking only ' .($damage). ' damage!';
}


db_query("
UPDATE 
{$db_prefix}themes
SET value = 
{$HP2}
WHERE variable = 'CP9' AND ID_MEMBER = 
{$attacked_id}"__FILE____LINE__);

db_query("
UPDATE 
{$db_prefix}themes
SET value = 
{$MP2}
WHERE variable = 'CP10' AND ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);

$msgOptions = array(
'id' => 0,
'subject' => 'Magic Attack!',
'body' => $msg,
'icon' => 'xx',
'smileys_enabled' => 1,
'attachments' => array(),
);
$topicOptions = array(
'id' => $attacked_topic,
'board' => $attacked_board,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => $ID_MEMBER,
'update_post_count' => 1,
);

require_once($sourcedir '/Subs-Post.php');
createPost($msgOptions$topicOptions$posterOptions);

redirectexit('topic=' $attacked_topic);
}

?>

Now, after the set of variables that determine what happens, I want to add an "If" clause that basically checks the following:

-If you're attacking yourself, give a message that says you cant attack yourself.
-If you're attacking a person with 0 HP, you can't attack them.

And the same for the Magical function, but also:

-If $A is greater than your current MP, you can't do it.

But I tried adding them in and I can't seem to make them work, I keep getting Parse Errors complaining about an unexpected t_string after the 'If" clause. Any ideas?

I figured it'd be like these:

Code: [Select]
\\Check to see if they have enough MP.
if ($MP < $A)
{
$msg = '' .($you). ' tried to magically attack ' .($them). ' but didn't have enough MP!';
}

Code: [Select]
//Make sure they're not kicking a dead horse.
if (HP = 0)
{
$msg = '' .($you). ' tried attacking ' .($them). ' but you can't attack a dead person!';

Actually, if it went to an error page instead of posting it would be even better.
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 29, 2008, 02:20:26 PM
Quote
-If you're attacking yourself, give a message that says you cant attack yourself.

Make this if statement the first:

if($attacked_id == $ID_MEMBER)
   $msg = 'You cannot attack yourself.';

Quote
If you're attacking a person with 0 HP, you can't attack them.

After the if above, use this if with elseif:

if(empty($HP))
   $msg = 'You do not have enough HP to attack';

Can you show me the codes that give those parse errors?

And what makes the Magical function different? Why don't you use the same?
Title: Re: Stat Battle Mod
Post by: Marcus Forsberg on September 29, 2008, 02:44:56 PM
You did? You put in the custom profile mod and everything?

No, I just tested how the button and Attack.php works.
I could test everything if You tell me what CP fields to add :)

And btw, if a users HP is 0, how does the users get new HP?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 29, 2008, 02:53:37 PM
The ones I gave were the codes that were causing errors. I assume it was because I was wording them wrong.

The Magic function is just like the attack function, except it takes MP to do it. The drawback is that regular attacks are free, but the bonus is most people expect everyone to use physical attacks, and as a result they often leave their Magic Defense low enough that a Magic attack can hit someone that a Physical attack could not.

Coding-wise, the only real difference is the stats for $A and $D are actually Magic A and Magic D rather than regular A and D, and there is a DB query to reduce the MP of the attacker. However, I was trying to figure out a way to (like the above two) tell a person that thay cannot attack with a magic attack if their MP is less than their Magic Attack. So it'd be kinda like I posted above, I think.

Also, I went and made the following changes to Index.php:

Code: [Select]
'physicalattack' => array('StatBattle.php', 'Physical'),
'magicalattack' => array('StatBattle.php', 'Magical'),

And to display.template.php:

Code: [Select]
// StatBattle
echo ' Attack!<br />';
echo ' <a href="', $scripturl, '?action=physicalattack;attacked=', $message['member']['id'], ';country=', $context['current_board'], ';arena=', $context['current_topic'], ';sesc=', $context['session_id'], '">[Physical]</a><br />';
echo ' <a href="', $scripturl, '?action=magicalattack;attacked=', $message['member']['id'], ';country=', $context['current_board'], ';arena=', $context['current_topic'], ';sesc=', $context['session_id'], '">[Magical]</a><br />';

That way it has 2 actions, physical attack and Magical attack, and displays a button for both.

@ Nascar:

I have to CP fields. If you want to try it out (And i'd be very grateful, as it might help me solve my "big text" problem) add 10 fields and call them out as follows:

CP1: Max HP
CP2: Max MP
CP3: Atk
CP4: Def
CP5: M. Atk
CP6: M. Def
CP7: Spd
CP8: R. Spd
CP9: HP
CP10: MP

And make the changes to the files I mentioned above in this post to add "Physical" and "Magical" attack buttons.

Hey, SiNaN, How'd I do? I really only copied what you did, lol.

Also, I had to make this change to the code you gave me, SiNaN:

Code: [Select]
if($attacked_id == $ID_MEMBER)
  {
$msg = 'You cannot attack yourself!';
$HP2 = 0;
}

elseif(empty($HP))
{
$msg = 'You cannot attack a dead person!';
$HP2 = 0;
}

Without the "$HP2 = 0;" lines, it would give a syntax error when it looked at the HP-changing DB query without having gotten an $HP2.
Title: Re: Stat Battle Mod
Post by: Marcus Forsberg on September 29, 2008, 03:11:00 PM
Okay.
I seams to be working great, but it only says "Your opponent dodged and took no damage!" every time I attack, so I don't know how it removes HP and all of that. :P

Also, I thought that if your users just keep fighting and fighting each topic will be filled up whit messages, which will Be pretty annoying.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 29, 2008, 03:22:51 PM
The script has been updated to say your name and their name in place of you  and your opponent.

If your stats are too much lower than your opponents, than yes, you'll never hurt them  ;).

Users can only use the attack buttons in threads called PvP threads, and the prupose behind the button is merely to tell the user whether they made a successful attack or not. The users at my site are Role-Players, so by using the attack function to determine whether they hit their opponent or not, they can then write out their action.

Example: Player A uses the attack button, and it says he hits. He writes a post like this:

"Player A draws his trusty pistol and cocks the hammer, firing a shot at the mysterious man in front of him. The bullet tears into his foe's shoulder."

His opponent can respond then by hitting the attack button and seeing what happens, then Posting a response in kind with that.

This goes back and forth until one person gives up or dies, and then the Admin can go back and delete the posts that simply state what hit and missed later, making it much easier to re-read for our other members. And I made a profile called "The Referee" and set his ID to the poster ID so he's the one who makes the posts, so that we can just go back and delete all his posts to clear out the forums.

I can send you the Stat Items I made for the Shop and some basic instructions on how to run it if you'd be interested.
Title: Re: Stat Battle Mod
Post by: Marcus Forsberg on September 29, 2008, 03:26:45 PM
I can send you the Stat Items I made for the Shop and some basic instructions on how to run it if you'd be interested.

Yes, I'm interested :)
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 29, 2008, 03:44:48 PM
Well, then before running those queries, check if the $HP is empty or not. And also, you can send 'type' with url and do them all with just one function.

For example:

For physical => http://yoursite.com/index.php?action=attack;attacked=3;arena=1;country=6;type=physical
For magical => http://yoursite.com/index.php?action=attack;attacked=3;arena=1;country=6;type=magical

Then at the start of your Attack function:

if(!empty($_REQUEST['type']) && in_array($_REQUEST['type'], array('physical', 'magical')))
  $type = $_REQUEST['type'];
else
  fatal_error('Undefined type');

Then you will calculate variables according to that:

if($type == 'magical')
  $variables = a;
else
  $variables = b;

I really don't know how can I help you anymore. If you have specific coding questions, I can answer them if I can.

And Nascar; you can easily limit to a single board and call it the Battle Area.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 29, 2008, 03:50:44 PM
Here you go, I attached the 12 items I have right now with a brief Read Me of what they do.

I'll write up a full explanation on the StatBattle system and how it works, what to do to set it up etc. and post it tomorrow.

Thanks for all your help, SiNaN! The only question I have is how to make it go to an error screen (like the "die(hacking attempt)" one and have it say "you can't attack for whatever reason" instead of actually posting it on the board.
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 29, 2008, 03:59:57 PM
That was an easy question really. :)

In the if, instead of doing

$msg = 'You cannot attack';

do

fatal_error('You cannot attack!', false);
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 29, 2008, 04:05:09 PM
Dude, you really are awesome at this!

If I ever make this into a complete Mod for the Mod site, I'm giving you top billing for the credit:

By SiNaN / Daisuke.

Thanks yet again, and if I ever need anything else I'l post. Thanks!
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 29, 2008, 04:06:38 PM
You're welcome. Glad that I could help you.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 29, 2008, 04:20:30 PM
Update for Nascar:

Please download the attached file, it has an updated version of Potion, Full Heal, and Elixir as well as a Pheonix Down to revive dead players.

The update makes it so dead players cannot use a potion to revive themselves (kind of cheating lol.)
Title: Re: Stat Battle Mod
Post by: matasanos on September 29, 2008, 04:21:04 PM
uhmm!!!

this sound more and more exciting !!!
when we will have a complete mod?? or a stable version? moreless..
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 29, 2008, 04:24:52 PM
The current version os Satble, but there's no mod for it yet lol.

At the moment, the following things are done:

-Stat system
-Stat items
-Auto-Adjusting HP and MP.
-Attack buttons

But there's still a few things I'll need to do before it's really ready to be done:

-Make the function move "dead" people into a non-post based group called "Dead."
-Make a permission so that "Dead" members cannot attack at all.
-Make a restriction somehow so that people cannot attack the same person repeatedly and kill them before an Admin can step in. (They'd get punished obviously, but it'd still suck to have to go back and fix it.)
-Making an edit to some files so that when a member gains enough posts to "level up" by reaching the next highest post group, he'll also get some stat items at random. (Should be easy to code, but I've no idea what files I'd need to edit...)
-Making a few other things just to make things smoother...
Title: Re: Stat Battle Mod
Post by: Marcus Forsberg on September 30, 2008, 01:07:01 AM
This sound really interesting. I'll test everything in a few hours.

And I just thought, couldn't you adjust the mod so that it adds its own profile fields when installed, so that Custom Profile Fields mod doesn't need to be used at all?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 30, 2008, 08:09:39 AM
Probably, but since it isn't yet a mod so much as it is 2 edits and 1 file, I'll have to see about adding that it when it's done.

Also, the Custom Profile Fields mod doesn't work on 1.1.6, so I'll probably just end up integrating that mod's edits into my own mod (As long as thats okay with the mod's maker.)
Title: Re: Stat Battle Mod
Post by: [SiNaN] on September 30, 2008, 09:23:20 AM
Custom Profile Field uses this (http://www.unknownbrackets.com/tutorials/custom-profile) system.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 30, 2008, 09:37:29 AM
Nice, thanks again!

Update:

I added some more checks to the codes (making sure you cannot attack dead people, people with no stats, yourself, if you have no stats, if you're dead) and also I added a chunk that checks to see if your attack killed the enemy, and if it did, to give you posts equal to 1/10th of their posts as a reward. (The stat system uses levels, and posts are the system's EXP. So, you get EXP for killing someone now.)\

Update again:

I'm working on adding Status effects to the Stat battle system, so that players can be poisoned, blind, silenced, etc. Also working on items to heal said status effects or cause them.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 01, 2008, 12:42:38 PM
Okay, now I need help again  :P.

Code: [Select]
<?php

if (!defined('SMF'))
die('Hacking attempt...');

//The Physical attack function.
function Physical()
{
global $db_prefix$sourcedir$ID_MEMBER;

//Find out who attacked who, and where.
$attacked_id = !empty($_REQUEST['attacked']) ? (int) $_REQUEST['attacked'] : 0;
$attacked_topic = !empty($_REQUEST['arena']) ? (int) $_REQUEST['arena'] : 0;
$attacked_board = !empty($_REQUEST['country']) ? (int) $_REQUEST['country'] : 0;

//Get the attacker's Atk value.
$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP3'
&& ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($A) = mysql_fetch_row($request);
mysql_free_result($request);

//Get the defender's Def value.
$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP4'
&& ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($D) = mysql_fetch_row($request);
mysql_free_result($request);

//Get the attacker's Spd value.
$request db_query("
SELECT value
FROM 
{$db_prefix}themes
WHERE variable = 'CP7'
&& ID_MEMBER = 
$ID_MEMBER
LIMIT 1"
__FILE____LINE__);
list ($S) = mysql_fetch_row($request);
mysql_free_result($request);

//Get the defender's R. Spd value.
$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP8'
&& ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($R) = mysql_fetch_row($request);
mysql_free_result($request);

//Get the Defender's HP value.
$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP9'
&& ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($HP) = mysql_fetch_row($request);
mysql_free_result($request);

//Get the attacker's HP value.
$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP9'
&& ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($youHP) = mysql_fetch_row($request);
mysql_free_result($request);

//Get the attacker's name.
$request db_query("
SELECT realname
FROM 
{$db_prefix}members   
WHERE ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($you) = mysql_fetch_row($request);
mysql_free_result($request);

//Get the defender's name.
$request db_query("
SELECT realname
FROM 
{$db_prefix}members   
WHERE ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($them) = mysql_fetch_row($request);
mysql_free_result($request);

//The actual Stat Battle formula.
$N1 mt_rand(110);
$N2 mt_rand(110);
$A1 $N1 $S;
$A2 $A1 $A;
$D1 $N2 $R;
$D2 $D1 $D;

//Can you even hurt anyone?
if(empty($A))
 
{
fatal_error('You have no attack value! Did you really think you could win by attacking for 0?'false);
$HP2 0;
}

//Are you suicidal?
elseif($attacked_id == $ID_MEMBER)
 
{
fatal_error('You cannot attack yourself!'false);
$HP2 0;
}

//Are you killing dead people?
elseif(empty($HP))
{
fatal_error('Either they are dead or have no stats! You cannot attack them!'false);
$HP2 0;
}

//Are you a dead?
elseif(empty($youHP))
{
fatal_error('You cannot attack someone if you are dead!'false);
$HP2 0;
}
//Are you beating the Ref?
elseif($attacked_id == 42)
{
fatal_error('You cannot attack the Referee!'false);
$HP2 0;
}
//Did you Smash them?
elseif ($A1 $D2)
{
$damage $A $A;
$HP2 $HP $damage $HP $damage 0;
$msg '' .($you). ' smashed ' .($them). ' for ' .($damage). ' damage!';
}

//Did you hit them?
elseif ($A2 $D2)
{
$HP2 $HP $A $HP $A 0;
$msg '' .($you). ' attacked ' .($them). ' for ' .($A). ' damage!';
}

//Did they dodge your attack?
elseif ($A2 <= $D1)
{
$msg '' .($them). ' dodged an attack by ' .($you). ' and took no damage!';
}

//Did they block your attack?
elseif ($A2 <= $D2)
{
$DA $A $D $A-$D 0;
$damage $DA 1;
$HP2 $HP $damage $HP $damage 0;
$msg '' .($them). ' blocked an attack by ' .($you). ', taking only ' .($damage). ' damage!';
}

//Do the damage.
db_query("
UPDATE 
{$db_prefix}themes
SET value = 
{$HP2}
WHERE variable = 'CP9' && ID_MEMBER = 
{$attacked_id}"__FILE____LINE__);

//Did you Kill them?
if (empty($HP2))
{
//Get their EXP.
$request db_query("
SELECT posts
FROM 
{$db_prefix}members   
WHERE ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($Exp) = mysql_fetch_row($request);
mysql_free_result($request);

$Exp2 $Exp/10;

round($Exp2);

//Give the winner some EXP.
db_query("
UPDATE 
{$db_prefix}members
SET posts = posts + 
{$Exp2}
WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);

//Did they recieve a Random Item drop?
$lucky mt_rand(30,80);
if($lucky 40 && $lucky 60 && $lucky != 49 && $lucky != 51 && $lucky != 52 && $lucky != 58)
{
db_query("
INSERT INTO 
{$db_prefix}shop_inventory
(ownerid, itemid, amtpaid)
VALUES (
{$ID_MEMBER},
{$lucky},
0)"
, __FILE____LINE__);

$request db_query("
SELECT name
FROM 
{$db_prefix}shop_items   
WHERE id = 
$lucky   
LIMIT 1"
__FILE____LINE__);
list ($item) = mysql_fetch_row($request);
mysql_free_result($request);

$msg2 '' .($msg). ' ' .($you). ' killed ' .($them). '! Congratulations, ' .($you). '! You got ' .($Exp2). ' EXP, and an item dropped! You recieved 1 ' .($item). '!';
}
else
{
$msg2 '' .($msg). ' ' .($you). ' killed ' .($them). '! Congratulations, ' .($you). '! You got ' .($Exp2). ' EXP!';
}
$msgOptions = array(
'id' => 0,
'subject' => 'Physical Attack!',
'body' => $msg2,
'icon' => 'xx',
'smileys_enabled' => 1,
'attachments' => array(),
);
$topicOptions = array(
'id' => $attacked_topic,
'board' => $attacked_board,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => 42,
'update_post_count' => 1,
);
}
//If they're still alive...
Else
{
$msgOptions = array(
'id' => 0,
'subject' => 'Physical Attack!',
'body' => $msg,
'icon' => 'xx',
'smileys_enabled' => 1,
'attachments' => array(),
);
$topicOptions = array(
'id' => $attacked_topic,
'board' => $attacked_board,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => 42,
'update_post_count' => 1,
);
}

require_once($sourcedir '/Subs-Post.php');
createPost($msgOptions$topicOptions$posterOptions);

redirectexit('topic=' $attacked_topic);
}



//Same as Physical, except for the reducing MP and checking MP parts.
function Magical()
{
global $db_prefix$sourcedir$ID_MEMBER;

$attacked_id = !empty($_REQUEST['attacked']) ? (int) $_REQUEST['attacked'] : 0;
$attacked_topic = !empty($_REQUEST['arena']) ? (int) $_REQUEST['arena'] : 0;
$attacked_board = !empty($_REQUEST['country']) ? (int) $_REQUEST['country'] : 0;

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP5'
&& ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($A) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP6'
&& ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($D) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes
WHERE variable = 'CP7'
&& ID_MEMBER = 
$ID_MEMBER
LIMIT 1"
__FILE____LINE__);
list ($S) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP8'
&& ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($R) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP9'
&& ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($HP) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP9'
&& ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($youHP) = mysql_fetch_row($request);
mysql_free_result($request);

//Get the attacker's MP Value.
$request db_query("
SELECT value
FROM 
{$db_prefix}themes   
WHERE variable = 'CP10'
&& ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($MP) = mysql_fetch_row($request);
mysql_free_result($request);

$request db_query("
SELECT realname
FROM 
{$db_prefix}members   
WHERE ID_MEMBER = 
$ID_MEMBER   
LIMIT 1"
__FILE____LINE__);
list ($you) = mysql_fetch_row($request);
mysql_free_result($request);


$request db_query("
SELECT realname
FROM 
{$db_prefix}members   
WHERE ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($them) = mysql_fetch_row($request);
mysql_free_result($request);

$N1 mt_rand(110);
$N2 mt_rand(110);
$A1 $N1 $S;
$A2 $A1 $A;
$D1 $N2 $R;
$D2 $D1 $D;
$MP2 $MP $A $MP $A 0

if(empty($A))
 
{
fatal_error('You have no Magic attack value! Did you really think you could win by attacking for 0?'false);
$HP2 0;
}

//No Mp? No attack.
elseif ($MP $A)
{
fatal_error('You do not have enough MP! Magic attacks are not free, you know.'false);
$HP2 0;
}
elseif($attacked_id == $ID_MEMBER)
 
{
fatal_error('You cannot attack yourself!'false);
$HP2 0;
}

elseif(empty($HP))
{
fatal_error('You cannot attack a dead person!'false);
$HP2 0;
}
elseif(empty($youHP))
{
fatal_error('You cannot attack someone if you are dead!'false);
$HP2 0;
}
//Are you beating the Ref?
elseif($attacked_id == 42)
{
fatal_error('You cannot attack the Referee!'false);
$HP2 0;
}
elseif ($A1 $D2)
{
$damage $A $A;
$HP2 $HP $damage $HP $damage 0;
$msg '' .($you). ' blasted ' .($them). ' for ' .($damage). ' damage!';
}
elseif ($A2 $D2)
{
$HP2 $HP $A $HP $A 0;
$msg '' .($you). ' attacked ' .($them). ' using Magic for ' .($A). ' damage!';
}
elseif ($A2 <= $D1)
{
$msg '' .($them). ' dodged a Magic attack from ' .($you). ' and took no damage!';
}
elseif ($A2 <= $D2)
{
$DA $A $D $A $D 0;
$damage $DA 1;
$HP2 $HP $damage $HP $damage 0;
$msg '' .($them). ' blocked a Magic attack from ' .($you). ', taking only ' .($damage). ' damage!';
}


db_query("
UPDATE 
{$db_prefix}themes
SET value = 
{$HP2}
WHERE variable = 'CP9' && ID_MEMBER = 
{$attacked_id}"__FILE____LINE__);

//Pay for the spell.
db_query("
UPDATE 
{$db_prefix}themes
SET value = 
{$MP2}
WHERE variable = 'CP10' && ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);

//Did you Kill them?
if (empty($HP2))
{
//Get their EXP.
$request db_query("
SELECT posts
FROM 
{$db_prefix}members   
WHERE ID_MEMBER = 
$attacked_id   
LIMIT 1"
__FILE____LINE__);
list ($Exp) = mysql_fetch_row($request);
mysql_free_result($request);

$Exp2 $Exp/10;

round($Exp2);

//Give the winner some EXP.
db_query("
UPDATE 
{$db_prefix}members
SET posts = posts + 
{$Exp2}
WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);

//Did they recieve a Random Item drop?
$lucky mt_rand(30,80);
if($lucky 40 && $lucky 60 && $lucky != 49 && $lucky != 51 && $lucky != 52 && $lucky != 58)
{
db_query("
INSERT INTO 
{$db_prefix}shop_inventory
(ownerid, itemid, amtpaid)
VALUES (
{$ID_MEMBER},
{$lucky},
0)"
, __FILE____LINE__);

$request db_query("
SELECT name
FROM 
{$db_prefix}shop_items   
WHERE id = 
$lucky   
LIMIT 1"
__FILE____LINE__);
list ($item) = mysql_fetch_row($request);
mysql_free_result($request);

$msg2 '' .($msg). ' ' .($you). ' killed ' .($them). '! Congratulations, ' .($you). '! You got ' .($Exp2). ' EXP, and an item dropped! You recieved 1 ' .($item). '!';
}

else
{
$msg2 '' .($msg). ' ' .($you). ' killed ' .($them). '! Congratulations, ' .($you). '! You got ' .($Exp2). ' EXP!';
}
$msgOptions = array(
'id' => 0,
'subject' => 'Physical Attack!',
'body' => $msg2,
'icon' => 'xx',
'smileys_enabled' => 1,
'attachments' => array(),
);
$topicOptions = array(
'id' => $attacked_topic,
'board' => $attacked_board,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => 42,
'update_post_count' => 1,
);
}
Else
{
$msgOptions = array(
'id' => 0,
'subject' => 'Physical Attack!',
'body' => $msg,
'icon' => 'xx',
'smileys_enabled' => 1,
'attachments' => array(),
);
$topicOptions = array(
'id' => $attacked_topic,
'board' => $attacked_board,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => 42,
'update_post_count' => 1,
);
}

require_once($sourcedir '/Subs-Post.php');
createPost($msgOptions$topicOptions$posterOptions);

redirectexit('topic=' $attacked_topic);
}

?>

Everything works fine, except one of my members gets an error when he tries to attack me:

Database Error
Please try again. If you come back to this error screen, report the error to an administrator.

I have no idea why though, other people can attack me and they can all attack each other. Any ideas?

Also, SiNaN, I'm not exactly sure how to make this into one function  :P sorry I'm not that good at this.

Also, the Round function isn't working for some reason.
Title: Re: Stat Battle Mod
Post by: [SiNaN] on October 01, 2008, 07:12:09 PM
Add this line to your Settings.php:

$db_show_debug = true;

Then you will be able to see the whole query causing error on the error page.

When you complete it, I can make it doing them with one function for you.

Instead of just round($var); you should make $var = round($var); to make it rounded.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 02, 2008, 08:36:13 AM
Thanks a bunch, SiNaN. It'll probably take me about a week to finish it though (I'm adding weapons and stat effects, spells, etc. stuff like that. It's all going to be "if" codes that check for the status effect / weapon and then carry out whatever the stat effect / weapon does.)

I'll post again if I need more help or when it's done.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 02, 2008, 12:36:49 PM
Ok, my letters got big again. I tried changing the names of the buttons, and they got huge and my avatar pic is now an x. I changed them back, but somethign must be wrong, as it isn't fixed... Attached the 2 files I edited, any idea why it got messed up?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 02, 2008, 02:31:12 PM
Also I can't log in... no one can... strange...?

Edit: Also, I get these errors at the top of the page:

Code: [Select]
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/daisuke/public_html/forum/index.php:3) in /home/daisuke/public_html/forum/Sources/Load.php on line 1981

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/daisuke/public_html/forum/index.php:3) in /home/daisuke/public_html/forum/Sources/Load.php on line 1981

Warning: Cannot modify header information - headers already sent by (output started at /home/daisuke/public_html/forum/index.php:3) in /home/daisuke/public_html/forum/Sources/Load.php on line 1985

Warning: Cannot modify header information - headers already sent by (output started at /home/daisuke/public_html/forum/index.php:3) in /home/daisuke/public_html/forum/Sources/Subs.php on line 3365

Warning: Cannot modify header information - headers already sent by (output started at /home/daisuke/public_html/forum/index.php:3) in /home/daisuke/public_html/forum/Sources/Subs.php on line 3366

Warning: Cannot modify header information - headers already sent by (output started at /home/daisuke/public_html/forum/index.php:3) in /home/daisuke/public_html/forum/Sources/Subs.php on line 3372

Warning: Cannot modify header information - headers already sent by (output started at /home/daisuke/public_html/forum/index.php:3) in /home/daisuke/public_html/forum/Sources/Subs.php on line 3375
Title: Re: Stat Battle Mod
Post by: [SiNaN] on October 02, 2008, 07:19:21 PM
Use the attached index.php file.

You had some bad HTML codes at the start of the file.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 03, 2008, 08:05:34 AM
You save me yet again, SiNaN. Thanks very much!

Update: I've begun adding Status effects to the Statbattle.php. Once everything is done i'll make some more Shop items to deal with them and post the updates in a .zip file.
Title: Re: Stat Battle Mod
Post by: Marcus Forsberg on October 03, 2008, 10:06:56 AM
It seams to be a lot of updates to this.
I'll est everything propably when the first stable version is done.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 03, 2008, 11:01:53 AM
Yes, i'd say wait until the whole thing is done because I keep making changes to everything  :P
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 07, 2008, 11:14:41 AM
Hey SiNaN, Q:

Is there a way to change the "return" function in my Statbattle code so that it returns to the post rather then the topic? Or at least the page? People are getting frustrated with having to go back to the last page of the thread after an attack.
Title: Re: Stat Battle Mod
Post by: [SiNaN] on October 08, 2008, 09:26:11 AM
To the attack link in Display.template.php, add this

field=', $message['id'], ';

So it should look like this:

         echo '<a href="', $scripturl, '?action=attack;attacked=', $message['member']['id'], ';country=', $context['current_board'], ';arena=', $context['current_topic'], ';field=', $message['id'], ';sesc=', $context['session_id'], '">[Attack]</a><br />';

Then in your StatBattle.php

Find:

Code: [Select]
$attacked_topic = !empty($_REQUEST['arena']) ? (int) $_REQUEST['arena'] : 0;
Replace:

Code: [Select]
$attacked_topic = !empty($_REQUEST['arena']) ? (int) $_REQUEST['arena'] : 0;
$attacked_message = !empty($_REQUEST['field']) ? (int) $_REQUEST['field'] : 0;

Find:

Code: [Select]
redirectexit('topic=' . $attacked_topic);
Replace:

Code: [Select]
redirectexit('topic=' . $attacked_topic . '.msg' . $attacked_message . '#msg' . $attacked_message);
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 08, 2008, 12:38:53 PM
Sweet, thanks. Okay one more for ya:

I want people to get a PM every time they "level up" (they reach the next-highest post-based group). However, I have no idea what files to mod or how to mod them. I assume there must be a file / files that take care of things like this...?
Title: Re: Stat Battle Mod
Post by: [SiNaN] on October 08, 2008, 01:02:55 PM
Well, not sure how they *level up* but after including Subs-Post.php, you can use these codes:

Code: [Select]
if('USER_LEVEL_UP')
{
$recipients = array(
'to' => array('ID_OF_USER_TO_SEND'),
'bcc' => array(),
);
$from = array(
'id' => 0,
'name' => 'StatBattle Guy',
'username' => 'Notifier',
);
sendpm($recipients, 'Level Up', 'Your level is up. :P', false, $from);
}
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 08, 2008, 01:59:08 PM
They "level up" when they reached a post-based group's number of posts. I.e. Level 1 is 0, level 2 is 25. So when they make their 25th post or somehow get their post total over 25, they "level up" and they get moved onto the next post-based membergroup.
Title: Re: Stat Battle Mod
Post by: [SiNaN] on October 08, 2008, 03:29:52 PM
I, unfortunately, don't know an easy way of doing it. You can check the updateSettings() function in Subs.php if you like.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 14, 2008, 09:58:06 AM
Well I'm pretty sure it has to be done here somewhere:

Code: [Select]
case 'postgroups':
// Parameter two is the updated columns: we should check to see if we base groups off any of these.
if ($parameter2 !== null && !in_array('posts', $parameter2))
return;

if (($postgroups = cache_get_data('updateStats:postgroups', 360)) == null)
{
// Fetch the postgroups!
$request = db_query("
SELECT ID_GROUP, minPosts
FROM {$db_prefix}membergroups
WHERE minPosts != -1", __FILE__, __LINE__);
$postgroups = array();
while ($row = mysql_fetch_assoc($request))
$postgroups[$row['ID_GROUP']] = $row['minPosts'];
mysql_free_result($request);

// Sort them this way because if it's done with MySQL it causes a filesort :(.
arsort($postgroups);

cache_put_data('updateStats:postgroups', $postgroups, 360);
}

// Oh great, they've screwed their post groups.
if (empty($postgroups))
return;

// Set all membergroups from most posts to least posts.
$conditions = '';
foreach ($postgroups as $id => $minPosts)
{
$conditions .= '
WHEN posts >= ' . $minPosts . (!empty($lastMin) ? ' AND posts <= ' . $lastMin : '') . ' THEN ' . $id;
$lastMin = $minPosts;
}

// A big fat CASE WHEN... END is faster than a zillion UPDATE's ;).
db_query("
UPDATE {$db_prefix}members
SET ID_POST_GROUP = CASE$conditions
ELSE 0
END" . ($parameter1 != null ? "
WHERE $parameter1" : ''), __FILE__, __LINE__);
break;

default:
trigger_error('updateStats(): Invalid statistic type \'' . $type . '\'', E_USER_NOTICE);

But i've no idea how...
Title: Re: Stat Battle Mod
Post by: marchingelite2 on October 21, 2008, 07:42:28 AM
any idea when this mod will be finished? it looks really really interesting and is it going to be an intergration to the smf shop same as pets? o and 1 more thing will it be available for 1.1.6?

cant wait!! lol
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 24, 2008, 08:15:32 AM
There's no real reason it can't work with 1.1.6. My forum is 1.1.4 upgraded to 1.1.6 though, so I don't really know.

I only had to edit 3 files so far, so manual edits will be quick and easy for those at least.

And I'm still working the bugs out lol. Speaking of which,

SiNaN: For some reason, I often get errors when trying to attack someone or when someone attacks me, but only me. I think it's because my ID# is 1... any ideas?
Title: Re: Stat Battle Mod
Post by: [SiNaN] on October 24, 2008, 11:28:03 AM
What are the errors?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 27, 2008, 02:10:50 PM
Ok, nevermind, it was just a few typo's on my part  :P.

Everything works fine as of now, and can be seen at:

www.daisukesdojo.web44.net

I'll put up some screen shots after I add all the equipment.
Title: Re: Stat Battle Mod
Post by: Marcus Forsberg on November 01, 2008, 06:19:20 AM
Let me know when I can test it ;)
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on November 01, 2008, 08:40:02 PM
No problem, I'll post when I stop getting errors (Almost all from typo's on my part.)
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on November 05, 2008, 03:41:38 PM
A few pics of the system in action:

Pic 1 is a battle between me and the member Salene. Notice the stats appear on the left as well as the Attack and Cast Magic buttons.

Pic 2 is the Equipment items in the shop, like Swords, Gloves, Boots, etc.

Pic 3 is the Stats as seen in a player's profile. It even includes a field to track who the member is battling, as well as fields for things like poison, Blind, etc.
Title: Re: Stat Battle Mod
Post by: SA™ on November 11, 2008, 06:33:40 PM
wow that looks pretty neat good job there are you going to release it ?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on November 12, 2008, 09:36:07 AM
Once I finish the few glitches that keep occuring, I'll release it with instructions on how to use it.
Title: Re: Stat Battle Mod
Post by: Feyd on November 12, 2008, 01:54:36 PM
It's really great!

I'm looking forward to it :)
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on November 20, 2008, 02:15:10 PM
Update: Added a Sell feature to the SMF shop, allowing members to sell unwanted / useless items (aka weapons that are weaker than their newer ones, spare items, etc.)

Working now on a Forge system, allowing members to combine items to make new items / equipment. Sorry, please be patient!
Title: Re: Stat Battle Mod
Post by: Marcus Forsberg on November 21, 2008, 04:37:28 AM
This will be a very good mod.
But still, it would be even better if you made it separete from SMF Shop and CUstpm profile fields mod.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on November 21, 2008, 08:34:00 AM
Custom Proifle fields I can add into the mod and it'll work the same.

Smf shop is kinds a big part of it though. Unless I made a whole new shop system... But that sounds like way too much work that I don'y have time or knowledge for.

Oh, but SMF shop doesn't work for the new 1.1.7, does it?
Title: Re: Stat Battle Mod
Post by: Aruta2001 on November 27, 2008, 09:44:42 AM
Oh, but SMF shop doesn't work for the new 1.1.7, does it?

Works for me.  :)

No problem for me that its depenend on the shop mod..
But then again.. I REALLY want the battle stats mod! :D
Title: Re: Stat Battle Mod
Post by: Succubus Evaligan on December 09, 2008, 04:48:05 AM
I want know more about this mod.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on December 09, 2008, 08:25:19 AM
Ok, more stuff is bieng worked on and added, including:

-A tab for the stat system.
-A "Statistics" section that shows your wins, losses, etc.
-An "Upgrade" section, allowing you to upgrade your stats to become stronger.
-A "Gauntlet" section, allowing members to fight until they lose, getting better rewards the longer they can last.
-An "Inn", which allows people to rest and restore their character to full health / MP for a price.
-An "Explore" function, allowing members to go explore, looking for treasure, fighting enemies, and running into other characters.
A "Boss" function, allowing members to unlock and defeat bosses for great rewards.

And possibly a training section so Admin no longer have to do it. For a full description of the mod, simply PM me at the Dojo (http://www.daisukesdojo.web44.net) and I'll fill you in, and once I have a full description I like i'll post it up.
Title: Re: Stat Battle Mod
Post by: Anviss on December 15, 2008, 01:34:04 PM
To: Daisuke_aurora
Hi. Could you put fashion in Attacements or provide a link for downloading?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on December 15, 2008, 02:27:36 PM
I'm sorry, I didn't quite understand that.

The mod is still not ready (sorry, been busy and little time to code.)
Title: Re: Stat Battle Mod
Post by: CoreDuo07 on January 04, 2009, 02:25:23 PM
Any news on this? :)
Title: Re: Stat Battle Mod
Post by: hash899 on January 06, 2009, 12:45:07 PM
can u give us a date when we might be able to beta test it or something.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on January 09, 2009, 04:10:40 AM
The test is already ongoing at daisukesdojo.web44.net and seems to be working okay. I wish I had more time to work on it though... I'll try and keep it updated with dates and as I finish things.
Title: Re: Stat Battle Mod
Post by: Avery on January 11, 2009, 04:36:09 AM
When will this mod be out for us to download? This mod seems really interesting!  :D
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on January 12, 2009, 02:49:18 AM
To be honest, I have no idea when it will be out. I work when I have the time to, so hopefully i'll have alot of free time coming up!
Title: Re: Stat Battle Mod
Post by: TaikiSan on January 12, 2009, 06:05:39 AM
(first of all, sorry for my english xD )

omg! This is the mod im looking for O_O I want to create a role game in my forum, and this mod is PERFECT! Great work Daisuke_aurora! I hope you release the final mod soon *-*

Thanks for all your work!
Title: Re: Stat Battle Mod
Post by: Navubi on January 30, 2009, 06:12:14 PM
I remember several forums back in the day when I started getting into message boards having similar mods like this. If you can pull this off, I am sure you will be a hero to many lol. Best of luck buddy!
Title: Re: Stat Battle Mod
Post by: fords8 on February 01, 2009, 01:44:13 AM
Want to keep a eye on this. I hope a release will be soon. You just planning for a 1.1.7 release? Or will there be one for 2.0 Beta 4 also? Nice work Daisuke_aurora!
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on February 01, 2009, 10:42:07 PM
The release will be for 1.1.7 when it comes.


Seeing as how it'll take a while for the Entire thing to be up, I'm thinking of uploading the one on my site now for others to use and just updating it later...
Title: Re: Stat Battle Mod
Post by: fords8 on February 02, 2009, 03:57:59 PM
Well RC1 will out very soon. Maybe a update for that instead of 2.0 Beta 4.
Title: Re: Stat Battle Mod
Post by: okapi on March 18, 2009, 06:25:08 PM
any news?
Title: Re: Stat Battle Mod
Post by: heinandar on March 18, 2009, 08:24:31 PM
where can i download stat battle mod?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on March 18, 2009, 08:46:07 PM
It is not done yet. I am actually still testing out the system on my site.
Title: Re: Stat Battle Mod
Post by: heinandar on March 19, 2009, 12:04:53 AM
It is not done yet. I am actually still testing out the system on my site.
Thanks for reply. I'm still waiting ur mod. Good luck
Title: Re: Stat Battle Mod
Post by: gman123 on May 21, 2009, 06:34:21 PM
Any chance there will be screen shots?
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 06, 2009, 04:24:42 AM
Sorry I've been on a kind of hiatus for a while now, but I'm back and have finished coding the system. I set up a test on my site and once I've confirmed that all the bugs are dealt with I'll be releasing it as a package for the newest version of SMF.
Title: Re: Stat Battle Mod
Post by: chinaren on September 23, 2009, 09:22:18 AM
Ooh, this sounds cool. 

~sits and waits~
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on September 24, 2009, 01:10:49 AM
I may need someone to help me write it into an actual package to be installed, otherwise i'll have to tell people how to manually do alot of stuff which will be unpleasant for those who want it.
Title: Re: Stat Battle Mod
Post by: die() on September 24, 2009, 01:16:11 AM
i can help you if you wanted pm me if you want
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on October 21, 2009, 08:11:32 AM
Ok, so after quite a while, I am finally on the verge of finishing this project. I have the entire thing up and working, including random encounters, stats and weapons that modify them, items, spells, levels and Stat upgrades, the whole thing. By the 24th I hope to have it all installed and working and will be testing it for any bugs or glitches that may occur. If anyone would like to, they can go to the site and try it out with everyone else to see what you think:

Daisuke's Dojo (http://www.daisukesdojo.web44.net)

And either way it'll be one step away from bieng available as a full-fledged package. All I will need to do after that is make it a simple-to-install package.
Title: Re: Stat Battle Mod
Post by: chinaren on October 21, 2009, 08:28:02 AM
Woooo!  8)


Now, stop reading this and get on with it!  ;)
Title: Re: Stat Battle Mod
Post by: chedie on January 20, 2010, 04:04:45 AM
Ahm... So I am wondering... is this mod finished. LOL

I'm really wanting a mod like this for SMF and would like to use it in our SMF forum. Is there a download area for this mod? I can't seem to find it.

Hope to have a reply soon! :D
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on January 27, 2010, 03:07:52 AM
Funny story. I keep adding more and more to the system.

I can probably make the edits for any person's site for them, just reply here and I'll set you up with what I have so far.
Title: Re: Stat Battle Mod
Post by: CKWT on May 01, 2010, 05:28:01 PM
Dont worry, Post the instructions we'll get it installed.. I can Bet you that with the code in the air, someone WILL package it really nicely
Title: Re: Stat Battle Mod
Post by: chinaren on May 01, 2010, 08:14:11 PM
Yes, please post the code!  ::)
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on July 07, 2010, 04:59:58 AM
Said it before and I'll say it again, still working on it. Good news is I have a computer now that works and will be releasing a small version of the whole thing soon, allowing players to try out the system and get to know the designs.
Title: Re: Stat Battle Mod
Post by: chinaren on July 07, 2010, 05:05:31 AM
Awesome! 


Now, the only thing is, since I first started waiting for this mod, I've upgraded my board to SMF2RC3.  Will your prototype work with this version?

Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on July 07, 2010, 08:52:04 AM
well the 3 things you will need are the files I made myself, the smf shop mod (which I believe a few people around here have said it is easy to add to any of the smf versions) and a few edits to a few already existing files (again, which I can post codes and instructions or a more skilled person can package the edits as an installer) so it should work fine it might just take a little longer while we wait for one of the mods or a more talented user to help with that part.
Title: Re: Stat Battle Mod
Post by: Citizen Erased on August 03, 2010, 09:18:49 AM
Can you post the files you made, and the modifications to other files, at least?

You can put your work as a "Hack" instead as a "Mod" and maybe someone could make a package for you.

I could try, but I'm newbie =\
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on August 10, 2010, 02:03:15 AM
Yes I can probably do that before this gets packaged for the people who don't want to wait. I am simply cleaning up the codes and checking for interactions that are bad / harmful or that can be utilized to break the system I have designed, you know, glitches and such.
Title: Re: Stat Battle Mod
Post by: honeywick on June 06, 2011, 10:34:34 AM
anything yet call this a official bump
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on June 21, 2011, 01:29:20 PM
I decided to call the game "Reflections" on my site. These are a few screens of it in action.

As of now, you can explore the area to engage in fights and events that develop the story further, or jump in the gauntlet to fight increasingly tougher enemies. there is also an Inn to heal at, a section to upgrade your stats, a special section for specifc boss fights that you can unlock in explore mode, and a stats board to track what you've done during fights against other players. Also, there is a large inventory in the shop and hidden shops with increasingly better items can be found in explore mode.

Skills and abilities are in the works, and Magic and Items can be used in combat, as well as PvP.

I've been pretty busy these past months, but I plan to keep working on this and post updates when I can.
Title: Re: Stat Battle Mod
Post by: chinaren on June 21, 2011, 06:52:21 PM
Oooooh!  I like! 


One question: Would it be possible to edit the 'map' with your own descriptions?  Also I have the SA shop, would it work with that, or would I have to reinstall the SMF shop?  (Which I'm thinking of doing anyway).
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on June 22, 2011, 01:18:50 AM
I can make it work with any version of the shop, and and as far as the storyline / descriptions of the maps and enemies, it can all be changed around. Equipment and skills / abilities can all be edited to your liking. I'm currently contemplating whether or not to make multiple playable characters, like allies, to help you fight enemies, and whether or not to make them automated or controllable in combat if I do.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on August 18, 2011, 02:08:55 AM
UPDATE: Explore mode has been cleaned up and worked on, now featuring life bars, map of the area, and arrows instead of text links where applicable.

Also, a Challenge mode has been completed, allowing members to challenge each other at any time in any place. challenging a member sends them a PM, in which they can accept the duel to open a thread automatically in the arena. It will choose which fighter goes first and then members can fight each other.

And finally for now, a "Sell" feature has been created for the SMFshop, allowing members to sell back their purchased goods for half of the value that was paid for it, and a "Forge" feature has been made, allowing members to combine items into more powerful or more useful ones.

Sorry it is taking so long, but I have gotten free time only recently and have spent the last few nights working on the system. Also I switched to a paid host, and the new dojo was just recently put up.
Title: Re: Stat Battle Mod
Post by: Masrit on October 20, 2011, 01:08:06 PM
This is very interesting. I am really looking forward to testing this out.
For the explore, will there be a way to edit it to how you want to put it. Like if you want you own story line to go in. And as well as quests or things like that.

Edit. Just noticed someone else asked that. That would be cool. Is there anyway for a quick download or someway that I can be a tester. I have a little experience in php, not too much though.
Your doing an awesome job. Wish I could help.
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on February 03, 2012, 11:25:49 AM
My next idea is to make an Admin section that lets you input a few basic things (Dialogue on the screen, which directions you can move in, the area's location, events, etc.) and then have it generate a map square for that specific input, allowing a person to create an entire map complete with encounters, events and whatnot in a relatively shorter time.
Title: Re: Stat Battle Mod
Post by: KingNFM on February 28, 2012, 05:54:36 PM
I'm optimistic seeing that you're latest post was this month and this year....

Any news?  I recently converted over to SMF again after being away a few years.  I'd love to add this to my site.

Thanks!
Title: Re: Stat Battle Mod
Post by: Daisuke_aurora on May 21, 2012, 11:04:31 AM
About to put the mod into testing phase, probably in mid to late June. The site is up right now, and the mod seems to be working fine, in about a week I'll pull the forum out of maintainence mode and people can come sign up and try it out.

As of right now, assuming the testing goes well, I would spend most of june making an admin section for the RPG mod, allowing you to easily configure the game, enemies, locations / maps, and bosses. The shop already handles the inventory and currency parts nicely, so i'll leave those in the shop admin.
Title: Re: Stat Battle / RPG Mod
Post by: avguste on June 15, 2012, 11:34:23 PM
This sounds great. Any ETA on when the mod will be available for download?