Ticket #3889: xpPerHit.diff

File xpPerHit.diff, 1.6 KB (added by sanderd17, 4 years ago)
  • binaries/data/mods/public/simulation/components/Looter.js

     
    1414    if (!cmpLoot)
    1515        return;
    1616
    17     // Loot experience points as defined in the template
    18     var xp = cmpLoot.GetXp();
    19     if (xp > 0)
    20     {
    21         let cmpPromotion = Engine.QueryInterface(this.entity, IID_Promotion);
    22         if (cmpPromotion)
    23             cmpPromotion.IncreaseXp(xp);
    24     }
    25 
    2617    // Loot resources as defined in the templates
    2718    var resources = cmpLoot.GetResources();
    2819    for (let type in resources)
  • binaries/data/mods/public/simulation/helpers/Damage.js

     
    7474    // Damage the target
    7575    var targetState = cmpDamageReceiver.TakeDamage(data.strengths.hack * data.multiplier, data.strengths.pierce * data.multiplier, data.strengths.crush * data.multiplier);
    7676
     77    var cmpPromotion = Engine.QueryInterface(data.attacker, IID_Promotion);
     78    var cmpLoot = Engine.QueryInterface(data.target, IID_Loot);
     79    if (cmpPromotion && cmpLoot && cmpLoot.GetXp() > 0)
     80        cmpPromotion.IncreaseXp(cmpLoot.GetXp() * -targetState.change / cmpHealth.GetMaxHitpoints());
     81
    7782    // If the target was killed run some cleanup
    7883    if (targetState.killed)
    7984        Damage.TargetKilled(data.attacker, data.target);