Author Topic: Broken Y-scripts  (Read 698 times)

Offline Yankes

  • Commander
  • *****
  • Posts: 3210
    • View Profile
Re: Broken Y-scripts
« Reply #15 on: March 08, 2024, 12:11:54 am »
Code: [Select]
Error in parsing script 'hitUnit' for 'Global Event Script': invalid operation in line: 'if and eq shield_skipper 1 shieldType 0;'

This error is because you have only one `eq`, basic `if` look like `if eq x y;` but you can have multiple conditions by appending `and`
like:
Code: [Select]
if and
   eq x y #first `eq`
   eq z w; #second `eq`

Code: [Select]
Error in parsing script 'hitUnit' for 'Global Event Script': invalid operation in line: 'set attacker is_concealed 0;'
set have only two arguments not three.


Code: [Select]
Error in parsing script 'hitUnit' for 'Global Event Script': invalid operation in line: 'BattleUnit.setTag is_concealed 1;'I have no idea what your intention was with this code, what tag and what object you want update?

Offline Barghum

  • Sergeant
  • **
  • Posts: 29
  • Doing my best to help (:
    • View Profile
Re: Broken Y-scripts
« Reply #16 on: March 08, 2024, 01:16:58 am »
I want to make a script that on hit (from an enviroEffect) sets units wearing armor marked with "armor_is_stealthy 1" to  "is_concealed 1"
until they attack with any weapon not marked with "weapon_is_quiet 1"


(the visibility script sets it so that concealed units are 95% harder to see)

i hope this helped.
also thank you for the help.  :)

Offline Yankes

  • Commander
  • *****
  • Posts: 3210
    • View Profile
Re: Broken Y-scripts
« Reply #17 on: March 08, 2024, 01:30:06 am »
But there is nothing like `is_concealed` in unit, you have `Tag`-s  that can you set specific values.
Like:
Code: [Select]
unit.setTag Tag.SOME_NAME value.
And it always start with `Tag.`, you need have define it some where otherwise game refules to use this tag if do not know it.

Offline Barghum

  • Sergeant
  • **
  • Posts: 29
  • Doing my best to help (:
    • View Profile
Re: Broken Y-scripts
« Reply #18 on: March 10, 2024, 05:46:58 am »
so i now have a problem with the game crashing due to laser goggles

here is the code:
Code: [Select]
    newTurnUnit: #ALL GOGGLES
      - offset: 1.6
        code: |
          var int las_goggles_worn;
          #var ptre BattleUnit itemOwner;     
          #item.getOwner itemOwner;     
          # Clear all unit resist types and minimums so resistance items can set again
          #itemOwner.setTag Tag.UNIT_RESIST_ITEM_SLOT_300 0; #unit
          set las_goggles_worn 0;
          return; 
    newTurnItem: #ITS GOGGLES THAT CRASH THE GAME!!!!!!!!!!!!!!
      - new: GOGGLES_STRENGTH
        offset: 9.1
        code: |
          var ptre BattleUnit itemOwner;   
          var ptr RuleItem itemRuleset;
          var int anti_laser_goggles;
          var int las_goggles_worn;
          var int goggles_are_broken;   #something is wrong     
          var int temp;

          item.getOwner itemOwner;
          # If no owner, skip script
          if eq itemOwner null;
            debug_log "ItemOwnerIsNullValue";             
            return;       
          end;       

          item.getRuleItem itemRuleset;
          itemRuleset.getTag anti_laser_goggles Tag.ANTI_LASER_GOGGLES; 

          if eq anti_laser_goggles 1;
            set las_goggles_worn 1;
            itemOwner.getTag temp Tag.UNIT_RESIST_ITEM_SLOT_300;
            debug_log "Anti_laser_goggles_working";   
          else;
            itemOwner.setTag Tag.UNIT_RESIST_ITEM_SLOT_1 1; 
            #if eq temp 1;
              #debug_log "TEMP = 1";
              #itemOwner.setTag Tag.UNIT_RESIST_ITEM_SLOT_300 1;
            #end;                                 
          end;

          debug_log "laser_goggles_var: " anti_laser_goggles;
          debug_log "anti laser goggles worn: " las_goggles_worn;

          if eq temp 1;           
            set las_goggles_worn 1;
          end; 

          if eq goggles_are_broken 1;
            debug_log "Goggles_blown_to_heaven't";           
            set las_goggles_worn 0;
          end;           

          return;

game log:
Code: [Select]
[2024-03-09_15-52-32] [FATAL] A fatal error has occurred: code 0xc0000094
[2024-03-09_15-52-32] [FATAL] ??
[2024-03-09_15-52-32] [FATAL] ??
[2024-03-09_15-52-32] [FATAL] ??
[2024-03-09_15-52-32] [FATAL] ??
[2024-03-09_15-52-32] [FATAL] ??
[2024-03-09_15-52-32] [FATAL] ??
[2024-03-09_15-52-32] [FATAL] ??
[2024-03-09_15-52-32] [FATAL] 0x7ffd8a5b2560 BaseThreadInitThunk
[2024-03-09_15-52-32] [FATAL] 0x7ffd8c54aa30 RtlUserThreadStart
[2024-03-09_15-52-32] [FATAL] Crash dump generated at C:/Users/IDKin/OneDrive/Documents/OpenXcom/2024-03-09_15-52-32.dmp
[2024-03-09_15-52-54] [FATAL] OpenXcom has crashed: code 0xc0000094
Log file: C:/Users/IDKin/OneDrive/Documents/OpenXcom/openxcom.log
If this error was unexpected, please report it on the OpenXcom forum (OXCE board).
The following can help us solve the problem:
1. a saved game from just before the crash (helps 98%)
2. a detailed description how to reproduce the crash (helps 80%)
3. a log file (helps 10%)
4. a screenshot of this error message (helps 5%)

was listed in the crash log:
Code: [Select]
The thread tried to divide an integer value by an integer divisor of zero.
thank you for all the help.
dump included below  :)

