ID:168050
 
How to make a gun that shoots only 1 type of monster,i made a gun but it shoots everything even other users
i need some sort of proc to check if the mob is that monster
but i dont know how to make it...
Well, perhaps the line
for(var/mob/M in view(usr))
if(M.client)
return ..()
else
// insert attacking stuff here
In response to Magus_Christel
This is what I use, it is simple, and it works:

client
DblClick(mob/M)
if(istype(M,/mob/Monster/)) //insert type path of monster here
switch(usr.weapon)
if("Gun") //this is where you check for the weapon
//insert your effects here
else
..()


Note: Remember, in this case, use missile or similar proc, other than walk, to shoot the projectile, if you use projectiles for your guns.

Now, if you're guns shoot projectiles, and you use walk to move them, you just need to set the projectile to check for type:

obj
Bullet
Bump(mob/M)
if(istype(M,/mob/Monster/)) //type path
//effects go here
In response to Bobthehobo
can you tell my a way to get a working gun,mine dosnt work anymore
In response to EkstreM
Show the code then.
In response to Bobthehobo
You wouldn't want to check what type of gun it is. You'd want to call the gun's procedure for firing. Checking if the gun is x is a method people have used for a long while, and it's dumb.

[dm]
obj/Gun
proc/fire()
[/dm]

Now instead of checking if Gun is "Pistol1" or "Rifle2", just call the gun's fire procedure.
In response to Crashed
so how does the program know which gun i got a m16 or a Ak47?
In response to EkstreM
You have to make an equip verb, that sets the weapon as your current weapon.
mob/var
obj/weapon //the variable for holding your weapon

obj/gun
verb/Equip()
set src in usr //so the verb is only visible when\
the object is in their contents

if(src!=usr.weapon) //if the gun isnt currently equipped
usr.weapon=src //set the gun to the var
usr<<"You equip [src]."//message the user
else
usr.weapon=null //clear the users weapon var
usr<<"You unequip [src]." //message the user

Don't forget to stop people from dropping a weapon they have equipped, and such, or you'll run into a mess of trouble later.

Mind you, copy and paste is evil. Don't do it. Period. =P Take the information, and write your own code. You'll learn much more that way.