Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Seph's Test Bed V.4

Status
Not open for further replies.

fuso

Member

Code:
   def setup_map(sx,sy,ex,ey)
      map = Table.new($game_map.width, $game_map.height)
      map[ex,ey] = 1
      old_positions = []
      new_positions = []
      old_positions.push([ex, ey])
      depth = 2
      depth.upto(100){|step|
        loop do
          break if old_positions[0] == nil
          x,y = old_positions.shift
          return [true, map, step] if x == sx and y+1 == sy
          if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
            map[x,y + 1] = step
            new_positions.push([x,y + 1])
          end
          return [true, map, step] if x-1 == sx and y == sy
          if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
            map[x - 1,y] = step
            new_positions.push([x - 1,y])
          end
          return [true, map, step] if x+1 == sx and y == sy
          if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
            map[x + 1,y] = step
            new_positions.push([x + 1,y])
          end
          return [true, map, step] if x == sx and y-1 == sy
          if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
            map[x,y - 1] = step
            new_positions.push([x,y - 1])
          end
        end
        old_positions = new_positions
        new_positions = []
      }
      return [false, nil, nil]
    end
Was hoping Prexus would release a new pathfinding script but he perhaps got more interested in other things. Neither my original implemention or Near's nicer remake uses A*, they were merely BFS, I think it was cause we at that time didn't know what A* was. For many environments, A* can work at O( d) in practice, where d is the length of the shortest path, while BFS in practice does O( d^2), i.e. checks a quadratic number of tiles of the depth. BFS is easy to turn into A* though, but I do not have RMXP to test it with. If the target cannot be found however, A* does as bad as BFS, it must search all possible tiles. In fact, it is even slower than BFS since it must also keep track of the order it should test tiles in. Since we wish to do pathfinding in real-time however, the number of steps are arbitrarily restricted and A* is then vital for finding paths. During some tests a year ago, I was able to find a 240 or so path in a maze like 50x50 map which certainly wasn't even near a staight path in less than 5 seconds (forgot the exact number), this BFS implementation timed out before that and instead had to run on shorter paths where it stood 14.2 versus something less than a second.
first you need
Code:
    def heuristics(x0, y0, x1, y1, step = 0, nudge = 0.8, manhattannudge = 0.1)
      step + (1 + nudge) * ((x1-x0) * (x1-x0) + (y1-y0) * (y1-y0)) ** 0.5\
	+ manhattannudge * ((x1-x0).abs + (y1-y0).abs) 
    end
Nudge >= 1/min_depth may cause the path to include an unnecessary step, it makes it a lot faster in practice for complicated environments however, it's up to you.

