Author Topic: New to scripting -- can anyone help fix this?  (Read 307 times)

Legacy_LindsayReynolds

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
New to scripting -- can anyone help fix this?
« on: October 21, 2012, 09:27:40 pm »


                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));
}
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
New to scripting -- can anyone help fix this?
« Reply #1 on: October 23, 2012, 08:57:48 am »


               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);
}