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

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Prevent Chryssalid Insta Kill
« on: November 16, 2023, 06:36:22 am »
my script triggers on the hit but soldier dies anyway,looked at script ,donno what to look for

any way to prevent the transformation with scripts?4

Online Nord

  • Commander
  • *****
  • Posts: 1643
  • The Gate is open.
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #1 on: November 16, 2023, 11:18:08 am »
you need scripthook "damageSpecialUnit"
in which you should modify variable "transform_chance".

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #2 on: November 16, 2023, 11:02:42 pm »
you need scripthook "damageSpecialUnit"
in which you should modify variable "transform_chance".


Thnx Dude

question: this obviously isnt the entirte hook list,mind dirrecting me to the complete list?

Code: [Select]
    Unit scripts
        recolorUnitSprite: Runs for every pixel of a units graphic. Change to any color.
        selectUnitSprite: Runs for every part of a units graphic. E.g. Change the graphic used for legs.
        selectMoveSoundUnit: Runs for each unit step.
        reactionUnitAction: Runs when an unit performs an action that triggers reaction fire.
        reactionUnitReaction: Runs when a unit sees another unit perform an action that triggers reaction fire.
        hitUnit: When a unit is hit it allows adjusting damage and the part of the body it affects. Runs before damageUnit
        damageUnit: Used to alter the final change to stats of a unit when its hit by a weapon. If unit receives a hit with 0 power this script doesnt run.
        healUnit: Used to alter effect of medikit on unit. Can alter exp from usage of it.
        createUnit: Runs when new unit is created
        newTurnUnit: Runs for every unit every turn (this includes alien, civilian and xcom turns)
        returnFromMissionUnit: Runs for every unit at the end of a mission.
        awardExperience: Runs whenever a unit performs an action that can earn it experience.
        visibilityUnit: Runs to check if two units of opposing factions can see each other.
    Item scripts
        recolorItemSprite: Runs for every pixel of sprite. Change color.
        selectItemSprite: Run to change the graphic of an item when its on the floor or in the hands of a soldier
        reactionWeaponAction: Runs for the weapon that triggered reaction shots by firing.
        createItem: Runs when a new item is created.
        newTurnItem: Runs for each item each turn. (this includes alien, civilian and xcom turns)
    Stat bonus scripts
        For armors: psiDefence, meleeDodge, recovery (time, energy, morale, health, stun, mana)
        For items: damageBonus, meleeBonus, accuracyMultiplier, meleeMultiplier, throwMultiplier, closeQuartersMultiplier
        For units: applySoldierBonuses: Runs once for each bonus of each soldier on mission start.

seems oxce has alot of variations of get/set

edit: what is the correct synthax to get/set transform_chance?

edit2: typo
« Last Edit: November 17, 2023, 12:31:04 am by Nirran »

Online Nord

  • Commander
  • *****
  • Posts: 1643
  • The Gate is open.
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #3 on: November 17, 2023, 08:27:06 am »
To create full list of script commands, you need to switch "verboseLogging" in options.cfg to "true", then launch oxce, then quit and open file "openxcom.log". It will contain not only log, but script help. Save it somewhere, and remember to update when upgrade to newer OXCE version.

Quote
edit: what is the correct synthax to get/set transform_chance?
Just as any variable,
Code: [Select]
set temp transform_chance;
...magic...
set transform_chance temp;

Like 0 is no transform at all, 100 - transform by any circumstances.

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #4 on: November 17, 2023, 08:47:04 am »
To create full list of script commands, you need to switch "verboseLogging" in options.cfg to "true", then launch oxce, then quit and open file "openxcom.log". It will contain not only log, but script help. Save it somewhere, and remember to update when upgrade to newer OXCE version.
Just as any variable,
Code: [Select]
set temp transform_chance;
...magic...
set transform_chance temp;

Like 0 is no transform at all, 100 - transform by any circumstances.

I Tried both of those,they both break the script

thnx tho for trying

Online Nord

  • Commander
  • *****
  • Posts: 1643
  • The Gate is open.
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #5 on: November 18, 2023, 09:44:38 am »
Youmust
I Tried both of those,they both break the script
Show it here.

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #6 on: November 18, 2023, 10:31:05 am »
Youmust Show it here.

