Stat Battle / RPG Mod

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

Previous topic - Next topic

[SiNaN]

Use the attached index.php file.

You had some bad HTML codes at the start of the file.
Former SMF Core Developer | My Mods | SimplePortal

Daisuke_aurora

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.

Marcus Forsberg

It seams to be a lot of updates to this.
I'll est everything propably when the first stable version is done.

Daisuke_aurora

Yes, i'd say wait until the whole thing is done because I keep making changes to everything  :P

Daisuke_aurora

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.

[SiNaN]

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:

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

Replace:

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


Find:

redirectexit('topic=' . $attacked_topic);

Replace:

redirectexit('topic=' . $attacked_topic . '.msg' . $attacked_message . '#msg' . $attacked_message);
Former SMF Core Developer | My Mods | SimplePortal

Daisuke_aurora

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

[SiNaN]

Well, not sure how they *level up* but after including Subs-Post.php, you can use these codes:

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);
}
Former SMF Core Developer | My Mods | SimplePortal

Daisuke_aurora

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.

[SiNaN]

I, unfortunately, don't know an easy way of doing it. You can check the updateSettings() function in Subs.php if you like.
Former SMF Core Developer | My Mods | SimplePortal

Daisuke_aurora

Well I'm pretty sure it has to be done here somewhere:

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

marchingelite2

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

Daisuke_aurora

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?

[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

Daisuke_aurora

#74
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.

Marcus Forsberg

Let me know when I can test it ;)

Daisuke_aurora

No problem, I'll post when I stop getting errors (Almost all from typo's on my part.)

Daisuke_aurora

#77
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.

SA™

wow that looks pretty neat good job there are you going to release it ?
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Daisuke_aurora

Once I finish the few glitches that keep occuring, I'll release it with instructions on how to use it.

Advertisement: