ID:874580
 
(See the best response by Dj dovis.)
Hi My English is not good. So I help myself with translator. Sorry if something is not understood.

Code:
mob
var
Enemykill=(new/mob/Monster/Krolik)
proc
KillEnemyInQuest()
for(var/mob/Monster/M in src.Enemykill)

if("[M.name]"== "Krolik")
src.quest1killed+=1
usr << output("<B>System :<font color=#DA5101>[M.name] </font>zabito [quest1killed]/[quest1killedmax] </font>", "ChatPaneSys.Output")


Problem description:If I kill an enemy who is in the list "Enemykill" This should add to the usr "quest1killed + = 1". A problem is that if you kill an enemy it gives me var from every enemy on the map of the same type. How do I fix this? . Please write the correct code. Because there is a chance that I do not understand :p.

Best response
well for one the Enemykill isnt a list. also theres no need for "" and [] around the M.name
Thanks a lot :D
KillEnemyInQuest() should be called with a mob in mind, simply call the proc within the 'attack' like so usr.KillEnemyInQuest(mob/MonsterBeingAttacked) (Most commonly people use mob/M). And define the proc with that in mind.

KillEnemyInQuest(mob/MonsterBeingAttacked)

Then set it to reconize the enemy.

if(istype(MonsterBeingAttacked,/mob/Monster/ MonsterBeingAttackedType))
Please correct it and write my code in your post.

Because not all understand.

(For reasons of speaking)
It's all my code .
mob/Monster
Krolik
icon='Krolik.dmi'
name = "Krolik"
......
Robak
icon='Robak.dmi'
name = "Robak"
.......
mob
var
Enemykill[] = list()




proc

KillEnemyQuest()
var/obj/Skills/S
for(var/mob/Monster/M in src.Enemykill)
if("[M.name]"== "Krolik")
src.quest1killed+=1
usr << output("<B>System :<font color=#DA5101>[M.name] </font>zabito [quest1killed]/[quest1killedmax] </font>", "ChatPaneSys.Output")



DeathCheck(mob/Killer)
if(src.HP<=0)
if(src.key) //if its a player you wana do something different right?
src<<"<I><small>You were Killed by [Killer]!" //a quick death message so u know u died
src.HP=src.MaxHP //restores users HP and MP after dying
src.MP=src.MaxMP
src.loc=locate(8,16,1) //sends the dead guy back to the start
else
Killer<<"<I><small>You Killed a [src]! Gained [src.Exp] EXP and [src.Gold] Gold"
Killer.Exp+=src.Exp
Killer.Gold+=src.Gold
Killer.UpdateHuds()
Killer.LevelCheck() //check if the player has enough EXP to level up
Killer.KillEnemyQuest(src)
del(src)
QuestNPC
Aska
icon='Magician.dmi'
verb/Talk()
set src in oview(1)
usr.Enemykill.Add(new/mob/Monster/Krolik,new/mob/Monster/Robak)//test 2 object destroy
In response to Marekssj3
You actualy almost got it. Though moral standings and BYOND moderators prevent me from giving you the code I'll show you what I mean.

mob
proc
KillEnemyQuest(mob/M)
if(istype(M,/mob/[inserttype]))
[insert actions here]

Of course it's wise not to use spaces and such but meh, I wrote this in the browser. What can you expect?
In response to Marekssj3
When adding to your list simply add the path without the 'new' part, it's unneeded.

// simply add to the list like so:
somelist.Add(/mob/enemy/rat, /mob/enemy/frog)

I was getting confused reading the comments here, I think this will lead you into a better direction on doing it.

// setup a list of enemies to kill
mob/var/list/enemiestokill = new

// create a check to find whether a not the enemy is in the list
proc/enemycheck(var/list/list, var/type)
if((type in list))
return 1
return 0

mob
// setup your deathcheck(), you can do it this way or
// you can do it the current way that you have it setup
proc/deathcheck(var/mob/m)
if(src.HP <= 0)
...
src << "..."

enemy
// this is how you would separately change it for enemies
deathcheck(var/mob/m)
if(src.HP <= 0)
m << "..."
// check whether or not this mob is in the enemiestokill list
if(enemycheck(m.enemiestokill, type))
// it'll return 1 on success & reward them
m.completedsomequest = TRUE
// continue with the rest of the proc
...
In response to Boubi
My response was on-point to his issue. The problem presented isn't that he wants to check through multiple types via a list, he's just trying to check for one specific type of mob to present a var related to defeating the mob.

Though, I agree with the Death proc being called from the specific type of mob to add that var. Though, it'd be easier to run it through a proc in the death proc to check the type and assign values as such.

Example:
A developer makes 50 bosses and 50 vars to check which bosses the player has killed.

It's easier to run all 50 through a proc and assign vars accordingly rather than adding in 50 various death checks to each specific mob type.
I have a problem. How to remove a monster from the list?
Because this method does not work ;/

mob/var/list/enemiestokill[] = list()

usr.enemiestokill.Add(new/mob/Monster/frog)//at the beginning of the mission I set it. I gives me a monster to the listenemiestokill[] list.

usr.enemiestokill.Remove(new/mob/Monster/frog)//and this is the end. Theoretically, it should delete the enemy from list , and it is not.

What am I doing wrong ?
Sorry for my retarded english.
If you only want to remove one then you could do this:
proc
list_remove(var/list/L, var/removee)
for(var/R in L)
if(R == removee)
L.remove(R)
break


Sorry for lack of tabbing I couldn't be asks to open Dreamseeker to do it.
In response to Marekssj3
You're creating a new mob/Monster/frog when you remove it. You should be able to get it to work by removing the new/ in the .Remove().

Though the new/ is un-needed in the .Add aswell.
I'm sorry I'm really a beginner, could you explain to me what I did wrong?
proc
list_remove(var/enemiestokill, var/removee[I do not know what has to be here;/])
for(var/mob/Monster/frog in enemiestokill)
if(frog == removee)
enemiestokill.remove(frog)
break


loading Quilby.dme
loading Interface.dmf
Code\MissionSystem.dm:120:error: enemiestokill.remove: undefined proc

Quilby.dmb - 1 error(double-click on an error to jump to it)


And is it possible to call this procedure would take away the monster?
for example:
list_remove (procenemiestokill, var / mob / Monster / frog)
It's probably easier to do it like this:
mob
proc
Death(mob/killer)//the mob here is the one that did the killing
//death stuff here and then put this at the end
for(var/H in killer.enemiestokill)
if(H == src)
killer.enemiestokill.remove(src)
break

Just copy the last bit to the end of your death proc. or wherever you kill the frog and pass the person who killed it as the arg in the brackets.
Those aren't they ways you remove it, you're not adding mobs to the list you're only adding their type path if you're using my example. I highly suggest you do not add mob references to the path when you have to save the list.

mob
enemy
// this is how you would separately change it for enemies
deathcheck(var/mob/m)
if(src.HP <= 0)
m << "..."
// check whether or not this mob is in the enemiestokill list
if(enemycheck(m.enemiestokill, type))
// it'll return 1 on success & reward them
m.completedsomequest = TRUE
// remove them such as so:
m.enemiestokill.Remove(type)
// continue with the rest of the proc
...
Boubi's way is a lot easier by the way.