Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Graal Main Forum (English) (https://forums.graalonline.com/forums/forumdisplay.php?f=4)
-   -   .graal to .nw program (https://forums.graalonline.com/forums/showthread.php?t=36568)

Er1c 08-27-2002 05:54 AM

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? :eek: :confused:

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>
<?
}
?>



All times are GMT +2. The time now is 06:25 PM.

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