ID:174096
 
I need some help, I'm making a castle raid game, where you build your own castle and can attack eachother ect. But I have A major problem, And I need to fix it. I Would greatly appriectate it if someone would help. Heres my problem, Like I said, The players build there own castles, and currenlty can defy the laws of physiscs. To fix It I need to know how to make this build verb check for surrounding walls, mobs, Specil areas(areas beside area/, so like area/ceiling), and any other dense things. Heres the build verb for an advanced dugout:
Build_Advanced_Dugout()
new /turf/walls/wall2blocker(locate(src.x,src.y -1,src.z))
var/mob/Defenser/I = new /mob/Defenser(locate(src.x,src.y,src.z))
new /turf/walls/roofspecil(locate(src.x,src.y,src.z))
new /turf/walls/roofspecil(locate(src.x,src.y +1,src.z))
new /turf/walls/roofspecil(locate(src.x +1,src.y +1,src.z))
new /turf/walls/roofspecil(locate(src.x +1,src.y,src.z))
new /turf/walls/roofspecil(locate(src.x -1,src.y,src.z))
new /turf/walls/wall2blocker(locate(src.x -1,src.y -1,src.z))
new /turf/walls/wall2blocker(locate(src.x +1,src.y -1,src.z))
new /turf/walls/roofspecil(locate(src.x -1,src.y +1,src.z))

new /area/nopoeplecangothrough(locate(src.x -1,src.y,src.z))
new /area/nopoeplecangothrough(locate(src.x,src.y -1,src.z))
new /area/nopoeplecangothrough(locate(src.x,src.y +1,src.z))
new /area/nopoeplecangothrough(locate(src.x +1,src.y +1,src.z))
new /area/nopoeplecangothrough(locate(src.x +1,src.y,src.z))
new /area/nopoeplecangothrough(locate(src.x -1,src.y -1,src.z))
new /area/nopoeplecangothrough(locate(src.x +1,src.y -1,src.z))
new /area/nopoeplecangothrough(locate(src.x -1,src.y +1,src.z))
I.side = usr.side
usr.x += 2


I would Be Very thankful to whoever helps and would gladly give them credit in the game if they requested it =)
proc/IsSomethingThere(turf/T)
var/atom/A
if(T.density)
return 0 // If the turf is dense bail out with failure
if(T.loc.type != /area)
return 0 // There's an area other than /area
for(A in T)
if(A.density)
return 0 // There's a dense object/mob on the turf
return 1 // Nothing special here!

proc/IsSomethingInBlock(turf/Ref, dist)
var/turf/T
for(T in range(Ref, dist))
if(!IsSomethingThere(T))
return 0 //There's something on one of the tiles
return 1 // It's an empty patch of land


That should help for checking for something special. Also I don't know if you create areas the way you're doing. I think you need to set the areas like

T.loc = locate(/area/somearea) //Where T is some turf you're setting the area for


This is because a turf is contained within an area and not the other way around. But let me go verify this as I haven't played with this myself.
In response to Theodis (#1)
Nope, Still lets me build on top of stuff and I got this error:<FONT color=Red>
runtime error: Cannot read null.density
proc name: IsSomethingThere (/proc/IsSomethingThere)
source file: Castleraid.dm,184
usr: DarkCampainger (/mob/PC)
src: null
call stack:
IsSomethingThere(null)
DarkCampainger (/mob/PC): Build Advanced Dugout()</font>
In response to DarkCampainger (#2)
runtime error: Cannot read null.density
proc name: IsSomethingThere (/proc/IsSomethingThere)
source file: Castleraid.dm,184
usr: DarkCampainger (/mob/PC)
src: null
call stack:


IsSomethingThere(null)

Garbage in, garbage out :).
In response to Theodis (#3)
???? What?!?!?!?
Are you calling my game garbage =(
=(
so you gave me garbage help????
confusing.... I guess
well, I'll make it work, or download every demo untill I find one that does, or maybe I'll just post this again later on the fourm...
In response to DarkCampainger (#4)
I Made It Work =)
In your face Garbage!
come to think of it that reminds me that our garbage men are on strike..... I guess we'll be eating out =)
In response to DarkCampainger (#4)
Sorry my watch beeped which meant my class had started and I had to run before explaining what that phrase meant :).

Basically the phrase "Garbage in, garbage out" is a phrase programmers use when someone passes in something stupid into a function and expects some kind of result.

My function expected a turf and you gave it a null which makes no sesnse to my function which is why it didn't do anything meaningful. Hence garbage in, garbage out.
In response to Theodis (#6)
ok..... so you where doing this at school... or collage? Maybe during study hall??