Author Topic: NPCs resurrecting other NPCS  (Read 318 times)

Legacy_Imperator

  • Full Member
  • ***
  • Posts: 128
  • Karma: +0/-0
NPCs resurrecting other NPCS
« on: August 06, 2015, 04:33:09 am »


               

I've run into a little problem with NPCs casting resurrection, for some reason when I use the command GetIsDead and try to see if it's true, it doesn't do what I'm asking it to do in the following if statement



object oTESTaxb;

oTESTaxb = GetNearestObjectByTag("TESTaxb", OBJECT_SELF);

oTESTaxb = GetNearestSeenFriend(OBJECT_SELF);


 


if(GetIsDead(oTESTaxb)==TRUE)

{

ActionCastSpellAtObject(SPELL_RESURRECTION, oTESTaxb);

}


 


The creature that's supposed to be casting resurrection is a cleric and has the spell resurrection known and memorized in its slots, at least it should because that's what I set it to. 20 Resurrections memorized.


 


I also have the SetIsDestroyable set to FALSE, TRUE, TRUE so it can be raised properly, I tried using a test raise dead misc on one of the fallen npcs and it worked just fine.


 


I've also run into another problem with harm not healing undead when one NPC casts it on another, as a friendly action. It's strange because when they cast negative energy burst at themselves or close to themselves that heals them just fine.



               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
NPCs resurrecting other NPCS
« Reply #1 on: August 06, 2015, 06:16:48 am »


               

Have you added a debug statement inside and outside the GetIsDead() check to see what the problem is? I suspect that GetIsDead() is not getting called on the object you think it is because you assign oTESTaxb to one object, then immediately re-assign it to another. Try something like this and see if it helps track down the error:



SpeakString("Checking to see whether " + GetName(oTESTaxb) + " is dead...");
if(GetIsDead(oTESTaxb))
{
    SpeakString("Yep, he's dead.");
    ActionCastSpellAtObject(SPELL_RESURRECTION, oTESTaxb);
}


               
               

               
            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
NPCs resurrecting other NPCS
« Reply #2 on: August 06, 2015, 06:20:06 am »


               

I am far from an expert on getting AI-related things to do what I want. But, it may be useful to note that the GetNearestObjectByTag line is doing nothing, since oTESTaxb is immediately redefined in the next line. Which brings up the question of what the function GetNearestSeenFriend is, as I don't recall seeing it as a standard function. If it's a custom function that combines a couple others (like GetNearestCreature or something), I might wonder if perhaps one of the components doesn't work the way you think if the creature tested is dead.


 


I am not sure what you mean by trying "raise dead misc"; maybe posting that code would help show what was working.



               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
NPCs resurrecting other NPCS
« Reply #3 on: August 06, 2015, 06:27:07 am »


               


Which brings up the question of what the function GetNearestSeenFriend is, as I don't recall seeing it as a standard function. If it's a custom function that combines a couple others (like GetNearestCreature or something), I might wonder if perhaps one of the components doesn't work the way you think if the creature tested is dead.




 


It's from x0_i0_enemy. It's a wrapper for GetNearestCreature():



object GetNearestSeenFriend(object oSource=OBJECT_SELF, int nNth=1)
{
    return GetNearestCreature(CREATURE_TYPE_REPUTATION,
                              REPUTATION_TYPE_FRIEND,
                              oSource, nNth,
                              CREATURE_TYPE_PERCEPTION,
                              PERCEPTION_SEEN);
}

               
               

               
            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
NPCs resurrecting other NPCS
« Reply #4 on: August 06, 2015, 07:15:54 pm »


               

Ah, very good. It looks like that GetNearestCreature can take another criterion pair. Potentially, whole check could be done with one call by defining



object GetNearestSeenDeadFriend(object oSource=OBJECT_SELF, int nNth=1)
    {
    return GetNearestCreature(CREATURE_TYPE_REPUTATION,
                              REPUTATION_TYPE_FRIEND,
                              oSource, nNth,
                              CREATURE_TYPE_PERCEPTION,
                              PERCEPTION_SEEN,
                              CREATURE_TYPE_IS_ALIVE,
                              TRUE);
    }

Then calling object oTESTaxb = GetNearestSeenDeadFriend(OBJECT_SELF); instead of the first three lines in the first post. SM's suggesting of adding some debugging print statements is a good one.


I did a little testing last night and the basic friend/neutral/hostile tests and the basic call to GetIsFriend works, even with dead NPCs. So, I am still not sure what's causing trouble with your cleric AI, Imperator. One idea would be to look up the scripting for the golem resurrection from the Scavenger Golem from the Isle of the Maker's Upper Ruins area in HotU. He seems to be doing something very similar to what you are looking to do.



               
               

               
            

Legacy_Imperator

  • Full Member
  • ***
  • Posts: 128
  • Karma: +0/-0
NPCs resurrecting other NPCS
« Reply #5 on: August 06, 2015, 11:09:47 pm »


               

lol... commenting out this line, "oTESTaxb = GetNearestSeenFriend(OBJECT_SELF);" worked perfectly fine. I'm not sure why I put that in there, I think originally I just wanted the cleric to raise and heal things that were considered allies to the hostile faction.


 


Does anyone know what might be causing this weird problem with undead npcs casting harm on one another as a friendly action? For some reason it isn't healing them and I'm not sure why, the healing vfx fires but no hp is restored.



               
               

               
            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
NPCs resurrecting other NPCS
« Reply #6 on: August 07, 2015, 12:13:41 am »


               

lol... commenting out this line, "oTESTaxb = GetNearestSeenFriend(OBJECT_SELF);" worked perfectly fine. I'm not sure why I put that in there, I think originally I just wanted the cleric to raise and heal things that were considered allies to the hostile faction.




Keep in mind that the code above without that line may also cause your NPCs to raise dead PCs or the PC's allies. You may still want some sort of reputation check, if that's a possible issue.


 


Did you add any debug prints to see if GetNearestSeenFriend is returning a valid object?

 



Does anyone know what might be causing this weird problem with undead npcs casting harm on one another as a friendly action? For some reason it isn't healing them and I'm not sure why, the healing vfx fires but no hp is restored.



This is a little bizarre, though I have never checked that harm works properly when it's cast from an NPC to an allied undead NPC, both hostile to the PC. The harm script (NW_S0_Harm) runs the visual effect right after it applies the heal effect, so if it does one, it should be doing the other.