News:

Wondering if this will always be free?  See why free is better.

Main Menu

Stat Battle / RPG Mod

Started by Daisuke_aurora, September 04, 2008, 11:56:08 AM

Previous topic - Next topic

Daisuke_aurora

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'),

Daisuke_aurora

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

[SiNaN]

Quote from: Daisuke_aurora on September 11, 2008, 03:43:13 PM
I got this error when I did that:

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

Quote from: 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

When does it get bigger? When you take the change back in index.php, does it show as usual?
Former SMF Core Developer | My Mods | SimplePortal

Daisuke_aurora

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.

Daisuke_aurora

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.

Daisuke_aurora

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.

Daisuke_aurora


[SiNaN]

Use createPost() function to create post.

Send the topic id with url and after doing all that, use redirectindex() 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);
Former SMF Core Developer | My Mods | SimplePortal

Daisuke_aurora

Like this?:

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.

[SiNaN]

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.
Former SMF Core Developer | My Mods | SimplePortal

Daisuke_aurora

#30
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:

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

If ($A1 > $D2)
{
                        <CODE HERE>
}


or something like that?

Daisuke_aurora

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?

[SiNaN]

Take all the changes back.

../index.php

Find:

'announce' => array('Post.php', 'AnnounceTopic'),

Replace:

'announce' => array('Post.php', 'AnnounceTopic'),
'attack' => array('StatBattle.php', 'Attack'),


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

Find:

// Show online and offline buttons?

Replace:

// 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.
Former SMF Core Developer | My Mods | SimplePortal

Daisuke_aurora

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.

Marcus Forsberg

I tested this on my forum and it works pretty godd :)

Daisuke_aurora

You did? You put in the custom profile mod and everything?

Daisuke_aurora

Okay, nest question:

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

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


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



//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.

[SiNaN]

#37
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.';

QuoteIf 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?
Former SMF Core Developer | My Mods | SimplePortal

Marcus Forsberg

#38
Quote from: Daisuke_aurora on September 28, 2008, 05:31:19 AM
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?

Daisuke_aurora

#39
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:


'physicalattack' => array('StatBattle.php', 'Physical'),
'magicalattack' => array('StatBattle.php', 'Magical'),


And to display.template.php:

// 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:

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.

Advertisement: