Does anyone have experience doing something similar?
Zombies? Zombies!
Débuté par
Snarkblat
, juil. 28 2011 03:45
#1
Posté 28 juillet 2011 - 03:45
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?
Does anyone have experience doing something similar?
#2
Posté 28 juillet 2011 - 03:53
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);
}
}
//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 .
#3
Posté 28 juillet 2011 - 03:59
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.
#4
Posté 28 juillet 2011 - 04:01
Hmm perhaps you're right. In that case I would need to call the script from a trigger instead.
#5
Posté 28 juillet 2011 - 04:07
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?
Does that not work for you?
#6
Posté 28 juillet 2011 - 04:12
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);
}
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);
}
#7
Posté 28 juillet 2011 - 04:16
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.
#8
Posté 28 juillet 2011 - 04:41
you should lookup how you write loops because you are missing one, that script won't work.
#9
Posté 28 juillet 2011 - 07:21
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.
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.
#10
Posté 28 juillet 2011 - 07:52
I can always count on you, Ghost. 
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.
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.





Retour en haut






