Browser MMO Video#6a and 6b

Location of the Videos
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#6a and 6b

Post by hallsofvallhalla »

look at video 7, i had a couple videos that i didnt get source on, so watch video 7 then get the source.
noahqw
Posts: 8
Joined: Fri Sep 04, 2009 9:48 pm

Re: Video#6a and 6b

Post by noahqw »

I need video 6 code for attack.php.... Please reply with code.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#6a and 6b

Post by hallsofvallhalla »

i cant i dont have it. If you continue to 7 it has the attack.php code.
princezane
Posts: 11
Joined: Sun Nov 29, 2009 3:35 am

Re: Video#6a and 6b

Post by princezane »

my attack.php after video 6. Everything that I have tested on it is working (calculating exp correctly, etc.), but of course it's possible there is a bug I hadn't triggered :roll:

attack.php

Code: Select all

<?php
include_once 'connect.php';
session_start();

if (isset($_SESSION['player']))
{
  $player = $_SESSION['player'];
}
else
{
  echo "Not logged in<br>";
  echo "<a href='login.php'>Login</a>";
  exit;
}

$playerinfo = "SELECT * from players where name='$player'";
$playerinfo2 = mysql_query ($playerinfo) or die ("could not get player stats!");
$playerinfo3 = mysql_fetch_array ($playerinfo2);

if (isset($_GET['creature']))
{
  $creature = $_GET['creature'];
  $creatureinfo = "select * from creatures where name = '$creature'";
  $creatureinfo2 = mysql_query ($creatureinfo) or die ("Could not get the creature you were fighting'");
  $creatureinfo3 = mysql_fetch_array ($creatureinfo2);
}
else
{
  echo "<a href='battle.php'>No creature selected. Go back!</a>";
  exit;
}

$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];

$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];

// player's turn

echo "<u> " . $playerinfo3['name'] . "'s Attack</u><br>";
$playerattack = rand(1,20) + $playerattack;
$creaturedefense = rand(1,20) + $creaturedefense;

echo $playerinfo3['name'] . "'s attack roll is " . $playerattack . "<br>";
echo $creature . "'s defense roll is " . $creaturedefense . "<br>";

if ($playerattack > $creaturedefense)
{
  echo $playerinfo3['name'] . " hits! <br>";
  $playerdamage = rand(1,6);
  $newcreaturehp = $creaturehp - $playerdamage;
  echo "For " . $playerdamage . " points of damage. <br>";
  if ($newcreaturehp < 1)
  {
    echo "The " . $creature . " has been killed!";
    $updatecreature = " delete from creatures where name = '$creature' limit 1";
    mysql_query($updatecreature) or die ("Could not update creature");
    if ($playerinfo3['level'] > $creatureinfo3['level'])
    {
      $firstmod = $playerinfo3['level'] - $creatureinfo3['level'];
      $secondmod = $firstmod * 10;
      if ($secondmod > 90) ($secondmod = 90);
      $thirdmod = ($secondmod / 100) * $creatureinfo3['exper'];
      $totalexper = $creatureinfo3['exper'] - $thirdmod;
    }
    else
    {
      $firstmod = $creatureinfo3['level'] - $playerinfo3['level'];
      $secondmod = $firstmod * 10;
      if ($secondmod > 90) ($secondmod = 90);
      $thirdmod = ($secondmod / 100) * $creatureinfo3['exper'];
      $totalexper = $creatureinfo3['exper'] + $thirdmod;
    }
    $totalexper = (int)$totalexper;

    echo "<br><big><b>You gain " . $totalexper . " experience.</b></big><br>";
    $updateplayer = "update players set exper = exper + '$totalexper' where name = '$player'";
    mysql_query ($updateplayer) or die ("Could not update player");

    echo "<a href='battle.php'> Go back";
    exit;
  }
  $updatecreature = "update creatures set hpoints = '$newcreaturehp' where name = '$creature' limit 1";
  mysql_query($updatecreature) or die("Could not update creature");
}
else
{
  echo $playerinfo3['name'] . " misses!<br>";
}

// creature's turn

echo "<u> " . $creature . "'s Attack</u><br>";
$creatureattack = rand(1,20) + $creatureattack;
$playerdefense = rand(1,20) + $playerdefense;

echo $creature . "'s attack roll is " . $creatureattack . "<br>";
echo $playerinfo3['name'] . "'s defense roll is " . $playerdefense . "<br>";

if ($creatureattack > $playerdefense)
{
  echo $creature . " hits! <br>";
  $creaturedamage = rand(1,6);
  $newplayerhp = $playerhp - $creaturedamage;
  echo "For " . $creaturedamage . " points of damage. <br>";
  if ($newplayerhp < 1)
  {
    echo $playerinfo3['name'] . " has been killed! <br>";
    echo "<a href='gameover.php'>Continue</a><br>";
    exit;
  }
  $updateplayer = "update players set hpoints = '$newplayerhp' where name = '$player'";
  mysql_query ($updateplayer) or die ("Could not update player");
}
else
{
  echo $creature . " misses!";
}
echo "<br><br><br><a href='battle.php?creature=$creature>Battle Again!</a>";
?>
User avatar
sonicatu
Posts: 6
Joined: Tue Dec 22, 2009 11:16 am

Re: Video#6a and 6b

Post by sonicatu »

