OpenXcom Forum

Modding => Help => Topic started by: Nord on July 14, 2021, 06:21:39 am

Title: Skill script question.
Post by: Nord on July 14, 2021, 06:21:39 am
Hi. I am stuck with a question.
I have psi-amp for skills:
Code: [Select]
  - type: STR_WEAPON_2
    battleType: 9
    ...
    tags:
      IS_SKILL: 1 #mental
and soldier skill, based on that item:
Code: [Select]
  - type: STR_STOP_SKILL
    tags:
      SKILL_ID: 17
    costUse:
      time: 5
    targetMode: 14
    compatibleWeapons: [STR_WEAPON_2]
    checkHandsOnly: false
When i use
Code: [Select]
    tryPsiAttackUnit:
      - offset: 15   #Always success for inspiration etc.
        code: |
         ...
            skill.getTag skill_id Tag.SKILL_ID;
         ...
i get skill_id=17.
But later, when i use:
Code: [Select]
   
    hitUnit:
      - offset: 7   # for scripted items(Fright, Inspiration)
        code: |
          ...
          skill.getTag skill_id Tag.SKILL_ID;
          ...
i get skill_id=0

Question: WHY?
Title: Re: Skill script question.
Post by: Yankes on July 14, 2021, 02:29:36 pm
This could be bug, skill is not propagated to damage function and because of this, to script
Title: Re: Skill script question.
Post by: Nord on July 15, 2021, 02:42:03 am
Addition:
Same script hook with shooting or melee weapon works fine. Only psi-amp affected.
Title: Re: Skill script question.
Post by: Yankes on July 17, 2021, 03:50:55 pm
I will look on this today, clearly bug in logic
Title: Re: Skill script question.
Post by: Nord on July 22, 2021, 04:35:43 am
Another question:
Code: [Select]
BattleGame.randomChancealways returns 0.
(I see it in the physical shield script)
Is something wrong or i should turn something on to power up randomizer?

Thanks.
Title: Re: Skill script question.
Post by: Meridian on July 22, 2021, 02:09:12 pm
it's battle_game, not BattleGame
Title: Re: Skill script question.
Post by: Nord on July 22, 2021, 03:54:23 pm
Yes, thanks. It is my mistake when writing this topic.

Found it. There must be a limits defined.
not
Code: [Select]
battle_game.randomChance temp;
but

Code: [Select]
battle_game.randomChance temp 1 100;
Upd.
not
Code: [Select]
randomChance but
Code: [Select]
randomRange.
Still dont understand how to use randomChance.
Title: Re: Skill script question.
Post by: Yankes on July 24, 2021, 11:54:33 am
`randomChance` expect value in range of 0 to 100 and return 0 or 1
`randomRange` you give some range and you get some random value from this range e.g. 50-100 -> 57
Title: Re: Skill script question.
Post by: Yankes on July 24, 2021, 02:17:02 pm
@Nord I looked on code of `hitUnit`and I do not see any thing that could affect it. could you show me working example that have this error?
Title: Re: Skill script question.
Post by: Nord on July 25, 2021, 04:50:45 am
@Nord I looked on code of `hitUnit`and I do not see any thing that could affect it. could you show me working example that have this error?
I'll try to. But you need a whole working mod, i assume. And my internet is... well, i will try.
Here is Skills and Items rules, we are interested in "STR_MENTAL_WEAPON_2" item and "STR_STOP_SKILL" skill.

Later i'll try to upload entire mod.

Upd.
Uploaded mod:  https://openxcom.org/forum/index.php/topic,6792.msg140197.html#msg140197 (https://openxcom.org/forum/index.php/topic,6792.msg140197.html#msg140197)
Title: Re: Skill script question.
Post by: Yankes on August 29, 2021, 04:18:53 pm
After returning to this bug, I find that PSI attacks to not use correctly propagate skill, now it should work correctly (OXCE 7.0.19).
Title: Re: Skill script question.
Post by: Nord on August 29, 2021, 04:45:44 pm
After returning to this bug, I find that PSI attacks to not use correctly propagate skill, now it should work correctly (OXCE 7.0.19).
Great, thanks!