ID:1410683
 



A good idea for rpg games :)
http://www.megafileupload.com/en/file/465364/ Phase-Atom-rar.html

/*
//////////////////////////
Phase Atom
//////////////////////////
*/

var/list/PhasedIcons=list(/**/)
proc/PhaseWorld()
set background=1
for(var/turf/T in world)
T.PhaseAtom(/**/)
mob/see_invisible=1
atom/var/Phase=0
atom/var/DontPhase=0

obj/Phase
layer=5
density=0
invisibility=1
mouse_opacity=0

atom/proc/PhaseAtom(/**/)
if(src.Phase || (src.layer>=5 && !src.density))
if(src.layer>=6 || src.contents.len || src.overlays.len || src.DontPhase) return
src.layer=2.2
var/srcLoc=locate(src.x,src.y,src.z)
for(var/obj/Phase/P in srcLoc) return
var/icon/I
if("[src.icon]" in PhasedIcons) I=PhasedIcons["[src.icon]"]
else {I=src.icon-rgb(0,0,0,100);PhasedIcons["[src.icon]"]=I}
var/obj/Phase/O=new(srcLoc)
O.icon=I;O.icon_state=src.icon_state
O.pixel_x=src.pixel_x;O.pixel_y=src.pixel_y
You can speed this up by using the atom.alpha variable instead of making new transparent icons.
The problem with this system is that it still looks like you're above the tree, you're just transparent and above the tree. The tree needs to be the thing that's transparent so that its texture is above you.

Theorizing, what if you just placed the tree down normally, but then placed a transparent version of the tree above it and at a higher layer as an overlay at runtime? That way, the tree would look non-transparent, but then it would be transparent only when there's something under the transparent layer and above the non-transparent layer. Hopefully I explained that well enough.
In response to Fugsnarf
I think that's what he's doing, actually. Putting a transparent tree above the solid tree.

Either way, the player is over a solid tree, which is problematic.

Someone else some years ago made a system that replaces the tree entirely with a transparent version when a player moves behind it. That one fits better and is done more often in other games.
Well im still learning and I didn`t post this so people will criticize.
I am still learning and if you have a better way of doing it-go ahead post it.
I decided to try this on my own. I used my Megaman game. Basically, all I did was add the object to the map, then I added another one on top of it. I made both undense, then I made one of them transparent and have a higher layer value. The object looks perfectly normal until you walk under it. I feel like this method is easier, more efficient, and also accounts for other variables. You could set it up so that all objects that you want to have this property automatically gain a transparent overlay at runtime.


In response to Fugsnarf
You described his system and got the same results. Why not show code to compare the part that matters?
That's the thing. I didn't use any code. I did everything in the map. I'm showing that his system is overly complicated for something that's relatively easy to do by just overlaying another object that's transparent.
In response to Fugsnarf
Oh, I see. That sounds tedious, though, to have to do that manually for every kind of object. His system adds the transparent layer at run-time, like you suggested at the end.
I think Fugsnarf suffers from the same impression I did (until I saw this little discussion, and went back to actually read the code Phat T provided). From those first screenshots, it appears that what has been done is turn the player semi-transparent. There's just something about the way the effect looks in those images that gives me (and apparently, Fugsnarf) that impression.

I think that it's simply a matter of making the covering object too transparent. Something higher than alpha of 100 would make it look a little more like we expect, I think.

But anyway, it is operating from this assumption that made Fugsnarf think that his method was significantly different from what Phat T has done. Even though in the end, they're the same thing (well, aside from one being done procedurally, and one being done manually)
You're right. My impression was wrong. Either way, you could greatly reduce the code down to making use of the alpha var and adding a simple overlay whenever the object is created.