aliens

Author Topic: [Example] Handcuffs script  (Read 17037 times)

Offline Kozinsky

  • Colonel
  • ****
  • Posts: 128
  • Sorry for my bEd English
    • View Profile
[Example] Handcuffs script
« on: April 29, 2020, 04:40:55 pm »
This script makes it possible to fully use the handcuffs - each prisoner becomes stunned forever and does not die from overstun. The idea of ​​handcuffs is taken from the X-Piratez mod: this is a medikit with one charge of the stimulator, which can only be used on stunned bodies. After use, the handcuffs disappear from the player’s inventory.
Code: [Select]
items:
  - type: STR_HANDCUFFS
    medikitTargetImmune: true
    medikitTargetMatrix: 21
    stimulant: 1
    stunRecovery: 0 #no matter what value is here - script overrides it
    isConsumable: true
    costUse:
      time: 75
      energy: 10
    tags:
      HANDCUFF_STRENGTH: 1

extended:
  tags:
    RuleItem:
      HANDCUFF_STRENGTH: int
    BattleItem:
      ITEM_HANDCUFF_STRENGTH: int
    BattleUnit:
      IS_HANDCUFFED: int
  scripts:
    createItem:
      - offset: 1
        code: |
          var ptr RuleItem itemRuleset;
          var int strength;
         
          item.getRuleItem itemRuleset;
          itemRuleset.getTag strength Tag.HANDCUFF_STRENGTH;
         
          if gt strength 0;
            item.setTag Tag.ITEM_HANDCUFF_STRENGTH strength;
            debug_log "item.setTag.ITEM_HANDCUFF_STRENGTH: " strength;
          end;
          return;         
    healUnit:
      - offset: 1
        code: |
          var int strength 0;
          var int NewStun;
         
          item.getTag strength Tag.ITEM_HANDCUFF_STRENGTH;
          debug_log "item.getTag.ITEM_HANDCUFF_STRENGTH: " strength;
          if gt strength 0;
            target.setTag Tag.IS_HANDCUFFED 1;
            debug_log "target.setTag.IS_HANDCUFFED: " 1;
           
            target.getStunMax NewStun;
            target.setStun NewStun;
            debug_log "target.setStun: " NewStun;
          end;
         
          return;
    newTurnUnit:
      - offset: 2
        code: |
          var int IsHandcuff;
          var int NewStun;
         
          unit.getTag IsHandcuff Tag.IS_HANDCUFFED;
          debug_log "unit.getTag.IS_HANDCUFFED: " IsHandcuff;
         
          if gt IsHandcuff 0;
            unit.getStunMax NewStun;
            unit.setStun NewStun;
            debug_log "unit.setStun: " NewStun;
          end;
          return;
Sorry for my bad English.
« Last Edit: February 12, 2023, 02:59:22 pm by Meridian »

Offline Thermite

  • Colonel
  • ****
  • Posts: 146
    • View Profile
Re: [Script] Handcuffs
« Reply #1 on: April 30, 2020, 12:45:08 am »
This script makes it possible to fully use the handcuffs - each prisoner becomes stunned forever and does not die from overstun. The idea of ​​handcuffs is taken from the X-Piratez mod: this is a medikit with one charge of the stimulator, which can only be used on stunned bodies. After use, the handcuffs disappear from the player’s inventory.
Code: [Select]
items:
  - type: STR_HANDCUFFS
    medikitTargetImmune: true
    medikitTargetMatrix: 21
    stimulant: 1
    stunRecovery: 0 #no matter what value is here - script overrides it
    isConsumable: true
    costUse:
      time: 75
      energy: 10
    tags:
      HANDCUFF_STRENGTH: 1

