ID:159925
 
Hi, I am trying to make my quest npcs have a "!" on them if they have a quest and that only you can see, but if you have finished the quest the "!" dissapears.
any help would be great.
Look up images.
In response to Andre-g1
mob
NPC
man
icon = 'mobs.dmi'
icon_state = "mman"
New()
..()
for(var/mob/M in world)if(!M.quest)
var/image/i=image('turfs.dmi',"questmark",src)
M<<i
proc/endquest(mob/M)
for(var/i in M.client.images)del(i)


Ok, this is what I got, but it isnt working...
In response to Carnia
Two problems that I can see outright.

1) The if(!M.quest) checks to see if they DO NOT have a quest. I would think that you'd check to see if they DO have a quest. I could be wrong though, as I don't know how you coded the rest of your game...

2) That proc doesn't have a defined image, so just giving the letter "i" a variable and deleting it, won't reference the defined image variable in the New() proc. You need to define the image again in the proc, so it knows what to delete exactly.

Correct me if I'm off a little please. (Jeff, Kaioken, Andre, etc) :)
In response to Mizukouken Ketsu
Ah, I figured it out, thanks alot :)
In response to Carnia
Carnia wrote:
> mob
> NPC
> man
> icon = 'mobs.dmi'
> icon_state = "mman"
> New()
> ..()
> for(var/mob/M in world)if(!M.quest)
> var/image/i=image('turfs.dmi',"questmark",src)
> M<<i
> proc/endquest(mob/M)
> for(var/i in M.client.images)del(i)
>

Ok, this is what I got, but it isnt working...

If I'm reading it right (aside from the issue mentioned above), it would only show the ! to players who were in the game when the mob is created. IIRC the last time I made something like that, I used Enter() on the area the npc was on, so that when the player enters the area it checks all the npcs and whether they have a particular quest or not. Whether this is the best way to do it or not, it seemed to get the job done.

Edit: There was a thread not too long ago discussing the use of ..() in the new proc... in this case I don't think it's necessary, but I could be wrong.
In response to Carnia
Code matters (such as using the wrong arguments order in image()) aside, the design itself is bad; often people don't pay enough attention to these things and waste considerable resources instead of reusing existing ones.
The way your code works, when an NPC is created, you create a new image object for every player. So an object for every NPC, for every player (f.ex. 20 NPCs and 10 players produces 200 images). Again, aside from this utterly failing because you're not likely going to have players logged in when the NPCs are first initialized et cetera, this wastes resources: you only really need to maintain a single image on each quest giver NPC, and then turn that single image on and off for players, by simply adding and removing it from the client's images list (not creating new instances and deleting them per player).
mob/npc/questgiver
var
...
list/quests
quest/quest //whatever
var/image/quest_marker
New()
quest_marker = new('icons.dmi',src,"questmarker")
verb/Complete_Quest()
set src in oview(1)
usr << "congrats, you finis quast!"
usr.Has_Finished_Quest()
if(player has finished all available quests of npc)
usr.client.images -= src.quest_marker //remove the image
else //if there are quests remaining
//as a safety fallback, if the image isn't already\
there, then add it

if(!(src.quest_marker in usr.client.images))
usr.client.images += src.quest_marker

mob/player/New()
for(var/mob/npc/questgiver/M) //loop through all questgiver mobs
if(player hasn't finished all of M's quests)
src << M.quest_marker

Note you could use more resource effective methods, but that's a tad more involving.
EDIT: Fixed a Miss
In response to Kaioken
Wow, thanks Kaioken, your way is alot let resource killing then mine that I figured out, thanks for the tips, they helped alot :)