Post new topic    
Metal Slime
Send private message
Trying to make a walk through walls script 
 PostSat Dec 01, 2018 6:35 pm
Send private message Reply with quote
I want to have a script where a character's ability lets them walk through hidden passages. Here's how I'd want it done:



Basically the hero finds a hidden passage spot (where the circle is), activates it, and the script has them walk through the hidden passage and out the other side, then resumes player. However as far as how to rig the walking along a specific path to work, I'm not sure what the best way to do that is.

I thought there were hero pathfinding commands, but I just checked plotdict.xml and there aren't any, just NPCs. Was thinking of having hidden passage zone and drawing the path with it, then temporarily writing the wallmap to 0 along those zones and pathfinding the hero, but can't do that apparently.

Any other ideas? I just gotta get this implemented quick, still got a lot of other things to work on.
Metal Slime
Send private message
 
 PostSat Dec 01, 2018 6:50 pm
Send private message Reply with quote
Kylekrack just suggested trying to put in "pathfind hero to" and compiling to see if it'd take, and it did. Huh.
Liquid Metal Slime
Send private message
 
 PostSat Dec 01, 2018 8:45 pm
Send private message Reply with quote
Can't you just use "walk hero to x" and "walk hero to y" commands when the hero is suspended? It's pretty quick and easy (and accurate) to just tell the script where you want the hero to walk.

As far as wallmaps are concerned, I think you can just use "suspend hero walls" and "resume hero walls" to achieve what you want.

Is what you want to do more complicated than that?
Place Obligatory Signature Here
Metal Slime
Send private message
 
 PostSat Dec 01, 2018 11:39 pm
Send private message Reply with quote
That would work fine for a one-off sequence, but since I'm having several of these on the map, it would be pretty bad to have to manually put in walk sequences into the .HSS file for each one.

I ended up actually not using pathfinding and instead went with a "breadcrumb" zone method, where the hero looks for an adjacent tile with the breadcrumb, removes the breadcrumb from the current spot, and moves to the adjacent spot.

Here's the working code if anyone's curious.

Code:
global variable (400, raccoon detecting)

plotscript, raccoon detect, begin
   variable (tile x, tile y, radius)
   raccoon detecting := true
   radius := 3
   
   for (tile x, hero x(me)--radius, hero x(me)+radius) do (
      for (tile y, hero y(me)--radius, hero y(me)+radius) do (
         if (read zone (zone:Raccoon path marker, tile x, tile y) &&
         npc at spot (tile x, tile y) == false) then (
            create npc (npc:Path marker, tile x, tile y)
            play sound (3)
            wait (5)
         )
      )
   )
   raccoon detecting := false
end

plotscript, use raccoon path marker, arg, ref, begin
   variable (tile x, tile y)
   delete npc (ref)
   suspend player
   suspend hero walls
   raccoon detecting := true
   
   ## Put 'breadcrumbs' on the hidden path
   for (tile x, hero x(me)--9, hero x(me)+9) do (
      for (tile y, hero y(me)--6, hero y(me)+6) do (
         if (read zone (zone:Raccoon path, tile x, tile y)) then (
            write zone (zone:Raccoon breadcrumbs, tile x, tile y, true)
         )
      )
   )
   
   ## Follow & remove the breadcrumbs by looking for adjacent zone
   while (true) do (
      if (read zone (zone:Raccoon breadcrumbs, hero x(me), hero y(me)--1)) then (   ## Up
         passage step (up)
      ) elseif (read zone (zone:Raccoon breadcrumbs, hero x(me)+1, hero y(me))) then (   ## Right
         passage step (right)
      ) elseif (read zone (zone:Raccoon breadcrumbs, hero x(me), hero y(me)+1)) then (   ## Down
         passage step (down)
      ) elseif (read zone (zone:Raccoon breadcrumbs, hero x(me)--1, hero y(me))) then (   ## Left
         passage step (left)
      ) else (   ## No more breadcrumbs, step away from the path
         walk hero (me, hero direction(me), 1)
         wait for hero
         resume player
         resume hero walls
         raccoon detecting := false
         exit script
      )
   )
   subscript, passage step, dir, begin
      write zone (zone:Raccoon breadcrumbs, hero x(me), hero y(me), false)
      walk hero (me, dir, 1)
      wait for hero
   end
end
Metal King Slime
Send private message
 
 PostSun Dec 02, 2018 12:53 am
Send private message Reply with quote
Wow, that looks like a really complicated solution!

"pathfind hero to" is documented in the plotscripting dictionary, but is new in Fufluns. You must have been looking at the dictionary for Etheldreme. Note that both of them are linked to from the wiki. The version is displayed at the top, and nightly versions have "nightly" as part of the URL.
Display posts from previous: