Skip to content

AssignCommand not crediting assignee with damage

When passing an EffectDamage through an AssignCommand function to give "credit" for the damage in the combat log to some object other than the caller, it doesn't seem to work.

For example, I have the following code in the OnUsed script of a placeable in a test area:

effect eDam=EffectDamage(1); object oArm=GetFirstPC(); ApplyEffectToObject(DURATION_TYPE_INSTANT,eDam,oArm); AssignCommand(oArm,ApplyEffectToObject(DURATION_TYPE_INSTANT,eDam,oArm));

The expectation is that I should see in the combat log that the PC using the object gets dealt 1 point of damage, twice. The first instance should be credited to the placeable, the second time should be credited to the PC. Here is what happens:



...Both effects are credited to the combat dummy.

Can anyone point me in the right direction? I had been led to believe that AssignCommand could be used in this manner. Am I incorrect?

Comments

  • DazDaz Member Posts: 127
    It should work like you described if you wrap the damage effect in its own function, like this:

    void DealDamage(object oTarget) { effect eDamage = EffectDamage(1); ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oTarget); } void main() { object oPlayer = GetLastUsedBy(); DealDamage(oPlayer); AssignCommand(oPlayer, DealDamage(oPlayer)); }
  • meaglynmeaglyn Member Posts: 151
    What Daz said. The reason being that it's the creation of the effect not the application of the effect that determines the object which does the damage (or whatever the effect is). i.e. this line: effect eDam=EffectDamage(1);
  • BluesorcBluesorc Member Posts: 3
    Thank you both very much, that makes sense.
Sign In or Register to comment.