ID:273363
 
Ok i am currently making a bleach game from scratch and i was wondering how would i go about making the creatures in my game have no density if u cant see em but if u can then they have density.. i can make them invisible but i cant take away their density.
hmm.
you could give your character a state.
like
mob/shinigami/var
spiritform=1//if zero then you are in your real body


then you could edit the mob/shinigami bump() so that when your character bumps into a monster, the monsters density turns to 0 for a second or two as long as they arent in spirit form,just long enough for them to pass through.

mob/monster
proc/make_ghost()
src.density = 0

Or since you claim that doesn't work. >.>
mob/monster
var/isghost
Enter(atom/movable/a)
if(src.check_ghost())return 1
..()
proc/check_ghost()
return isghost
proc/toggle_ghost()
isghost = !isghost


I'd handle it something like this.

turf
Enter(mob/m)
// We have to rewrite the Enter() proc to handle
// this.

if(density || loc.density)
// If the turf, or the /area the turf is in, are
// dense, don't allow entry.
return 0

for(var/atom/movable/n in contents)
// Look through the other things in the turf's
// contents.

if(n.density)
// If they're dense, then don't bother
// checking if the user can see them. Just
// block them from entering the turf.
return 0

else if(m.SeeCheck(n))
// If they're not dense, then check if
// the thing trying to enter the turf can
// see them. If they can, then block the
// player from entering the turf.
return 0

// If there is nothing else dense on the turf, and
// the player can't see anything, then allow them to
// enter.
return 1

mob
var
list/can_see // This is a list of things the player
// can see.

proc
AllowSee(mob/m)
// This is the proc that allows the player to
// see certain things.
if(!can_see)
// If the list hasn't been created, create
// it now.
can_see = new

can_see += m

// There are a couple ways you can handle
// actually being able to see or not see mobs
// and objs. I won't handle this here, as that's
// beyond the scope of your question.

DisallowSee(mob/m)
can_see -= m
if(!can_see.len)
// If there's nothing else in the list,
// delete it to free up resources.
del can_see

// Same as above, this is where you'd write the
// stuff to handle removing the thing from the
// player's view.

SeeCheck(atom/a)
// If the thing is in the player's can_see list,
// then return 1, meaning they're able to see
// them.
return (a in can_see)


The only requirement for this is that you make things that are possibly not seen by the player have a density of 0. Anything with a density of 1 will automatically block the player.
In response to Dariuc
This won't work. By the time Bump() is called, they're already blocked from Enter()ing the turf they're trying to get into.
In response to Popisfizzy
You forgot to check if m is a mob before calling SeeCheck().

A more generic solution might be preferable:

atom
movable
proc
//analogous to Enter()
StepOn(atom/movable/A)
//always allow an object to step on itself
if(A == src) return 1
//do not allow two dense objects in the same turf
else return !(density & A.density)
//analogous to Exit()
StepOff(atom/movable/A)
//always allow stepping off of something by default
return 1
//analogous to Entered()
SteppedOn(atom/movable/A)
//analogous to Exited()
SteppedOff(atom/movable/A)

turf
Enter(atom/movable/A)
//don't allow dense movables onto dense turfs
if((density | loc.density) & A.density) return 0
else
//check contents of this turf for something else that will block A
for(var/atom/movable/M in src)
if(M != A)
if(!M.StepOn(A))
return 0

return 1
Exit(atom/movable/A)
//check for something that will prevent A exiting src
for(var/atom/movable/M in src)
if(M != A)
if(!M.StepOff(A))
return 0

return 1

Entered(atom/movable/A)
//perform the default action
..()
//call SteppedOn() for everything in contents
for(var/atom/movable/M in src)
if(M != A)
M.SteppedOn(A)

Exited(atom/movable/A)
..()
for(var/atom/movable/M in src)
if(M != A)
M.SteppedOff(A)


And then to adapt that to this specific purpose:

atom/movable/StepOn(var/mob/M)
if(ismob(M) && !M.CanSee(src))
return 1
else
return ..()