Hey, me again. in Developer Help
|
|
I'm making somewhat of an effort to add marine craft to my game; I've successfully managed to enable them to get in and out of the boats, and only be able to "drive" on water and nothing else, But then I figured 'Hey, why not make the boats 64x32?' So I arrive at my problem.
The craft are from an aerial view, and I've got the states set up so that they both always face the same way and stuff, but I'm not quite sure what to do to make the rear end of the boat follow the front.
obj boatrear icon = 'boat.dmi' icon_state = "speedboatback" density = 1
mob Speedboat icon = 'boat.dmi' icon_state = "speedboatfront" var obj/back = /obj/boatrear Move(Loc) ..() for(var/mob/M in world) if(M.vehicle == src) src.loc = locate(M.loc) if(NORTH) var/turf/T = locate(src.x,src.y-1,src.z) if(T) back.loc = T back.dir = src.dir if(SOUTH) var/turf/T = locate(src.x,src.y+1,src.z) if(T) back.loc = T back.dir = src.dir if(EAST) var/turf/T = locate(src.x-1,src.y,src.z) if(T) back.loc = T back.dir = src.dir if(WEST) var/turf/T = locate(src.x+1,src.y,src.z) if(T) back.loc = T back.dir = src.dir
|
|
<code>mob Speedboat var/obj/boatrear/back = new var/list/peopleonboat=list() // Add people to this list when they get on, and remove them when they get off Move(Loc,Dir) .=..() // Looping through everyone on the boat is much faster than looping through everyone in the world. // As Move() is called pretty frequently, it needs to be as optimised as possible. for (var/mob/M in peopleonboat) M.loc=src.loc // You can replace that entire messy switch() with three lines. (Although it's not a switch() because you forgot to put in the switch() line... whoops!) var/turf/T=get_step(src,turn(dir,180)) if (T) back.loc=T back.dir=src.dir</code>
Tada. The only thing wrong with that is that the back of the speedboat will swing around all over the place, but I'm guessing you can live with that as that's how you designed it in the first place. =) A better way might be to swivel the front around and have the back of the speedboat be the bit that gets controlled; that wouldn't require many changes, basically just switch the icons around and replace "turn(dir,180)" with just "dir".