Aller au contenu

Photo

New to scripting -- can anyone help fix this?


  • Veuillez vous connecter pour répondre
1 réponse à ce sujet

#1
LindsayReynolds

LindsayReynolds
  • Members
  • 10 messages
 Hi all!

I'm working on a script that will create a visual effect on the player which was the most recent target of a creature, and would want to place this in the "creature heartbeat" area. I'm new to scripting, so I've patched this together from another script I've gotten to work, but I'm having trouble with this one. Can anyone help get me back on track and show me what I'm doing wrong?

Thanks so much!

void main(){
object GetAttackTarget(object oCreature=OBJECT_SELF)object GetAttemptedAttackTarget (object oCreature=OBJECT_SELF;
if (!GetIsPC(oPC)) return;
object oTarget;oTarget = oPC;
int nInt;nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), oTarget);else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), GetLocation(oTarget));
oTarget = OBJECT_SELF;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), oTarget);else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), GetLocation(oTarget));
}

#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
I'm a bit rusty but maybe you could simplify it with something more like so?:

void main()
{
    object oPC = GetAttackTarget();
    if (!GetIsObjectValid(oPC)) oPC = GetAttemptedAttackTarget();
    if (!GetIsPC(oPC) || !GetIsObjectValid(oPC)) return;
    ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), oPC);
}