Dismount vehicle by bumping into wall B?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Dismount vehicle by bumping into wall B?

Post by sheamkennedy »

I have this vehicle I made which is essentially a raft. When the player steps on it they mount it, then as they move it appears as though they are riding this raft. I'd like to make the player dismount it whenever they bump into wall B since wall B is what allows the vehicle to only access a contained region of water. How can I make it so the player dismounts when bumping in to wall B (without using the "use" button)?
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

An "on touch" or "on step" NPC that calls a script with "dismount vehicle" and perhaps moves the player onto the nearest land block. I can't remember how dismounting works exactly - whether it automatically moves you 1 square in the direction you are facing or not.
Last edited by guo on Sun Mar 27, 2016 2:32 am, edited 1 time in total.
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

If I remember correctly, on-touch activation only activates when the hero or the npc tries to move into the other, not when they simply move next to each other.

If you didn't want to use touch-activated NPCs, I would adapt the hero will move script on the wiki. Something like this:

Code: Select all

script, check for raft dismount, begin
  variable (dir, npc, wall)

  if (hero is walking(0)) then (exit script)

  # Check for player input
  dir := trying to move direction
  if (dir == -1) then (exit returning (false)) 

  # Don't check for walls in the way, like "hero will move" does.

  # Check for an NPC in the way which you can't step on
  # (this isn't correct either if obstruction is suspended, or other edge cases)
  npc := npc at spot (hero x(0) + dir x(dir), hero y(0) + dir y(dir))
  if &#40;npc && readNPC&#40;npc, NPCstat&#58;activation&#41; <> NPCactivation&#58;stepon&#41; then &#40;exit script&#41;

  wall &#58;= read pass block &#40;hero x&#40;0&#41; + dir x&#40;dir&#41;, hero y&#40;0&#41; + dir y&#40;dir&#41;&#41;
  if &#40;wall, and, vehicleB&#41; then &#40;
    # OK, the player is trying to move onto a tile with the B vehicle bit set.

    dismount vehicle
  &#41;
end
That calls other scripts, which you can find on the wiki page.
Last edited by TMC on Sun Mar 27, 2016 3:08 am, edited 1 time in total.
Post Reply