aliens

Author Topic: [Documentation] Soldier Skill Menu  (Read 14022 times)

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #15 on: April 17, 2020, 05:37:55 pm »
It has not been added to that call, yet. True.
Any plans of adding skill support into "healUnit" and "tryPsiAttackUnit"?

Also it will be useful IMHO to add restriction for psi-item skill, for using only on ally/only on enemy.
Thanks.
« Last Edit: April 17, 2020, 05:42:10 pm by Nord »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #16 on: April 17, 2020, 05:48:24 pm »
For psi is already pans, I have not finished it yet.

Offline TBeholder

  • Sergeant
  • **
  • Posts: 41
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #17 on: December 14, 2022, 01:30:01 pm »
I seem to almost get it. So for example —
Code: [Select]
items:
  - type: STR_HIGH_EXPLOSIVE
    twoHanded: true
  - type: STR_SNIPER_RIFLE
# [. . .] from "Sniper Rifle" or "New Heavy Weapons".

soldiers:
  - type: STR_SOLDIER
    skills:
      - STR_SNIPE
      - STR_PLANT_CHARGE


soldierTransformation:
  - name: STR_SNIPER_TRAINING
    keepSoldierArmor: true
    allowsDeadSoldiers: false
    allowsLiveSoldiers: true
    allowedSoldierTypes:
      - STR_SOLDIER
    forbiddenPreviousTransformations:
      - STR_SNIPER_TRAINING
    cost: 2000
    transferTime: 120
    includeBonusesForMinStats: true
    requiredMinStats:
      firing: 60
    soldierBonusType: STR_TRAINED_SNIPER
    lowerBoundAtMinStats: true
    upperBoundAtMaxStats: false
    upperBoundAtStatCaps: true
    flatOverallStatChange:  # ??? are adjustments this needed in both places, if only for indication? or will this add stats both here and from the bonus?
      reactions: 5
      firing: 10

  - name: STR_DEMOLITIONS_TRAINING
    keepSoldierArmor: true
    allowsDeadSoldiers: false
    allowsLiveSoldiers: true
    allowedSoldierTypes:
      - STR_SOLDIER
    forbiddenPreviousTransformations:
      - STR_DEMOLITIONS_TRAINING
    cost: 2000
    transferTime: 120
    includeBonusesForMinStats: true
    requiredMinStats:
      bravery: 40
      tu: 40
    soldierBonusType: STR_TRAINED_DEMOMAN
    lowerBoundAtMinStats: true
    upperBoundAtMaxStats: false
    upperBoundAtStatCaps: true
    flatOverallStatChange:
      bravery: 5
      tu: 6


soldierBonuses:
  - name: STR_TRAINED_SNIPER
    stats:
      reactions: 5
      firing: 10
    recovery:
      morale:
        flatOne: 1

  - name: STR_TRAINED_DEMOMAN
    stats:
      bravery: 5
      tu: 6


skills:
  - type: STR_SNIPE
    tags:
      SKILL_ID: 1
    costUse:
      time: 5
    flatUse:
      time: true
    targetMode: 9
    requiredBonuses: STR_TRAINED_SNIPER
    compatibleWeapons: [STR_RIFLE STR_LASER_RIFLE STR_PLASMA_RIFLE STR_SNIPER_RIFLE]
    checkHandsOnly: true

  - STR_PLANT_CHARGE
    tags:
      SKILL_ID: 2
    costUse:
      time: 10
    targetMode: 11
    requiredBonuses: STR_TRAINED_DEMOMAN
    compatibleWeapons: STR_HIGH_EXPLOSIVE
    checkHandsOnly: true


extended:
  tags:
    RuleSkill:
      SKILL_ID: int
  scripts:
    skillUseUnit:
      - offset: 22  # ??? how to determine this?
        code: |
          var int skill_id;

          skill.getTag skill_id Tag.SKILL_ID;
         
          battle_game.flashMessage "SkillUse triggered {0} {1}" skill_id have_tu;

          if eq have_tu 0;
            debug_log "No Time. Aborted.";
            set continue_action 0;
            return;
          end;

          # do stuff here

          if eq skill_id 1;

            #???

            return;
          end;
         
          if eq skill_id 2;

            #???

            return;
          end;

          return;
Is this right this far?
Now… I want to add for (1) tweaked item properties, such as increased kneelBonus, accuracy and confAimed: range: …

 and for (2) damageAlter: ToTile: 0.92
I want to do it just for this one action, without altering anything permanently? So, no messing with RuleItem?

If that can be done, are LOSRequired and blockBothHands for this action checked before script hook of Skill, or they can be introduced in the script (and likewise either used locally or reset later) too?
If so, when a two-handed item is required, is there a way to make sure the other hand is empty for this action (rather than just give it blockBothHands always)? Or drop the other item (if any)?
Or check for 2 items in hands (including empty hand) somehow? The latter would also allow pistols akimbo.
« Last Edit: December 14, 2022, 07:24:45 pm by TBeholder »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #18 on: December 15, 2022, 01:25:23 pm »
What exactly you want to archive?
Did you read https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Soldier_Skillls ?
It should have answer for most of your questions.

Offline TBeholder

  • Sergeant
  • **
  • Posts: 41
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #19 on: December 15, 2022, 08:50:35 pm »
What exactly you want to archive?
Specifically, change properties of the required items for this action
Did you read https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Soldier_Skillls ?
It should have answer for most of your questions.
I don’t see how. It’s just a list of properties for Skills. There’s nothing at all on how to make skills actually do something.

