if(istype(M,/mob/red))
Although, now that I think about it, I could check the mob's team var... heh... *smacks himself* Anyways...
So I have:
mob
red
choppers
icon = 'choppers.dmi'
var
mob/red/chopper_blades/BLADES = new()
mob/red/shadow/SHADOW = new()
FLYING = 0
TRANSIT = 0
verb
flight()
toggle_flight(usr) // defined below as a mob/proc
light
icon_state = "red_light"
heavy
icon_state = "red_bomber"
Choppers also have mobs for thier shadow when they take off, and a mob for thier blades, which both move with the chopper as it travels... ( I would like to make the blades overlays, but I'm not sure if I can change an overlay's icon_state)
chopper_blades
icon = 'choppers.dmi'
icon_state = "blades_off"
layer = MOB_LAYER + 1
var
SPINNING = 0
shadow
icon = 'choppers.dmi'
icon_state = "shadow"
layer = MOB_LAYER - 1
density = 0
Now this is where all those nasty : come in... the toggle_flight() proc:
mob
proc
toggle_flight(var/mob/M as mob)
if(M:TRANSIT) return 0
var
DIRECTION = src.dir
if(M:FLYING == 1)
M:TRANSIT = 1
step(M,SOUTH)
M.dir = DIRECTION
M:SHADOW.loc = M.loc
M:BLADES.loc = M.loc
density = 1
M:FLYING = 0
M:BLADES.icon_state = "medium_blades"
sleep(6)
sight = 0
sleep(6)
M:BLADES.icon_state = "slow_blades"
sleep(9)
M:BLADES.icon_state = "blades_off"
M:BLADES:SPINNING = 0
M:TRANSIT = 0
return 0
if(M:FLYING == 0)
M:TRANSIT = 1
M:BLADES.icon_state = "slow_blades"
sleep(9)
M:BLADES.icon_state = "medium_blades"
sleep(12)
M:BLADES.icon_state = "fast_blades"
density = 0
step(M,NORTH)
sight = 30
M.dir = DIRECTION
M:BLADES.loc = src.loc
M:BLADES:SPINNING = 1
M:FLYING = 1
M:TRANSIT = 0
return 1
Now I know that's a horendous way of doing things, but it works.... (poor excuse for bad code) What am I doing wrong here, that : is so prevelant? I am thouroughly baffled... Comments, critisizm, heckling and fun-poking all welcome! (Also, any other general flaws you might notice in my code I would like to know about) Thanx!
~X :-\
if(!istype(M,/mob/chopper))
world.log << "ERROR: [M] is not a chopper!"
return
to make sure the proc crashes if the mob type is not correct. I hope I was of help to you!
-Lord of Water