Turn ya darn plane o.o in Developer Help
|
|
Code:
obj snow mid12 name = "Cockpit" density = 1 layer = MOB_LAYER-1 icon = 'snow.dmi' icon_state = "mid1" Click() if(usr.flying == 1) usr << "<b>You are already flying a plane!" return else usr.flying = 1 usr.loc = locate(src.x,src.y,src.z) usr.icon_state = "above" usr.overlays += /obj/snow/lwing2 usr.overlays += /obj/snow/rwing2 usr.overlays += /obj/snow/top2 usr.overlays += /obj/snow/bottom2 usr.overlays += /obj/snow/mid22 usr.overlays += /obj/snow/mid32 usr.density = 0 usr.rundelay = 0 usr.health = 300 usr.mhealth = 300 usr.verbs += new/mob/verb/shoot usr.verbs += new/mob/verb/shootm usr << "You currently have 5 missles left." usr.flying() mob proc flying() set background = 1 serp if(src.flying == 1) walk(src,dir) if(src.flying == 0) return goto serp mob Move() if(src.frozen||src.moving) return src.moving = 1 ..() sleep(src.rundelay) src.moving = 0
|
Problem description: I'm trying to make it so i can get in the plane and fly around in it... well i can get that much done but when your in the plane and its using the flying proc it doesn't let me turn the plane.. at all! and then if i shoot a bullet it gets behind me somehow... which either means i made the plane too fast for the bullets or somehow i messed that up but can you help with making the plane turn please? i tried everything i can think of o.o
|
I'm guessing that the problem is in there. First, not having to do with your problem but something to fix anyways is the use of goto. You don't need to use goto there. A while loop could go there instead. You can either do while(1), and have the rest of the code remain unchanged, or better yet, while(flying). Then both of those if() statements become unnecessary and the code looks much cleaner and should be easier to maintain.
Concerning the problem you're having, the loop you've set up never sleeps. It's constantly calling walk(src,dir) and never leaves time for any other kind of movement to happen. After replacing goto with while(), try adding a call to sleep(). sleep(1) would have the plane wait 1 tick (0.1 seconds) between moves: increase the sleep time if it moves too fast or you find the plane still unresponsive.