my script i tried these :

Code: [Select]
          #get transform_chance temp;
          #set transform_chance temp;
          #set temp transform_chance;  
          #debug_log "transform " temp;

it is a script to cheat death,originaly copied from Meridian lucky script i found on this forum,this doesnt fire if i uncoment those(one at a time of course)

Code: [Select]
          unit.getHealth Health;                 # get current health
          sub Health to_health;                  # sub projected hp loss from current hp
          debug_log "Unconscious Code Health:" Health;     
         
          unit.getStun stunLevel;                # set var to unit stun level
          add stunLevel to_stun;                 # add projected stun level to current stun level
          debug_log "Unconscious Code Stun:" stunLevel;       
         
          #get transform_chance temp;
          #set transform_chance temp;
          #set temp transform_chance;  
          #debug_log "transform " temp;         
          if ge stunLevel Health;
             #battle_game.flashLongMessage "STR_TRANSFORM_STRING";
             battle_game.flashLongMessage "STR_UNCONSCIOUS_STRING";
             #set transform_chance temp;
             #debug_log "transform " temp";         
             unit.getHealthMax temp;
             unit.setHealth temp;
             mul temp 4;
             unit.setStun temp;
             set to_health 0;
             set to_stun 0;
             set to_wound -50;
             unit.disableIndicators;
             unit.setTag Tag.LRF_IS_DEAD 1;
             return;
          end;

Online Nord

  • Commander
  • *****
  • Posts: 1643
  • The Gate is open.
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #7 on: November 19, 2023, 09:17:20 am »
first string is wrong, and you forget about @magic@ in a middle.
If you want make chances equal to 0:
Code: [Select]
set transform_chance 0;If you want set chances 15% less:
Code: [Select]
set temp transform_chance;
muldiv temp 85 100;
set transform_chance temp;
And dont forget to define variable in a beginning of script:
Code: [Select]
    damageSpecialUnit:
      - offset: 11    # any number for counting
        code: |
          var int temp;

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #8 on: November 19, 2023, 11:00:20 am »
first string is wrong, and you forget about @magic@ in a middle.
If you want make chances equal to 0:
Code: [Select]
set transform_chance 0;If you want set chances 15% less:
Code: [Select]
set temp transform_chance;
muldiv temp 85 100;
set transform_chance temp;
And dont forget to define variable in a beginning of script:
Code: [Select]
    damageSpecialUnit:
      - offset: 11    # any number for counting
        code: |
          var int temp;

ok thnx for reply,i tried a few variasions of this

Code: [Select]
  scripts:
    damageSpecialUnit:
      - offset: 99
        code: |
          var int temp 0;
          var int transform 0; 
           
          set temp transform_chance;
          ...magic...
          set transform_chance temp;
          debug_log "transform " temp;  
          battle_game.flashLongMessage "STR_TRANSFORM_STRING";

they break the code,and the string dosnt fire

Online Nord

  • Commander
  • *****
  • Posts: 1643
  • The Gate is open.
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #9 on: November 19, 2023, 03:26:22 pm »
:) "...magic..." is not an operator, it is a joke.
Dont write it.

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #10 on: November 19, 2023, 10:51:39 pm »
:) "...magic..." is not an operator, it is a joke.
Dont write it.

haha wasnt sure,tried this and debug line doesnt fire

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

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #11 on: November 22, 2023, 04:10:41 am »
anybody know why that code fails?

Offline Yankes

  • Commander
  • *****
  • Posts: 3210
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #12 on: November 22, 2023, 11:15:26 am »
You should know it, you have all available tools to debug this, look in logs and see what was there.

Online Nord

  • Commander
  • *****
  • Posts: 1643
  • The Gate is open.
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #13 on: November 22, 2023, 12:06:39 pm »
you forget
Code: [Select]
return; in the end.

Offline Nirran

  • Captain
  • ***
  • Posts: 94
    • View Profile
Re: Prevent Chryssalid Insta Kill
« Reply #14 on: November 23, 2023, 01:53:35 am »
You should know it, you have all available tools to debug this, look in logs and see what was there.

its is bit problematic,as the debug doesnt spam anything i try,nothign fires

you forget
Code: [Select]
return; in the end.

tried that,no dice,thnx for trying