Could anyone point out why this script doesn't loop through the objects?
void main()
{
object oPC = GetEnteringObject();
int nEffect = 1;
object oEffect = GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect);
location lEffect = GetLocation(oEffect);
effect eEffect = EffectNWN2SpecialEffectFile("ajoc_12_fx_gariusshadow", oEffect);
if (!GetIsPC(oPC)) return;
int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
if (DoOnce==TRUE) return;
SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);
while(GetIsObjectValid(oEffect))
{
ApplyEffectAtLocation(2, eEffect, lEffect);
oEffect = GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect++);
}
}
All help is appreciated.
I've always been kinda dumb with looping
Débuté par
Orion7486
, févr. 01 2011 11:12
#1
Posté 01 février 2011 - 11:12
#2
Posté 01 février 2011 - 11:22
Try it like this:
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
if (DoOnce==TRUE) return;
int nEffect = 1;
object oEffect = GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect);
location lEffect = GetLocation(oEffect);
effect eEffect = EffectNWN2SpecialEffectFile("ajoc_12_fx_gariusshadow", oEffect);
SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);
while(GetIsObjectValid(oEffect))
{
ApplyEffectAtLocation(2, eEffect, lEffect);
nEffect++;
oEffect = GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect);
}
}
You want to advance nEffect before you redefine oEffect. Also it is a good habbit to put your return statements in before declaring all your major variables. No sense in putting them into memory if you don't need to.
Hope it helps. Good luck.
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
if (DoOnce==TRUE) return;
int nEffect = 1;
object oEffect = GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect);
location lEffect = GetLocation(oEffect);
effect eEffect = EffectNWN2SpecialEffectFile("ajoc_12_fx_gariusshadow", oEffect);
SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);
while(GetIsObjectValid(oEffect))
{
ApplyEffectAtLocation(2, eEffect, lEffect);
nEffect++;
oEffect = GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect);
}
}
You want to advance nEffect before you redefine oEffect. Also it is a good habbit to put your return statements in before declaring all your major variables. No sense in putting them into memory if you don't need to.
Hope it helps. Good luck.
#3
Posté 01 février 2011 - 11:35
Thanks for the response, but it still is placing the effect on only one object.
#4
Posté 01 février 2011 - 11:55
GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect);will always give you the same object I am afraid.
#5
Posté 02 février 2011 - 12:23
Actually I think its because the location is never getting changed. I was thinking object. Try it like so and see if it helps:
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
if (DoOnce==TRUE) return;
int nEffect = 1;
object oEffect = GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect);
location lEffect;
effect eEffect;
SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);
while(GetIsObjectValid(oEffect))
{
eEffect = EffectNWN2SpecialEffectFile("ajoc_12_fx_gariusshadow", oEffect);
lEffect = GetLocation(oEffect);
ApplyEffectAtLocation(2, eEffect, lEffect);
nEffect++;
oEffect = GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect);
}
}
P.S. I don't normally script for NWN2 so Im not familiar with that type of effect you are using. I see its asking for an object parameter. Hopefully that is not messing things up.
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
if (DoOnce==TRUE) return;
int nEffect = 1;
object oEffect = GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect);
location lEffect;
effect eEffect;
SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);
while(GetIsObjectValid(oEffect))
{
eEffect = EffectNWN2SpecialEffectFile("ajoc_12_fx_gariusshadow", oEffect);
lEffect = GetLocation(oEffect);
ApplyEffectAtLocation(2, eEffect, lEffect);
nEffect++;
oEffect = GetNearestObjectByTag("01_wp_gariuseffect", oPC, nEffect);
}
}
P.S. I don't normally script for NWN2 so Im not familiar with that type of effect you are using. I see its asking for an object parameter. Hopefully that is not messing things up.
Modifié par GhostOfGod, 02 février 2011 - 12:25 .
#6
Posté 02 février 2011 - 12:30
That's got it. Defining the location within the loop makes it work. Thank you.





Retour en haut






