Daily Lucky Numbers:
13
18
19
35
38
44

Battle Mod

Started by Fog, July 10, 2013, 10:14:27 PM

Previous topic - Next topic

Chen Zhen

Fog,

  You posted an image in this message: Here ... which showed a max input. I posted what the input field should be for that file input in case you did it incorrectly.

Fog

I see what you did...

Fog

Quote from: underdog on July 11, 2013, 10:35:13 PM
Fog,

  You posted an image in this message: Here ... 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>

Chen Zhen

#18
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 ... and apply that edit to the admin source file again as I just fixed it. 

Fog

I see what you just edited...give me a minute.

Fog

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.

Chen Zhen

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.

Fog

OK...

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


Chen Zhen

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

Fog


Fog

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

Fog

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

Under what PHP file should I be looking for these functions?

Chen Zhen


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. 

Fog

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.

Chen Zhen

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.