Offline Yankes

  • Commander
  • *****
  • Posts: 3210
    • View Profile
Re: Broken Y-scripts
« Reply #19 on: March 10, 2024, 01:20:08 pm »
I do not see how script itself could cause this crash, you not even have `div` in it.
Remove this script completely and see if crash is still there.

Offline Barghum

  • Sergeant
  • **
  • Posts: 29
  • Doing my best to help (:
    • View Profile
Re: Broken Y-scripts
« Reply #20 on: March 10, 2024, 10:13:52 pm »
Quote
I do not see how script itself could cause this crash, you not even have `div` in it.
you are right.
turns out it was the lock and generators lacking T.Us and energy.

Offline Yankes

  • Commander
  • *****
  • Posts: 3210
    • View Profile
Re: Broken Y-scripts
« Reply #21 on: March 10, 2024, 11:25:30 pm »
Could you show exact thing that cause this error? Game should not crash and this need be fixed anyway.

Offline Barghum

  • Sergeant
  • **
  • Posts: 29
  • Doing my best to help (:
    • View Profile
Re: Broken Y-scripts
« Reply #22 on: March 11, 2024, 01:45:55 am »
Quote
"Could you show exact thing that cause this error? Game should not crash and this need be fixed anyway." ~ Yankes

here is the broken ruleset:

Code: [Select]
    stats:
      tu: 0
      stamina: 0

and the nonbroken version:

Code: [Select]
    stats:
      tu: 4
      stamina: 1

Offline Barghum

  • Sergeant
  • **
  • Posts: 29
  • Doing my best to help (:
    • View Profile
Re: Broken Y-scripts
« Reply #23 on: March 13, 2024, 01:31:38 am »
so i fixed most of the code but still i have a few errors.

mainly in the code here:
Code: [Select]
    hitUnit: 
      - new: GOGGLES_STRENGTH_lowerer_and_breaker
        offset: 9
        code: |
          var ptr RuleItem itemRuleset;
          var ptr RuleArmor armor_rule;
          #var ptr BattleItem ItemBattle;               
          var ptre BattleUnit itemOwner;         
          var ptre BattleUnit Unit;             
          var int goggles_curr_strength;
          var int goggles_are_broken;
          var int las_goggles_worn;
          var int temp;
          var int dumb;

          item.getOwner itemOwner;
          itemOwner.getTag temp Tag.UNIT_RESIST_ITEM_SLOT_300;
          itemOwner.getTag dumb Tag.GOGGLES_BROKEN_FR;         

          if eq temp 1; #las_goggles_worn 1;
            sub goggles_curr_strength 1;
            debug_log "goggles current strength is: " goggles_curr_strength; 
          end; 
         
          if eq goggles_curr_strength 0;
            set goggles_are_broken 1;
            itemOwner.setTag Tag.GOGGLES_BROKEN_FR 1;               
          end;         

          return power part side;
    newTurnItem: #ITS not GOGGLES THAT CRASH THE GAME!!!!!!!!!!!!!!
      - new: GOGGLES_STRENGTH
        offset: 9.1
        code: |
          var ptre BattleUnit itemOwner;   
          var ptr RuleItem itemRuleset;
          var int anti_laser_goggles;
          var int las_goggles_worn;
          var int goggles_are_broken;   #something is wrong     
          var int temp;

          item.getOwner itemOwner;
          # If no owner, skip script
          if eq itemOwner null;
            debug_log "ItemOwnerIsNullValue";             
            return;       
          end;       

          item.getRuleItem itemRuleset;
          itemRuleset.getTag anti_laser_goggles Tag.ANTI_LASER_GOGGLES; 
          unit.getTag goggles_are_broken Tag.GOGGLES_BROKEN_FR;               

          if eq anti_laser_goggles 1;
            set las_goggles_worn 1;
            itemOwner.getTag temp Tag.UNIT_RESIST_ITEM_SLOT_300;
            debug_log "Anti_laser_goggles_working";   
          else;
            itemOwner.setTag Tag.UNIT_RESIST_ITEM_SLOT_300 1; 
            #if eq temp 1;
              #debug_log "TEMP = 1";
              #itemOwner.setTag Tag.UNIT_RESIST_ITEM_SLOT_300 1;
            #end;                                 
          end;

          #debug_log "laser_goggles_var: " anti_laser_goggles;
          #debug_log "anti laser goggles worn: " las_goggles_worn;

          if eq temp 1;           
            set las_goggles_worn 1;
          end; 

          if eq goggles_are_broken 1;
            debug_log "Goggles_blown_to_heaven't";           
            set las_goggles_worn 0;
            itemOwner.setTag Tag.UNIT_RESIST_ITEM_SLOT_300_BROKEN 1;             
          end;           

          return;



ERROR LOG:
Code: [Select]
[2024-03-12_15-25-06] [ERROR] Unknown variable name 'item'
[2024-03-12_15-25-06] [ERROR] Error in parsing script 'hitUnit' for 'Global Event Script': invalid operation 'item.getOwner'
[2024-03-12_15-25-06] [ERROR] Error in parsing script 'hitUnit' for 'Global Event Script': invalid operation in line: 'item.getOwner itemOwner;'
[2024-03-12_15-25-06] [ERROR] Unknown variable name 'unit'
[2024-03-12_15-25-06] [ERROR] Error in parsing script 'newTurnItem' for 'Global Event Script': invalid operation 'unit.getTag'
[2024-03-12_15-25-06] [ERROR] Error in parsing script 'newTurnItem' for 'Global Event Script': invalid operation in line: 'unit.getTag goggles_are_broken Tag.GOGGLES_BROKEN_FR;'

Thank you for all the help  :)

Offline Yankes

  • Commander
  • *****
  • Posts: 3210
    • View Profile
Re: Broken Y-scripts
« Reply #24 on: March 13, 2024, 04:43:03 pm »
You had already similar errors, `item` and `unit` do not exist in given script, if you do not know what is available in given script, you can set config `verboseLogging: true` and `debug: true`  that make game dump all script meta data into logs.