WebDev

SMF Modifications => General Code/Script Inquiries => Topic started by: Fog on July 10, 2013, 10:14:27 PM

Title: Battle Mod
Post by: Fog on July 10, 2013, 10:14:27 PM
I'm looking for help with the Battle Mod Game that SA and Andrew put together.

I'm not certain if anyone here has ever played the Battle Game so I'm not sure where to begin.

You Battle Monsters with certain attack and def along with health.

As you battle these monsters you gain experience and as you gain experience you can level up.

When you are setting up a monster you can add what level you want it to enter at...

For Example:

You have a weaker monster at level one than you do at level 250.

However you will continue to see those lower level monsters when you get into the upper levels.

And sometime those upper level monsters can still attack you even if you haven't reached their level yet.

So here's what I'm looking to do...

Instead of one input box for the level you want for a monster

Create two input boxes for the lowest level you want the monster to show up and the highest level you want to see the monster.

A Min/Max type of function.


I'll provide screen shot of the admin control panel for editing a monster....

In my case I've converted the monsters into WWII Tanks...

(http://www.ngsforums.com/forums/images/BattleSS.jpg)

I can provide additional info if requested.

Thanks for any help...I've done lots of PHP code changes with SMF before and had a fix for Simple Portal and their blocks.
Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 12:09:34 AM
Fog,

  Imo first you need to edit the language from monster to enemy to make it more appropriate for tanks. 

  So you wish to add a second input box beside the one you have pointed at for a max value and have it save that integer to the data base. Then for the game itself, if the user has a rated power level greater then the max value you want the enemy not to attack?

  I would prefer if the code you need edited was posted so I can show you examples of what needs to be done. Are you able to gather the bits of code from the templates and source files of this mod and post it? I do not mean all of the files but just the area of codes that need to be edited.
ie.

  Without this information you are asking me to install and peruse the mod whereas the mod author would know best. Has SA given up on its development and support?
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 01:31:40 AM
I'm going to start with this one...Battle.Admin.php


<?php



if (!defined('SMF'))

die('Hacking attempt...');



function 
battleAdmin() { 



global $context$sourcedir$txt;



//require_once($sourcedir . '/ManageServer.php');



    
//Set title and default sub-action.

loadTemplate('Battle_Admin');

//Load the language strings

loadLanguage('Battle');

//Are you allowed to administrate Battle?

isAllowedTo('admin_battle');

    
$context['page_title'] = $txt['battle_adminmmc'];



$context[$context['admin_menu_name']]['tab_data']['title'] = $txt['battle_adminmm'];

$context[$context['admin_menu_name']]['tab_data']['description'] = $txt['battle_adminmmd'];



$subActions = array(

    'main' => 'battle_main',

'config' => 'battle_settings',

'shop' => 'battle_shop',

'add_item' => 'battle_shop_add_edit',

'edit_item' => 'battle_shop_add_edit',

'save_item' => 'battle_shop_add_edit',

'shop_del' => 'battle_shop_item_delete',

'bmem' => 'battle_members',

'monsterlist' => 'battle_monsterlist',

'editm' => 'battle_monster',

'monster' => 'battle_monster',

'savemonster' => 'battle_monster',

'del' => 'battle_monster_delete',

'quest_edit' => 'battle_quest_add_edit',

        
'quest_save' => 'battle_quest_add_edit',

        
'quest_add' => 'battle_quest_add_edit',

'quest' => 'battle_quest',

'quest_del' => 'battle_quest_delete',

        
'custom' => 'battle_custom',

        
'custom_del' => 'battle_cust_delete',

        
'custom_edit' => 'battle_cust_add_edit',

        
'custom_save' => 'battle_cust_add_edit',

        
'custom_add' => 'battle_cust_add_edit',

        
'maintain' => 'battle_maintain',

        
'reset' => 'battle_reset',

        
'dshout' => 'battle_reset_shouts',

        
'dhist' => 'battle_reset_hist',



);



$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'main';

$subActions[$_REQUEST['sa']]();



}



function 
battle_main()

{

}



function 
battle_maintain()

{

global 
$txt$context;

$context['sub_template'] = 'maintain';

$context['page_title'] = $txt['battle_tabaman'];



}



function 
battle_reset_hist() 

{

global  
$smcFunc;



$smcFunc['db_query']('''

TRUNCATE {db_prefix}battle_history'
,

array());



redirectexit('action=admin;area=battle;sa=maintain;dhist=done');

}



function 
battle_reset_shouts() 

{

global  
$smcFunc;



$smcFunc['db_query']('''

TRUNCATE {db_prefix}battle_shouts'
,

array());

   

redirectexit('action=admin;area=battle;sa=maintain;dshout=done');



}



function 
battle_reset()

{

global 
$db_prefix$modSettings$txt$sourcedir$smcFunc;



$smcFunc['db_query']('','UPDATE {db_prefix}members

             SET 

 gold = {int:gold},

 hp = {int:hp},

 max_hp = {int:max_hp},

 atk = {int:atk},

 max_atk = {int:max_atk},

 def = {int:def},

 max_def = {int:max_def},

 energy = {int:energy},

 max_energy = {int:max_energy},

 stamina = {int:stamina},

 max_stamina = {int:max_stamina},

 level = {int:level},

 exp = {int:exp},

 max_exp = {int:max_exp},

 mon_slays = {int:mon_slays},

 mem_slays = {int:mem_slays},

 is_dead = {int:is_dead}'
,

array(

'gold' => $modSettings['battle_gold_reg'],

'hp' => $modSettings['battle_hp_reg'],

'max_hp' => $modSettings['battle_hp_max_reg'],

'atk' => $modSettings['battle_atk_reg'],

'max_atk' => $modSettings['battle_atk_max_reg'],

'def' => $modSettings['battle_def_reg'],

'max_def' => $modSettings['battle_def_max_reg'],

'energy' => $modSettings['battle_energy_reg'],

'max_energy' => $modSettings['battle_energy_max_reg'],

'stamina' => $modSettings['battle_stamina_reg'],

'max_stamina' => $modSettings['battle_stamina_max_reg'],

'level' => 0,

'exp' => 0,

'max_exp' => $modSettings['exp_bef_level'],

'mon_slays' => 0,

'mem_slays' => 0,

'is_dead' => 0,

)

);



// emtyp the quest history

$smcFunc['db_query']('''

TRUNCATE {db_prefix}battle_quest_hist'
,

array());



//empty the grave yard

$smcFunc['db_query']('''

TRUNCATE {db_prefix}battle_graveyard'
,

array());



//reset quest plays to zero

//make it a value between 1 and 0 checked = 1 

$_POST['is_final'] = isset($_POST['is_final'])? 0;

$smcFunc['db_query']('''

UPDATE {db_prefix}battle_quest

SET 

plays = {int:play}'
,

array(

'play' => 0,

));



        if(
$modSettings['enable_battle_hist']) 

    {

require_once($sourcedir '/Battle/Battle_Shouts.php');

$content '<span class="error"><strong>'.$txt['battle_hist28'].'</strong></span>';

        
add_to_battle_hist($content);

}



    redirectexit('action=admin;area=battle;sa=maintain;reset=done');

}



function 
battle_cust_add_edit()

{

global $smcFunc$context$txt;



isAllowedTo('admin_battle');



$context['cust']['id'] = !empty($_REQUEST['cust']) ? (int) $_REQUEST['cust'] : 0;



if (!empty($_POST['submit']))

{

checkSession();



$fields = array('outcome1''outcome1_reward''outcome1_action''outcome2''outcome2_reward''outcome2_action''start','price');



foreach ($fields as $field)

{

if (empty($_POST[$field]))

fatal_error($field ' left empty!'false);

else

$_POST[$field] = $smcFunc['htmlspecialchars']($_POST[$field], ENT_QUOTES);

}



if (empty($context['cust']['id']))

{

$smcFunc['db_insert']('',

'{db_prefix}battle_explore',

array('outcome1' => 'string''outcome2' => 'string', 'outcome1_reward' => 'string''outcome2_reward' => 'string''outcome1_action' => 'string''outcome2_action' => 'string''start' => 'string''price' => 'string'),

array($_POST['outcome1'], $_POST['outcome2'], $_POST['outcome1_reward'], $_POST['outcome2_reward'], $_POST['outcome1_action'], $_POST['outcome2_action'], $_POST['start'], $_POST['price']),

array()

);

}

else

{

$smcFunc['db_query']('''

UPDATE {db_prefix}battle_explore

SET

outcome1 = {string:outcome1},

outcome2 = {string:outcome2},

outcome1_reward = {string:outcome1_reward},

outcome2_reward = {string:outcome2_reward},

outcome1_action = {string:outcome1_action},

    outcome2_action = {string:outcome2_action},

start = {string:start},

price = {string:price}

WHERE id_explore = {int:id_cust}'
,

array(

'id_cust' => $context['cust']['id'],

'outcome1' => $_POST['outcome1'],

'outcome2' => $_POST['outcome2'],

'outcome1_reward' => $_POST['outcome1_reward'],

'outcome2_reward' => $_POST['outcome2_reward'],

'outcome1_action' => $_POST['outcome1_action'],

'outcome2_action' => $_POST['outcome2_action'],

'start' => $_POST['start'],

'price' => $_POST['price'],

)

);

}



redirectexit('action=admin;area=battle;sa=custom');

}



if (!empty($context['cust']['id']))

{

$request $smcFunc['db_query']('''

SELECT id_explore, outcome1, outcome1_reward, outcome2, outcome2_reward, outcome2_action, outcome1_action, start, price

FROM {db_prefix}battle_explore

WHERE id_explore = {int:id_cust}'
,

array(

'id_cust' => $context['cust']['id'],

)

);

while ($row $smcFunc['db_fetch_assoc']($request))

{

$context['cust'] += array(

'id_explore' => $row['id_explore'],

'outcome1' => $row['outcome1'],

'outcome1_reward' => $row['outcome1_reward'],

'outcome2' => $row['outcome2'],

'outcome2_reward' => $row['outcome2_reward'],

'outcome2_action' => $row['outcome2_action'],

'outcome1_action' => $row['outcome1_action'],

'start' => $row['start'],

'price' => $row['price']

);

}

$smcFunc['db_free_result']($request);

}

else

{

$context['cust'] += array(

        'id_explore' => '',

'outcome1' => '',

'outcome2' => '',

'outcome1_reward' => '',

'outcome2_reward' => '',

'outcome1_action' => '',

'outcome2_action'=> '',

'start' => '',

'price' => '',

);

}



$context['sub_template'] = 'custEdit_Add';

$context['page_title'] = $txt['battle_ce'];

}



function 
battle_cust_delete()

{

global 
$smcFunc;



$cust_id = !empty($_REQUEST['cust']) ? (int) $_REQUEST['cust'] : 0;



   
$smcFunc['db_query']('''

DELETE FROM {db_prefix}battle_explore

WHERE id_explore = {int:q_id}'
,

array(

'q_id' => $cust_id,

)

);


redirectexit('action=admin;area=battle;sa=custom');

}



function 
battle_custom()

{

global $context$txt$smcFunc$scripturl;



$context['page_title'] = 'Custom Actions';

$context['sub_template'] = 'battle_custom';



    
$context['battle_cust'] = array();



$request $smcFunc['db_query']('''

SELECT COUNT(*)

FROM {db_prefix}battle_explore'
,

array());



list ($quest) = $smcFunc['db_fetch_row']($request);

$smcFunc['db_free_result']($request);



// Now create the page index.

$context['page_index'] = constructPageIndex($scripturl '?action=admin;area=battle;sa=custom;sort=' $_REQUEST['start'] . (isset($_REQUEST['desc']) ? ';desc' ''), $_REQUEST['start'], $quest10);

$context['start'] = $_REQUEST['start'];



$request $smcFunc['db_query']('''

SELECT id_explore, start

FROM {db_prefix}battle_explore

ORDER BY id_explore DESC

LIMIT {int:start}, 10'
,

array(

'start' => $context['start'],



)

);

// Loop through all results

while ($row $smcFunc['db_fetch_assoc']($request))

// And add them to the list

$context['battle_cust'][] = array(

'id_explore' => $row['id_explore'],

'start' => $row['start']



);



$smcFunc['db_free_result']($request);



}



function 
battle_quest()