extended:
  tags:
    RuleItem:
      HANDCUFF_STRENGTH: int
    BattleItem:
      ITEM_HANDCUFF_STRENGTH: int
    BattleUnit:
      IS_HANDCUFFED: int
  scripts:
    createItem:
      - offset: 1
        code: |
          var ptr RuleItem itemRuleset;
          var int strength;
         
          item.getRuleItem itemRuleset;
          itemRuleset.getTag strength Tag.HANDCUFF_STRENGTH;
         
          if gt strength 0;
            item.setTag Tag.ITEM_HANDCUFF_STRENGTH strength;
            debug_log "item.setTag.ITEM_HANDCUFF_STRENGTH: " strength;
          end;
          return;         
    healUnit:
      - offset: 1
        code: |
          var int strength 0;
          var int NewStun;
         
          item.getTag strength Tag.ITEM_HANDCUFF_STRENGTH;
          debug_log "item.getTag.ITEM_HANDCUFF_STRENGTH: " strength;
          if gt strength 0;
            target.setTag Tag.IS_HANDCUFFED 1;
            debug_log "target.setTag.IS_HANDCUFFED: " 1;
           
            target.getStunMax NewStun;
            target.setStun NewStun;
            debug_log "target.setStun: " NewStun;
          end;
         
          return;
    newTurnUnit:
      - offset: 2
        code: |
          var int IsHandcuff;
          var int NewStun;
         
          unit.getTag IsHandcuff Tag.IS_HANDCUFFED;
          debug_log "unit.getTag.IS_HANDCUFFED: " IsHandcuff;
         
          if gt IsHandcuff 0;
            unit.getStunMax NewStun;
            unit.setStun NewStun;
            debug_log "unit.setStun: " NewStun;
          end;
          return;
Sorry for my bad English.

OwO
Solarius, I think this would be a nice addition to XCF...

Offline vadracas

  • Colonel
  • ****
  • Posts: 285
  • Just another player/modder combo.
    • View Profile
Re: [Script] Handcuffs
« Reply #2 on: April 30, 2020, 12:57:04 am »
OwO
Solarius, I think this would be a nice addition to XCF...

Lol, you really need to check out the discord.

Online Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Script] Handcuffs
« Reply #3 on: April 30, 2020, 08:07:58 pm »
Yep, I am quite excited about this development. ;)

Offline Thermite

  • Colonel
  • ****
  • Posts: 146
    • View Profile
Re: [Script] Handcuffs
« Reply #4 on: May 01, 2020, 06:51:21 am »
Lol, you really need to check out the discord.

I am a forum kiddy, ok.
>_<

Offline Kozinsky

  • Colonel
  • ****
  • Posts: 128
  • Sorry for my bEd English
    • View Profile
Re: [Script] Handcuffs
« Reply #5 on: May 01, 2020, 06:20:07 pm »
So, here is an improved version of the script:
Code: [Select]
items:
  - type: STR_HANDCUFFS
    battleType: 6
    invWidth: 1
    invHeight: 2
    medikitType: 2 #stimulant only
    medikitTargetSelf: false #not for user
    medikitTargetImmune: true #can use also on an bleed units
    medikitTargetMatrix: 21 #only for all stunned bodies
    medikitActionName: STR_HANDCUFFS_ACTION
    stimulant: 1
    stunRecovery: 0 #no matter what value is here - script overrides it
    isConsumable: true
    costUse:
      time: 75
      energy: 10
    twoHanded: true
    blockBothHands: true
    listOrder: 46290
    tags:
      HANDCUFF_STRENGTH: 40

armors:
  - type: CIVM_ARMOR
    tags:
      HANDCUFF_PROTECTION: 10
  - type: CIVF_ARMOR
    tags:
      HANDCUFF_PROTECTION: 5

