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.
ID:1019675
![]() |
|
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 |
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)) 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? |
Here's the first thing that's going wrong:
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:
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:
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:
This is what you would see running the above code:
Looping...
Looping...
Looping...
Looping...
And stuff!
This is what you would see running the above code:
Looping...
And stuff!
Looping...
And stuff!
Looping...
And stuff!
Looping...
And stuff!