Recent posts

#41
Development / Re: Need Help With Having an N...
Last post by lefthandedhero - May 21, 2023, 06:01:55 PM
Using the suggestions above, I have refined the code. Here is the current version:

-- Follower's Movement 
  -- Initialize table to store the hero's old coordinates <List[0] = x, List[1] = y>:
  List = {}
  -- Obtain the hero's movement speed
  local speed = hero:get_walking_speed()
  -- Initialize the movement
  local movement = sol.movement.create("target")
  movement:set_target(Follower:get_position())
  movement:set_speed(speed)
  movement:start(Follower)
  -- Movement pathing:
  function hero:on_position_changed(x, y, layer)
  -- Update list and move accordingly
    -- If this is not the hero's first movement:
    if List[0] ~= nil then
      -- Move the NPC to the old coordinates
      movement:set_target(List[0], List[1])
    end
    -- Record the hero's current position:
    List[0] = x
    List[1] = y
  end


Initially, the movement works exactly as I would like. However, there are three problems that appear after the hero either stops moving or changes direction:

1. The NPC "Follower" continues moving after reaching the target position.
2. It is impossible for the hero to move backwards since Follower is in the way.
3. When I move the hero in a new direction, I want Follower to continue moving forward before then moving in the new direction, as I want Follower to follow the exact same path as the hero. Follower does not do this; I suspect this problem is related to problem 1.

Three questions:
1. How do I remove collision between the NPC Follower and the hero?
2. Any suggestions for how to make Follower stop moving when the hero stops moving?
3. Any idea what could be causing the third problem?

Incidentally, after playing Ocean's Heart recently, I reached a point in the game where an NPC follows the hero, and the NPC does exactly what I'm trying to get Follower to do: they follow the exact path the hero just walked. Does anyone know how Ocean's Heart did this?

UPDATE 2: I added the line, "Follower:set_traversable(true)", so now the hero can pass through Follower. The other two problems remain; Follower continues moving either left-and-right if facing up or down or up-and-down if facing left or right after the hero stops moving, and the movement only works the way that I want it to until the hero changes direction:

When I have the hero go in a new direction, Follower should move to the last place the hero was in the first direction before moving in the new direction, since I want Follower to follow the same path as the hero. Instead, Follower stands still for a while and then catches up. Any idea what is causing this?

There's another problem: despite Follower's speed being set to the hero's speed in the code, when I tested it, Follower slowly begins falling behind.

UPDATE 3: I set Follower to ignore obstacles to see if that was the reason it stood still whenever the hero turned to the left or right. It was the reason, and it revealed a different problem: despite the existence of the table being to record where the hero was previously, whenever the hero stops moving, follower stops at the hero's current position, not the hero's position a step previously.
#42
Development / Re: Removing the select player...
Last post by PhoenixII54 - May 19, 2023, 06:40:47 PM
Yes. In fact, the bare minimum required to start a game is : open main.lua, and in the solarus starting function, create a game object, setup starting point/HP/whatever you need at game start, and start the game. hints : sol.game.load; game:start() --> More info in the documentation page here. That's what file selection menus do, but in a more visual -and enhanced- way.
#43
Development / Battle System
Last post by Rhinosaur - May 19, 2023, 04:04:50 AM
Hi Everyone,

I am new to Solarus and interested in trying to develop a game with it.  I was hoping to create a game with a battle system akin to something like Mario & Luigi: Superstar Saga.  Is this possible with Solarus?  Or would it be easier to develop using a different game engine?  If you are not familiar with Mario & Luigi Superstar Saga, it uses a turn based battle system which incorporates user input during the attacks.  So if you select a melee attack, you can get bonus damage by pressing the appropriate buttons at certain times.  Also, you can dodge the enemies attacks by jumping at the right time, etc.

My apologies if this has been answered already, I attempted to search but wasn't able to find the answer.