extended:
  tags:
    RuleItem:
      HANDCUFF_STRENGTH: int #the handcuff strength in ruleset for items
    RuleArmor:
      HANDCUFF_PROTECTION: int #the handcuff protection in ruleset for units
    BattleItem:
      ITEM_HANDCUFF_STRENGTH: int #the handcuff strength for every copy of item in battlescape
    BattleUnit:
      UNIT_HANDCUFF_PROTECTION: int #the handcuff protection for every copy of unit in battlescape
      IS_HANDCUFFED: int #is this unit under handcuffs?
      VIRTUAL_STUN_LEVEL: int #real stunlevel for every copy of unit on battlescape
  scripts:
    createItem:
      - offset: 1
        code: |
          var ptr RuleItem ItemRuleset;
          var int HandcuffStrength 0;
         
          item.getRuleItem ItemRuleset;
          ItemRuleset.getTag HandcuffStrength Tag.HANDCUFF_STRENGTH;
         
          if gt HandcuffStrength 0;
            item.setTag Tag.ITEM_HANDCUFF_STRENGTH HandcuffStrength;
            debug_log "createItem: STR_HANDCUFF with tag ITEM_HANDCUFF_STRENGTH: " HandcuffStrength;
          end;
          return;         
    createUnit:
      - offset: 1
        code: |
          var ptr RuleArmor UnitRuleset;
          var int HandcuffProtection 0;
          var int UnitID 0;
         
          unit.getId UnitID;
          unit.getRuleArmor UnitRuleset;
          UnitRuleset.getTag HandcuffProtection Tag.HANDCUFF_PROTECTION;
         
          if gt HandcuffProtection 0;
            unit.setTag Tag.UNIT_HANDCUFF_PROTECTION HandcuffProtection;
            debug_log "createUnit: ID " UnitID " with tag UNIT_HANDCUFF_PROTECTION: " HandcuffProtection;
          end;
          return;
    healUnit:
      - offset: 1
        code: |
          var int HandcuffStrength 0;
          var int HandcuffProtection 0;
          var int CurrStun;
          var int NewStun;
          var int UnitID 0;
         
          target.getId UnitID;
         
          item.getTag HandcuffStrength Tag.ITEM_HANDCUFF_STRENGTH;
          target.getTag HandcuffProtection Tag.UNIT_HANDCUFF_PROTECTION;
          debug_log "healUnit: used item with ITEM_HANDCUFF_STRENGTH: " HandcuffStrength " on target " UnitID " with UNIT_HANDCUFF_PROTECTION: " HandcuffProtection;
          if and gt HandcuffStrength 0 gt HandcuffStrength HandcuffProtection;
            target.setTag Tag.IS_HANDCUFFED 1;
            debug_log "healUnit: if item with ITEM_HANDCUFF_STRENGTH (" HandcuffStrength ") > 0 and item with ITEM_HANDCUFF_STRENGTH (" HandcuffStrength ") > target " UnitID " with UNIT_HANDCUFF_PROTECTION (" HandcuffProtection ") then: set to target " UnitID " tag IS_HANDCUFFED: " 1;
           
            target.getStunMax NewStun;
            target.getStun CurrStun;
            target.setTag Tag.VIRTUAL_STUN_LEVEL CurrStun;
            target.setStun NewStun;
            debug_log "healUnit: set to target " UnitID " VIRTUAL_STUN_LEVEL: " CurrStun " and real stun level: " NewStun;
          end;
         
          return;
    newTurnUnit:
      - offset: 2
        code: |
          var int IsHandcuff;
          var int NewStun;
          var int CurrStrength 0;
          var int CurrStun 0;
          var int PrevStun 0;
          var int StrengthLevel 0;
          var int RandomValue 0;
          var int UnitID 0;
          unit.getId UnitID;
          debug_log "---------- Turn " turn ", unit " UnitID ":";
         
          unit.getTag IsHandcuff Tag.IS_HANDCUFFED;
                   
          if gt IsHandcuff 0; 
            unit.Stats.getStrength CurrStrength;
            debug_log "newTurnUnit: for unit " UnitID " get strength: " CurrStrength;
            battle_game.randomRange RandomValue 1 100;
            debug_log "newTurnUnit: generate RandomValue (1..100): " RandomValue;           
            if and ge CurrStrength 0 le CurrStrength 39;
              set StrengthLevel 1;
            else and ge CurrStrength 40 le CurrStrength 49;
              set StrengthLevel 5;
            else and ge CurrStrength 50 le CurrStrength 59;
              set StrengthLevel 10;
            else and ge CurrStrength 60 le CurrStrength 69;
              set StrengthLevel 20;
            else and ge CurrStrength 70 le CurrStrength 79;
              set StrengthLevel 30;
            else and ge CurrStrength 80 le CurrStrength 89;
              set StrengthLevel 40;
            else and ge CurrStrength 90 le CurrStrength 99;
              set StrengthLevel 50;
            else and ge CurrStrength 100 le CurrStrength 109;
              set StrengthLevel 60;
            else and ge CurrStrength 110 le CurrStrength 119;
              set StrengthLevel 70;
            else and ge CurrStrength 120 le CurrStrength 129;
              set StrengthLevel 80;
            else and ge CurrStrength 130 le CurrStrength 139;
              set StrengthLevel 90;
            else ge CurrStrength 140;
              set StrengthLevel 100;
            end;
            debug_log "newTurnUnit: unit " UnitID " got StrengthLevel: " StrengthLevel;
           
            unit.getTag PrevStun Tag.VIRTUAL_STUN_LEVEL;
            if le RandomValue StrengthLevel;
              if lt PrevStun 0;
                clear PrevStun;
              end;
              unit.setStun PrevStun;
              unit.setTag Tag.IS_HANDCUFFED 0;
              unit.setTag Tag.VIRTUAL_STUN_LEVEL 0;
              debug_log "newTurnUnit: if RandomValue (" RandomValue ") <= unit " UnitID " StrengthLevel (" StrengthLevel ") then set real stun: " PrevStun " and remove tag IS_HANDCUFFED";
            else gt RandomValue StrengthLevel;
              unit.getStun CurrStun;
              unit.getStunMax NewStun;
              sub CurrStun NewStun;
              add PrevStun CurrStun;
              unit.setTag Tag.VIRTUAL_STUN_LEVEL PrevStun;
              unit.setStun NewStun;
              debug_log "newTurnUnit: if RandomValue (" RandomValue ") > unit " UnitID " StrengthLevel (" StrengthLevel ") then set VIRTUAL_STUN_LEVEL: " PrevStun " and real stun: " NewStun;
            end;           
          end;
          return;

