aliens

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Filip H

Pages: [1]
1
OXCE Support Y-scripts / Re: Drugs that restore / give time (tu)
« on: June 17, 2022, 01:55:18 am »
I see two issues with the script.
Firstly the scripthook is missing (i.e. the part that determines when the script runs). I presume the script you grabbed used the healUnit: hook, you need to add it one line above code: |. Note that if you're adding it to a file with multiple existing scripts, there might already be a healUnit: hook, in which case you only need to add the script after it (adding the hook again will not work).
Secondly the Tag required by the script most likely isn't defined which means you need to add that too. Here is an example on how it should look like:
Code: [Select]
extended:
  tags:
    RuleItem:
      WM_IS_WACKY: int
If the RuleItem section already exists in the file you can just add WM_IS_WACKY: int among the existing tags.

One pitfall to avoid is that you need to add tags to an item in the same file as where the tags are defined, otherwise the script may not work.
The easiest way to achieve what you're trying to do would be to just to create a new .rul file and add the new script and item, it should look something like this
Code: [Select]
items:
  - type: STR_COMBAT_DRUGS
    medikitActionName: STR_INJECT
    costUse:
      time: 1
      health: 1  (We will lost 1 hp for each use)
      stun: -50
      morale: -50
      mana: -50
    costThrow:
      energy: 6
      time: 40
    flatRate: true
    isConsumable: true
    flatUse:
      time: true
      health: true
    recoveryPoints: 1
    tags:  (The tag is what the script will use)
      WM_IS_WACKY: 1

extended:
  tags:
    RuleItem:
      WM_IS_WACKY: int
  scripts:
    healUnit:
    code: |
          var int temp;

          item.getTag temp Tag.WM_IS_WACKY;

          if neq temp 0;
            # debug_log "healUnit: applying wacky medikit, skip normal effects completely";
            set medikit_action_type 0;

            target.getTimeUnits temp;
            add temp 55;
            target.setTimeUnits temp;

            target.getEnergy temp;
            add temp 50;
            target.setEnergy temp;

            return;
          end;

          # debug_log "healUnit: not wacky...";
          return;

2
40k / Re: [ADDON] ROSIGMA
« on: April 29, 2022, 06:10:28 pm »
I believe this is the space hulk mission objective.

3
OXCE Support Y-scripts / Re: Scripting 'isFuseEnabled'
« on: February 25, 2022, 02:58:11 pm »
Code: [Select]
[25-02-2022_14-45-00] [ERROR] Error in parsing script 'newTurnItem' for 'Global Event Script': invalid variable definition after other operations: 'var int Fuse_State;'I believe this error is caused due to all variables being required to be declared before any operations (which is why var int Current_Turn; isn't throwing an error since it's before any operations).
I get no errors after editing the script to this:
Code: [Select]
extended:
  tags:
    RuleItem:
      AUTO_PRIMED_ENABLED: int
      AUTO_PRIMED_FUSE_TIME: int
      AUTO_PRIMED_GROUND_ARM: int
      AUTO_PRIMED_FIRST_TURN_ONLY: int
  scripts:
    newTurnItem:
      - offset: 52
        code: |
          var int Current_Turn;
          var int Fuse_State;
          var ptr RuleInventory Items_Inventory;
          var int Inventory_Slot;
          var int Auto_Prime;
          var int Fuse_Time;
          var int Ground_Arm;
          var int First_Turn_Only;
         
          battle_game.getTurn Current_Turn;

          item.isFuseEnabled Fuse_State;


          item.getSlot Items_Inventory;
          Items_Inventory.getType Inventory_Slot;

          item.getTag Auto_Prime Tag.AUTO_PRIMED_ENABLED;

          item.getTag Fuse_Time Tag.AUTO_PRIMED_FUSE_TIME;

          item.getTag Ground_Arm Tag.AUTO_PRIMED_GROUND_ARM;

          item.getTag First_Turn_Only Tag.AUTO_PRIMED_FIRST_TURN_ONLY;




          # If Grenade is not set for Auto Prime, Return.
          if neq Auto_Prime 1;
            return;
          end;

          # If Grenade is already armed, return
          if neq Fuse_State 0;
            return;
          end;

          # If Grenade is on ground and cannot ground arm, return
          if eq Ground_Arm 0;
            if eq Inventory_Slot INV_GROUND;
              return;
            end;
          end;

          # If Grenade can only be auto armed on first turn and it is after that, return
          if eq First_Turn_Only 1;
            if neq Current_Turn 1;
              return;
            end;
          end;

          # Set Grenade fuse to Fuse_Time
          item.setFuseTimer Fuse_Time;
          return;

4
OXCE Support Y-scripts / Re: Scripting 'isFuseEnabled'
« on: February 23, 2022, 08:41:26 pm »
The var int that the isFuseEnabled requires is where its return value is written.
So to do what you're trying to accomplish you'd need to do something like this:
Code: [Select]
scripts:
   newTurnItem:       
       - offset: 1
         code: |
          var int x;
          item.isFuseEnabled x; #x gets the value 0 or 1 depending on if the fuse is lit
          if eq x 0;
            <CODE>
          end;
          return;

Regarding the additional question, no, the pointer names vary between script hooks. You can find the pointers available for each hook in the script data section of the API.
For example in the newTurnItem hook, the pointer for the BattleItem is just item
Code: [Select]
Name: battle_game                             ptre      BattleGame
Name: item                                    ptre      BattleItem
Name: null                                              null     
Name: rules                                   ptr       RuleMod 
Name: side                                              int     
Name: turn                                              int
The pointer for BattleGame seems to be consistently battle_game though.

5
Help / Re: Recovering friendly spawned units?
« on: January 12, 2022, 09:14:36 pm »
Using builtInWeaponSets to add a dummy item with recoveryTransformations to change it back to the original item could probably do it.
Something like this:
Code: [Select]
units:
   - type: STR_EXAMPLE_UNIT
     builtInWeaponSets:
       - - STR_DUMMY_ITEM
items:
   - type: STR_DUMMY_ITEM
     fixedWeapon: true
     recover: true
     recoveryTransformations:
        STR_EXAMPLE_ITEM: [1]

6
OXCE Support Y-scripts / Re: Replacing weapon sprite depending of ammo.
« on: September 23, 2021, 01:50:40 pm »
Counter-Terrorist Operations, UNEXCOM: bureau 11 and OpenScarfCom also have scripts that do this

Pages: [1]