{

global $context$txt$smcFunc$scripturl;



$context['page_title'] = $txt['battle_Quest'];

$context['sub_template'] = 'battle_quest';



    
$context['battle_quest'] = array();



$request $smcFunc['db_query']('''

SELECT COUNT(*)

FROM {db_prefix}battle_quest'
,

array());



list ($quest) = $smcFunc['db_fetch_row']($request);

$smcFunc['db_free_result']($request);



// Now create the page index.

$context['page_index'] = constructPageIndex($scripturl '?action=admin;area=battle;sa=quest;sort=' $_REQUEST['start'] . (isset($_REQUEST['desc']) ? ';desc' ''), $_REQUEST['start'], $quest10);

$context['start'] = $_REQUEST['start'];



$request $smcFunc['db_query']('''

SELECT b.id_quest, b.gold, b.itext, b.stext, b.ftext, b.stext, b.exp, b.level,

b.success, b.name, b.plays, b.energy

FROM {db_prefix}battle_quest AS b

ORDER BY id_quest DESC

LIMIT {int:start}, 10'
,

array(

'start' => $context['start'],



)

);

// Loop through all results

while ($row $smcFunc['db_fetch_assoc']($request))

// And add them to the list

$context['battle_quest'][] = array(

'id_quest' => $row['id_quest'],

'name' => $row['name'],

'itext' => $row['itext'],

'ftext' => $row['ftext'],

'stext' => $row['stext'],

'exp' => $row['exp'],

'level' => $row['level'],

'success' => $row['success'],

'gold' => $row['gold'],

'plays' => $row['plays'],

'energy' => $row['energy']



);



$smcFunc['db_free_result']($request);



}



function 
battle_quest_delete()

{



// Gotta global it other wise thing dont work properly

global $smcFunc;



$quest_id = !empty($_REQUEST['quest']) ? (int) $_REQUEST['quest'] : 0;



   
$smcFunc['db_query']('''

DELETE FROM {db_prefix}battle_quest

WHERE id_quest = {int:q_id}'
,

array(

'q_id' => $quest_id,

)

);


redirectexit('action=admin;area=battle;sa=quest');

}



function 
battle_quest_add_edit()

{

global $smcFunc$context$txt;



isAllowedTo('admin_battle');



$context['quest']['id'] = !empty($_REQUEST['quest']) ? (int) $_REQUEST['quest'] : 0;



if (!empty($_POST['submit']))

{

checkSession();



$fields = array('name''gold''itext''stext''ftext','exp''energy''success');



foreach ($fields as $field)

{

if (empty($_POST[$field]))

fatal_error($field ' left empty!'false);

else

$_POST[$field] = $smcFunc['htmlspecialchars']($_POST[$field], ENT_QUOTES);

}

// Make it a value between 1 and 0 checked = 1 

$_POST['is_final'] = isset($_POST['is_final'])? 0;

if (empty($context['quest']['id']))

{

$smcFunc['db_insert']('',

'{db_prefix}battle_quest',

array('name' => 'string''gold' => 'string', 'itext' => 'string''stext' => 'string''ftext' => 'string''exp' => 'string''energy' => 'string''success' => 'string''level' => 'string''is_final' => 'string'),

array($_POST['name'], $_POST['gold'], $_POST['itext'], $_POST['stext'], $_POST['ftext'], $_POST['exp'], $_POST['energy'], $_POST['success'], $_POST['level'], $_POST['is_final']),

array()

);

}

else

{

$smcFunc['db_query']('''

UPDATE {db_prefix}battle_quest

SET

name = {string:name},

gold = {string:gold},

itext = {string:itext},

stext = {string:stext},

ftext = {string:ftext},

exp = {string:exp},

energy = {string:energy},

success = {string:success},

level = {string:level},

is_final = {int:is_final}

WHERE id_quest = {int:id_quest}'
,

array(

'id_quest' => $context['quest']['id'],

'name' => $_POST['name'],

'gold' => $_POST['gold'],

'itext' => $_POST['itext'],

'stext' => $_POST['stext'],

'ftext' => $_POST['ftext'],

'exp' => $_POST['exp'],

'energy' => $_POST['energy'],

'success' => $_POST['success'],

'level' => $_POST['level'],

'is_final' => $_POST['is_final'],

)

);

}



redirectexit('action=admin;area=battle;sa=quest');

}



if (!empty($context['quest']['id']))

{

$request $smcFunc['db_query']('''

SELECT b.id_quest, b.gold, b.itext, b.stext, b.ftext, b.stext, 

b.exp, b.level, b.success, b.name, b.plays, b.energy, b.is_final

FROM {db_prefix}battle_quest AS b

WHERE id_quest = {int:id_quest}'
,

array(

'id_quest' => $context['quest']['id'],

)

);

while ($row $smcFunc['db_fetch_assoc']($request))

{

$context['quest'] += array(

'id_quest' => $row['id_quest'],

'name' => $row['name'],

'itext' => $row['itext'],

'ftext' => $row['ftext'],

'stext' => $row['stext'],

'exp' => $row['exp'],

'level' => $row['level'],

'success' => $row['success'],

'gold' => $row['gold'],

'plays' => $row['plays'],

'energy' => $row['energy'],

'is_final' => $row['is_final'],

);

}

$smcFunc['db_free_result']($request);

}

else

{

$context['quest'] += array(

        'id_quest' => '',

'name' => '',

'itext' => '',

'ftext' => '',

'stext' => '',

'exp' => '',

'level'=> '',

'success' => '',

'gold' => '',

'plays' => '',

'energy' => '',

'is_final' => '',

);

}



$context['sub_template'] = 'questEdit_Add';

$context['page_title'] = $txt['battle_Quest'];

}



function 
battle_monster()

{

global $smcFunc$context$txt;

isAllowedTo('admin_forum');

$context['monster']['id'] = !empty($_REQUEST['monster']) ? (int) $_REQUEST['monster'] : 0;

if (!empty($_POST['submit']))

{

checkSession();

$fields = array('atk''def''name''hp''img''max_hp','mon_range');

foreach ($fields as $field)

{

if (empty($_POST[$field]))

fatal_error($field ' left empty!'false);

else

$_POST[$field] = $smcFunc['htmlspecialchars']($_POST[$field], ENT_QUOTES);

}

if (empty($context['monster']['id']))

{

$smcFunc['db_insert']('',

'{db_prefix}battle_monsters',

array('atk' => 'string''def' => 'string''name' => 'string''hp' => 'string''img' => 'string''max_hp' => 'string''mon_range' => 'string'),

array($_POST['atk'], $_POST['def'], $_POST['name'], $_POST['hp'], $_POST['img'], $_POST['max_hp'], $_POST['mon_range']),

array()

);

}

else

{

$smcFunc['db_query']('''

UPDATE {db_prefix}battle_monsters

SET

name = {string:name},

atk = {string:atk},

def = {string:def},

hp = {string:hp},

img = {string:img},

max_hp = {string:max_hp},

mon_range = {string:mon_range}

WHERE id_monster = {int:id_monster}'
,

array(

'id_monster' => $context['monster']['id'],

'name' => $_POST['name'],

'atk' => $_POST['atk'],

'def' => $_POST['def'],

'hp' => $_POST['hp'],

'img' => $_POST['img'],

'max_hp' => $_POST['max_hp'],

'mon_range' => $_POST['mon_range'],

)

);

}

redirectexit('action=admin;area=battle;sa=monsterlist');

}

 if (!empty(
$context['monster']['id']))

 {

$request $smcFunc['db_query']('''

SELECT name, atk, def, hp, img, max_hp, mon_range

FROM {db_prefix}battle_monsters

WHERE id_monster = {int:id_monster}'
,

array(

'id_monster' => $context['monster']['id'],

)

);

  while (
$row $smcFunc['db_fetch_assoc']($request))

  {

$context['monster'] += array(

'name' => $row['name'],

    
'atk' => $row['atk'],

    
'def' => $row['def'],

    
'hp' => $row['hp'],

    
'img' => $row['img'],

    
'max_hp' => $row['max_hp'],

    
'mon_range' => $row['mon_range'],

   );

  }

  
$smcFunc['db_free_result']($request);

 }

 else

 {

$context['monster'] += array(

   
'name' => '',

   
'atk' => '',

   
'def' => '',

   
'hp' => '',

   
'img' => '',

   
'max_hp' => '',

   
'mon_range' => '',

  );

 }

 
$context['sub_template'] = 'monsterEdit_Add';

 
$context['page_title'] = $txt['battle_monsters'];

}



function 
getImageList()

{

global $settings;



// Start with an empty array

$imageList = array();

// Try to open the images directory



if ($handle opendir($settings['default_theme_dir'] . '/' basename($settings['default_images_url']) . '/battle/monsters'))

{

// For each file in the directory...

while (false !== ($file readdir($handle)))

{

// ...if it's a valid file, add it to the list

if (!in_array($file, array('.''..''blank.gif')))

$imageList[] = $file;

}

// Sort the list

sort($imageList);

return $imageList;

}

// Otherwise, if directory inaccessible, show an error

else

{

fatal_lang_error('cannot_open_images');

}

}



function 
battle_monster_delete()

{

global 
$smcFunc$txt;



$monster_id = !empty($_REQUEST['monster']) ? (int) $_REQUEST['monster'] : 0;



if (empty(
$monster_id))

fatal_error($txt['battle_nomon'], false);



   
$smcFunc['db_query']('''

DELETE FROM {db_prefix}battle_monsters

WHERE id_monster = {int:mon_id}'
,

array(

'mon_id' => $monster_id,

)

);


redirectexit('action=admin;area=battle;sa=monsterlist');

}





function 
battle_monsterlist() {



// Must global it otherwise we get erros

   
global $smcFunc$scripturl$txt$request$context;

 

 
$context['sub_template'] = 'battle_admin_monsters';

 
$context['page_title'] = $txt['battle_monsters'];

 

// Get the total amount of entries.

$request $smcFunc['db_query']('''

SELECT COUNT(*)

FROM {db_prefix}battle_monsters'
,

array(



)

);



list ($totalmonsters) = $smcFunc['db_fetch_row']($request);

$smcFunc['db_free_result']($request);



// Create the page index.

$context['page_index'] = constructPageIndex($scripturl '?action=admin;area=battle;sa=monsterlist;sort=' $_REQUEST['start'] . (isset($_REQUEST['desc']) ? ';desc' ''), $_REQUEST['start'], $totalmonsters10);

$context['start'] = $_REQUEST['start'];



// Get the data.

$request $smcFunc['db_query']('''

SELECT id_monster, atk, def, hp, name, img, max_hp

FROM {db_prefix}battle_monsters

ORDER BY atk DESC

LIMIT {int:start}, 10'
,

array(

'start' => $context['start'],

)

);



// Set the value of the callback function.

$context['get_monsters'] = 'getmonstersEntry';

}



function 
getmonstersEntry($reset false)

{

// Gotta global it other wise thing dont work properly

global $smcFunc$request;



if ($request == false)

return false;



if (!($row $smcFunc['db_fetch_assoc']($request)))

return false;



$output = array(

'id_monster' => $row['id_monster'],

'name' => $row['name'],

'atk' => $row['atk'],

'def' => $row['def'],

'hp' => $row['hp'],

'img' => $row['img'],

'max_hp' => $row['max_hp'],



);



return $output;



}



function 
battle_shop_item_delete()

{

global 
$smcFunc;



$item_id = !empty($_REQUEST['item']) ? (int) $_REQUEST['item'] : 0;



if (empty(
$item_id))

fatal_error('No Item Selected'false);



   
$smcFunc['db_query']('''

DELETE FROM {db_prefix}battle_shop

WHERE id_item = {int:item_id}'
,

array(

'item_id' => $item_id,

)

);


redirectexit('action=admin;area=battle;sa=shop');

}



function 
battle_shop_add_edit()

{

global 
$smcFunc$context$txt;



isAllowedTo('admin_battle');



$context['item']['id'] = !empty($_REQUEST['item']) ? (int) $_REQUEST['item'] : 0;



if (!empty($_POST['submit']))

{

checkSession();



$fields = array('name''price''act''img''description''amount');



foreach ($fields as $field)

{

if (empty($_POST[$field]))

fatal_error($field ' left empty!'false);

else

$_POST[$field] = $smcFunc['htmlspecialchars']($_POST[$field], ENT_QUOTES);

}



if (empty($context['item']['id']))

{

$smcFunc['db_insert']('',

'{db_prefix}battle_shop',

array('name' => 'string''price' => 'int', 'action' => 'string''img' => 'string''description' => 'string''amount' => 'int'),

array($_POST['name'], $_POST['price'], $_POST['act'], $_POST['img'], $_POST['description'], $_POST['amount']),

array()

);

}

else

{

$smcFunc['db_query']('''

UPDATE {db_prefix}battle_shop

SET

name = {string:name},

price = {int:price},

action = {string:action},

img = {string:img},

description = {string:description},

amount = {int:amount}

WHERE id_item = {int:id_item}'
,

array(

'id_item' => $context['item']['id'],

'name' => $_POST['name'],

'price' => $_POST['price'],

'action' => $_POST['act'],

'img' => $_POST['img'],

'description' => $_POST['description'],

'amount' => $_POST['amount'],

)

);

}