Each type of handcuffs must have a HANDCUFF_STRENGTH parameter in the "tags" section. By default, it is zero, which means the item is not handcuffs.
For each type of armor, you can specify the HANDCUFF_PROTECTION parameter in the "tags" section. By default, it is equal to zero, which means that the creature can be handcuffed of any handcuffs strength.
When trying to put on handcuffs, the condition is checked: if HANDCUFF_STRENGTH is greater than HANDCUFF_PROTECTION, then the handcuffs will be put on, otherwise not.
The unit, that is handcuffed, is assigned the parameter IS_HANDCUFFED: 1.
Each turn, each unit, in which the IS_HANDCUFFED parameter is 1, is checked for the possibility to free, based on his strength:
if strength in 0..39 then unit has 1% chance to be free,
if 40..49 - 5%,
if 50..59 - 10%,
if 60..69 - 20%,
if 70..79 - 30%,
if 80..89 - 40%,
if 90..99 - 50%,
if 100..109 - 60%,
if 110..119 - 70%,
if 120..129 - 80%,
if 130..139 - 90%,
if 140..infinity - 100%.
Each turn checks how much the unit’s stunning level has changed and this change is recorded to the VIRTUAL_STUN_LEVEL variable in the unit's "tags" section.
If the unit was able to free, its stun level from the VIRTUAL_STUN_LEVEL variable is returned to his stunLevel" and the script finishes its work with this unit.

For understandable how script works, I provided almost every action with a message output to the "openxcom.log" file, because for the player there are no visible changes in the game.

Offline Thermite

  • Colonel
  • ****
  • Posts: 146
    • View Profile
Re: [Script] Handcuffs
« Reply #6 on: May 01, 2020, 08:15:33 pm »
So, here is an improved version of the script:
Code: [Select]
items:
  - type: STR_HANDCUFFS
    battleType: 6
    invWidth: 1
    invHeight: 2
    medikitType: 2 #stimulant only
    medikitTargetSelf: false #not for user
    medikitTargetImmune: true #can use also on an bleed units
    medikitTargetMatrix: 21 #only for all stunned bodies
    medikitActionName: STR_HANDCUFFS_ACTION
    stimulant: 1
    stunRecovery: 0 #no matter what value is here - script overrides it
    isConsumable: true
    costUse:
      time: 75
      energy: 10
    twoHanded: true
    blockBothHands: true
    listOrder: 46290
    tags:
      HANDCUFF_STRENGTH: 40

armors:
  - type: CIVM_ARMOR
    tags:
      HANDCUFF_PROTECTION: 10
  - type: CIVF_ARMOR
    tags:
      HANDCUFF_PROTECTION: 5

