aliens

Author Topic: [Solved] Help with scripting...  (Read 5518 times)

wcho035

  • Guest
Re: Help with scripting...
« Reply #15 on: October 08, 2019, 01:21:42 pm »
Can the script give an item with armour like behavior?

Like for example, you hold a shield or some amulet, the script will graft the amulet which the soldier is holding with a secondary Armour like effect?

Like a Soldier is wearing Personal Armour for example.  Personal armour draw the codes from Armour.rul.

He's holding a stats boosting device, it also draw codes from  Armour.rul.

If this can be done, I can give the amulet in its armor.rul

    stats:
      psiStrength: 60

This will solve my problem.

It will also solve my stealth device problem too, with a few other codes I can find in the armour ruleset


« Last Edit: October 08, 2019, 01:24:20 pm by Precentor Apollyon »

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Help with scripting...
« Reply #16 on: October 08, 2019, 03:26:48 pm »
It will also solve my stealth device problem too, with a few other codes I can find in the armour ruleset
So your plan is to make it so that while a unit is holding the item it is granted a change to these two variables?
camouflageAtDay: X
camouflageAtDark: X


I think that I read somewhere on the forum that it was possible to make items change the units stats while directly held in the left or right hand slot.

I'm unsure if it is possible to overwrite the values of variables other than the stat related ones via this method though.

If it is then that is really cool.

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Help with scripting...
« Reply #17 on: October 11, 2019, 12:25:42 am »
Can the script give an item with armour like behavior?

Like for example, you hold a shield or some amulet, the script will graft the amulet which the soldier is holding with a secondary Armour like effect?

Like a Soldier is wearing Personal Armour for example.  Personal armour draw the codes from Armour.rul.

He's holding a stats boosting device, it also draw codes from  Armour.rul.

If this can be done, I can give the amulet in its armor.rul

    stats:
      psiStrength: 60

This will solve my problem.

It will also solve my stealth device problem too, with a few other codes I can find in the armour ruleset

First of all you should not add pis strength to make unit immune to psi because it will be like god when it will use psi-amp.

correct way is change:
Code: [Select]
armors:
  - type: STR_NONE_UC
    psiDefence:
      flatOne: 1000

or even better, use script version

Code: [Select]
armors:
  - type: STR_NONE_UC
    psiDefence: | #start of string, code will tread this as script
      return 1000;

Now you can look what variables are available (only `unit` for stat bonuses) and add logic to expand it.

wcho035

  • Guest
Re: Help with scripting...
« Reply #18 on: October 12, 2019, 04:32:54 am »
Hi Yankes,

The code has no effect at all in a battlescape mission.

Here is my coding so far.

items:
  - type: STR_PSISHIELD_DEFENSE
    size: 0.15
    costBuy: 1
    costSell: 1
    weight: 1
    bigSprite: 23
    floorSprite: 23
    handSprite: 1075
    battleType: 7   
    costThrow:
      energy: 12
      time: 30
    flatThrow:
      time: true
    armor: 35
    listOrder: 14948

units:    
  - type: STR_PSISHIELD_DEFENSE
    armor: STR_PSYSHEILDITEM_UC
armors:
  - type: STR_PSYSHEILDITEM_UC
    #stats:
    #  psiStrength: 60
    psiDefence:
      flatOne: 1000


I am using the item as a unit with armor. Personally, I am not sure this is even possible.

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Help with scripting...
« Reply #19 on: October 12, 2019, 12:57:03 pm »
`STR_PSYSHEILDITEM_UC` is not correct armor. AFAIR working armor need lot more properties than you used.

First of all I used standard armor that is defined in basic game AKA `STR_NONE_UC`, because of this I do not need define anything other that things that I want override.

You should start from working armor in game, if you create something that not work in first place its will be hard to my changes work in any way.

btw what point of this is?
Code: [Select]
units:   
  - type: STR_PSISHIELD_DEFENSE
    armor: STR_PSYSHEILDITEM_UC
Do you want create item or new unit?

Remember to start using any scripts you need first fully understand normal modding of OXC because script heavy relay on it.

wcho035

  • Guest
Re: Help with scripting...
« Reply #20 on: October 12, 2019, 01:50:43 pm »
Hi Yankes