ok, this is my first post so don`t get mad if i am mistaking.

Code: Select all

        if ($playerinfo3['level'] > $creatureinfo3['level'])
        {
         $firstmod = $playerinfo3['level'] - $creatureinfo3['level'];
         $secondmod = $firstmod * 10 ;
         if ($secondmod > 90){$secondmod = 90;}
         $thirdmod = ($secondmod / 100) * $creatureinfo3['exper'];
         $totalexper =$creatureinfo3['exper'] - $thirdmod;
        }
        else
        {
         $firstmod = $creatureinfo3['level'] - $playerinfo3['level'];
         $secondmod = $firstmod * 10 ;
         if ($secondmod > 90){$secondmod = 90;}
         $thirdmod = ($secondmod / 100) * $creatureinfo3['exper'];
         $totalexper =$creatureinfo3['exper'] + $thirdmod;


this code seems useless to me. let's say player is lvl 1 and orc is lvl 3 and if u kill it u get 30xp, and if u are lvl 5 and orc lvl 3 u get 10xp. why do u wanna do that? let the xp be the same for all player level, just change the whey the player levels on xp. if player is lvl 1 he needs 50xp to get to lvl 2, and 100xp to get to lvl 3 and so on.

dunno if u understand what i am saying, but i think it`s more efficient the way i said it. :)
GrInd3r
Posts: 66
Joined: Mon Jul 13, 2009 10:34 pm

Re: Video#6a and 6b

Post by GrInd3r »

ok well.. if a mob or (monster) is higher then you. you will want to give the user less exp. that way they cant abuse the system and get the 30 exp from a mod that is 5 - 10 level's lower then them. the higher the level the lower the exp you want to give the player from that mob
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#6a and 6b

Post by hallsofvallhalla »

yeah, it causes grinding without. I understand what you mean but trust me, if you leave any way for a player to grind they will.

Say it takes 500 Exp to get from level 1 to level 2 and 5000 to get to level 10 from 9

if you give the same amount of exp (lets say 50 for a goblin) a level 1 could battle the goblin nearly dying and it would take 10 of them to level, not only that each battle would be long.
a level 10 could easily kill it in one wack and just sit and grind, it would take him 100 goblins but he would never need to fight bigger creatures

now this is not to say you couldnt balance the battles with better loot but the object is to make the playing level even for people with lots of time and people who can only play every now and then. it makes people buff their characters and build them up for tough battles.

its preference really.

Thanks for the question, I don't get mad at questions, so no worries.
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Video#6a and 6b

Post by OldRod »

sonicatu wrote:ok, this is my first post so don`t get mad if i am mistaking.

Code: Select all

        if ($playerinfo3['level'] > $creatureinfo3['level'])
        {
         $firstmod = $playerinfo3['level'] - $creatureinfo3['level'];
         $secondmod = $firstmod * 10 ;
         if ($secondmod > 90){$secondmod = 90;}
         $thirdmod = ($secondmod / 100) * $creatureinfo3['exper'];
         $totalexper =$creatureinfo3['exper'] - $thirdmod;
        }
        else
        {
         $firstmod = $creatureinfo3['level'] - $playerinfo3['level'];
         $secondmod = $firstmod * 10 ;
         if ($secondmod > 90){$secondmod = 90;}
         $thirdmod = ($secondmod / 100) * $creatureinfo3['exper'];
         $totalexper =$creatureinfo3['exper'] + $thirdmod;


this code seems useless to me. let's say player is lvl 1 and orc is lvl 3 and if u kill it u get 30xp, and if u are lvl 5 and orc lvl 3 u get 10xp. why do u wanna do that? let the xp be the same for all player level, just change the whey the player levels on xp. if player is lvl 1 he needs 50xp to get to lvl 2, and 100xp to get to lvl 3 and so on.

dunno if u understand what i am saying, but i think it`s more efficient the way i said it. :)
2 examples:

Example 1 - player is level 5, monster is level 7, base experience for killing monster is 50. Under the formula above, the player would get 60 xp.

Example 2 - player is level 7, monster is level 5, base experience for killing monster is 50. Under the formula above, the player would get 40 xp.

Killing a monster higher than you gets base experience+modifier. Killing a monster the same as you gets base experience. Killing a monster lower level than you gets base experience-modifier.
User avatar
sonicatu
Posts: 6
Joined: Tue Dec 22, 2009 11:16 am

Re: Video#6a and 6b

Post by sonicatu »

@hallsofvallhalla

as you said, you can balance the amount of xp for each lvl. you can for example duble the amount, let's say:

lvl 1 to lvl 2 = 100xp
lvl 2 to lvl 3 = 200xp
lvl 3 to lvl 4 = 400xp
lvl 4 to lvl 5 = 800xp
lvl 5 to lvl 6 = 1600xp
and form here it get`s harder.

I played a lot of games and that`s how it works :). I`m not saying your code is bad, but in my opinion it would be better how i suggested :)

the only thing good that i see in your code is that the database will get smaller in numbers :D

@OldRod

i know what the code does, i just came up with another suggestion.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#6a and 6b

Post by hallsofvallhalla »

actually if you watch the rest of the videos I set up a experience table that does something similar. The main thing I do not like about this is 2 characters of different levels should never get the same experience for killing the same creature. A 2nd level player should get more experience for killing a 4th level creature than a 5th level killing a 4th level creature. It rewards bravery and punishes cowardice.

Making higher exp caps does not fix the problem though. You will have grinding that will unbalance the game. I know this from experience from my other games.

But like you say either way works. Its preference :)
Post Reply

Return to “Older Browser MMO Videos”