extended:
  tags:
    RuleItem:
      HANDCUFF_STRENGTH: int #the handcuff strength in ruleset for items
    RuleArmor:
      HANDCUFF_PROTECTION: int #the handcuff protection in ruleset for units
    BattleItem:
      ITEM_HANDCUFF_STRENGTH: int #the handcuff strength for every copy of item in battlescape
    BattleUnit:
      UNIT_HANDCUFF_PROTECTION: int #the handcuff protection for every copy of unit in battlescape
      IS_HANDCUFFED: int #is this unit under handcuffs?
      VIRTUAL_STUN_LEVEL: int #real stunlevel for every copy of unit on battlescape
  scripts:
    createItem:
      - offset: 1
        code: |
          var ptr RuleItem ItemRuleset;
          var int HandcuffStrength 0;
         
          item.getRuleItem ItemRuleset;
          ItemRuleset.getTag HandcuffStrength Tag.HANDCUFF_STRENGTH;
         
          if gt HandcuffStrength 0;
            item.setTag Tag.ITEM_HANDCUFF_STRENGTH HandcuffStrength;
            debug_log "createItem: STR_HANDCUFF with tag ITEM_HANDCUFF_STRENGTH: " HandcuffStrength;
          end;
          return;         
    createUnit:
      - offset: 1
        code: |
          var ptr RuleArmor UnitRuleset;
          var int HandcuffProtection 0;
          var int UnitID 0;
         
          unit.getId UnitID;
          unit.getRuleArmor UnitRuleset;
          UnitRuleset.getTag HandcuffProtection Tag.HANDCUFF_PROTECTION;
         
          if gt HandcuffProtection 0;
            unit.setTag Tag.UNIT_HANDCUFF_PROTECTION HandcuffProtection;
            debug_log "createUnit: ID " UnitID " with tag UNIT_HANDCUFF_PROTECTION: " HandcuffProtection;
          end;
          return;
    healUnit:
      - offset: 1
        code: |
          var int HandcuffStrength 0;
          var int HandcuffProtection 0;
          var int CurrStun;
          var int NewStun;
          var int UnitID 0;
         
          target.getId UnitID;
         
          item.getTag HandcuffStrength Tag.ITEM_HANDCUFF_STRENGTH;
          target.getTag HandcuffProtection Tag.UNIT_HANDCUFF_PROTECTION;
          debug_log "healUnit: used item with ITEM_HANDCUFF_STRENGTH: " HandcuffStrength " on target " UnitID " with UNIT_HANDCUFF_PROTECTION: " HandcuffProtection;
          if and gt HandcuffStrength 0 gt HandcuffStrength HandcuffProtection;
            target.setTag Tag.IS_HANDCUFFED 1;
            debug_log "healUnit: if item with ITEM_HANDCUFF_STRENGTH (" HandcuffStrength ") > 0 and item with ITEM_HANDCUFF_STRENGTH (" HandcuffStrength ") > target " UnitID " with UNIT_HANDCUFF_PROTECTION (" HandcuffProtection ") then: set to target " UnitID " tag IS_HANDCUFFED: " 1;
           
            target.getStunMax NewStun;
            target.getStun CurrStun;
            target.setTag Tag.VIRTUAL_STUN_LEVEL CurrStun;
            target.setStun NewStun;
            debug_log "healUnit: set to target " UnitID " VIRTUAL_STUN_LEVEL: " CurrStun " and real stun level: " NewStun;
          end;
         
          return;
    newTurnUnit:
      - offset: 2
        code: |
          var int IsHandcuff;
          var int NewStun;
          var int CurrStrength 0;
          var int CurrStun 0;
          var int PrevStun 0;
          var int StrengthLevel 0;
          var int RandomValue 0;
          var int UnitID 0;
          unit.getId UnitID;
          debug_log "---------- Turn " turn ", unit " UnitID ":";
         
          unit.getTag IsHandcuff Tag.IS_HANDCUFFED;
                   
          if gt IsHandcuff 0; 
            unit.Stats.getStrength CurrStrength;
            debug_log "newTurnUnit: for unit " UnitID " get strength: " CurrStrength;
            battle_game.randomRange RandomValue 1 100;
            debug_log "newTurnUnit: generate RandomValue (1..100): " RandomValue;           
            if and ge CurrStrength 0 le CurrStrength 39;
              set StrengthLevel 1;
            else and ge CurrStrength 40 le CurrStrength 49;
              set StrengthLevel 5;
            else and ge CurrStrength 50 le CurrStrength 59;
              set StrengthLevel 10;
            else and ge CurrStrength 60 le CurrStrength 69;
              set StrengthLevel 20;
            else and ge CurrStrength 70 le CurrStrength 79;
              set StrengthLevel 30;
            else and ge CurrStrength 80 le CurrStrength 89;
              set StrengthLevel 40;
            else and ge CurrStrength 90 le CurrStrength 99;
              set StrengthLevel 50;
            else and ge CurrStrength 100 le CurrStrength 109;
              set StrengthLevel 60;
            else and ge CurrStrength 110 le CurrStrength 119;
              set StrengthLevel 70;
            else and ge CurrStrength 120 le CurrStrength 129;
              set StrengthLevel 80;
            else and ge CurrStrength 130 le CurrStrength 139;
              set StrengthLevel 90;
            else ge CurrStrength 140;
              set StrengthLevel 100;
            end;
            debug_log "newTurnUnit: unit " UnitID " got StrengthLevel: " StrengthLevel;
           
            unit.getTag PrevStun Tag.VIRTUAL_STUN_LEVEL;
            if le RandomValue StrengthLevel;
              if lt PrevStun 0;
                clear PrevStun;
              end;
              unit.setStun PrevStun;
              unit.setTag Tag.IS_HANDCUFFED 0;
              unit.setTag Tag.VIRTUAL_STUN_LEVEL 0;
              debug_log "newTurnUnit: if RandomValue (" RandomValue ") <= unit " UnitID " StrengthLevel (" StrengthLevel ") then set real stun: " PrevStun " and remove tag IS_HANDCUFFED";
            else gt RandomValue StrengthLevel;
              unit.getStun CurrStun;
              unit.getStunMax NewStun;
              sub CurrStun NewStun;
              add PrevStun CurrStun;
              unit.setTag Tag.VIRTUAL_STUN_LEVEL PrevStun;
              unit.setStun NewStun;
              debug_log "newTurnUnit: if RandomValue (" RandomValue ") > unit " UnitID " StrengthLevel (" StrengthLevel ") then set VIRTUAL_STUN_LEVEL: " PrevStun " and real stun: " NewStun;
            end;           
          end;
          return;