Thanks for replying

A few messages before, as quote by you.

“Now you can look what variables are available (only `unit` for stat bonuses) and add logic to expand it.”

My interpretation of the sentence above was, if I use

Armor:
-STR_Somthing_UC

then in order to use the properties declare in the armor section, I have to put it in a unit to make it work. Hence my coding outcome and confusion.

Okay, from what I can understand of your message, you want me to use STR_NONE_UC to override something.

Armour is something an Soldier wears. How can an item have armour properties? I am looking for items to have stats effect. 

If you are pointing towards using armour that a soldier is wearing to boost his or her stats, I know how to do that.

I want this stat boost on an Item that a solder is holding, or he or she can consume to have a temp stats boost, which ever direction works.

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Help with scripting...
« Reply #21 on: October 12, 2019, 02:36:48 pm »
Armor is something completely separate to item. Only place where they link is HWD.

First of all:
Code: [Select]
Remember to start using any scripts you need first fully understand normal modding of OXC because script heavy relay on it.When I post something I rely on some convections and knowledge of OXC behaviour.

Example is `STR_NONE_UC` this is basic armor with your solders start in original XCOM1.

When I post:
Code: [Select]
armors:
  - type: STR_NONE_UC
    psiDefence:
      flatOne: 1000
You should add it to your mod (that have master XCOM1), start game with instant battle, choose some aliens with psi, and for your soldiers give different armors.

After that look if basic armor is indeed immune to PSI. And code I posted work exactly as I said (because I can do mistakes sometimes).

Without something like that I can't help you because I do not have enough time to check what you exactly do wrong.

wcho035

  • Guest
Re: Help with scripting...
« Reply #22 on: October 12, 2019, 03:07:23 pm »
"Remember to start using any scripts you need first fully understand normal modding of OXC because script heavy relay on it."

Some documentations on the methods available for your unit class would be very helpful in understanding of your scripts, beside examples. Also the messages are sometimes subject to misinterpretation and miss direction. The message I sent before is a very good example.

Anyway, I do understand `STR_NONE_UC` is the bare basic armor. What I do understand is, you are putting the

    psiDefence:
      flatOne: 1000

In that armor, all basic soldier came hire with it will have that effect. That is what I understand in what you are trying to achieve.

However, I just want an item that can boost psiStrength stats. Not your starting armour giving you the boost up Psidefence.

Anyway, I will do what you propose, I have a feeling it is what I always suspect it will do. Which it is completely different to the request I desired out of this.
« Last Edit: October 12, 2019, 03:11:46 pm by Precentor Apollyon »

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Help with scripting...
« Reply #23 on: October 12, 2019, 03:47:09 pm »
"Remember to start using any scripts you need first fully understand normal modding of OXC because script heavy relay on it."

Some documentations on the methods available for your unit class would be very helpful in understanding of your scripts, beside examples. Also the messages are sometimes subject to misinterpretation and miss direction. The message I sent before is a very good example.

No, I mean OXC rule sets and its behaviour not my scripts, if you do not understand it you will not understand what scripts do.

This: https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)


wcho035

  • Guest
Re: Help with scripting...
« Reply #24 on: October 12, 2019, 04:38:41 pm »
You miss understood my sentence. The scripting language you graciously made available for us all to extend from what is not available in the rulesets.

Link

https://openxcom.org/forum/index.php?topic=5245.0

It would be a lot easier if you have documentation on the methods available for unit, besides just examples. So it is more accessible for a new starter like myself at trying to understand your scripting language.

OXC rule sets and its behavior are far more straight forward to understand because of the excellent and diligent documentation.

Anyway, thank you for your help Yankes. I will try to experiment more for what I seek. I just hope that I find my direction.
« Last Edit: October 12, 2019, 04:43:57 pm by Precentor Apollyon »

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Help with scripting...
« Reply #25 on: October 12, 2019, 05:27:29 pm »
I already said where you can get all script function/variables, how many times I need repeat this?

Use verbose logging.

wcho035

  • Guest
Re: Help with scripting...
« Reply #26 on: October 12, 2019, 05:58:49 pm »
I have found my solution. Thank you kindly again Yankes, for your time and help on this.