Instead of
Code:
def setup_map(sx,sy,ex,ey)
      map = Table.new($game_map.width, $game_map.height)
      map[ex,ey] = 1
      old_positions = []
      new_positions = []
      old_positions.push([ex, ey])
      depth = 2
      depth.upto(100){|step|
        loop do
        break if old_positions[0] == nil
        x,y = old_positions.shift
use
Code:
def setup_map(sx,sy,ex,ey,max_steps = 10000)
      map = Table.new($game_map.width, $game_map.height)
      map[ex,ey] = 1
      positions = []
      positions.push([ex, ey, 0, heuristics(ex, ey, sx, sy)]) # where the third element would be the number of steps to get here and the fourth the heuristics
      max_steps.times {
        break if positions.empty?
        x,y,step,h = positions.shift
        step += 1

For these 4 (for instance x, y + 1, or x - 1, y)
Code:
new_positions.push([x + a,y + b])
use
Code:
h = heuristics(x + a, y + b, sx, sy, step)
pos = (0...positions.size).find{|i| positions[i][3] > h } || positions.size
positions.insert(pos, [x + a, y + b, step, h])

Then remove
Code:
end # for the loop do
        old_positions = new_positions
        new_positions = []

Making it
Code:
    def heuristics(x0, y0, x1, y1, step = 0, nudge = 0.8, manhattannudge = 0.1)
      step + (1 + nudge) * ((x1-x0) * (x1-x0) + (y1-y0) * (y1-y0)) ** 0.5\
	+ manhattannudge * ((x1-x0).abs + (y1-y0).abs) 
    end
    
    def setup_map(sx,sy,ex,ey,max_steps = 10000)
      map = Table.new($game_map.width, $game_map.height)
      map[ex,ey] = 1
      positions = []
      positions.push([ex, ey, 0, heuristics(ex, ey, sx, sy)]) # where the third element would be the number of steps to get here and the fourth the heuristics
      max_steps.times {
        break if positions.empty?
        x,y,step,h = positions.shift
        step += 1
        return [true, map, step] if x == sx and y+1 == sy
        if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
          map[x,y + 1] = step
          h = heuristics(x, y + 1, sx, sy, step)
          pos = (0...positions.size).find{|i| positions[i][3] > h } || positions.size
          positions.insert(pos, [x, y + 1, step, h])
        end
        return [true, map, step] if x-1 == sx and y == sy
        if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
          map[x - 1,y] = step
          h = heuristics(x - 1, y, sx, sy, step)
          pos = (0...positions.size).find{|i| positions[i][3] > h } || positions.size
          positions.insert(pos, [x - 1, y, step, h])
        end
        return [true, map, step] if x+1 == sx and y == sy
        if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
          map[x + 1,y] = step
          h = heuristics(x + 1, y, sx, sy, step)
          pos = (0...positions.size).find{|i| positions[i][3] > h } || positions.size
          positions.insert(pos, [x + 1, y, step, h])
        end
        return [true, map, step] if x == sx and y-1 == sy
        if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
          map[x,y - 1] = step
          h = heuristics(x, y - 1, sx, sy, step)
          pos = (0...positions.size).find{|i| positions[i][3] > h } || positions.size
          positions.insert(pos, [x, y - 1, step, h])
        end
      }
      return [false, nil, nil]
    end

This code at least works with fake RMXP classes but I cannot try it with these so it's still a bit uncertain. Perhaps you could experiment and see if it works better.
 
The testbed is awesome. :)

But I encountered errors. (Don't kill me :p )

Whenever you press F12, you will get a error. In Map, Title anywhere.
The error message is;
Script 'Party SP' line 118: SystemStackError occured
Stack level too deep

(The Line changes to 179 if you pressed F12 in Titlescreen)

GoldenShadow's script, I had trouble equipping rods and baits.
I did try equip it after I got the items from the chest.
Then went to the water and pressed enter and got an error.

The Quick Party changer. Whenever you remove all of your character,
it will causes an error.
(Maybe add a rescue, to stop players to remove the final character)

And finally, not a scripting error, but, i can't keep it quiet :( ;
Ccoa's Minecarts minigame. Whenever you press down or up whilst in the black area (you can ride over them, is this normal?)

And the puzzle (Shifting puzzle)
What's the control for it?

And again, I'm sorry to find them errors.

Keep up the awesome work on the testbed.

~Kuri$u
 
SephirothSpawn;115649 said:
@TywinLannister2: Good deal. Actually, the STR already has the @str_bonus instance, this script simply adds one for the stats that don't, such as eva, atk, etc.

This is exactly what i was looking for! cheers!!!
 

Dko

Member

Hey can anyone tell me how to best use Sephs Virtual Database? He says that currently the header isn't correct in some way and that he wants to re write the script to be easier to use. But I don't know how long that will take and I really want to get working on my script.
 
No, but I have been busy. I am updating every script with the new SDK, adding more options to probably half of the scripts so far, and trying to get 10-20 new scripts in the V.4 version. It will be the last version for a while, because after it, I am moving on to BIG BIG BIG scripts (starter kits and such) and work on my own systems for a game.

Hopefully I will have the V.4 in a couple of weeks. I just need to get this new SDK finished up and everything else. I actually had to acquire a few secretaries to help me out because I am beyond un-organized. ^_^
 
Sorry for bumping this, but I was wondering something about the encyclopedia script. For some reason, it won't work when the 'word' is either more than one words or something hyphenated. Does anyone know why?
 
Aw Seph, this looks really good. I have to admit, I was bummed because your blue mage script, as far as I can see, is like Fomar's in that there is no way to learn Support/Healing skills with it (since the party would never be targetted by those)

Will you be making a script to make this possible? Or possibly a command (like lancet), that can have a chance to learning those skills from the enemies that possess them?



Also! In my current project, and probably future projects, I'd love to use SDK and a lot of your scripts, unfortunately right now there seems to be incompatibility with either SDK or just certain scripts and this script, which basically just renames the commands and does nothing else: http://www.rmxp.org/forums/showthread.php?t=8074

Do you have a script that would work with SDK/your scripts? All I want to be able to do is switch 'Skills' to Black Magic, Dark Sword, White Magic, etc. I don't need spells grouped or anything else, just a renaming of the command.
 
Sorry for bumping this, but I was wondering something about the encyclopedia script. For some reason, it won't work when the 'word' is either more than one words or something hyphenated. Does anyone know why?
That's partially because each word is checked seperately. I can change how this is done when I update to V.4

Will you be making a script to make this possible? Or possibly a command (like lancet), that can have a chance to learning those skills from the enemies that possess them?
I will make a Lancet script and add it to the BGL Skills (making it BGLL Skills :p).

Also! In my current project, and probably future projects, I'd love to use SDK and a lot of your scripts, unfortunately right now there seems to be incompatibility with either SDK or just certain scripts and this script, which basically just renames the commands and does nothing else: http://www.rmxp.org/forums/showthread.php?t=8074

Do you have a script that would work with SDK/your scripts? All I want to be able to do is switch 'Skills' to Black Magic, Dark Sword, White Magic, etc. I don't need spells grouped or anything else, just a renaming of the command.

All oh my scripts will be configured to work with the most recent version of the SDK (2.0 - 2.2). I have one thing left to do before the 2.2 release. Any command can be changed simply by modifing commands in the SDK Part IV. Things like this are made a lot easier with the Part IV, which is why it was made.

I will add an individual battle commands to my list of things to do.

And since this thread got bumpped...

I am going to start posting pieces of the next version. Next week I will post a V 0.4 and every week after that, I will add another 0.01. Hopefully having around 5-10 script updates and new scripts. I will do this until I get to the 0.5 version which will be what was intended to be the 0.4 version. So just expect weekly updates on this from here on out.
 
You can only alter then for every actor, going into SDK Part IV under module SDK::Scene_Command then under the module Scene_Battle and modify the Attack, Item, Skill, Defend commands.

Modifing then in the middle of battle or whatever requires a bit more work than that.
 

Z-Man

Member

Okay, I'm going to start asking my questions here, since this is supposed to be where I would get support on all your scripts (or at least I think so...)

Using the Additional Items Drop script, I get the following error after the battle ends:
"undefined method `add_multi_drops' for nil:NilClass"

The exact line it references has the following code:
"@result_window.add_multi_drops"
 
the quick switcher errors when you try to move all the party members out just reporting a bug I saw good work though

Check the V.4 beta in Trickster (Username SephirothSpawn's) signature. There is a fixed version of Party Switcher in there.

Okay, I'm going to start asking my questions here, since this is supposed to be where I would get support on all your scripts (or at least I think so...)

Using the Additional Items Drop script, I get the following error after the battle ends:
"undefined method `add_multi_drops' for nil:NilClass"

The exact line it references has the following code:
"@result_window.add_multi_drops"

Same to you. I have an updated and greatly improved version in my V.4 beta. If you are using a Battle Report window or something similar, then that is why.
 

Z-Man

Member

Okay, so I got the new Dyanmic/Additional items script, but as soon as I run, it disables itself because it says I don't have the SDK...

It says I'm missing part 1, which is actually the only part I really do have. (I put this script below SDK and above Main)
 
You have the SDK 2.0 - 2.2?

Just give me a day to organize my beta and get the 2.2 out an going. Then I will help you with everything. Until then, I am far too unorganized for anything.
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top