I don’t see anything on scripting in the context of skills in general anywhere else, never mind related to the targetMode actions or the compatibleWeapons items in particular (are those even passed to the scripts, or just checked when validating activation and forgotten?).
The only available example is the first post of this thread, which… shows that in practice those properties would need to be supplemented by «tags:» rather than relying on the name under «type:»? It also introduces the relevant script hook skillUseUnit, shows how to wrap it all in a sanity check / pseudo-case… but even then, for the actually working part there’s just placeholder «# do stuff here ».

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #20 on: December 15, 2022, 09:55:04 pm »
main function of script hook`skillUseUnit` is to determine if given action will execute, you can block action based on some custom condition (variable `continue_action` set to 1).
Another function is determine if use cost of action should be applied on unit (variable `spend_tu` set to 1).
And finally script is allowed to change whole game state, this is done before processing of action is done but you can kill every unit in game if you want, or change states of any unit.

You can in some cases ignore this hook as most logic is done by engine itself. `targetMode` and `compatibleWeapons` are used to prepare action before any script is called. Based on this this engine determine what normal unit action should be performed and what unit weapon should be choose.
What action will be performed and on what weapon you get this in script in variables `battle_action` and `item`.

Btw to see what exactly is available in scripts you should look in verbose logs where game dup all scripts with all its meta data.
Old copy of list of all hooks can be find in https://www.ufopaedia.org/index.php/Script_(OpenXcom)#

Offline TBeholder

  • Sergeant
  • **
  • Posts: 41
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #21 on: December 24, 2022, 05:26:52 am »
main function of script hook`skillUseUnit` is to determine if given action will execute

to see what exactly is available in scripts you should look in verbose logs where game dup all scripts with all its meta data.
Old copy of list of all hooks can be find in https://www.ufopaedia.org/index.php/Script_(OpenXcom)
Thanks. The links to examples from that page helped, too.
So, this script runs before the action itself, mostly as free-form validation, any follow-ups would need to use other hooks somehow. It could adjust stats for the soldier or item involved, but then resetting them will be very tricky… unless doing this on new turn is acceptable (if it is, a special tag could be set, to be checked in newTurnUnit / newTurnItem).
While checking hands is trivial — the item is given as a pointer that can be compared to output of actor.getLeftHandWeapon and actor.getRightHandWeapon, much like in Vampiric item script.
Are my conclusions correct?

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #22 on: December 24, 2022, 11:19:38 am »
Yes, you can check on what hand item is held.

Another things is that damage scripts hooks have pointer to used skill, this mean hen you hit any thing you can check if that hit was done using skill.
Same with accuracy and base damage calculation, it too have access to used skill.

Offline Kronos913

  • Colonel
  • ****
  • Posts: 124
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #23 on: August 07, 2023, 08:58:54 pm »
Quote
This of course means, that only one of these icons can be shown at the same time. So no special weapon icon and skill menu item at the same time.
When I tested this - I had two icons displayed side by side

Offline Kozinsky

  • Colonel
  • ****
  • Posts: 128
  • Sorry for my bEd English
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #24 on: May 11, 2024, 02:29:31 pm »
I have a problem: the soldier's skills button is displayed even when the soldier currently has no skills, but may have them in the future.
My idea is this: a soldier has many skills, but each particular skill requires the soldier to have certain transformation bonuses or medal bonuses.  And in the case where the soldier does not have any of the bonuses that the skills require, the skills button is displayed, but nothing happens when you click on it. Is it possible to not display it? Or am I doing something wrong?

The simplest example of my rullset:
Code: [Select]
soldiers:
  - update: STR_SOLDIER
    skills:
      - STR_SKILL_1
      - STR_SKILL_2
skills:
  - type: STR_SKILL_1
    requiredBonuses:
      - STR_MEDIC_TRANSFORMATION_BONUS
      - STR_MEDAL_MEDIC_3
  - type: STR_SKILL_2
    requiredBonuses:
      - STR_MEDIC_TRANSFORMATION_BONUS
      - STR_MEDAL_MEDIC_4
soldierTransformation:
  - name: STR_MEDIC_TRANSFORMATION
    allowedSoldierTypes:
      - STR_SOLDIER
    requiredCommendations:
      STR_MEDAL_MEDIC: 1
    soldierBonusType: STR_MEDIC_TRANSFORMATION_BONUS
commendations:
  - type: STR_MEDAL_MEDIC
    soldierBonusTypes: [STR_MEDAL_MEDIC_1, STR_MEDAL_MEDIC_2, STR_MEDAL_MEDIC_3, STR_MEDAL_MEDIC_4, STR_MEDAL_MEDIC_5]
    criteria:
      totalWoundsHealed: [5, 10, 20, 30, 50]
soldierBonuses:
  - name: STR_MEDIC_TRANSFORMATION_BONUS
    stats:
      melee: 2
      tu: 1
  - name: STR_MEDAL_MEDIC_1
    stats:
      bravery: 10
  - name: STR_MEDAL_MEDIC_2
    stats:
      bravery: 20
  - name: STR_MEDAL_MEDIC_3
    stats:
      bravery: 30
  - name: STR_MEDAL_MEDIC_4
    stats:
      bravery: 40
  - name: STR_MEDAL_MEDIC_5
    stats:
      bravery: 50

So, when a soldier has only the first level of medal "- {commendationName: STR_MEDAL_MEDIC, decorationLevel: 0}" and has no transformation bonus "STR_MEDIC_TRANSFORMATION_BONUS", he logically should not have access to any of the skills, but the skills button is still shown to the player.