Author Topic: How to move the player  (Read 299 times)

Offline Ioncloud

  • Zombie Food
  • *
  • Posts: 6
    • View Profile
How to move the player
« on: June 23, 2017, 06:15:51 PM »
I am attempting to move the player outside of the keyboard but am having difficulty locating the correct place to call to do so.

plmove seems to be what moves the player; however, the method is private which I'm sure means that it is not the right thing.

Any pointers would be helpful.

Offline Coolthulhu

  • Contributor
  • Survivor
  • ****
  • Posts: 3839
    • View Profile
Re: How to move the player
« Reply #1 on: June 23, 2017, 07:17:21 PM »
What do you want to achieve? Teleport, teleport with proper destination checks (traps etc.), do the same thing that would happen if player moved by keyboard, do a proper move as if player wanted to move but not attack?

plmove is a rather complex method that does the same thing as if player pressed a keyboard button for movement. Exactly that, with all the checks and all the prompts.

The automove (press left mouse button in tiles) uses plmove. If you really need it for something good, you can make it public.
If you want just the move, with less bullshit, you'd need game::walk_move.

Offline Ioncloud

  • Zombie Food
  • *
  • Posts: 6
    • View Profile
Re: How to move the player
« Reply #2 on: June 23, 2017, 07:35:25 PM »
Same as keyboard, so move north if num8 is pushed, etc

The basics of what I'm trying to accomplish is use an external program that calls into the DDA code and executes whatever action that key is suppose to perform. In this case movement, later down the road things like inventory and item interaction.

I took a look through the action class, but wasn't sure how to properly execute an action (or what the mechanism would be to execute one)

Offline Coolthulhu

  • Contributor
  • Survivor
  • ****
  • Posts: 3839
    • View Profile
Re: How to move the player
« Reply #3 on: June 23, 2017, 07:59:41 PM »
Then you want to change game::handle_action, game::get_player_input or game::handle_mouseview (even if you aren't using mouse here).
handle_mouseview is the lowest level one, the one that actually gets the actions. If you changed that one, you could feed the game actions directly, by changing the "action" variable and returning true.