aliens

Author Topic: Medic stat as a medal(it works, but please tell me if I'm doing it wrong)  (Read 1124 times)

Offline HinterDemGlas

  • Captain
  • ***
  • Posts: 56
    • View Profile
EDIT: Revised, tested. Happy Easter!

Born out of this thread, as something I would like to do for this mod, I made a "medic stat" that grows with healed wounds and increases the HP restored with every heal. After mixing up all the very similar variables ten thousand times I finally got it to work! Please take a look at it and let me know there is an obvious problem with it. Thanks to Yankes and everybody else working on this project and all the modders for providing examples I could borrow.

(attached file identical to the below code)

Code: [Select]
commendations:
  - type: STR_MEDAL_MEDICAL_STAT #healed lethal wounds
    description: STR_MEDAL_MEDICAL_STAT_UFOPEDIA
    sprite: 5
    soldierBonusTypes: [STR_MEDIC_BONUS_1,STR_MEDIC_BONUS_1,STR_MEDIC_BONUS_1,STR_MEDIC_BONUS_1,STR_MEDIC_BONUS_1,STR_MEDIC_BONUS_1,STR_MEDIC_BONUS_2,STR_MEDIC_BONUS_2,STR_MEDIC_BONUS_2,STR_MEDIC_BONUS_3]
    criteria:
      totalWoundsHealed: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
     

extended:
  tags:
    RuleSoldierBonus:
      TAG_MEDIC_PLUS: int
    BattleUnit:
      TAG_MEDIC_STAT: int
  scripts:
    applySoldierBonuses: # apply tag
      - offset: 14
        code: |
          var int bonus_temp;
          var int soldier_temp;
         
          soldier_bonus.getTag bonus_temp Tag.TAG_MEDIC_PLUS;
          unit.getTag soldier_temp Tag.TAG_MEDIC_STAT;
          if gt bonus_temp soldier_temp;
            unit.setTag Tag.TAG_MEDIC_STAT bonus_temp;
          end;
          return;
         
    healUnit:
      - offset: 15
        #*** extra Healing ***
        code: |
          var int medic_stat;
         
          actor.getTag medic_stat Tag.TAG_MEDIC_STAT;
          if gt medic_stat 0;
            if eq medikit_action_type 1;
              add health_recovery medic_stat;
              debug_log "Medic Stat used. " medic_stat " extra HP for a Total of " health_recovery;
            end;
          end;
          return;
         
soldierBonuses:
  - name: STR_MEDIC_BONUS_1
    tags:
      TAG_MEDIC_PLUS: 1 
  - name: STR_MEDIC_BONUS_2
    tags:
      TAG_MEDIC_PLUS: 2
  - name: STR_MEDIC_BONUS_3
    tags:
      TAG_MEDIC_PLUS: 3
« Last Edit: March 31, 2024, 09:44:51 pm by HinterDemGlas »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
You should check for current `Tag.TAG_MEDIC_STAT` before you set new value as you could override bigger value by smaller, e.g. `STR_MEDIC_BONUS_3` by `STR_MEDIC_BONUS_1`

Offline HinterDemGlas

  • Captain
  • ***
  • Posts: 56
    • View Profile
Good point. I made some adjustments.

Offline HinterDemGlas

  • Captain
  • ***
  • Posts: 56
    • View Profile
Just did the same for the totalRevives medal and stun_recovery. Seems to work, but stun_recovery was a lucky guess since there doesn't appear to be much documentation on healUnit. Oh well. Now I need to think of something sufficiently interesting for the third commendation.