ID:162335
 
I was wanting to make an attack (a projectile, actually) that when fired, it'll cause the ground under it to freeze into ice along the path the projectile has gone. I have no idea how to do this...

Anyhow, here is the projectile code that I have. I'm not sure exactly what is needed, so I'll post the entire thing.


obj
var/mob/owner //This var will reference the owner
waterproj
icon='proj.dmi'
icon_state="water"
density = 1
Bump(mob/M)
if(istype(M,/mob))
if(!owner) del src //Deletes itself if there is no owner to avoid runtimes
var/damage=round(owner.maxreiatsu/10)
M.health-=damage
view(6)<<"[M] takes [damage] damage."
KOcheck(M)
mob
verb
Mizu_Houkou()
usr.projectile(new/obj/waterproj(usr.loc),usr.dir,20)


mob
proc
projectile(obj/projectile,var/dir,var/delay)
projectile.owner = src //Sets the mob as the owner of the projectile
sleep(1)
walk(projectile,dir)
sleep(delay)
del(projectile)


So let's say I'm standing on

turf/grass


and I want the grass under the projectile to turn into

turf/ice
Edit: I was wrong, ignore this post.

Unfortunately, /turf's cannot be modified at runtime... howeverm you can either replace the /turf by creating a new /turf at that same location or, better yet, make a pseudo-turf (false /turf)

For a pseudo-turf, if you do go with it, you should modify Move() of /atom/movable to give it the "same properties" of a /turf:
pseudo_turf       // Long live datums
parent_type = /atom/movable // The /pseudo_turf path we just made has the characteristics as a /atom/movable
layer = TURF_LAYER+1

atom/movable/Move(NewLoc, Dir=0) // Modifying Move() to make /pseudo_turf act like a turf
var/pseudo_turf/P = locate() in NewLoc // Sees if a /pseudo_turf is in the next location
if(P)
.=P.Enter(src) // Checks if the object can enter the fake turf
if(.) .=P.Exit(src)
.=..()
if(.) // If everything's okay to leave
if(P)
.=P.Exited(src)|P.Entered(src)


I am sure there may be a better way to do the above.
In response to GhostAnime
Turfs can be modified at runtime, they just can't be moved. There's no reason to create a 'psuedo-turf' even if turf couldn't be modified, because the problem here was creating a turf of type /turf/ice to replace another turf, which suffice to say, doesn't require changing any of that turf's properties.
In response to GhostAnime
Is there no simpler way of doing it that you know of? I hate to incorporate coding into my game when I don't know exactly how it works... it makes me nervous >_>
In response to DivineO'peanut
Hm, right, right, you are correct.
new/turf/ice(__loc of old__)


Though it may be tricky putting the old turf back... well, maybe not...
In response to GhostAnime
So how would I implement that?
In response to GohanIdz
proc/iceturf(var/turf/T)
if(!istype(T, /turf/ice))
var/type = T.type
var/turf/ice/I = new(T)
spawn(50)
new type(I)


Of course, you're going to lose any data stored in the old turf's variables when you do this.
In response to GhostAnime
Well, if you need to put the old turf back, this seems like a design problem, and the ice is better off being one of those 'psuedo-turfs' you mentioned... but that's not the problem posed. Putting it back is not a problem though, you just need to store whatever is important about it in a variable or a savefile.
In response to DivineO'peanut
not that i know much about coding but maybe you could set a time limit on this psuedoturf so that after that time period that turf would be erased leaving the original? Just like melting ice