Each type of handcuffs must have a HANDCUFF_STRENGTH parameter in the "tags" section. By default, it is zero, which means the item is not handcuffs.
For each type of armor, you can specify the HANDCUFF_PROTECTION parameter in the "tags" section. By default, it is equal to zero, which means that the creature can be handcuffed of any handcuffs strength.
When trying to put on handcuffs, the condition is checked: if HANDCUFF_STRENGTH is greater than HANDCUFF_PROTECTION, then the handcuffs will be put on, otherwise not.
The unit, that is handcuffed, is assigned the parameter IS_HANDCUFFED: 1.
Each turn, each unit, in which the IS_HANDCUFFED parameter is 1, is checked for the possibility to free, based on his strength:
if strength in 0..39 then unit has 1% chance to be free,
if 40..49 - 5%,
if 50..59 - 10%,
if 60..69 - 20%,
if 70..79 - 30%,
if 80..89 - 40%,
if 90..99 - 50%,
if 100..109 - 60%,
if 110..119 - 70%,
if 120..129 - 80%,
if 130..139 - 90%,
if 140..infinity - 100%.
Each turn checks how much the unit’s stunning level has changed and this change is recorded to the VIRTUAL_STUN_LEVEL variable in the unit's "tags" section.
If the unit was able to free, its stun level from the VIRTUAL_STUN_LEVEL variable is returned to his stunLevel" and the script finishes its work with this unit.

For understandable how script works, I provided almost every action with a message output to the "openxcom.log" file, because for the player there are no visible changes in the game.

What if the handcuff strength is far greater than their handcuff protection?
It wouldn't make sense for a strong civilian to be able to be able to free itself from the cuffs capable of restraining reapers or chryssalids.

Online Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Script] Handcuffs
« Reply #7 on: May 01, 2020, 08:25:06 pm »
As of today, this submod has been included with the X-Com Files mod, with very minor adjustments.

Thank you very much, Kozinsky!

Offline vadracas

  • Colonel
  • ****
  • Posts: 285
  • Just another player/modder combo.
    • View Profile
Re: [Script] Handcuffs
« Reply #8 on: May 01, 2020, 09:32:51 pm »
What if the handcuff strength is far greater than their handcuff protection?
It wouldn't make sense for a strong civilian to be able to be able to free itself from the cuffs capable of restraining reapers or chryssalids.


I sincerely hope that handcuffs won't be able to restrain most monsters(excluding mongorns).