Thanks!
#44
Development / Removing the select player scr...
Last post by xglichtrapx - May 11, 2023, 07:09:33 PM
Hi all is there a way to remove the select player screen? For instance in the sample quest it goes straight from the title screen and directly to the start of the game.
#45
Your projects / Ideas for a Zelda game?
Last post by mine - May 10, 2023, 12:58:47 AM
I'm a big Zelda fan, and I'm planning to use Solarus as an engine for a Zelda fan game...but I don't know what the plot should be, what the map should be like, what the dungeon themes should be, or anything! Please give me ideas!
#46
Development / Re: Need Help With Having an N...
Last post by lefthandedhero - May 09, 2023, 08:17:49 PM
Quote from: PhoenixII54 on May 09, 2023, 11:40:17 AM
I don't see any obvious mistake (maybe i would have organized the list in the style 1 entry = an {x=x,y=y} pair but that's just a coding preference) so my guess is that your movement gets overwritten each frame you move and doesn't have time to even start until you stop moving.
So what you should try to do is to detect if the follower NPC already has a movement and update it's target (if possible) instead of recreating a new one each frame, and only create it again if it it reached its actual destination when the hero has stopped moving.

Thank you. That is most likely the reason for the first problem. I am currently working on modifying it as suggested.
#47
Development / Re: Need Help With Having an N...
Last post by PhoenixII54 - May 09, 2023, 11:40:17 AM
I don't see any obvious mistake (maybe i would have organized the list in the style 1 entry = an {x=x,y=y} pair but that's just a coding preference) so my guess is that your movement gets overwritten each frame you move and doesn't have time to even start until you stop moving.
So what you should try to do is to detect if the follower NPC already has a movement and update it's target (if possible) instead of recreating a new one each frame, and only create it again if it it reached its actual destination when the hero has stopped moving.
#48
Development / Re: Need Help With Having an N...
Last post by lefthandedhero - May 08, 2023, 07:09:26 PM
Using the advice above, I created the following code. Note that "Follower" is the name of the NPC:


-- Table to store the hero's old postion (List[0] = x, List[1] = y, List[2] = layer):
  List = {}
  -- Follower Movement:
  function hero:on_position_changed(x, y, layer)
    -- If not the hero's first movement:
    if List[0] ~= nil then
      -- Move Follower to the old coordinates
      local movement = sol.movement.create("target")
      -- Set the previous position as the target
      movement:set_target(List[0], List[1])
      -- Make the movement speed match the hero
      movement:set_speed(88)
      -- Move
      movement:start(Follower)
    end
    -- Record the hero's new position
    List[0] = x
    List[1] = y
  end


The current code has two main problems:

1. Follower does not start moving until the moment the hero stops moving, when the idea was that the follower would move while the hero moves and stop when the hero stops.

2. Follower does not stop moving, as if the current target is the hero's current position when it should be the hero's previous position.

Where have I gone wrong in my implementation that is causing these problems?
#49
Development / Re: Need Help With Having an N...
Last post by lefthandedhero - May 05, 2023, 04:09:45 PM
Quote from: PhoenixII54 on May 05, 2023, 11:30:22 AM
Hello, you can use the hero:on_position_changed() event, which is called each frame Link has moved.


-- <initialization stuff where you get the hero and NPC entities>

function hero:on_position_changed(x, y, layer)
--update your list here and move the NPC accordingly

end


Thank you very much. This is a big help.

Quote from: Christopho on May 05, 2023, 03:20:57 PM
An alternative way is to make a target movement towards the hero, and stop that movement when the distance between the NPC and the hero gets below some threshold. I think it is done that way in the Zelda A Link to the Dream project.
Your choice, I guess it depends on whether you want the NPC to follow exactly the same path as the hero or not.

Thank you. I do want the NPC to follow the same path as the hero; it's important for another component of the game that I'm trying to make that the NPC follow the same path. But I may fall back on that method if I can't get my current plan to work.
#50
Development / Re: Need Help With Having an N...
Last post by Christopho - May 05, 2023, 03:20:57 PM
An alternative way is to make a target movement towards the hero, and stop that movement when the distance between the NPC and the hero gets below some threshold. I think it is done that way in the Zelda A Link to the Dream project.
Your choice, I guess it depends on whether you want the NPC to follow exactly the same path as the hero or not.