Author Topic: [2238] Worried callback  (Read 2302 times)

Offline SEGA_RUS

  • Arbeit macht frei
[2238] Worried callback
« 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?
Skype - sega_75rus

Offline Wipe

  • Rotator
  • Random is god
Re: [2238] Worried callback
« Reply #1 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]
« Last Edit: August 16, 2015, 05:22:30 pm by Wipe »
Games are meant to be created, not played...

Offline SEGA_RUS

  • Arbeit macht frei
Re: [2238] Worried callback
« Reply #2 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.
Skype - sega_75rus