ID:1019675
 
(See the best response by Magicsofa.)
Code:

2012-10/Boakev12-0001/hg.dm

Problem description:

when i run this code doesnt work right i dont know what im doing wrong but when u kill the npc u dont get the demon that you should from the npc.
Best response
Damn...you are doing a LOT of things wrong. I'm not trying to be insulting, I just want to let you know that you have a lot of things to work on. I'm having a really hard time figuring out what the hell is going on in this Death() proc (what in the world is hyoushou???) but I will try to help.

Here's the first thing that's going wrong:

Death(mob/M)
if(istype(src,/mob/pet)&&src.isdog&&!src.owned)
del(src)


You deleted the mob! Any code after this line will not happen because it belongs to the object that you just deleted. One way to fix this is to set its loc to null, and then use del(src) at the end. That way it will disappear from the map, but still exist to run the rest of the code.

The other problems I see don't break your code, but they make it ridiculously hard to type and to edit. You must learn how to use inheritance to your advantage:

mob
enemy
icon = 'npcs.dmi'
icon_state = "ninja4"
weaknin = 1
Tekken = 1
tele = 1
maxhealth=1800000000
health = 180000000
tai = 100000000000
nin = 7000000000
gen = 4000000000
NPC=1

Shakakuguy
icon = 'someothericon.dmi'
Sanbiguy
Nibiguy
Kyuubiguy
Shichibiguy
Gobiguy
Yonbiguy
Hachibiguy
Rokubiguy


Instead of re-writing all the same values for every different mob type, you can have them inherit values from the parent. This way you can define things that are common to all objects of type /mob/enemy, and then change only what you want to be different (I used Shakakuguy as an example if you wanted a different icon)

Here is another example:
    Demon_Guy
name = "Demon_Nin"
icon = 'APCs.dmi'
icon_state="Bounty Man"
health = 9.99999e+999
verb/Talk()
set src in oview(3)
switch(input("You think you are ready for the demon Mission,Warning u only can do this once")in list("Do it Im ready!","I killed my dude","Cancel"))
if("Do it Im ready!")
if(!usr.demon)
usr<<"U cant do this quest"
else
var/choices = list("Shukkaku","Sanbi","Nibi","Kyuubi","Gobi","Yonbi","Hachibi","Rokubi","Shichibi")
var/mychoice = pick(choices)

if(mychoice == "Shukkaku")
usr<<"Mission Accepted.you now have to kill the Npc which i will tele u to his location island. this makes the random demon of Shukkaku urs :D"
else
usr<<"Mission Accepted,You get to go kill [mychoice] powered npc."

usr.loc=locate(mychoice)
usr.current_island = mychoice
if("I killed my dude")

if("Cancel")
return

turf
islandstart
tag = "Sanbi"

mob/var
demon=0
current_island = ""


In the map editor, you would find turf/islandstart, right-click on it in the object window, and click on "new instance." Then edit the tag to be one of the names. This way you can change their location or add new ones without touching your code.

You also need to pay closer attention to your indentation. Here's an example of how indentation affects the way code executes:

for(var/inc = 5, inc, inc--)      //creates a loop which keeps going as long as inc > 0
world << "Looping..."
world << "And stuff!"


This is what you would see running the above code:

Looping...
Looping...
Looping...
Looping...
And stuff!

for(var/inc = 5, inc, inc--)      //creates a loop which keeps going as long as inc > 0
world << "Looping..."
world << "And stuff!" //noticed I indented this line


This is what you would see running the above code:

Looping...
And stuff!
Looping...
And stuff!
Looping...
And stuff!
Looping...
And stuff!
Also, please don't ever use things like "U" in a message to the player. You are capable of writing complete words and sentences, so do it. Otherwise your game makes you look like an idiot.



EDIT: I forgot something, and I don't want to stick it in the middle of the post above in case you miss it :D

I removed all the lines that said name = "Sanbiguy" or whatever. This is because, by default, the name variable is the same as the name you give it in the object tree! You only need to specify a name if you want it to be different:

mob
something
name = "Fred"
ok but i was really looking for the when i kill that npc player should automatically get the demon they want but when i run it that doesn't happen
Okay well all I see is that you have a Death() proc which alters a bunch of variables based on the type of src.

I assume this is one of the places you're supposed to "get" a demon:

if(istype(src,/mob/enemy/Gobiguy))
M<<"You have completed your mission and got the Gobi!"
M.Ryo+=20000
M.demon = 1
usr.Gobi = 1
del(src)
return


In the first part of my post I told you that you deleted the object too soon, so if you changed that then killing a Gobiguy should get you to this spot.

However, variables like demon and Gobi are not used anywhere else in the code you gave me. I also can't see how the Death() proc is being called. So there's no way for anyone to figure out why you don't "get the demon." You're gonna have to provide more information.
they are both just simple vars like

mob/var/demon = 0(to notify if u have a demon or not)
mob/var/Gobi = 0(to note if u got that demon already)
so are you only testing to see if those vars are set to 1?

Your death proc is defined as Death(mob/M). Then, in the code, you set M.demon to 1 and usr.Gobi to 1. But src appears to be the mob you killed. So who is M?
well "M" is suppose to be the npc for the case of Desth(mob/M) but the M.demon = 1 is for the player
M.demon means the variable "demon" belonging to the object "M"

If M is the mob you killed, then why are you setting stuff for both src and usr?
true ill fix that then update you