fodev.net

FOnline Development => Questions and Answers => Topic started by: SEGA_RUS on August 16, 2015, 04:31:13 pm

Title: [2238] Worried callback
Post by: SEGA_RUS on August 16, 2015, 04:31:13 pm
Code: [Select]
[14:09:560] Script exception: Null pointer access : main : void critter_dead(Critter&inout, Critter@) : 5474, 3 : FOServer::KillCritter : Npc (5002122).
[14:09:560] Execution of script stopped due to exception.
[14:09:560] Context<FOServer::KillCritter : Npc (5002122)>, state<Exception>, call stack<1>:
[14:09:560]   0) main : void critter_dead(Critter&inout, Critter@) : 5474, 3.

My path
Code: [Select]
void critter_dead(Critter& cr, Critter@ killer)
............................................
    // npc
    if(cr.IsNpc() && killer.IsPlayer() )
    {
        // Добавляет в стек игрока. Было Clear NPC memory about enemies after it dies.
        cr.AddEnemyInStack(killer.Id);
    }
    else     // players


NPC with 5002122 ID have 1 player in enemy stack?
Is it something wrong in critter_dead working? 
How to disable that callbacks or fix it?
Title: Re: [2238] Worried callback
Post by: Wipe on August 16, 2015, 05:19:29 pm
killer can be null and you're not checking it before using.
Code: [Select]
if(cr.IsNpc() && (valid(killer) && killer.IsPlayer()) )
Oh btw, your code does exactly opposite of what comment says :P [at least english part]
Title: Re: [2238] Worried callback
Post by: SEGA_RUS on August 16, 2015, 05:49:02 pm
killer can be null and you're not checking it before using.
Code: [Select]
if(cr.IsNpc() && (valid(killer) && killer.IsPlayer()) )
Oh btw, your code does exactly opposite of what comment says :P [at least english part]
Thanks Wipe. I found 4 ghouls in 1 Glow lvl. They are dying and respawning after some sec.
Code: [Select]
    // npc
    if(cr.IsNpc())
    {
if(valid(killer) && killer.IsPlayer())
{
        // Добавляет в стек убийцу. Было Clear NPC memory about enemies after it dies.
        cr.AddEnemyInStack(killer.Id);
}
    }
    else     // players
btw there is on russian
Quote
Add killer in stack. Was Clear NPC memory about enemies after it dies.