Author Topic: Zombies? Zombies!  (Read 547 times)

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Zombies? Zombies!
« on: July 28, 2011, 04:45:29 pm »


               I want to create a script where the PC encounters zombie corpses, unselectable, on the ground. But when they get within a certain distance, the zombie stands up, becomes selectable, and starts coming at them.  I think what I need to do is first place the zombie down from the palette, make them destroyable(FALSE) and kill them, then apply a resurrect script when the PC approaches... but it's not working for me. ':?'

Does anyone have experience doing something similar?
               
               

               
            

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Zombies? Zombies!
« Reply #1 on: July 28, 2011, 04:53:28 pm »


               Okay, here's the spawn script, this one I use to create unselectable corpses:

//Spawn in Dead
void main()
{

SetIsDestroyable(FALSE, FALSE, FALSE);
SetLootable(OBJECT_SELF, FALSE);

ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDeath(), OBJECT_SELF);

}






And here's the heartbeat script, the one that's not working:

//ZombieHeartbeat
#include "nw_i0_generic"
void main()
{
  object oCreature = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
if (GetIsObjectValid(oCreature) == TRUE && GetDistanceToObject(oCreature) < 10.0)
  {
object oTarget;
oTarget = OBJECT_SELF;

ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectResurrection(), OBJECT_SELF);

ActionAttack(oCreature);

DetermineCombatRound(oCreature);

  }
}
               
               

               


                     Modifié par Snarkblat, 28 juillet 2011 - 03:59 .
                     
                  


            

Legacy_CID-78

  • Sr. Member
  • ****
  • Posts: 261
  • Karma: +0/-0
Zombies? Zombies!
« Reply #2 on: July 28, 2011, 04:59:49 pm »


               Do heartbeat work on dead creatures? I am not sure they do and the two last lines should use OBJECT_SELF (the zombie) not oCreature (the player) right.
               
               

               
            

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Zombies? Zombies!
« Reply #3 on: July 28, 2011, 05:01:27 pm »


               Hmm perhaps you're right. In that case I would need to call the script from a trigger instead.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Zombies? Zombies!
« Reply #4 on: July 28, 2011, 05:07:59 pm »


               This sort of thing has been done before, but as a placeable that spawns a zombie and destroys itself when a player is within a certain distance.

Does that not work for you?
               
               

               
            

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Zombies? Zombies!
« Reply #5 on: July 28, 2011, 05:12:53 pm »


               I want to use a custom creature blueprint, not a placeable.

This is my OnEnter script for my trigger, but it's not working. My poor zombies just lie there... dead... never knowing the sweet taste of adventurer flesh.

//OnEnter, raises all the zombies in area
void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;
int DoOnce = GetLocalInt(oPC, GetTag(OBJECT_SELF));
if (DoOnce==TRUE) return;
SetLocalInt(oPC, GetTag(OBJECT_SELF), TRUE);

object oTarget;
oTarget = GetNearestObjectByTag("MINER_DEAD");



ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectHeal(100), oTarget, 0.0);

ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectResurrection(), oTarget, 0.0);

int nNth = 0;
nNth++;
oTarget = GetObjectByTag("MINER_DEAD", nNth);
}
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Zombies? Zombies!
« Reply #6 on: July 28, 2011, 05:16:21 pm »


               Creatures can't be unselectable, dead or not. Maybe they can be with some custom content, but still you would at the very least have the name when you press TAB.
               
               

               
            

Legacy_CID-78

  • Sr. Member
  • ****
  • Posts: 261
  • Karma: +0/-0
Zombies? Zombies!
« Reply #7 on: July 28, 2011, 05:41:39 pm »


               you should lookup how you write loops because you are missing one, that script won't work.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Zombies? Zombies!
« Reply #8 on: July 28, 2011, 08:21:08 pm »


               First thing that needs to be fixed in the first script is in the line:

SetIsDestroyable(FALSE, FALSE, FALSE);

The second parameter is whether or not the creature is raisable. If you have it set to false then you won't be able to raise them anyway. So it should be:

SetIsDestroyable(FALSE, TRUE, FALSE);

Then you trigger script, with a loop like CID-78 has stated, should be like so:


void main()
{
    object oPC = GetEnteringObject();
    if (!GetIsPC(oPC)) return;
    int DoOnce = GetLocalInt(oPC, GetTag(OBJECT_SELF));
    if (DoOnce==TRUE) return;
    SetLocalInt(oPC, GetTag(OBJECT_SELF), TRUE);
    int iNth = 1;
    object oDead = GetNearestObjectByTag("MINER_DEAD", oPC, iNth);
    while (GetIsObjectValid(oDead))
    {
        ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectResurrection(), oDead, 0.0);
        ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectHeal(100), oDead, 0.0);
        SetIsDestroyable(TRUE, TRUE, TRUE);
        SetLootable(OBJECT_SELF, TRUE);
        iNth++;
        oDead = GetNearestObjectByTag("MINER_DEAD", oPC, iNth);
    }
}


Hope it helps. Good luck.
               
               

               
            

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Zombies? Zombies!
« Reply #9 on: July 28, 2011, 08:52:48 pm »


               I can always count on you, Ghost. '<img'>

The script worked like a thing of beauty. There was a slight delay where the zombies just stood there looking confused, so I added an attack command to make it seem more like they woke up hungry. Thanks for setting me straight.