ID:170060
 
I'm currently making a verb where you construct a weapon. Once the weapon is constructed it sets the weapons var. Now separately when the player walks past the weapon they made it does not fire upon them but fires on others. I have the building part down, and the checking for the var but I'm stumped on trying to set the var from the verb. Any help?

~>Jiskuha

mob
verb
create_sword()
var/obj/sword = new /obj/sword(usr.loc)
sword.fire = 1
obj
var/fire = 0
sword
icon = 'sword.dmi'


i guess... <_<
In response to Zero's Baby
Whoa that is totally not what i wanted. Anyways here is what i have now.

obj
var
creator
Turret
icon='weapons.dmi'
icon_state="turret"
density = 1
New()
src.creator="[usr.key]"
spawn(10)
look()
proc
look()
while(1)
if(locate(/mob) in oview(src,5))
var/list/mobs_in_oview=new
for(var/mob/M in oview(src,5))
mobs_in_oview.Add(M)
var/mob/M=pick(mobs_in_oview)
if(src.creator==M)
return 0
var/obj/Bullet/B=new(src.loc)
walk_towards(B, M)
mob/verb/BuildTurrets()
new /obj/Turret (locate(usr.x,usr.y,usr.z))


Now this still shoots the creator and I don't want it to. Any suggestions?

~>Jiskuha
In response to Jiskuha
obj
var
reloadtime
creator
color
Turret
icon='weapons.dmi'
icon_state="turret"
density = 1
reloadtime=30
New()
src.color=usr
spawn(10)
look()
proc
look()
while(1)
if(locate(/mob) in oview(src,5))
var/list/mobs_in_oview=new
for(var/mob/M in oview(src,5))
mobs_in_oview.Add(M)
var/mob/M=pick(mobs_in_oview)
if(M.color==src.color&&M.health>0)return
var/obj/Bullet/B=new(src.loc)
walk_towards(B, M)
sleep(reloadtime)


Updated -- still does not work with this line
if(M.color==src.color&&M.health>0)return


~>Jiskuha
In response to Jiskuha

> obj
> var
> reloadtime
> creator
> color
> Turret
> icon='weapons.dmi'
> icon_state="turret"
> density = 1
> reloadtime=30
> New(loc,mob/M)//Changed
> //Call this like var/obj/turret=new(src.loc,src) or whatever
> ..()
> //Have a var for mobs called color? If so, make the below M.color
> src.color=M
> spawn(10)
> look()
> proc
> look()
> while(1)
> if(locate(/mob) in oview(src,5))
> var/list/mobs_in_oview=new
> for(var/mob/M in oview(src,5))
> mobs_in_oview.Add(M)
> var/mob/M=pick(mobs_in_oview)
> if(M.color==src.color||M.health>0)return//changed
> var/obj/Bullet/B=new(src.loc)
> walk_towards(B, M)
> sleep(reloadtime)
>


Let me help with that a bit.

<_<; That should work
In response to Hell Ramen
Hmph, Now it wont shoot at all. Perplexing...

~>Jiskuha
Here's something that may help you out, plus some.

#define SECOND              10 //one second
#define MINUTE 600 //one minute
#define HOUR 36000 //one hour
obj
weapons
var
health=100
const
max_health=100
reloadtime=MINUTE
color="#000000" //default color is black can achieve same effect using this way:
// color=rgb(0,0,0) which returns "#000000"
tmp
mob
creator
proc
Look()
Destroy()
Turret
icon='weapons.dmi'
icon_state="turret"
density=1
New(Loc,Dir,mob/Creator)
src.creator=Creator
src.name="[src.x],[src.y]"
spawn(10)
src.look()
Look()
while(src&&src.creator&&src.health) //We don't want a turret existing without its owner do we?
var/mob/M=locate() in oview(5,src)
if(M)
var/list/Mobs=list()
for(var/mob/Mob in oview(5,src))
Mobs.Add(Mob)
var/mob/Mob=pick(Mobs)
if(src.creator!=Mob)
var/obj/Bullet/B=new(src.loc)
walk_towards(B,Mob,5)
sleep(10)
if(!src.creator||!src.health)
src.Destroy()
Destroy()
if(!src.creator)
del(src)
if(!src.health)
if(src.creator)
src.creator.Turrets.Remove(src,null)
src.creator<<"Turret [src.name] was destroyed!"
del(src)
mob
var
Turrets=list() //Keeps track of all turrets made
Max_Turrets=20 //If you want to impose a limit on the amount
verb
BuildTurret()
if(Max_Turrets!=Turrets.len)
Turrets.Add(new/obj/weapons/Turret(locate(src.x,src.y,src.z),src.dir,src))