Offline Kozinsky

  • Colonel
  • ****
  • Posts: 128
  • Sorry for my bEd English
    • View Profile
Re: [Script] Handcuffs
« Reply #9 on: May 01, 2020, 10:06:04 pm »
What if the handcuff strength is far greater than their handcuff protection?
It wouldn't make sense for a strong civilian to be able to be able to free itself from the cuffs capable of restraining reapers or chryssalids.
I sincerely hope that handcuffs won't be able to restrain most monsters(excluding mongorns).

If the strength of the handcuffs is greater than the creature's protection, the handcuffs will be put on the creature. If it's less, it won't. Unfortunately, in both cases handcuffs will disappear from the game forever - I don't know how to solve this problem due to limited knowledge or missing script functionality.

The parameters "handcuff strength" and "handcuff protection" have been introduced so that it is possible to introduce several types of handcuffs with different durability. Stronger handcuffs are for catching stronger creatures.

Offline vadracas

  • Colonel
  • ****
  • Posts: 285
  • Just another player/modder combo.
    • View Profile
Re: [Script] Handcuffs
« Reply #10 on: May 01, 2020, 11:19:24 pm »
I like the idea of Alien Alloy and plasma handcuffs.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3347
    • View Profile
Re: [Script] Handcuffs
« Reply #11 on: May 02, 2020, 12:26:24 am »
If the strength of the handcuffs is greater than the creature's protection, the handcuffs will be put on the creature. If it's less, it won't. Unfortunately, in both cases handcuffs will disappear from the game forever - I don't know how to solve this problem due to limited knowledge or missing script functionality.

The parameters "handcuff strength" and "handcuff protection" have been introduced so that it is possible to introduce several types of handcuffs with different durability. Stronger handcuffs are for catching stronger creatures.
Because you spend last charge, if you block it, game would not remove your item.
Probably most correct way to do it is set `medikit_action_type` to zero if you are prevented doing any thing.

Offline Thermite

  • Colonel
  • ****
  • Posts: 146
    • View Profile
Re: [Script] Handcuffs
« Reply #12 on: May 02, 2020, 11:35:39 pm »
If the strength of the handcuffs is greater than the creature's protection, the handcuffs will be put on the creature. If it's less, it won't. Unfortunately, in both cases handcuffs will disappear from the game forever - I don't know how to solve this problem due to limited knowledge or missing script functionality.

The parameters "handcuff strength" and "handcuff protection" have been introduced so that it is possible to introduce several types of handcuffs with different durability. Stronger handcuffs are for catching stronger creatures.

No, that isn't what I meant! :o
I meant that, if you have a restraining item with, let's say, 5 handcuff strength and use it to restrain a creature that has 2 handcuff protection, it would not make sense for that creature to break free from it, even if it had 50 strength, because the handcuffs are far too potent in handcuff strength for the creature.

Offline Kozinsky

  • Colonel
  • ****
  • Posts: 128
  • Sorry for my bEd English
    • View Profile
Re: [Script] Handcuffs
« Reply #13 on: May 03, 2020, 09:32:19 am »
No, that isn't what I meant! :o
I meant that, if you have a restraining item with, let's say, 5 handcuff strength and use it to restrain a creature that has 2 handcuff protection, it would not make sense for that creature to break free from it, even if it had 50 strength, because the handcuffs are far too potent in handcuff strength for the creature.
My idea is that parameters "handcuff strength" and "handcuff protection" are only for the purpose of understanding whether a creature can be handcuffed, and if so, what kind of handcuffs he can use. The ability to be released from handcuffs depends on the strength of the creature. Although I am thinking of adding "handcuff strength" to this formula as well, the chance of escaping is calculated from the strength of the prisoner and the strength of the handcuffs. The stronger the handcuffs, the less chance of escape. A weak creature in strong handcuffs can have a 0% chance of escape.
That's what I'll do after I understand and can apply what the Yankes suggested))

Offline vadracas

  • Colonel
  • ****
  • Posts: 285
  • Just another player/modder combo.
    • View Profile
Re: [Script] Handcuffs
« Reply #14 on: May 04, 2020, 02:54:17 am »
Quick question, where do you find this relationship in the save? Basically, what I'm asking is, will the handcuffs work if you handcuff something, save the game, and load it? I can't find it on the unit id in the save.