redirectexit('action=admin;area=battle;sa=shop');

}



if (!empty($context['item']['id']))

{

$request $smcFunc['db_query']('''

SELECT id_item, name, price, action, img, description, amount

FROM {db_prefix}battle_shop

WHERE id_item = {int:id_item}'
,

array(

'id_item' => $context['item']['id'],

)

);

while ($row $smcFunc['db_fetch_assoc']($request))

{

$context['item'] += array(

'id_item' => $row['id_item'],

'name' => $row['name'],

'price' => $row['price'],

'action' => $row['action'],

'img' => $row['img'],

'description' => $row['description'],

'amount' => $row['amount'],



);

}

$smcFunc['db_free_result']($request);

}

else

{

$context['item'] += array(

        'id_item' => '',

'name' => '',

'price' => '',

'action' => '',

'img' => '',

'description' => '',

'amount'=> '',

);

}



$context['sub_template'] = 'shopEdit_Add';

$context['page_title'] = $txt['battle_shop_item'];



}



function 
getshopImageList()

{

global $settings;



// Start with an empty array

$imageList = array();

// Try to open the images directory



if ($handle opendir($settings['default_theme_dir'] . '/' basename($settings['default_images_url']) . '/battle/shop'))

{

// For each file in the directory...

while (false !== ($file readdir($handle)))

{

// ...if it's a valid file, add it to the list

if (!in_array($file, array('.''..''blank.gif')))

$imageList[] = $file;

}

// Sort the list

sort($imageList);

return $imageList;

}

// Otherwise, if directory inaccessible, show an error

else

{

fatal_lang_error('cannot_open_images');

}

}



function 
battle_shop()

{

global  
$smcFunc$scripturl$txt$context;



$context['sub_template'] = 'battle_shop';

$context['page_title'] = $txt['battle_shop_item'];



$context['shop'] = array();

 

 

$request $smcFunc['db_query']('''

SELECT COUNT(*)

FROM {db_prefix}battle_shop'
,

array(



)

);



list ($shop) = $smcFunc['db_fetch_row']($request);

$smcFunc['db_free_result']($request);



// Now create the page index.

$context['page_index'] = constructPageIndex($scripturl '?action=admin;area=battle;sa=shop;sort=' $_REQUEST['start'] . (isset($_REQUEST['desc']) ? ';desc' ''), $_REQUEST['start'], $shop10);

$context['start'] = $_REQUEST['start'];

  

$battleQ $smcFunc['db_query']('''

SELECT id_item, name, price, action, img, description, amount

FROM {db_prefix}battle_shop

LIMIT {int:start}, 10'
,

array(

'start' => $context['start'],



)

);



while ($row $smcFunc['db_fetch_assoc']($battleQ))

// And add them to the list

$context['shop'][] = array(

'id_item' => $row['id_item'],

'name' => $row['name'],

'price' => $row['price'],

'action' => $row['action'],

'img' => $row['img'],

'amount' => $row['amount'],

'description' => $row['description'],

);



$smcFunc['db_free_result']($battleQ);

}





function 
battle_settings($return_config false)

{

    
// Must global it otherwise we get erros

global $txt$scripturl$context$sourcedir$modSettings;



// We need this 

require_once($sourcedir.'/ManageServer.php');

$context['sub_template'] = 'show_settings';



$txt['battle_add_amount'] = sprintf($txt['battle_add_amount'],$modSettings['battle_time']);

$config_vars = array(

array('check''enable_battle'),

array('check''enable_img_menu'),

array('check''enable_battle_shoutbox'),

array('check''enable_show_who_battle'),

array('check''enable_battle_hist'),

array('check''enable_sts_post'),

array('check''enable_sts_pm'),

array('check''enable_sts_profile'),

//'',

array('text''bcash'),

'',

array('int''battle_map_across'),

array('int''battle_map_down'),

'',

array('int''exp_bef_level'),

array('int''exp_stat_level'),

'',

array('int''exp_def_mem'),

array('int''exp_def_mon'),

'',

array('int''battle_time'),

array('int''battle_add_amount'),

'',

array('int''battle_how_much_reviv_user'),

array('int''battle_how_much_hp'),

'',

array('int''battle_gold_reg'),

array('int''battle_hp_reg'),

array('int''battle_hp_max_reg'),

array('int''battle_atk_reg'),

array('int''battle_atk_max_reg'),

array('int''battle_def_reg'),

array('int''battle_def_max_reg'),

array('int''battle_energy_reg'),

array('int''battle_energy_max_reg'),

array('int''battle_stamina_reg'),

array('int''battle_stamina_max_reg'),



);



if (isset($_GET['save']))

{

saveDBSettings($config_vars);

redirectexit('action=admin;area=battle;sa=config');

}

$context['post_url'] = $scripturl .'?action=admin;area=battle;save;sa=config';

$context['settings_title'] = $txt['battle_config'];

prepareDBSettingContext($config_vars);

}



function 
battle_members() {

global  $context$smcFunc$b$txt$userid;



$context['sub_template'] = 'bmembers';

$context['page_title'] = $txt['battle_mem'];



$_POST['thename'] = !empty($_POST['thename']) ? $smcFunc['htmlspecialchars']($_POST['thename'], ENT_QUOTES) : '';



if(isset($_REQUEST['next']) && isset($_POST['thename']))

{

$userid battle_UserId($_POST['thename']);

if(!isset($userid)) 

{

$b['b_message'] = $txt['battle_mem_error'];

}

}



if(isset($_REQUEST['update']))

{

//check the users session

checkSession();

$cash = !empty($_POST['cash']) ? (int) $_POST['cash'] : 0;

$atk = !empty($_POST['atk']) ? (int) $_POST['atk'] : 0;

$def = !empty($_POST['def']) ? (int) $_POST['def'] : 0;

$stam = !empty($_POST['stam']) ? (int) $_POST['stam'] : 0;

$max_stam = !empty($_POST['max_stam']) ? (int) $_POST['max_stam'] : 0;

$hp = !empty($_POST['hp']) ? (int) $_POST['hp'] : 0;

$max_hp = !empty($_POST['max_hp']) ? (int) $_POST['max_hp'] : 0;

$energy = !empty($_POST['energy']) ? (int) $_POST['energy'] : 0;

$level = !empty($_POST['level']) ? (int) $_POST['level'] : 0;

$exp = !empty($_POST['exp']) ? (int) $_POST['exp'] : 0;

$max_land = !empty($_POST['max_land']) ? (int) $_POST['max_land'] : 0;

$max_atk = !empty($_POST['max_atk']) ? (int) $_POST['max_atk'] : 0;

$max_def = !empty($_POST['max_def']) ? (int) $_POST['max_def'] : 0;

$max_energy = !empty($_POST['max_energy']) ? (int) $_POST['max_energy'] : 0;

$userid $_POST['thename'];

battle_do_gold($userid$cash);

battle_do_atk($userid$atk);

battle_do_def($userid$def);

battle_do_hp($userid$hp);

battle_do_max_hp($userid$max_hp);

battle_do_level($userid$level);

battle_do_exp($userid$exp);

battle_do_max_atk($userid$max_atk);

battle_do_max_def($userid$max_def);

battle_do_stam($userid$stam);

battle_do_max_stam($userid$max_stam);

battle_do_energy($userid$energy);

battle_do_max_energy($userid$max_energy);

}

}

function 
battle_do_stam($userid$stam

{


updateMemberData($userid, array('stamina' => $stam));

}



function 
battle_do_energy($userid$energy

{


updateMemberData($userid, array('energy' => $energy));

}



function 
battle_do_max_energy($userid$max_energy

{


updateMemberData($userid, array('max_energy' => $max_energy));

}



function 
battle_do_max_stam($userid$max_stam

{


updateMemberData($userid, array('max_stamina' => $max_stam));

}



function 
battle_do_max_def($userid$max_def

{

updateMemberData($userid, array('max_def' => $max_def));

}



function 
battle_do_max_atk($userid$max_atk

{


updateMemberData($userid, array('max_atk' => $max_atk));

}



function 
battle_do_exp($userid$exp

{


updateMemberData($userid, array('exp' => $exp));

}



function 
battle_do_level($userid$level

{

updateMemberData($userid, array('level' => $level));

}



function 
battle_do_hp($userid$hp

{

updateMemberData($userid, array('hp' => $hp));

}



function 
battle_do_max_hp($userid$max_hp

{

updateMemberData($userid, array('max_hp' => $max_hp));

}



function 
battle_do_def($userid$def

{

updateMemberData($userid, array('def' => $def));

}



function 
battle_do_gold($userid$cash

{

global 
$modSettings;

updateMemberData($userid, array($modSettings['bcash'] => $cash));

}



function 
battle_do_atk($userid$atk

{

updateMemberData($userid, array('atk' => $atk));

}



function 
battle_UserId($nameid

{

global $smcFunc;



$result $smcFunc['db_query']('','

SELECT id_member

FROM {db_prefix}members

WHERE member_name = {string:nameid}

LIMIT 1'
,

array(

'nameid' => $nameid,

)

);;



$row =  $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['id_member'];

}



function 
battle_gold($userid

{

global $modSettings$smcFunc;



$result $smcFunc['db_query']('''

SELECT {raw:cash} 

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

'cash' => $modSettings['bcash'],

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row[$modSettings['bcash']];

}



function 
battle_atk($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT atk 

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['atk'];

}



function 
battle_max_atk($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT max_atk 

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['max_atk'];

}



function 
battle_max_def($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT max_def

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['max_def'];

}



function 
battle_def($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT def

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['def'];

}



function 
battle_energy($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT energy

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['energy'];

}



function 
battle_max_energy($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT max_energy

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['max_energy'];

}



function 
battle_stamina($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT stamina

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['stamina'];

}



function 
battle_max_stamina($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT max_stamina

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['max_stamina'];

}



function 
battle_hp($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT hp

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['hp'];

}



function 
battle_max_hp($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT max_hp

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['max_hp'];

}



function 
battle_level($userid

{

global $smcFunc;



$result $smcFunc['db_query']('''

SELECT level

FROM {db_prefix}members 

WHERE id_member = {int:userid}

LIMIT 1'
,

array(

'userid' => $userid,

)

);

$row $smcFunc['db_fetch_assoc']($result);

$smcFunc['db_free_result']($result);

return $row['level'];

}

?>
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 01:37:29 AM
I've edited a bit of text to reflect Tanks instead of tanks on my site...I struggle to keep from typing Tanks instead of Monsters...LOL

Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 07:43:39 AM
Fog,

  I asked for the part of the code that is needed for edit & not the whole file. You should have just posted the function for editing monsters/enemies from that file.

This is the function you need to edit:

function battle_monster()

{

   global $smcFunc, $context, $txt;

   isAllowedTo('admin_forum');

   $context['monster']['id'] = !empty($_REQUEST['monster']) ? (int) $_REQUEST['monster'] : 0;

   if (!empty($_POST['submit']))

   {

      checkSession();

      $fields = array('atk', 'def', 'name', 'hp', 'img', 'max_hp','mon_range');

      foreach ($fields as $field)

      {

         if (empty($_POST[$field]))

         fatal_error($field . ' left empty!', false);

      else

         $_POST[$field] = $smcFunc['htmlspecialchars']($_POST[$field], ENT_QUOTES);

      }

      if (empty($context['monster']['id']))

      {

         $smcFunc['db_insert']('',

            '{db_prefix}battle_monsters',

            array('atk' => 'string', 'def' => 'string', 'name' => 'string', 'hp' => 'string', 'img' => 'string', 'max_hp' => 'string', 'mon_range' => 'string'),

            array($_POST['atk'], $_POST['def'], $_POST['name'], $_POST['hp'], $_POST['img'], $_POST['max_hp'], $_POST['mon_range']),

            array()

         );

      }

      else

      {

         $smcFunc['db_query']('', '

            UPDATE {db_prefix}battle_monsters

            SET

            name = {string:name},

            atk = {string:atk},

            def = {string:def},

            hp = {string:hp},

            img = {string:img},

            max_hp = {string:max_hp},

            mon_range = {string:mon_range}

            WHERE id_monster = {int:id_monster}',

            array(

            'id_monster' => $context['monster']['id'],

            'name' => $_POST['name'],

            'atk' => $_POST['atk'],

            'def' => $_POST['def'],

            'hp' => $_POST['hp'],

            'img' => $_POST['img'],

            'max_hp' => $_POST['max_hp'],

            'mon_range' => $_POST['mon_range'],

            )

         );

      }

   redirectexit('action=admin;area=battle;sa=monsterlist');

   }

if (!empty($context['monster']['id']))

{

   $request = $smcFunc['db_query']('', '

   SELECT name, atk, def, hp, img, max_hp, mon_range

   FROM {db_prefix}battle_monsters

   WHERE id_monster = {int:id_monster}',

   array(

      'id_monster' => $context['monster']['id'],

   )

);

  while ($row = $smcFunc['db_fetch_assoc']($request))

  {

   $context['monster'] += array(

   'name' => $row['name'],

    'atk' => $row['atk'],

    'def' => $row['def'],

    'hp' => $row['hp'],

    'img' => $row['img'],

    'max_hp' => $row['max_hp'],

    'mon_range' => $row['mon_range'],

   );

  }

  $smcFunc['db_free_result']($request);

}

else

{

   $context['monster'] += array(

   'name' => '',

   'atk' => '',

   'def' => '',

   'hp' => '',

   'img' => '',

   'max_hp' => '',

   'mon_range' => '',

  );

}

$context['sub_template'] = 'monsterEdit_Add';

$context['page_title'] = $txt['battle_monsters'];

}







I need the admin template code before you can commence the following edits to that function...


function battle_monster()

{

   global $smcFunc, $context, $txt;

   isAllowedTo('admin_forum');

   $context['monster']['id'] = !empty($_REQUEST['monster']) ? (int) $_REQUEST['monster'] : 0;

   if (!empty($_POST['submit']))

   {

      checkSession();

      $fields = array('atk', 'def', 'name', 'hp', 'img', 'max_hp','mon_range', 'mon_max_range');

      foreach ($fields as $field)

      {

         if (empty($_POST[$field]))

         fatal_error($field . ' left empty!', false);

      else

         $_POST[$field] = $smcFunc['htmlspecialchars']($_POST[$field], ENT_QUOTES);

      }

      if (empty($context['monster']['id']))

      {

         $smcFunc['db_insert']('',

            '{db_prefix}battle_monsters',

            array('atk' => 'string', 'def' => 'string', 'name' => 'string', 'hp' => 'string', 'img' => 'string', 'max_hp' => 'string', 'mon_range' => 'string', 'mon_max_range' => 'int'),

            array($_POST['atk'], $_POST['def'], $_POST['name'], $_POST['hp'], $_POST['img'], $_POST['max_hp'], $_POST['mon_range'], $_POST['mon_max_range']),

            array()

         );

      }

      else

      {

         $smcFunc['db_query']('', '

            UPDATE {db_prefix}battle_monsters

            SET

            name = {string:name},

            atk = {string:atk},

            def = {string:def},

            hp = {string:hp},

            img = {string:img},

            max_hp = {string:max_hp},

            mon_range = {string:mon_range},
           
            mon_max_range = {int:mon_max_range}

            WHERE id_monster = {int:id_monster}',

            array(

            'id_monster' => $context['monster']['id'],

            'name' => $_POST['name'],

            'atk' => $_POST['atk'],

            'def' => $_POST['def'],

            'hp' => $_POST['hp'],

            'img' => $_POST['img'],

            'max_hp' => $_POST['max_hp'],

            'mon_range' => $_POST['mon_range'],
           
            'mon_max_range' => $_POST['mon_max_range'],

            )

         );

      }

   redirectexit('action=admin;area=battle;sa=monsterlist');

   }

if (!empty($context['monster']['id']))

{

   $request = $smcFunc['db_query']('', '

   SELECT name, atk, def, hp, img, max_hp, mon_range, mon_max_range

   FROM {db_prefix}battle_monsters

   WHERE id_monster = {int:id_monster}',

   array(

      'id_monster' => $context['monster']['id'],

   )

);

  while ($row = $smcFunc['db_fetch_assoc']($request))

  {

   $context['monster'] += array(

   'name' => $row['name'],

    'atk' => $row['atk'],

    'def' => $row['def'],

    'hp' => $row['hp'],

    'img' => $row['img'],

    'max_hp' => $row['max_hp'],

    'mon_range' => $row['mon_range'],
   
    'mon_max_range' => $row['mon_max_range'],

   );

  }

  $smcFunc['db_free_result']($request);

}

else

{

   $context['monster'] += array(

   'name' => '',

   'atk' => '',

   'def' => '',

   'hp' => '',

   'img' => '',

   'max_hp' => '',

   'mon_range' => '',
   
   'mon_max_range' => '',

  );

}

$context['sub_template'] = 'monsterEdit_Add';

$context['page_title'] = $txt['battle_monsters'];

}


  Without the admin template that displays the input boxes you may get an error therefore I need you to post that part of the admin template.  Also I need to see the part of code for the install that creates the tables & columns because you now need to create an int(10) column in the battle_monsters table named mon_max_range unless you want to create that manually.

Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 11:20:06 AM
Thanks Underdog...I'll work on that when I get home from work.
Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 05:27:16 PM
These are the steps you need to take to accomplish your task:


Step 2 is shown above and you need to apply the others.

I see you are having issues when attempting to attach files. This is due to the free hosting environment used here on this site.
Simply follow the instructions from this link to accomplish that: http://webdevelop.comli.com/index.php?topic=4.msg44#msg44
It will allow up to 50MB per file which Imo is more than enough for website files.
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 09:38:43 PM
I got the battle admin template modified with another input field...

I manually enters a new table on my DB.

But I haven't been able to link them together...I'm guessing thats where step two is important.
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 10:04:06 PM
Here's the install part

$smcFunc['db_add_column']('{db_prefix}battle_monsters',
array(
'name' => 'mon_range',
'type' => 'varchar',
'size' => '255',
'null' => false
)
);
Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 10:12:37 PM
Fog,

Here is the admin template code. I fixed up the html a bit as it was broken (errors). I am not sure if it looks proper atm as I am not able to test it.


function template_monsterEdit_Add()
{
global $context, $scripturl, $settings, $txt;

$context['battle_images'] = getImageList();

echo '
<form action="', $scripturl, '?action=admin;area=battle;save;sa=savemonster" method="post" name="theAdminForm" accept-charset="', $context['character_set'], '">
<table border="0" width="80%" align="center" cellspacing="1" cellpadding="3" class="tborder windowbg2">
<tr class="titlebg">
<td>'.$txt['battle_monsters'].'</td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_name'].'</td>
<td><input type="text" name="name" value="', $context['monster']['name'], '" /></td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_atk'].'</td>
<td><input type="text" name="atk" value="', $context['monster']['atk'], '" /></td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_def'].'</td>
<td><input type="text" name="def" value="', $context['monster']['def'], '" /></td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_hp'].'</td>
<td><input type="text" name="hp" value="', $context['monster']['hp'], '" /></td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_m_hp'].'</td>
<td><input type="text" name="max_hp" value="', $context['monster']['max_hp'], '" /></td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_range'].'</td>
<td>
<span>
<input type="text" name="mon_range" size="6" maxlength="5" value="', $context['monster']['mon_range'], '" />
</span>
<span style="position:relative;left:10px;">
<input type="text" name="mon_max_range" size="6" maxlength="5" value="', $context['monster']['mon_max_range'], '" />
</span>
</td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_img'] .'</td>
<td>
<script type="text/javascript" language="javascript"><!-- // --><![CDATA[
function show_image()
{
if (document.theAdminForm.icon.value !== "none")
{
// TODO: Should this detect the sources URL, rather than just assume?
var image_url = "', $settings['images_url'], '/battle/monsters/" + document.theAdminForm.icon.value;
document.images["icon"].src = image_url;
}
else
{
document.images["icon"].src = "', $settings['images_url'], '/battle/monsters/blank.gif";
}
}
// ]]></script>
<select name="img" id="icon" onchange="show_image()">
<option value="blank.gif"', ($context['monster']['img'] == 'blank.gif' ? ' selected="selected"' : ''), '>
', $txt['battle_none'], '
</option>';

// Get all images for the dropdown list
foreach ($context['battle_images'] as $image)
echo '
<option value="', $image, '"', ($context['monster']['img'] == $image ? ' selected="selected"' : ''), '>
', $image, '
</option>';

echo '
</select>';

if (empty ($context['monster']['img']))
echo '
<img name="icon" src="', $settings['images_url'], '/battle/monsters/blank.gif" border="1" alt="" />';
else
echo '
<img name="icon" src="', $settings['images_url'], '/battle/monsters/', $context['monster']['img'], '" border="1"  alt="" />';

echo '
<br />
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<input type="submit" name="submit" value="'.$txt['battle_save'].'" />
</td>
</tr>
</table>
<input type="hidden" name="monster" value="', $context['monster']['id'], '" />
<input type="hidden" name="sc" value="', $context['session_id'], '" />
</form>';
}

Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 10:22:09 PM
For the install you need to add this code in that file perhaps under the code you just posted from that file:

$smcFunc['db_add_column']('{db_prefix}battle_monsters',
array(
'name' => 'mon_max_range',
'type' => 'int',
'size' => '10',
'null' => false
)
);


also in the language file you need to change the text of the $txt variable.
ie.

$txt['battle_monsters_range'] = 'Battle Monster Range (Min/Max)';


Also I corrected the last code as I left an extra input by mistake.. please copy and paste it anew.
Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 10:27:46 PM
Fog,

  If you like your template editing then just make sure the input field for the addition is something like this:

<input type="text" name="mon_max_range" value="', $context['monster']['mon_max_range'], '" />


... and it should work for allowing the input.
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 10:28:53 PM
$smcFunc['db_add_column']('{db_prefix}battle_monsters',
array(
'name' => 'mon_range',
'type' => 'varchar',
'size' => '255',
'null' => false
)
);
   
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 10:31:41 PM
which code...sorry


I thought you meant my last one.
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 10:33:25 PM
Quote from: underdog on July 11, 2013, 10:12:37 PM
Fog,

Here is the admin template code. I fixed up the html a bit as it was broken (errors). I am not sure if it looks proper atm as I am not able to test it.


function template_monsterEdit_Add()
{
global $context, $scripturl, $settings, $txt;

$context['battle_images'] = getImageList();

echo '
<form action="', $scripturl, '?action=admin;area=battle;save;sa=savemonster" method="post" name="theAdminForm" accept-charset="', $context['character_set'], '">
<table border="0" width="80%" align="center" cellspacing="1" cellpadding="3" class="tborder windowbg2">
<tr class="titlebg">
<td>'.$txt['battle_monsters'].'</td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_name'].'</td>
<td><input type="text" name="name" value="', $context['monster']['name'], '" /></td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_atk'].'</td>
<td><input type="text" name="atk" value="', $context['monster']['atk'], '" /></td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_def'].'</td>
<td><input type="text" name="def" value="', $context['monster']['def'], '" /></td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_hp'].'</td>
<td><input type="text" name="hp" value="', $context['monster']['hp'], '" /></td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_m_hp'].'</td>
<td><input type="text" name="max_hp" value="', $context['monster']['max_hp'], '" /></td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_range'].'</td>
<td>
<span>
<input type="text" name="mon_range" size="6" maxlength="5" value="', $context['monster']['mon_range'], '" />
</span>
<span style="position:relative;left:10px;">
<input type="text" name="mon_max_range" size="6" maxlength="5" value="', $context['monster']['mon_max_range'], '" />
</span>
</td>
</tr>
<tr>
<td style="text-align: right;">'.$txt['battle_monsters_img'] .'</td>
<td>
<script type="text/javascript" language="javascript"><!-- // --><![CDATA[
function show_image()
{
if (document.theAdminForm.icon.value !== "none")
{
// TODO: Should this detect the sources URL, rather than just assume?
var image_url = "', $settings['images_url'], '/battle/monsters/" + document.theAdminForm.icon.value;
document.images["icon"].src = image_url;
}
else
{
document.images["icon"].src = "', $settings['images_url'], '/battle/monsters/blank.gif";
}
}
// ]]></script>
<select name="img" id="icon" onchange="show_image()">
<option value="blank.gif"', ($context['monster']['img'] == 'blank.gif' ? ' selected="selected"' : ''), '>
', $txt['battle_none'], '
</option>';

// Get all images for the dropdown list
foreach ($context['battle_images'] as $image)
echo '
<option value="', $image, '"', ($context['monster']['img'] == $image ? ' selected="selected"' : ''), '>
', $image, '
</option>';

echo '
</select>';

if (empty ($context['monster']['img']))
echo '
<img name="icon" src="', $settings['images_url'], '/battle/monsters/blank.gif" border="1" alt="" />';
else
echo '
<img name="icon" src="', $settings['images_url'], '/battle/monsters/', $context['monster']['img'], '" border="1"  alt="" />';

echo '
<br />
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<input type="submit" name="submit" value="'.$txt['battle_save'].'" />
</td>
</tr>
</table>
<input type="hidden" name="monster" value="', $context['monster']['id'], '" />
<input type="hidden" name="sc" value="', $context['session_id'], '" />
</form>';
}


Are you suggesting I should replace the whole admin template code with the one you have posted?

Just making sure...
Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 10:35:13 PM
Fog,

  You posted an image in this message: Here (http://webdevelop.comli.com/index.php?topic=35.msg46#msg46) ... which showed a max input. I posted what the input field should be for that file input in case you did it incorrectly.
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 10:36:13 PM
I see what you did...
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 10:44:33 PM
Quote from: underdog on July 11, 2013, 10:35:13 PM
Fog,

  You posted an image in this message: Here (http://webdevelop.comli.com/index.php?topic=35.msg46#msg46) ... which showed a max input. I posted what the input field should be for that file input in case you did it incorrectly.

OK...

This is what I did to create the input field, under the Battle Admin Temp.

function template_monsterEdit_Add()

{

global $context, $scripturl, $settings, $txt;



echo '

<form action="', $scripturl, '?action=admin;area=battle;save;sa=savemonster" method="post" name="theAdminForm" accept-charset="', $context['character_set'], '">

<table border="0" width="80%" align="center" cellspacing="1" cellpadding="3" class="tborder">

<tr class="titlebg">

<td>'.$txt['battle_monsters'].'</td>

</tr>

<tr>

<td class="windowbg2">

<table border="0" cellpadding="3" width="80%">

<tr>

<td style="text-align: right;">'.$txt['battle_monsters_name'].'</td>

<td><input type="text" name="name" value="', $context['monster']['name'], '" /></td>

</tr>

<tr>

<td style="text-align: right;">'.$txt['battle_monsters_atk'].'</td>

<td><input type="text" name="atk" value="', $context['monster']['atk'], '" /></td>

</tr>

<tr>

<td style="text-align: right;">'.$txt['battle_monsters_def'].'</td>

<td><input type="text" name="def" value="', $context['monster']['def'], '" /></td>

</tr>

<tr>

<td style="text-align: right;">'.$txt['battle_monsters_hp'].'</td>

<td><input type="text" name="hp" value="', $context['monster']['hp'], '" /></td>

</tr>

<tr>

<td style="text-align: right;">'.$txt['battle_monsters_m_hp'].'</td>

<td><input type="text" name="max_hp" value="', $context['monster']['max_hp'], '" /></td>

</tr>

<tr>

                            <td style="text-align: right;">'.$txt['battle_monsters_range'].'</td>

                            <td><input type="text" name="mon_range" value="', $context['monster']['mon_range'], '" /></td>

                        </tr>

</tr>
                                         <tr>

                            <td style="text-align: right;">'.$txt['battle_monsters_max_range'].'</td>

                            <td><input type="text" name="mon_max_range" value="', $context['monster']['mon_max_range'], '" /></td>

                        </tr>

</tr>
Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 10:48:21 PM
Fog,

  As long as the input was correct although there are HTML errors there. Most browsers will fix those HTML errors but really you should fix them up.

Anyhow, I made a few mistakes in the source file edit.. look back at this post: Here (http://webdevelop.comli.com/index.php?topic=35.msg41#msg41) ... and apply that edit to the admin source file again as I just fixed it. 
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 10:51:52 PM
I see what you just edited...give me a minute.
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 11:06:28 PM
Done...and it works.

I thank you so much...

We'll give it a try and see how this works out...

I don't know how to thank you...

This is awesome...

Underdog...thanks for spending the time with me.

You're a great teacher.
Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 11:10:49 PM
Fog,

  No problem. You are not finished yet though... We did not apply the new setting to the battle/map source file. All we did was add the appropriate setting to the template and allow it to save in the database. You need to now edit the source file that deals with battling enemies/monsters and apply the new setting the way you want it to work (step 4) ref. here (http://webdevelop.comli.com/index.php?topic=35.msg43#msg43).
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 11:26:59 PM
OK...

Step four should make more sense to me now...I was lost on that step.

Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 11:40:17 PM
Fog,

  In the other source file (for battle/map) you need to find where it queries the database for the mon_range value from that table and make it also query the mon_max_range value and put it in the appropriate array/variable. Then when it uses logic to apply the mon_range value you need additional logic for the new mon_max_range value and apply it as you see fit.

ie.

if ($userPower < $mon_range)
{// ignore the user}


becomes...

if ($userPower < $mon_range || $userPower > $mon_max_range)
{// ignore the user}


.. not those variables as that is just an example.
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 11:45:17 PM
thank you...
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 11:49:11 PM
Right now I have all the min max levels below the current level I'm at but yet I can still attack these lower level tanks.

I'm guessing that goes hand in hand what you've been posting....
Title: Re: Battle Mod
Post by: Fog on July 11, 2013, 11:52:11 PM
Quote from: underdog on July 11, 2013, 11:10:49 PM
Fog,

  No problem. You are not finished yet though... We did not apply the new setting to the battle/map source file. All we did was add the appropriate setting to the template and allow it to save in the database. You need to now edit the source file that deals with battling enemies/monsters and apply the new setting the way you want it to work (step 4) ref. here (http://webdevelop.comli.com/index.php?topic=35.msg43#msg43).

Under what PHP file should I be looking for these functions?
Title: Re: Battle Mod
Post by: Chen Zhen on July 11, 2013, 11:56:09 PM

Fog,

  There should be another php file in the Sources folder for that mod. The one you posted earlier was just for the admin settings. The one you are looking for is for battle. I do not have this mod so I can not look for you. 
Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 12:04:14 AM
Quote from: underdog on July 11, 2013, 11:56:09 PM

Fog,

  There should be another php file in the Sources folder for that mod. The one you posted earlier was just for the admin settings. The one you are looking for is for battle. I do not have this mod so I can not look for you.

So in theory where I will find the mon_range function I need to add a mon_max_range function to link the action to the data base.
Title: Re: Battle Mod
Post by: Chen Zhen on July 12, 2013, 12:06:02 AM
Fog,

  As I stated I do not have the mod to look for myself. I am guessing that Battle.php is the control file and it uses require_once() or include_once() to bring up the other files as it needs them. You may have to edit 2 or 3 files to accomplish your task.
  I would look at Battle.php, Battle_Battle.php and Battle_Monsters.php. Use the search function in your editor to look for that column value (ctrl-f) from those files.
Title: Re: Battle Mod
Post by: Chen Zhen on July 12, 2013, 12:16:19 AM
Fog,

  Take a good look at those source files tonight. Post in here if/when you need further assistance and I will respond tomorrow.. time for some tv and then bed. 
Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 12:22:03 AM
Quote from: underdog on July 12, 2013, 12:16:19 AM
Fog,

  Take a good look at those source files tonight. Post in here if/when you need further assistance and I will respond tomorrow.. time for some tv and then bed.

I will sir...have a good night

Thanks.
Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 06:22:48 PM
I found all the mon_range in the sources...however I did find this in Battle Temp.

// Attack or run away?

if (empty($row['mon_range']) or $row['mon_range'] <= $user_info['level']) {

echo '

                <br />

                <form action="' . $scripturl . '?action=battle;sa=fm;mon='.$row['id_monster'].'" method="post">

<input type="submit" value ="'.$txt['battle_atk'].'" />

                 </form>

'.$txt['battle_or'].'<br />

                 <form action="' . $scripturl . '?action=battle;sa=explore" method="post">

                 <input type="submit" value ="'.$txt['battle_run'].'" />

                 </form>';

}

else {

echo '<br />'.$txt['battle_not_range'].'',

battle_return();

}

}

}

}

}



Not sure what to do with this code...

It looks like this code you posted...

if ($userPower < $mon_range || $userPower > $mon_max_range)
{// ignore the user}
Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 08:05:08 PM
BTW...this is what the page looks like when you create or edit a Tank.

Title: Re: Battle Mod
Post by: Chen Zhen on July 12, 2013, 09:44:16 PM
Fog,

Perhaps this is what you want for that edit :

// Attack or run away?
$checkTank = array(!empty($row['mon_range']) ? $row['mon_range'] : 1, !empty($row['mon_max_range']) ? $row['mon_max_range'] : 1);
if ($checkTank[0] >= $user_info['level'] && $checkTank[1] <= $user_info['level']) {

echo '

                <br />

                <form action="' . $scripturl . '?action=battle;sa=fm;mon='.$row['id_monster'].'" method="post">

<input type="submit" value ="'.$txt['battle_atk'].'" />

                 </form>

'.$txt['battle_or'].'<br />

                 <form action="' . $scripturl . '?action=battle;sa=explore" method="post">

                 <input type="submit" value ="'.$txt['battle_run'].'" />

                 </form>';

}

else {

echo '<br />'.$txt['battle_not_range'].'',

battle_return();

}

}

}

}

}


  Before that will work you have to ensure it queries $row['mon_max_range'] in the mysql directly prior to it.

  Imo should be Tanks Attack Range instead of Tanks Starting Range because it is min/max. The template looks good but perhaps position the image directly above the drop-down directly to the right of Tank Image: (<-- couple of spaces)? .. just a suggestion.
Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 10:00:19 PM
Doing some testing...the min is working no problem

But the max isn't so far.
Title: Re: Battle Mod
Post by: Chen Zhen on July 12, 2013, 10:02:29 PM
Fog,

  Check the edit again as I adjusted it. You need to add to the mysql query prior to the above edit. Show me the mysql ($smcFunc) just before that edit within the while loop.
Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 10:06:00 PM
How do I add the MySQL query and how would I show you?

Title: Re: Battle Mod
Post by: Chen Zhen on July 12, 2013, 10:11:24 PM
Fog,

  The code you posted used a $row array so I am assuming just before that code is something querying data from the db. You will see something with $smcFunc in it follow by a while loop.

ie.

$request = $smcFunc['db_query']('', '

   SELECT name, atk, def, hp, img, max_hp, mon_range

   FROM {db_prefix}battle_monsters

   WHERE id_monster = {int:id_monster}',

   array(

      'id_monster' => $context['monster']['id'],

   )

);

  while ($row = $smcFunc['db_fetch_assoc']($request))

  {


.. you need to add mon_max_range to the query...


SELECT name, atk, def, hp, img, max_hp, mon_range, mon_max_range

Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 10:19:33 PM
function battle_search() {



global  $context, $user_info, $txt, $modSettings, $smcFunc;



// In the end every one of these should have a template instead of sharing.

$context['sub_template']  = 'battle_search';

$context['page_title'] = $txt['battle_expl'];



if(isset($_GET['open'])) {

// This is just here for now to pass the data.

explore_custom();

    } else {

// New battle search. Needed it badly, couldn't tell first attack from monsters or actions.

$rand = mt_rand(1, 2); // Well lets not count out the random

if ($rand == 1) {explore_custom_init();} else {explore_monster_init();}

}

}



function explore_custom_init() {



global  $context, $user_info, $txt, $modSettings, $smcFunc;



//Instead we will put a tag in a var.

$context['isbattle_action'] = true; // Now we know where we are.

$request = $smcFunc['db_query']('', '

SELECT m.id_explore, m.start

FROM {db_prefix}battle_explore AS m

ORDER BY RAND()

LIMIT 1',

array()

);



// Loop through all results

while ($row = $smcFunc['db_fetch_assoc']($request)) {

// And add them to the list

$context['battle_explore'][] = array(

'id_explore' => $row['id_explore'],

'start' => html_entity_decode($row['start']),

);

}

$smcFunc['db_free_result']($request);

}



function explore_monster_init() {



global  $context, $user_info, $txt, $modSettings, $smcFunc;



// First Attack !!!

$this_qfirstatk = mt_rand (0, 3);

if ($this_qfirstatk == 1) {

$this_firstatk = mt_rand (0, 25);

if ($this_firstatk > 0) {

$context['battle']['firstatk'] = $this_firstatk;

$user_info['hp'] = $user_info['hp'] - $this_firstatk;

if($user_info['hp'] < 0) {

$user_info['hp'] = 0;

$context['battle']['firstdead'] = true;

}

updateMemberData($user_info['id'], array('hp' => $user_info['hp']));

}

}

$request = $smcFunc['db_query']('', '

SELECT m.id_monster, m.name, m.atk, m.def, m.hp, m.img, e.id_explore, e.start, m.mon_range, m.mon_max_range

FROM {db_prefix}battle_monsters AS m

INNER JOIN {db_prefix}battle_explore AS e

WHERE hp <> 0

ORDER BY RAND()

LIMIT 1',

array()

);



// Loop through all results

while ($row = $smcFunc['db_fetch_assoc']($request)) {

// And add them to the list

$context['battle_explore'][] = array(

'id_monster' => $row['id_monster'],

'name' => $row['name'],

'mon_range' => $row['mon_range'],

                    'mon_max_range' => $row['mon_max_range'],

'atk' => $row['atk'],

'def' => $row['def'],

'hp' => $row['hp'],

'img' => $row['img']

);

}

$smcFunc['db_free_result']($request);

}

Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 10:23:18 PM
// Query the database for the targets information.

$request = $smcFunc['db_query']('','

SELECT def, atk, max_hp, hp, name, mon_range, mon_max_range

FROM {db_prefix}battle_monsters

WHERE id_monster = '.$attack_id.'

LIMIT 1'

);

while ($row = $smcFunc['db_fetch_assoc']($request)) {

$context['battle_target'] = array(

'def' => $row['def'],

'mon_range' => $row['mon_range'],

                    'mon_max_range' => $row['mon_max_range'],

'atk' => $row['atk'],

'max_hp' => $row['max_hp'],

'hp' => $row['hp'],

'name' => $row['name'],

);

}



This is what I have currently...as is the code above.
Title: Re: Battle Mod
Post by: Chen Zhen on July 12, 2013, 10:39:18 PM

Fog,

  Does it still allow you to attack the monster/tank? or does it say tank not in range?
Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 10:39:59 PM
it's not with those last two codes I posted...

I've been tweaking the code prior to that and user-info.

I changed this code:

// Attack or run away?
$checkTank = array(!empty($row['mon_range']) ? $row['mon_range'] : 1, !empty($row['mon_max_range']) ? $row['mon_max_range'] : 1);
if ($checkTank[0] >= $user_info['level'] && $checkTank[1] <= $user_info['level']) {

echo '

                <br />


to

// Attack or run away?
$checkTank = array(!empty($row['mon_range']) ? $row['mon_range'] : 1, !empty($row['mon_max_range']) ? $row['mon_max_range'] : 2);
if ($checkTank[1] >= $user_info['level'] && $checkTank[2] <= $user_info['level']) {

echo '

                <br />


I was able to attack the Tanks but the level didn't matter.

In your code I couldn't attack period.
Title: Re: Battle Mod
Post by: Chen Zhen on July 12, 2013, 10:44:25 PM

Fog,

  Both the mysql codes you posted put the data into $context yet the logic you posted was just using $row ... therefore you are not posting the proper mysql query.

this is the line of logic code you posted originally:

if (empty($row['mon_range']) or $row['mon_range'] <= $user_info['level']) {


.. see how it is using the $row array & not $context .. where is the mysql query for that code? 
Title: Re: Battle Mod
Post by: Chen Zhen on July 12, 2013, 10:49:31 PM

What are you trying to accomplish btw?
Do you want to be able to attack the tanks no matter what?
Do you not want to be able to attack the tanks when your user level is beyond the range?
Do you not want the tanks to attack you if outside the range?
Do you not want the tanks to appear on the map if the user is outside the given range?

I have never played the game.. do the tanks attack you, vice versa or both?
Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 11:11:07 PM
What are you trying to accomplish btw?

QuoteDo you want to be able to attack the tanks no matter what?
Quote

Nope.  We want the choice to turn away.

QuoteDo you not want to be able to attack the tanks when your user level is beyond the range?

Yes.

QuoteDo you not want the tanks to attack you if outside the range?

Nope.

QuoteDo you not want the tanks to appear on the map if the user is outside the given range?

Good question...Yes

QuoteI have never played the game.. do the tanks attack you, vice versa or both?

The tanks can catch you off guard and inflect damage but what we also see is that strong tanks in the upper levels can still catch you off guard. That goes with your one about getting attacked by tanks outside your range.

If you come along a tank that hasn't caught you off guard you have the choice to attack or run.

The idea is to start out with weaker tanks like we saw at the beginning of WWII and over the course of several years(levels) you started to see bigger and better tanks but as you built these bigger tanks the old ones were either destroyed or made into training tanks.

But not have the bigger tanks engage you until you built up your atk and def through leveling up.
Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 11:13:59 PM
is this the $content part you're looking for?

function template_battle_search() {
global $context, $settings, $scripturl, $txt, $user_info, $modSettings;

echo'

<div class="title_bar">

<h3 class="titlebg"><span>'.$txt['battle_expl'].'</span></h3></div>';



foreach ($context['battle_explore'] as $row) {

if(isset($_GET['open'])) {

$num = mt_rand(1, 2);

if ($num == '1') {

echo'

<div align="center">

'.$row['outcome1'].'<br /> <br />

<form action="' . $scripturl . '?action=battle;sa=explore;home" method="post">

            <input type="submit" value ="'.$txt['battle_back'].'" />

            </form>

<div>';

} elseif ($num == '2') {

echo'

<div align="center">

'.$row['outcome2'].'<br /><br />

<form action="' . $scripturl . '?action=battle;sa=explore;home" method="post">

            <input type="submit" value ="'.$txt['battle_back'].'" />

            </form>

<div>';

}



} else { // battle or explore action that is the question



if (isset($context['isbattle_action'])) { // Explore action

echo '

'.$row['start'].'<br />

              <br />

<div align="center">

            <form action="'. $scripturl . '?action=battle;sa=search;open='.$row['id_explore'].'" method="post">

            <input type="submit" value ="'.$txt['battle_ok'].'" />

</form>

            '.$txt['battle_or'].'<br />

            <form action="' . $scripturl . '?action=battle;sa=explore;home" method="post">

            <input type="submit" value ="'.$txt['battle_no'].'" />

            </form>

</div>';

} else { // Well it is not explore action, it has to be a MONSTER!!

echo'

<div align="center">

'.$txt['battle_you_in_mon'].'<br /><br />

'.$row['name'].' <br /><br /><img name="icon" src="', $settings['images_url'], '/battle/monsters/', $row['img'],'" alt="" /><br />

<img border="0" src="',$settings['images_url'],'/battle/bomb.png" alt="" />'.$txt['battle_atk'].'=', $row['atk'], '&nbsp;',  '&nbsp;', '<img border="0" src="',$settings['images_url'],'/battle/shield.png" alt="" /> '.$txt['battle_def'].'=', $row['def'],'';

if (isset($context['battle']['firstatk'])) { // Well did the monster attack first?

echo '

<br />'.$row['name'].' '.$txt['battle_game_mcog'].' '.$context['battle']['firstatk'].' '.$txt['battle_hist10'].'';

if (isset($context['battle']['firstdead'])) { // I guess they did attack first and killed you.

echo '

'.$txt['battle_game_mcog1'].'',

battle_return();

}

echo '

<br />';

}
Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 11:26:16 PM
On the DB...should I have both the mon_range  and mon_max_range on INT10?  because it's on VARCHAR 255.
Title: Re: Battle Mod
Post by: Chen Zhen on July 12, 2013, 11:48:55 PM
Fog,

Quote from: Fog on July 12, 2013, 11:26:16 PM
On the DB...should I have both the mon_range  and mon_max_range on INT10?  because it's on VARCHAR 255.

  Whomever created the db columns for that mod used varchar(255) which is for stings but used those columns for integers. This is ok but it would have been better and more secure if they created & used integer columns ( int(10) ) because it would force the saved data to always be integers. It makes no difference that I instructed you to create an integer column as you can mix the two within a table. I decided to do it proper for the column we added rather than copy what was already in place.

  The logic you previously posted is for when you decide to attack the tank or not. If you still want the option to do that or not to do that then perhaps change it back to how it was previously because that part you want to remain the same. You need to find the logic conditions for the other scenarios I listed to adjust their mysql queries and also the conditional logic that follows.

  Zip the mod in its current state and upload it to Tiny Upload (http://www.tinyupload.com/) ... then post the download link in this thread.



Title: Re: Battle Mod
Post by: Fog on July 12, 2013, 11:59:42 PM
OK...BRB
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 12:07:14 AM
http://s000.tinyupload.com/index.php?file_id=31228920135277626173

Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 12:26:53 AM
Here's some of the requests I've had to see if I could modify...

Can we do a progressive leveling up...

Meaning right now there is a set number we can input that it takes to level up per level.

What they suggested was if there was a way to create the game to progressively increase the number it take to level up.

In order to level up you have to gain experience points and you can do that by attacking tanks.

say it takes 2 exp points to hit the first level and then 4 exp points to hit the second level. The third level would take 8 exp points.
Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 12:36:49 AM

Fog,

  Let's do one thing at a time here and concentrate on what you were originally trying to alter.
The only thing you wanted to change regarding the tanks was that they don't attack you if the user level is outside specified range, is this correct?
All the other aspects like opting to attack any tank or all the tanks appearing on the map will remain the same, is this correct?
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 12:51:03 AM
Yes...
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 01:18:46 AM
Thanks so much...

Over the years I've been a theme maker and when one of my themes didn't work with SP...I learned about a little glitch and figured out how to fix it for my site and help some of the others over on SP.

This Battle Game I've been able to tweak here and there but is a far cry from what I know.

I want to learn more on how to do more tweaks but I'm not sure where to start.

You've been more than helpful in showing the steps needed....I'm a bit stuck on a few things to say the least.

Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 02:06:38 AM
Fog,

  I had to tend to something else for the moment.

  The link is for the mod with some edited files. If this does not work I will have to actually test the mod for another edit. I basically edited the same code as prior but fixed the mysql queries for it. I also omitted a lot of line breaks in php files I edited as I had a hard time perusing the files in their state.

http://s000.tinyupload.com/index.php?file_id=44201848699212582283
Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 09:29:04 AM
Fog,

  Is the lowest user level 1? What I mean is, does the user level start at 1 or does it start at 0? I made those adjustments assuming the user level starts at 1 and is never 0 is why I ask.
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 12:32:08 PM
We start at zero...

But the tanks only start at level 1...

There has been talk about me trying to fix it so a guy starts on level one instead of zero.

I'm testing a few things out this morning...I'll be lurking
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 01:30:05 PM
I downloaded the file you gave me and uploaded both templates and all the sources...Still finding that the Tank is out of range.

I'm at level 75 and I have the tank set at 1 and 100000

Database dlibson_ngs
Table structure for table ngs_battle_monsters
Column   Type   Null   Default
id_monster   int(10)   No   
atk   int(10)   No   
def   int(10)   No   
hp   int(10)   No   
max_hp   int(10)   No   
img   varchar(255)   No   
name   varchar(255)   No   
mon_range   int(10)   No   
mon_max_range   int(10)   No   
Dumping data for table ngs_battle_monsters
id_monster   atk   def   hp   max_hp   img   name   mon_range   mon_max_range
143   2   1   10   10   germany-ltraktor.png   Leichttraktor   1   100000


Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 02:35:59 PM

Fog,

  I have been editing the files of the mod including the admin template. I found by testing the game that the user starts at level 0 so I have now edited the source files accordingly.

  Are you the one who added mon_range to this mod? The logic statement you found and that I edited in the last post is for when the user attacks the enemy/monster. You stated that you want the option to attack the monster no matter what so it is not necessary in that part of the code and I will adjust it. Now I need to find where the monster decides to attack the user & not let it attack when the user is not in range. This is what you want to do, is that correct?
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 02:43:44 PM
No I didn't add the mon_range...see link below

http://www.simplemachines.org/community/index.php?topic=323835.0

QuoteThis is what you want to do, is that correct?

Yes...
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 03:02:25 PM
Right now...I updated all the sources and the Battle Template.

And it's working right however...it's backwards...I enter "1" in the max_range column and "80" in the mon_range column.
Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 03:43:17 PM
Use this mod install:
http://s000.tinyupload.com/index.php?file_id=48806241122561744862

.. the only edit you should have to make is changing the word monster to tank in the language file. All other edits are done including the admin template.


btw the part of code we were looking for was in Battle_Explore.php & was the function of explore_monster_init()
.. I had to bump the mysql query first to check the ranges and use logic to compare it to the user level.
The mod was set up to have a 1 in 5 chance of the monster attacking you. I edited it so that it will only do that if within the range level specified otherwise it will not attack.
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 03:43:44 PM
I switched this code and the greater than > or less than < and now it works perfect.

// Attack or run away?
if ($row['mon_range'] <= $user_info['level'] && $row['mon_max_range'] >= $user_info['level']) {
echo '



Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 03:45:28 PM
Quote from: Fog on July 13, 2013, 03:43:44 PM
I switched this code and the greater than > or less than < and now it works perfect.

// Attack or run away?
if ($row['mon_range'] <= $user_info['level'] && $row['mon_max_range'] >= $user_info['level']) {
echo '


Fog,

  That logic is for when you decide to attack the monster or not.. you said you still wanted the option so I changed that part of the code.
See my post above for the logic we were looking for.
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 03:59:24 PM
QuoteThat logic is for when you decide to attack the monster or not.. you said you still wanted the option so I changed that part of the code.
See my post above for the logic we were looking for.

OK I'm with you...

I just uploaded the templates and sources and it's working fine without changing those ">" or "<" around...

Totally Awesome...

I'm going to make some new tanks and give it some more testing...

Did you get your donation?
Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 04:28:12 PM
Fog,

  Thank you for the donation as it is appreciated.. I have not checked paypal yet but I will.

  There were some glitches with that last mod file that I have fixed. Before I post it should I change the possibility of those that can now attack to a greater percentage? The current setting is they will attack 25% of the time but since not all enemies attack now perhaps that number should be greater?? 40% or 50% ?? What do you think?
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 04:34:34 PM
QuoteThe current setting is they will attack 20% of the time but since not all enemies attack now perhaps that number should be greater?? 40% or 50% ?? What do you think?

That would be great but is that something I could find and change in the future if I wanted?
Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 04:48:57 PM
Fog,

  I set it to a 1 in 3 chance (33%) of the enemy attacking when within range and it works btw.

Here is that file:
http://s000.tinyupload.com/index.php?file_id=03658496250930052740

The edit for the occurrence is file: Sources/Battle/Battle_Explore.php
find:

// First Attack !!!
$this_qfirstatk = mt_rand (0, 2);

... the mt_rand function shown above picks a number 0, 1 or 2 ... if it is 1 then the enemy attacks.




  I noticed that after defeating an enemy when one clicks the link to explore it sometimes says a can't refresh error (in game error message). It is not a big deal as one can just opt the explore on the game's menu to the left but I am going to fix it anyhow. Imo this is not something I did by editing & was this already occurring before?


 
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 04:55:15 PM
There is a couple of missing echo' in the code...I'd have to go through the old thread over on SMF to figure out where they are missing.
Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 07:34:10 PM

Here is another mod zip file:
http://s000.tinyupload.com/index.php?file_id=03193651242874192554

  I believe I fixed the issue I noted prior and some others as well.

  It looks as though someone wanted to implement a way of taking points away from some stats, adding them to the usable stat points in order to apply them to others. I gather this is why there is a minus sign when one is out of stat points. I suppose it was not completed as it is not even a link and is currently only an image. I will look into this and possibly create some links and a function to do that.
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 07:56:22 PM
You may have hit on a glitch that we see every once in a while...

It's believed to be if you have saved any stat points and the game starts over they still show up and they don't get set back to zero.  However if you use the stat points it creates a minus stat number somewhere down the road.

Nobody can explain what they did to pin point where the glitch lays and it doesn't happen enough to know if it's really something we should be concerned about.

Under what file did you see that?

If it's under "Battle_Battle.php" then it probably was meant to attack another member and if you won you get to take away their stat points.

Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 08:08:29 PM

Fog,

  The stat points are for upgrading and the graphic minus sign is for taking them back to apply them elsewhere but that part has not been finished. I will finish it when I get the chance. The actual minus stat points are a penalty for cheating. This takes affect when one is out of stat points and attempts to use the url directly to apply them on various stats. There was an issue when it was down to 1 point which when used would penalize the user in error and set it to -1 instead of 0... I fixed that part and it should now operate properly.
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 08:16:16 PM
I see what you're saying...If they had 1200 in stat points on DEF they could do a minus and take it down to 900 and the apply those 300 stat points towards ATK.  That would be awesome....You've done so much it's been great.

Thanks Again for all this...
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 08:42:18 PM
Other ideas that you maybe able to add.

Progressive leveling up.

Making the Quests for only one level or putting a min max level(s) on them too.

Making the Custom Explore like the Tanks and Quests and tagging them with levels.
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 09:10:00 PM
First Error...

Members say they get this error when trying to battle another member.

http://s000.tinyupload.com/index.php?file_id=08886079756872952770&gk=hyip
Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 09:29:29 PM
Fog,

  That is most likely from me fixing some of those php source files. I need the actual error from the error log so I can pinpoint the line causing the issue.
Title: Re: Battle Mod
Post by: Chen Zhen on July 13, 2013, 09:43:14 PM

Fog,

  In /Sources/Battle/Battle_Battle.php

replace this function with code shown below:

function battle_fight()
{
global $smcFunc,  $monster, $sourcedir, $damage, $settings, $scripturl, $context, $txt, $modSettings, $user_info;
//We Need Our Template
$context['sub_template']  = 'battle_fight';
$context['page_title'] = $txt['battle'];

if ((@$_SESSION['just_attacked'] == 1))
fatal_error($txt['battle_cheatrefresh'], false);

$attack = !empty($_REQUEST['attack']) ? (int) $_REQUEST['attack'] : 0;
if ($attack == $user_info['id'])
fatal_error($txt['battle_error5'] , false);

// Query the database for the targets information.
$request = $smcFunc['db_query']('','
SELECT def, atk, hp, real_name, id_member, energy, stamina, level
FROM {db_prefix}members
WHERE id_member = '.$attack.'
LIMIT 1'
);

while ($row = $smcFunc['db_fetch_assoc']($request))
{
$context['battle_target'] = array(
'def' => $row['def'],
'atk' => $row['atk'],
'hp' => $row['hp'],
'real_name' => $row['real_name'],
'id_member' => $row['id_member'],
'energy' => $row['energy'],
'stamina' => $row['stamina'],
'level' => $row['level']
);
}
$smcFunc['db_free_result']($request);

// Figure out the attack and defense and who is better.
$which_atk = 0; $which_def = 0; $this_atk = 0; $this_def = 0;
if ($user_info['def'] > $context['battle_target']['atk'])
$which_atk = $context['battle_target']['atk'] - $user_info['def'];

if ($user_info['atk'] > $context['battle_target']['def'])
$which_def = $context['battle_target']['def'] - $user_info['atk'];

if ($context['battle_target']['def'] > $user_info['atk'])
$this_atk = $user_info['atk'] - $context['battle_target']['def'];

if ($context['battle_target']['atk'] > $user_info['def'])
$this_def = $user_info['def'] - $context['battle_target']['atk'];

// Figure out damage. Put a random seed in, just in case opponents are equal.
if ($user_info['energy'] > 0 && $user_info['stamina'] > 0 && $user_info['hp'] > 0)
{
$this_def = $this_def + mt_rand (0, 5) ;
$this_atk = $this_atk + mt_rand (0, 5);
$which_def = $which_def + mt_rand (0, 5);
$which_atk = $which_atk + mt_rand (0, 5);
if ($which_atk > $this_def)
$this_dmg = $which_atk - $this_def;
else
$this_dmg = mt_rand (0, 5);

if ($this_atk > $which_def)
$which_dmg = $this_atk - $which_def;
else
$which_dmg = mt_rand (0, 5);

//Lets deduct all the stats here since we know we are all good to go.
if ($context['battle_target']['hp'] > 0)
{
// Calculate hp for target and user
$this_hp = $user_info['hp'] - $this_dmg;
$which_hp = $context['battle_target']['hp'] - $which_dmg;
if ($this_hp < 0)
$this_hp = 0;

if ($which_hp < 0)
$which_hp = 0;

// Deduct stamina. Energy commented out, not too common battle apps use energy for attacks, so it made sense to undo my code.
//if ($user_info['energy'] > 0) {$this_energy =  $user_info['energy'] - 1;}
if ($user_info['stamina'] > 0)
$this_stam =  $user_info['stamina'] - 1;

// Some random and logic experience routines.
// Note: I turned exp_def_mem into a max exerience cap, language files need edit to reflect this.[DONE]
if ($user_info['level'] <= $context['battle_target']['level'] && $this_dmg < $which_dmg || $user_info['level'] <= $context['battle_target']['level'] && $which_hp == 0)
{
$this_exp = $user_info['level'] - $context['battle_target']['level'];
$this_exp = $this_exp + mt_rand (0, 3);
if ($this_exp < 1)
$this_exp = 1;

if ($this_exp > $modSettings['exp_def_mem'])
$this_exp = $modSettings['exp_def_mem'];
}

}
else
fatal_error($txt['battle_game_error_toolate'], false);
}
else
fatal_error($txt['battle_game_error_rrro'], false);


//Some stuff to show the user depending on the outcome. Again need to get this assosicated with language files.
if ($which_dmg < $this_dmg)
{
// You lost
@$context['battle_message'] .= '
<center><img border="0" src="'.$settings['images_url'].'/battle/winloose/looser.png" alt=""/></center>
<br />'.$txt['battle_game_lost_you1'] .' '.$which_dmg.' '.$txt['battle_game_lost_you2'].'
<strong>'.$context['battle_target']['real_name'].'</strong> '.$txt['battle_game_lost_you3'].' '.$this_dmg.' '.$txt['battle_game_pm_msg1'].'<br  />';
}
elseif ($which_dmg > $this_dmg)
{
// You won
@$context['battle_message'] .= '
<center><img border="0" src="'.$settings['images_url'].'/battle/winloose/victory.png" alt=""/></center>
<br />'.$txt['battle_game_won_you'].' '.$which_dmg.' '.$txt['battle_game_lost_you2'] .'
<strong>'.$context['battle_target']['real_name'].'</strong> '.$txt['battle_game_lost_you3'].' '.$this_dmg.' '.$txt['battle_game_pm_msg1'].'.<br  />';
}
else
{
// You tied
@$context['battle_message'] .= '
<center><img border="0" src="'.$settings['images_url'].'/battle/winloose/draw.png" alt=""/></center>
<br />'.$txt['battle_game_tied_you'].' '.$which_dmg.' '.$txt['battle_game_lost_you2'].'
<strong>'.$context['battle_target']['real_name'].'</strong> '.$txt['battle_game_lost_you3'].' '.$this_dmg.' '.$txt['battle_game_pm_msg1'].'.<br  />';
}

// If they got some experience show them.
if (isset($this_exp))
$context['battle_message'] .= ''.$txt['battle_game_this_exp'].' '.$this_exp.' '.$txt['battle_game_this_exp1'].'.';

// How about a battle again link? That is if no one is dead.
if ($this_hp > 0 && $which_hp > 0)
{
$context['battle_message'] .= '<br />
'.$txt['battle_this_member'].' '.$which_hp.' '.$txt['battle_points_left'].'
        <form action="' . $scripturl . '?action=battle;sa=fight;attack='.$attack.';home" method="post">
<input type="submit" value ="'.$txt['battle_ex_atk_again'].'" />
</form>';
}

if ($this_hp < 1)
{
// You were killed
$context['battle_message'] .= '
<br /><br />'.$txt['battle_game_99'].' <strong>'.$context['battle_target']['real_name'].'</strong> '.$txt['battle_game_101'].'';
$bhist = ''.$user_info['name'].' '.$txt['battle_hist23'].' '.$context['battle_target']['real_name'].' '.$txt['battle_hist24'].'';
}

if ($which_hp < 1)
{
// You killed them
$context['battle_message'] .= '
<br /><br />'.$txt['battle_game_102'].' <strong>'.$context['battle_target']['real_name'].'</strong>.';
battle_return();
$bhist = ''.$user_info['name'].' '.$txt['battle_hist25'].' '.$context['battle_target']['real_name'];
$_SESSION['just_attacked'] = 1;
$this_slays =  $user_info['mem_slays'] + 1;
}

// Get ready to apply everything
$t = time();
if (isset($this_hp))
updateMemberData($user_info['id'], array('hp' => $this_hp));

if (isset($this_stam))
updateMemberData($user_info['id'], array('stamina' => $this_stam));

// if (isset($this_energy)) {updateMemberData($user_info['id'], array('energy' => $this_energy));}
if (isset($this_exp))
{
$this_exp =  $user_info['exp'] + $this_exp;
updateMemberData($user_info['id'], array('exp' => $this_exp));
}

if (isset($this_hp) && $this_hp == 0)
{
updateMemberData($user_info['id'], array('is_dead' => 1));
battle_Insert_dead($context['battle_target']['id_member'],$user_info['id'],$user_info['username'],$t);
}

if (isset($which_hp))
updateMemberData($context['battle_target']['id_member'], array('hp' => $which_hp));

if (isset($which_hp) && $which_hp == 0)
{
updateMemberData($context['battle_target']['id_member'], array('is_dead' => 1));
updateMemberData($user_info['id'], array('mem_slays' => $this_slays));
battle_Insert_dead($user_info['id'],$context['battle_target']['id_member'],$context['battle_target']['real_name'],$t);
}

//Reset some stuff before the template is phased, we have to be acurate because we just took some points away.
if (isset($this_hp))
$user_info['hp'] = $this_hp;

if (isset($this_stam))
$user_info['stamina'] = $this_stam;

if (isset($this_energy))
$user_info['energy'] = $this_energy;

if (isset($this_exp))
$user_info['exp'] = $this_exp;

if($modSettings['enable_battle_hist'] && isset($bhist))
add_to_battle_hist($bhist);

$request = $smcFunc['db_query']('','
SELECT bpm
FROM {db_prefix}members
WHERE  id_member = {int:attack}
LIMIT 1',
array(
'attack' => $attack,
)
);

list ($no_pm_battle) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

if ($no_pm_battle)
{
$msg = ''.$user_info['username'].' '.$txt['battle_game_pm_msg'].' '.$which_dmg.' '.$txt['battle_game_pm_msg1'].'
[url='. $scripturl. '?action=battle;sa=fight;attack='.$user_info['id'].']'.$txt['battle_game_pm_msg2'].'[/url]';

require_once($sourcedir.'/Subs-Post.php');
$pmfrom = array(
'id' => 0,
'name' => $txt['battle_game_pm_msg3'],
'username' => $txt['battle_game_pm_msg3']
);

$pmto = array(
'to' => array($context['battle_target']['id_member']),
'bcc' => array()
);
sendpm($pmto, $txt['battle_game_pm_msg4'], $msg, 0, $pmfrom);
}
}


Newer mod file with above edit is here:
http://s000.tinyupload.com/index.php?file_id=62244121491388326514
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 10:13:02 PM
I have a couple members playing it right now and that's how they found that error...

However they don't like the idea of being able to have a choice of attacking the tank out of range....

They are now asking if they can only attack tanks that include their level in the tanks settings...

I was thinking that they would like the option...

I'll tell them to donate $15 to get the changes done...LOL

You've poured a ton of effort into this and my members are embracing the idea but are full of questions...

I'm amazed how far you've help changed the game...

I'll try to handle most of their question on my end and make sure I'm not going to be a pain in the ass.

It would be cool to get it all dialed in...
Title: Re: Battle Mod
Post by: Fog on July 13, 2013, 10:26:09 PM
I didn't get an error when attacking a member so it looks like that fixed it...

Thanks.

I'm guessing my screen shots with the url help point you in the right direction...

Like I said I didn't know where to start but you've been patient with me and I'm seeing how this all gets mapped out...

Title: Re: Battle Mod
Post by: Chen Zhen on July 14, 2013, 01:08:21 AM

Fog,

Here is another file:
http://s000.tinyupload.com/index.php?file_id=02192852801545469294

If you are using your language file to replace, make sure to add this:

$txt['battle_hp_low'] = '<strong>Warning: Your HP is getting low</strong>';


When a person's HP is running low in the middle of a battle it will display a warning to them with a link to the shop.
I moved the attack link/button to the bottom when in battle so that it is easy to know which to press quickly.
Other needed links/buttons are displayed now after defeating monsters/users. Also if the person is dead and attempts to access a quest or explore they get a warning with a link which was missing before.

Prior to me adding anything requested I am going to fix the Leaders info which is not working at the moment.
I do not understand why they do not like the option of attacking the monster. If they do not want to attack, simply run away.
Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 11:19:45 AM
I hope you got some sleep sometime last night....

You've done more than I ever expected...Thanks
Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 12:29:35 PM
I have one guy on my website that does most of the admin work on the game and so I gave him the same questions you gave me.

Here's what he said...

What are you trying to accomplish btw?   Ideally I'd love to have the quests dependent upon more than level & energy.   Level & stamina?  Our choice to force them to level their attributes equally.

Do you want to be able to attack the tanks no matter what?  No.

Do you not want to be able to attack the tanks when your user level is beyond the range?  That would speed and clean things up.  Might go against the plan if the goal is to slow them up a bit.

Do you not want the tanks to attack you if outside the range? Definitely not be able to attack tanks above your level.  Under...see last ?

Do you not want the tanks to appear on the map if the user is outside the given range?  It would speed things up if that didn't happen.  Do it.  Much cleaner.

I have never played the game.. do the tanks attack you, vice versa or both? You attack tanks except for the "catch you unaware" thing.  Losing that would be good for people starting out.


I kind of thought the other way round myself on a few things...
Title: Re: Battle Mod
Post by: Chen Zhen on July 14, 2013, 07:58:11 PM

Update:
http://s000.tinyupload.com/index.php?file_id=02067557409636957051

Changes:

! Added/Finished Leaders Board
! Fixed Admin -> Battle -> Members template and source files
! Language additions and changes
! Changed low hp warning logic and changed its button to just a link




  I'm going to get hold of Wayne & ask if I can take over this mod. After which I am going to fix all the code in it, make more changes/additions and release it anew.

Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 08:33:13 PM
I have Wayne on FB...do I need to say anything?

He knows I've been seeking help via FB...

Totally Awesome Job....

Let me know how I can help...
Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 09:37:33 PM
This may be an error on my part. I changed up the English text.

But there isn't a button to click on...

(http://www.ngsforums.com/forums/images/NOBUTTON.PNG)
Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 09:41:52 PM
Here's another look at the no button for repairs.

(http://www.ngsforums.com/forums/images/Repair.PNG)
Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 09:49:17 PM
If you want me to show you errors another way let me know.
Title: Re: Battle Mod
Post by: Chen Zhen on July 14, 2013, 09:51:59 PM

Fog,

  You must have changed the entire hyperlink to just text.  Show me the edit you did to the language file that caused that issue.
Title: Re: Battle Mod
Post by: Chen Zhen on July 14, 2013, 09:59:48 PM
Fog,

  Is this mod's normal behavior set up where an admin/moderator must add users to the game? Or does it normally start someone out with default stat values?
Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 10:06:05 PM
Quote from: underdog on July 14, 2013, 09:51:59 PM

Fog,

  You must have changed the entire hyperlink to just text.  Show me the edit you did to the language file that caused that issue.

Does your language file contain the link? If that's the case that would be the issue.
Title: Re: Battle Mod
Post by: Chen Zhen on July 14, 2013, 10:09:15 PM
Fog,

  Yes the language file contains the link now. It has some other additions as well & I forgot to keep track of them for you.
I received permission to modify this mod and release it btw.
Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 10:11:28 PM
Quote from: underdog on July 14, 2013, 09:59:48 PM
Fog,

  Is this mod's normal behavior set up where an admin/moderator must add users to the game? Or does it normally start someone out with default stat values?

With Default settings...
Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 10:13:36 PM
Quote from: underdog on July 14, 2013, 10:09:15 PM
Fog,

  Yes the language file contains the link now. It has some other additions as well & I forgot to keep track of them for you.
I received permission to modify this mod and release it btw.

Very Cool....

I'm here to help
Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 10:19:52 PM
Just uploaded the English file...I like it.

Title: Re: Battle Mod
Post by: Chen Zhen on July 14, 2013, 10:27:40 PM
Fog,

  It is in the last package that I posted. Here it is anyhow:
http://s000.tinyupload.com/index.php?file_id=07073821101023625727

.. I forgot to do the utf-8 file, if you use utf-8 that would be the issue.

Regarding some of the requested options, I can add member settings so that some can turn on/off things for themselves. Such as meeting monsters out of range from the map. I have a lot of cleaning up files to do though which will take me some time because some are a huge mess.
Title: Re: Battle Mod
Post by: Fog on July 14, 2013, 10:44:51 PM
I download the zip and then I only updated the source and temp files because I have all tank lingo with my language file. but just added your version and it's fine and looks great.

I did a full install on my test site a few days ago...I haven't tried it with this version yet...but the install went fine.

I like the idea to turn off and on certain features but would like to see that part done on the admin side so everyone is on the same playing level.


Title: Re: Battle Mod
Post by: Fog on July 16, 2013, 10:07:18 PM
When adding a monster you can't see the drop down menu for an image.

Title: Re: Battle Mod
Post by: Fog on July 16, 2013, 10:48:32 PM
Over on the site I help run, we started a new game of battle prior me looking for help on this mod.

So far it's been flawless with the updates we've been doing with Underdog's help.

My guys have seen and noticed the differences but it hasn't disrupted the game what so ever.

I've fixed the admin glitch on my end and changed up a few other things.

Title: Re: Battle Mod
Post by: Chen Zhen on July 17, 2013, 10:07:15 PM
Fog,

  I have been working on the mod when I have the time and have added plus fixed a lot of issues thus far. I have a list of things I still have to do prior to releasing another beta in this thread. One thing I neglected to do was configure the leader board so it only holds ie. 50 entries. I don't think a file is really necessary to hold older entries (as does most shoutboxes and such) but I do plan to include a link option to display a longer list. At the moment it will actually eventually cause an issue if there is a lot of game play that records thousands of entries because it will not empty itself. I will give you a code to manually run in a php portal block until I program something proper for it.  As far as files go so far I have tabbed and edited the two template files so they are legible and pass my firefox code filter (tidy) and I will release it in the next few days. I still have not tabbed out the source and js files as of yet as that will take time when I get the chance to do it.

Here is a php code to truncate the leader board that you can use prior to the next beta release. Imo perhaps once a week run the code in a Simple Portal php block by using preview and disable the block (just use preview to use it).

global $smcFunc;

// set to true to omit all entries from the table
$truncate = false;

if ($truncate)
$smcFunc['db_query']('', "TRUNCATE TABLE {db_prefix}battle_champs");
else
{
$request = $smcFunc['db_query']('', "SELECT id_champ FROM {db_prefix}battle_champs ORDER BY id_champ DESC LIMIT 50");
while ($row = $smcFunc['db_fetch_assoc']($request))
$del = !empty($row['id_champ']) ? $row['id_champ'] : 0;

$smcFunc['db_free_result']($request);
if (!empty($del))
$smcFunc['db_query']('', "DELETE FROM {db_prefix}battle_champs WHERE id_champ < {int:champ}",array('champ' => $del));
}



... that will empty the battle_champs table of any data if $truncate is set to true else it will only hold the last 50 entries.
Also that template does not currently display the data from that table properly which I noticed and will fix it for next release.

Title: Re: Battle Mod
Post by: Fog on July 17, 2013, 11:48:16 PM
Thanks Underdog....Great Stuff

Title: Re: Battle Mod
Post by: Chen Zhen on July 20, 2013, 04:09:46 PM

Beta releases for this modification will now be posted here:
http://webdevelop.comli.com/index.php?topic=38.0

Those beta packages will only be available to forum members therefore guests will not be able to view or download them.
Title: Re: Battle Mod
Post by: Chen Zhen on July 20, 2013, 05:55:41 PM

Fog,

  I forgot to fix the add monster template in that beta version as you had reported earlier.
Here is another link for beta2 which includes that fix:
http://s000.tinyupload.com/index.php?file_id=08509210599181428654


... Imo the display is superior as compared to before. Although I must replace all the help text to question marks where the q-mark link is opted to see the help text... in the next beta perhaps.
Title: Re: Battle Mod
Post by: Fog on July 20, 2013, 06:51:59 PM
I'll get that version uploaded and tested...

Title: Re: Battle Mod
Post by: Fog on July 20, 2013, 10:02:16 PM
Do you want me to report errors here or over on the other thread?
Title: Re: Battle Mod
Post by: Chen Zhen on July 20, 2013, 10:16:32 PM
Fog,

  In the beta thread would be preferable.

Thanks.
Title: Re: Battle Mod
Post by: Skhilled on July 22, 2013, 09:38:43 AM
That is a great idea turning it into tanks. LOL
Title: Re: Battle Mod
Post by: Fog on July 22, 2013, 09:25:07 PM
Quote from: Skhilled on July 22, 2013, 09:38:43 AM
That is a great idea turning it into tanks. LOL

Thank you sir...My members are hooked on the game and are helping test the newest version.

I want to give a big thanks to Underdog and his efforts.

I've been a WWII Tank buff for a while now and saw how tanks could fit right into this game.

From the Custom Explore to Quests.

Then one of my members asked if we could do certain battles and only have tanks from that era playing.

Like the Custom Explore we would do things like: Your forward scouts spot a fuel depot with armed guards but no heavy armour do you decide to attack or retreat.

The Quests were made up to include boot camp for level zero and tank training level one then for the tank part we would have an easy tank you could destroy and level up.

I modified the text and learned a few other things I could like add pictures but my php coding skills didn't allow me to modify the game any further.
Title: Re: Battle Mod
Post by: Skhilled on July 23, 2013, 08:20:59 AM
I was an admin at SA Mods and help to create it but I have no coding skills...none to brag about. LOL It's funny to see that my monster is still in it.

Yes, you can modify it to create various types of quests. We had a list of them but they never were realized as the forum died when Wayne started going back to school.
EhPortal 1.39.6 © 2024, WebDev