Ejemplo n.º 1
0
                $oppcharacter->place($arenalocation);
                $opponent_id = $oppcharacter->id;
                //paranoia
                $list[] = $opponent_id;
                $_SESSION['opponent_id'] = $opponent_id;
                --$oppsneeded;
                if (--$other_opp_level < 1) {
                    $other_opp_level = 1;
                }
            }
        }
        //place new monsters on map
        //            $query = "SELECT * FROM phaos_opponents WHERE location='$opplocation' ORDER BY RAND() LIMIT $oppsneeded";
        $blueprints = fetch_all($query);
        foreach ($blueprints as $blueprint) {
            $npc = new np_character_from_blueprint($blueprint, $other_opp_level, 'phaos_arena_fighting');
            $npc->place($arenalocation);
            $list[] = $npc->id;
            DEBUG and $_SESSION['disp_msg'][] = @"DEBUG: placing {$npc->name} {$npc->level} {$npc->user}";
        }
        //$list= whos_here($_SESSION['combatlocation'],'phaos_arena_fighting');
    }
    // set up arena
}
$_SESSION['num_of_opps'] = count($list);
DEBUG and $_SESSION['disp_msg'][] = "DEBUG: There are " . count($list) . " opponents here.";
//TODO: for spells
//$opponentList= makeList($list);
$oppcharacter = null;
if (!count($list)) {
    $comb_act = 'endfight';
Ejemplo n.º 2
0
/**
* @param: none
* return: none
* purpose: generate new NPC/monster and add to database
*/
function npcgen()
{
    $res = mysql_query("SELECT * FROM phaos_opponents WHERE location='0' ORDER BY RAND() LIMIT 1") or die(mysql_error());
    if ($blueprint = mysql_fetch_array($res)) {
        //create 50% level 1 characters, and not more than 37,5% characters with level>3
        $level = 1 + (int) (rand(0, 1) * (pow(1 + rand(0, 10) * rand(0, 10) * 0.01, 4) + rand(0, 99) * 0.01));
        $npc = new np_character_from_blueprint($blueprint, $level);
        $condition_passable = $npc->real_sql_may_pass();
        //TODO: add generator regions/locations feature to phaos
        $tries = 10;
        while ($tries-- > 0) {
            $res = null;
            //FIXME: this actually should depend on the area covered by dungeons
            //20050717
            //Wilderness    14277
            //Woodlands 	1891
            //Dungeon       675
            if (!@$res && rand(0, 99) < 4) {
                $location = 'Rune Gate%';
                $sql = "SELECT id FROM phaos_locations WHERE (name LIKE 'Rune Gate%' OR name LIKE 'Dungeon') AND {$condition_passable} ORDER BY RAND() LIMIT 1";
                //defined('DEBUG') and DEBUG and $GLOBALS['debugmsgs'][]= __FUNCTION__.": sql: $sql";
                $res = mysql_query($sql) or die(mysql_error());
            }
            if (!@$res) {
                $location = 'Wilderness';
                $sql = "SELECT id FROM phaos_locations WHERE (name LIKE 'Wilderness' OR name LIKE 'Woodlands' OR name LIKE 'Rune Gate%' OR name LIKE 'Dungeon') AND {$condition_passable} ORDER BY RAND() LIMIT 1";
                //defined('DEBUG') and DEBUG and $GLOBALS['debugmsgs'][]= __FUNCTION__.": sql: $sql";
                $res = mysql_query($sql) or die(mysql_error());
            }
            list($locationid) = mysql_fetch_array($res);
            //check whether location is crowded
            $res = mysql_query("SELECT count(*) FROM phaos_characters WHERE location='{$locationid}' AND username='******'") or die(mysql_error());
            list($count) = mysql_fetch_array($res);
            if ($count > $level + 1) {
                defined('DEBUG') and DEBUG and $GLOBALS['debugmsgs'][] = " location {$locationid} is <b>crowded</b>, not placing here ({$count} npcs)";
                //trying to fix
                $res = mysql_query("SELECT id FROM phaos_characters WHERE location='{$locationid}' AND username='******'") or die(mysql_error());
                while (list($id) = mysql_fetch_array($res)) {
                    $crowd = new character($id);
                    $crowd->relocate((int) rand(1, 8));
                }
            } else {
                break;
                //stop while loop
            }
        }
    } else {
        die("cant find valid mob in DB: " . mysql_error());
    }
    $npc->place($locationid);
    DEBUG and $_SESSION['disp_msg'][] = "**DEBUG: {$npc->name}({$npc->level}) generated at location {$location} {$locationid}";
    return 1;
}
Ejemplo n.º 3
0
}
$message = "";
while ($missing > 0 && $char_loc) {
    $query = "SELECT * FROM phaos_opponents WHERE location='" . $char_loc . "' ORDER BY RAND() LIMIT 1";
    $result = mysql_query($query);
    $blueprint = mysql_fetch_array($result);
    if (!$blueprint) {
        $query = "SELECT * FROM phaos_opponents WHERE location='0' ORDER BY RAND() LIMIT 1";
        $result = mysql_query($query);
        $blueprint = mysql_fetch_array($result);
        $message = "Please ask the arena administrator to hire some special opponents.";
    }
    if ($blueprint) {
        $maxlevel = 1 + (int) ((rand(1, 5) * rand(1, 5) + 4) / 9) + rand(0, $character->level);
        $level = rand(1, $maxlevel);
        $npc = new np_character_from_blueprint($blueprint, $level, 'phaos_npc_arena');
        $npc->place($char_loc);
        --$missing;
    } else {
        $message = "No opponents found.";
        break;
    }
}
$query = "SELECT * FROM phaos_characters WHERE {$where} ORDER BY xp DESC LIMIT {$num_limit},10";
$result = mysql_query($query);
$NA = false;
if ($row = mysql_fetch_array($result)) {
    do {
        $number = $number + 1;
        $opponent_id = $row["id"];
        $leader_name = $row["name"];