aliens

Author Topic: Prevent Chryssalid Insta Kill  (Read 4085 times)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #15 on: November 23, 2023, 08:19:57 am »
Sorry, but I tried your script and the logs clearly indicate what's wrong.

Code: [Select]
[23-11-2023_07-09-43] [ERROR] Invalid variable name 'transform'
[23-11-2023_07-09-43] [ERROR] Error in matching arguments for operator 'var'
[23-11-2023_07-09-43] [ERROR] Error in parsing script 'damageSpecialUnit' for 'Global Event Script': invalid operation in line: 'var int transform 0;'

It says exactly, which line is wrong ('var int transform 0;').
And it says exactly what's wrong (invalid variable name).

And Nord's answer is also correct.
Once you fix the issue with the variable name, the logs will complain about the missing return too.

Here's a fixed script:

Code: [Select]
extended:
  tags:                                                               
    BattleUnit:                           
      LRF_IS_DEAD: int                       
                   
  scripts:
    damageSpecialUnit:
      - offset: 99
        code: |
          var int temp 0;
          var int transformx 0; 
           
          set temp transform_chance;
          #...magic...
          set transform_chance temp;
          debug_log "transform " temp;  
          battle_game.flashLongMessage "STR_TRANSFORM_STRING";
          return;

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #16 on: November 23, 2023, 09:55:29 am »
Sorry, but I tried your script and the logs clearly indicate what's wrong.

Code: [Select]
[23-11-2023_07-09-43] [ERROR] Invalid variable name 'transform'
[23-11-2023_07-09-43] [ERROR] Error in matching arguments for operator 'var'
[23-11-2023_07-09-43] [ERROR] Error in parsing script 'damageSpecialUnit' for 'Global Event Script': invalid operation in line: 'var int transform 0;'

It says exactly, which line is wrong ('var int transform 0;').
And it says exactly what's wrong (invalid variable name).

And Nord's answer is also correct.
Once you fix the issue with the variable name, the logs will complain about the missing return too.

Here's a fixed script:

Code: [Select]
extended:
  tags:                                                               
    BattleUnit:                           
      LRF_IS_DEAD: int                       
                   
  scripts:
    damageSpecialUnit:
      - offset: 99
        code: |
          var int temp 0;
          var int transformx 0; 
           
          set temp transform_chance;
          #...magic...
          set transform_chance temp;
          debug_log "transform " temp;  
          battle_game.flashLongMessage "STR_TRANSFORM_STRING";
          return;

my bad god i was looking for errors at end of the log,thinking that the script would error after the attack and it would be at bottom of the file

thanks once again Meridian

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #17 on: November 23, 2023, 08:48:34 pm »
is  transform_chance always 100 if it isnt modded?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #18 on: November 23, 2023, 08:55:25 pm »
no, the default value is this:

Code: [Select]
const RuleItem *specialDamageTransform = attack.damage_item ? attack.damage_item->getRules() : nullptr;
int specialDamageTransformChance = 0;

if (specialDamageTransform
&& !specialDamageTransform->getZombieUnit(this).empty()
&& getArmor()->getZombiImmune() == false)
{
specialDamageTransformChance = getOriginalFaction() != FACTION_HOSTILE ? specialDamageTransform->getZombieUnitChance() : 0;
}

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #19 on: November 23, 2023, 10:39:15 pm »
no, the default value is this:

Code: [Select]
const RuleItem *specialDamageTransform = attack.damage_item ? attack.damage_item->getRules() : nullptr;
int specialDamageTransformChance = 0;

if (specialDamageTransform
&& !specialDamageTransform->getZombieUnit(this).empty()
&& getArmor()->getZombiImmune() == false)
{
specialDamageTransformChance = getOriginalFaction() != FACTION_HOSTILE ? specialDamageTransform->getZombieUnitChance() : 0;
}

thanks again dude