Graal Forums  

Go Back   Graal Forums > General Forums > Graal Main Forum (English)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #31  
Old 08-27-2002, 05:54 AM
Er1c Er1c is offline
Registered User
Er1c's Avatar
Join Date: Mar 2001
Location: Chicago, IL
Posts: 791
Er1c is on a distinguished road
Quote:
Originally posted by Aruchinjiru


o.O oh cool I'll have to look at that. So basically you could edit the text file..to edit the level?
Yeah... and make programs to edit levels for you.

This would add an NPC randomly into all the levels in the directory it's in (we used it for the kingdom trees on 2k2)
PHP Code:
<?php
if ($action=="generate" && $randmax>=&& sizeof($randtrees)>0) {
  
$dir opendir("./");

  
$filelist = array();
  
$filecount 0;
  while (
false!==($file readdir($dir))) {
    if (
is_file($file) && $file!=="index.php") {
      
$filelist[$filecount] = $file;
      
$filecount++;
    }
  }
  
closedir($dir);
  
printf($filecount " files recorded...<hr>");

  
$treetotal 0;
  
$treefile 0;
  for (
$cfile 0;$cfile<$filecount;$cfile++) {
    
$treetotal += $treefile;
    
printf("Working on file: " $filelist[$cfile] . "<br>");
    
$treefile 0;
    for (
$cy 0;$cy<64/8;$cy++) {
      for (
$cx 0;$cx<64/8;$cx++) {
        if (
1>rand(0,$randmax)) {
          
$file fopen($filelist[$cfile],"a");
          
$treetype $randtrees[rand(0,sizeof($randtrees)-1)];
          
$writetofile 
"NPC - " $cx*" " $cy*"
//Tree added by tree generator
if (created) {
  showcharacter;
  this.type = 
$treetype;
  setcharani realtree#v(this.type),;
}
join realtrees;
NPCEND
"
;
          
fwrite($file,$writetofile);
          
fclose($file);
          
$treefile++;
          
printf("Tree " $treetype " added to " $cx*"," $cy*" of " $filelist[$cfile] . "<br>");
        }
      }
    }
    
printf($treefile " trees were added to " $filelist[$cfile] . "<hr>");
  }
  
printf($treetotal " trees were added to " $filecount " levels.");
} else {
?>
<form method="get">
  <input type="hidden" name="action" value="generate">
  <br>
  Odds for a tree (every 8x8 tiles): 1 in <input type="text" name="randmax" value="25">
  <br>
  Select trees to choose from:
  <br>
<?
  
for ($i 1;$i<=20;$i++) {
    echo 
"Tree $i <input type=\"checkbox\" name=\"randtrees[]\" value=\"$i\"><br>";
  }
?>
  <br>
  <input type="submit" value="Generate">
</form>
<?
}
?>
__________________
Eric Kraft
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:48 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.