aliens

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

Offline Nord

  • Commander
  • *****
  • Posts: 1625
  • 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

  • Commander
  • *****
  • Posts: 3194
    • 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: 40
    • 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

  • Commander
  • *****
  • Posts: 3194
    • 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: 40
    • 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

  • Commander
  • *****
  • Posts: 3194
    • 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: 40
    • 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

  • Commander
  • *****
  • Posts: 3194
    • 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 Nord

  • Commander
  • *****
  • Posts: 1625
  • The Gate is open.
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #23 on: December 30, 2022, 04:24:06 pm »
I think it was allready discussed, but again:
When soldier have psionic skills (similar to vanilla panic or psi control ), then near the special skill button in top right corner of the screeen we can see an old psionic button, which can not be pressed or do something. How to remove this? Thanks.

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #24 on: December 30, 2022, 04:45:46 pm »
I recall that I already fixed this, if PSI is not useful then it should show only one button.
Could you make small mod that have this behavior or show it in bigger one what solder is affected?

Offline Nord

  • Commander
  • *****
  • Posts: 1625
  • The Gate is open.
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #25 on: January 01, 2023, 03:09:05 am »
It is from my X-Chronicles. Use any mentat soldier.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8598
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #26 on: April 23, 2023, 12:26:30 pm »
I recall that I already fixed this, if PSI is not useful then it should show only one button.

That's probably between a psi weapon and special weapon.

But the issue here is between a psi weapon and a soldier skill.

I can think of a few solutions, but I don't like any of them.
@Yankes: maybe you can think of something...

Could you make small mod that have this behavior or show it in bigger one what solder is affected?
It is from my X-Chronicles. Use any mentat soldier.

Attached a save from XCHR.

See soldiers Saba Zare and Isaura Fraga.

Offline Kronos913

  • Captain
  • ***
  • Posts: 88
    • View Profile
Re: [Documentation] Soldier Skill Menu
« Reply #27 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