GetDistanceToObject() Help
Zephirius
Member Posts: 419
I'm having problems getting this script to fire consistently. Well actually, it only worked once and I've tried to recreate my success with no luck.
The script is supposed to turn OBJECT_SELF hostile and attack oPC when oPC gets to close (5 meters)
For OnPerception Handler
No I've got it all wrong! Fixed it, yay! Just put it on OnHeartbeat() instead, and it works fine...
Sh***! That's not going to work either. I' mean it works, but every six seconds isn't going to cut it.
So I circle back to OnPerception - Just not havin luck there.
OK. I think I have it down now. I just put a fire DoOnce and everything seems to be working properly now...
The script is supposed to turn OBJECT_SELF hostile and attack oPC when oPC gets to close (5 meters)
For OnPerception Handler
void main() { ExecuteScript("nw_c2_default2", OBJECT_SELF); object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF); if (GetIsObjectValid(oPC) == TRUE && GetDistanceToObject(oPC) < 5.0) { string sString = "c_rathuge_bat1"; AssignCommand(oPC, PlaySound(sString)); effect eAttackFX = EffectVisualEffect(VFX_IMP_FORTITUDE_SAVING_THROW_USE); ApplyEffectToObject(DURATION_TYPE_INSTANT, eAttackFX, OBJECT_SELF); AssignCommand(OBJECT_SELF, ActionPlayAnimation(ANIMATION_FIREFORGET_TAUNT)); DelayCommand(1.5, ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_HOSTILE)); DelayCommand(2.0, AssignCommand(OBJECT_SELF, ActionAttack(oPC))); } }
No I've got it all wrong! Fixed it, yay! Just put it on OnHeartbeat() instead, and it works fine...
Sh***! That's not going to work either. I' mean it works, but every six seconds isn't going to cut it.
So I circle back to OnPerception - Just not havin luck there.
OK. I think I have it down now. I just put a fire DoOnce and everything seems to be working properly now...
int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF)); if (DoOnce==TRUE) { return; } SetLocalInt(OBJECT_SELFL, GetTag(OBJECT_SELF), TRUE);
Post edited by Zephirius on
0