Create noncollidable "Ghost" NPCs

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

Moderators: marionline, SDHawk

Post Reply
Wendigo
Red Slime
Posts: 52
Joined: Tue Feb 28, 2017 1:15 pm

Create noncollidable "Ghost" NPCs

Post by Wendigo »

Greetings fellow slime,
In order to create a more animate world I decided to make some butterfly NPCs that wander around the map.
The Player shouldn't interact with the butterflies at all but unfortunately I'm unable to just walk through them.
Is there a way to make them non collidable?

Thanks in advance. :)


EDIT:
I figured it out.
In "Edit NPCs..." set:
Activation: Step On
Last edited by Wendigo on Wed Mar 01, 2017 2:36 pm, edited 2 times in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

On-Step activated NPCs still obstruct other NPCs. If you want to avoid that you need to use scripting to set the NPCs as non-obstructing (I know, it's crazy that there's no setting in the editor for it) using the "set npc obstructs" command. That works on a single NPC instance rather than an NPC definition, so you would need to use a loop. You can use a map autorun script like:

Code: Select all

plotscript, butterflies map script, begin
  variable(index)
  for (index, 0, npc copy copy(10) -- 1) do (  # Change 10 to npc ID
    set npc obstructs(npc reference(10, index), false)  # Change 10
  )
end
Last edited by TMC on Wed Mar 01, 2017 3:16 pm, edited 1 time in total.
User avatar
BMR
Metal King Slime
Posts: 3310
Joined: Mon Feb 27, 2012 2:46 pm
Location: The Philippines
Contact:

Post by BMR »

Strangely enough, I was working on this exact thing a few weeks ago. My solution though was to use slices, as you'll be able to get more variety and better random movement that way. Also somewhat easier to animate. The way I went about it (I think, it's been a while) was to have a set of npcs on the map. Then, a script runs through all the npcs, and upon finding those of a specific number, deletes those npcs and replaces them with butterfly slices. Each slice has extra data attached to it, "life", "target x", and "target y". Each tick, life decreases by one, and upon hitting 0, a new random x and y target are generated within a specific range from the current position. A new random life is also created. For the next few ticks, until life hits 0 again, the butterfly will animate and move towards the random target. Repeats until the player leaves the map. Kinda a vague description, I know, but I'm sick right now so I reserve the right to be incoherent =p
Last edited by BMR on Wed Mar 01, 2017 4:06 pm, edited 1 time in total.
Being from the third world, I reserve the right to speak in the third person.

Using Editor version wip 20170527 gfx_sdl+fb music_sdl
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Basically, you scripted a particle effects system.
User avatar
BMR
Metal King Slime
Posts: 3310
Joined: Mon Feb 27, 2012 2:46 pm
Location: The Philippines
Contact:

Post by BMR »

Huh. Maybe I did. Wasn't intentional though, as in I didn't set out to script one. Also used pretty much the same system to do falling leaves from trees.
Being from the third world, I reserve the right to speak in the third person.

Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Wendigo
Red Slime
Posts: 52
Joined: Tue Feb 28, 2017 1:15 pm

Post by Wendigo »

Wow didn't expect any replies.
Thanks for info. :)
Post Reply