ID:177740
 
How would you make a mob type that more than one player can control? I mean, like a tank. One driver and around seven gunners. This is needed to create Class-B tanks in my game.
Drafonis wrote:
How would you make a mob type that more than one player can control? I mean, like a tank. One driver and around seven gunners. This is needed to create Class-B tanks in my game.

Basically I think the way you'd do this would be to have a dummy mob type.
world
mob=/mob/dummy

atom/movable // this is so /obj/turret and /mob will work
proc/Fire()
...

obj/turret
var/client/client // is a player controlling this

mob
dummy // /mob/dummy is a blank type
var/list/turrets // the objects under gunner control

Move(newloc)
.=..()
if(.)
if(!turrets) return .
for(var/obj/turret/O in turrets)
O.loc=newloc

Fire()
if(!turrets) return
for(var/obj/turret/O in turrets)
// we can use usr here because this is called by client.Center(), a verb
if(O.client) O.client << "<B>[usr.name]:</B> Fire!"
else O.Fire()

client
var/job // our job in the vehicle (client.eye)
perspective=EYE_PERSPECTIVE

// attach this player to a tank or turret
proc/TakeOver(atom/thing)
eye=thing
if(istype(thing,mob))
mob=thing
else
mob=new/mob/dummy
var/obj/turret/O=thing
O.client=src
eye=thing

North()
if(istype(mob,/mob/dummy)) return
mob.Move(get_step(mob,mob.dir))
South()
if(istype(mob,/mob/dummy)) return
mob.Move(get_step(mob,turn(mob.dir,180)))
West()
var/atom/movable/thing=client.eye // this may be a turret
if(!thing) return
thing.dir=turn(thing.dir,45)
East()
var/atom/movable/thing=client.eye
if(!thing) return
thing.dir=turn(thing.dir,-45)
Center()
var/atom/movable/thing=client.eye // this may be a turret
if(!thing) return
thing.Fire()

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Drafonis wrote:
How would you make a mob type that more than one player can control? I mean, like a tank. One driver and around seven gunners. This is needed to create Class-B tanks in my game.

Basically I think the way you'd do this would be to have a dummy mob type.
world
> mob=/mob/dummy
>
> atom/movable // this is so /obj/turret and /mob will work
> proc/Fire()
> ...
>
> obj/turret
> var/client/client // is a player controlling this
>
> mob
> dummy // /mob/dummy is a blank type
> var/list/turrets // the objects under gunner control
>
> Move(newloc)
> .=..()
> if(.)
> if(!turrets) return .
> for(var/obj/turret/O in turrets)
> O.loc=newloc
>
> Fire()
> if(!turrets) return
> for(var/obj/turret/O in turrets)
> // we can use usr here because this is called by client.Center(), a verb
> if(O.client) O.client << "<B>[usr.name]:</B> Fire!"
> else O.Fire()
>
> client
> var/job // our job in the vehicle (client.eye)
> perspective=EYE_PERSPECTIVE
>
> // attach this player to a tank or turret
> proc/TakeOver(atom/thing)
> eye=thing
> if(istype(thing,mob))
> mob=thing
> else
> mob=new/mob/dummy
> var/obj/turret/O=thing
> O.client=src
> eye=thing
>
> North()
> if(istype(mob,/mob/dummy)) return
> mob.Move(get_step(mob,mob.dir))
> South()
> if(istype(mob,/mob/dummy)) return
> mob.Move(get_step(mob,turn(mob.dir,180)))
> West()
> var/atom/movable/thing=client.eye // this may be a turret
> if(!thing) return
> thing.dir=turn(thing.dir,45)
> East()
> var/atom/movable/thing=client.eye
> if(!thing) return
> thing.dir=turn(thing.dir,-45)
> Center()
> var/atom/movable/thing=client.eye // this may be a turret
> if(!thing) return
> thing.Fire()

Lummox JR

Thing is, I have a different mob defined as the starter mob. What I want is so that the tank is placed on the map, and, when a player gets near it, he goes into the tank.
In response to Drafonis
Drafonis wrote:
Thing is, I have a different mob defined as the starter mob. What I want is so that the tank is placed on the map, and, when a player gets near it, he goes into the tank.

Ah. In that case this is easier to handle.
You'll need a var indicating which turret is being controlled, and when you're in a tank, mob.loc (if src is the client) will be the tank.
mob/tank
proc/RoomForCrew(mob/M)
... // return 1 if this person can board, 0 if they can't

mob/player
Bump(atom/A)
if(ismob(A))
var/mob/M=A
if(M.team!=team)
if(istype(M,/mob/player))
view() << 'punch.wav'
M.HP=max(M.HP-rand(1,3),0)
M.DeathCheck(src)
else
if(istype(M,/mob/tank))
var/mob/tank/T=M
if(T.RoomForCrew(src))
loc=T
T.AssignPlayer(src)
else
src << 'oof.wav'
else
// switch places
var/atom/oldloc=loc
loc=M.loc
M.loc=oldloc
oldloc.Exited(src)
loc.Exited(M)
oldloc.Entered(M)
loc.Entered(src)

Lummox JR