ID:1490569
 
(See the best response by Koshigia.)
Hello, i haven't post on dev help before, but i could use some help with this problem. Hopefully I'm not overlooking something obvious..

Basically for some reason i can't subtract from the 'enemies_list' by calling take_enemy(), as if when take_enemy() is called the list goes back to empty even if i added an enemy to it before. I don't understand why it is doing that at all.

Code:

wave
var
number_of_enemies
enemies_list[] = list()

proc
add_enemy(mob/m)
enemies_list += m
world << "[m] was added to [enemies_list]"
world << "Enemies_len:[enemies_list.len]"

take_enemy(mob/m)
world << "Enemies_len:[enemies_list.len]"
// enemies_list -= enemies_list[m]
enemies_list -= m
del m
world << "Enemies_len:[enemies_list.len]"



Problem description:
Showing the problem here.
I changed it to enemies_list -= m

Even thought that was really dumb, I still have the same problem.

I edited the first post, showing another gif.
Exactly, that's what i don't understand.
Best response
I believe you're dealing with two separate lists. Every time a mob is added to the wave, you can see that the count goes up by 1, and every time you kill something you keep getting a 0 reported. If I had to guess, I'd say that for one reason or another you have multiple waves being created... the mobs spawning are accessing ONE wave's list of mobs, and when the player kills something, another wave's list of mobs is accessed.
To verify if this is the case, add a piece of code like this

var/list/wave_list = new

wave

New()
..()
wave_list += wave


mob/verb/test()
world << length(wave_list)


*edit* just fixed all that code as I had it really jacked up :P
In response to Koshigia
Koshigia wrote:
I believe you're dealing with two separate lists. Every time a mob is added to the wave, you can see that the count goes up by 1, and every time you kill something you keep getting a 0 reported. If I had to guess, I'd say that for one reason or another you have multiple waves being created... the mobs spawning are accessing ONE wave's list of mobs, and when the player kills something, another wave's list of mobs is accessed.

That's extremely unlikely, since enemies_list as referenced in those procs is always going to be src.enemies_list by default.
It'd have to be a different /wave object, in that case. Or enemies_list is being modified somewhere else.
In response to Koshigia
Actually, this seems to be the problem, i verified with the test() verb that there were several waves defined so it seems that it was grabbing a separate list. Now it's accessing the same list, I'll post the code in a few.
var/game/game
var/wave/wave
world/New()
.=..()
game = new
wave = new
mob/Login()
.=..()
game.player = src
Start_Game()
game
var
__waves[]
current_wave = 1
mob/player
// wave/wave //THIS THE PROBLEM//


It's working properly, thanks everyone :)

In response to Neo Berserker
Woot =D Glad to be of use. Not often that I get to help out :P