aliens

Author Topic: Skill script question.  (Read 754 times)

Offline Nord

  • Commander
  • *****
  • Posts: 1268
  • The Gate will open... someday.
    • View Profile
Skill script question.
« 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?

Offline Yankes

  • Commander
  • *****
  • Posts: 2496
    • View Profile
Re: Skill script question.
« Reply #1 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

Offline Nord

  • Commander
  • *****
  • Posts: 1268
  • The Gate will open... someday.
    • View Profile
Re: Skill script question.
« Reply #2 on: July 15, 2021, 02:42:03 am »
Addition:
Same script hook with shooting or melee weapon works fine. Only psi-amp affected.

Offline Yankes

  • Commander
  • *****
  • Posts: 2496
    • View Profile
Re: Skill script question.
« Reply #3 on: July 17, 2021, 03:50:55 pm »
I will look on this today, clearly bug in logic

Offline Nord

  • Commander
  • *****
  • Posts: 1268
  • The Gate will open... someday.
    • View Profile
Re: Skill script question.
« Reply #4 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.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 6921
  • OXCE developer
    • View Profile
    • My Wiki
Re: Skill script question.
« Reply #5 on: July 22, 2021, 02:09:12 pm »
it's battle_game, not BattleGame

Offline Nord

  • Commander
  • *****
  • Posts: 1268
  • The Gate will open... someday.
    • View Profile
Re: Skill script question.
« Reply #6 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.
« Last Edit: July 23, 2021, 06:01:14 am by Nord »

Offline Yankes

  • Commander
  • *****
  • Posts: 2496
    • View Profile
Re: Skill script question.
« Reply #7 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

Offline Yankes

  • Commander
  • *****
  • Posts: 2496
    • View Profile
Re: Skill script question.
« Reply #8 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?

Offline Nord

  • Commander
  • *****
  • Posts: 1268
  • The Gate will open... someday.
    • View Profile
Re: Skill script question.
« Reply #9 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
« Last Edit: July 26, 2021, 04:35:18 am by Nord »

Offline Yankes

  • Commander
  • *****
  • Posts: 2496
    • View Profile
Re: Skill script question.
« Reply #10 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).

Offline Nord

  • Commander
  • *****
  • Posts: 1268
  • The Gate will open... someday.
    • View Profile
Re: Skill script question.
« Reply #11 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!