OpenXcom Forum

Modding => OXCE Support => OpenXcom Extended => OXCE Support Y-scripts => Topic started by: wcho035 on October 06, 2019, 10:09:19 pm

Title: [Solved] Help with scripting...
Post by: wcho035 on October 06, 2019, 10:09:19 pm
Hi, I am attempting to modify Yankee script for Piratez for my mod.
After looking through it the coding is straight forward enough.

However, there are a few things in it are not properly define if anyone can help.

1) There are 0-19 resist type, can anyone tell me what each is and does stacking them on an item provide combine boosting/ buff effects?

2) I need to modify a section of the script for ITEM_STUN_PER_TURN; for Psi-defense.

What is the proper variable or declaration in lower or upper case format like is it Psi-Defense? psiDefense? for example.. I can declare without generating syntax errors?

Thank you all!
Title: Re: Help with scripting...
Post by: ohartenstein23 on October 06, 2019, 10:23:32 pm
The resist types you can look up in the language files to match the number to the type. The 'vanilla' ones, 0-9, have some hardcoded behavior such as high-explosive/concussive being AoE, 50%-150% roll by default. Those you can look up on ufopaedia.org. All the rest only do anything different if told to do so by an item's damageAlter.

You can get the documentation for all of the scripts by running the game after setting "debug: true" and "verboseLogging: true" and then checking the openxcom.log file. I also keep a version of this file on GitHub if you want to reference that (https://raw.githubusercontent.com/ohartenstein23/Yankes-Scripting/master/yankesScript.txt).
Title: Re: Help with scripting...
Post by: wcho035 on October 06, 2019, 10:54:27 pm
Hi Ohartenstein23.

Thank you for your kindly for the reply.

I found the answer to my second question (I hope) in github.

For the resist 0-19 question, can’t find anything in the language files from OXCE.

Is there anywhere else I can find those references?

Thanks again!

Title: Re: Help with scripting...
Post by: The Martian on October 06, 2019, 11:53:04 pm
I'm not sure if this is what you are looking for, but perhaps it will be useful if you are not already aware of it:
https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Item_Damage_Types (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Item_Damage_Types)
Title: Re: Help with scripting...
Post by: wcho035 on October 07, 2019, 12:27:20 am
Thanks Martian, it is what I am looking for, it make sense now. It is similar to damage type but resist damage. I just remember OXCE has up to 18 of these.
Title: Re: Help with scripting...
Post by: wcho035 on October 07, 2019, 01:06:50 pm
Okay, I have whip up a prototype Script. However, it doesn't work.

Can anyone help?

 
Title: Re: Help with scripting...
Post by: Meridian on October 07, 2019, 01:32:15 pm
Do you even realize how ridiculous your request is?

You give us 2000+ lines of scripts and absolutely NO description what's wrong or how to reproduce it... I don't even have words for this.
Title: Re: Help with scripting...
Post by: wcho035 on October 07, 2019, 01:59:35 pm
Sorry Meridian. I was in a rush, not the time to post more details.

I am trying to create two items in my game. One is a personal energy shield similar to Piratez or Dioxine's mod. It can be prime and then generate a protection field. Instead of the shield as a melee weapon. I used the motion scanner and turn it into a device that can turn on or off energy shield protection.

However, the energy shield did not work, after it is prime. I tested it on the original version from Dioxine and now my motion scanner adaptation.  So, I am not 100% sure where is the problem.

In the script, everything after "extend" is a straight copy from Yankee's script in Dioxine's Piratez mod.

With the exception of.

          item.getRuleItem itemRuleset;
          itemRuleset.getTag changePerTurn Tag.ITEM_PSISTRENGTH_PER_TURN;
          unit.getPsiStrength currentValue;
          unit.getPsiStrengthMax maxValue;
          set changedValue currentValue;
          add changedValue changePerTurn;
          limit changedValue 0 maxValue;
          unit.setStun changedValue;

In line 1321.

The second device, the Psi-Shield, I was hoping to use ITEM_PSISTRENGTH_PER_TURN to boost the soldier's psi-defense stats.
This never seems to have any effect at all. Before, I uses Dioxine's original item script for STR_DRUG_DISPENSOR, now I modded it to my own version using a motion scanner to prime and turn on the Psi strength. It didn't work not surprisingly.

I was hopping someone experience modding with Yankee's scripts to help correct which ever it is not working in my script.

Sorry for the lack of details,

Title: Re: Help with scripting...
Post by: Yankes on October 07, 2019, 08:35:18 pm
could you say precisely what effect you want have? And what exactly result you get? "do not work" is not answer. Do you get error or something in logs?


Title: Re: Help with scripting...
Post by: wcho035 on October 07, 2019, 11:16:46 pm
Okay, I have no error in running the above script. The two items are tested in battlescape, it just that their desire effects are not functioning.

E.g I tested the personal shield by priming it, the plasma shot from alien heavy plasma turn soldier into chowder meat.

Same with the psi strength boosting device, in battlescape, it doesn’t boost the soldier’s stats, passive or otherwise.

Before changing the code like it is now, using these device like motion sensors. I had used the same exact coding like it’s from Piratez. Same results and outcome, either I am missing something in my mod or the script need something extra.

Thanks you all kindly for helping
Title: Re: Help with scripting...
Post by: Yankes on October 08, 2019, 12:12:27 am
E.g I tested the personal shield by priming it, the plasma shot from alien heavy plasma turn soldier into chowder meat.
This mean script do not work (if you do not break completely original script behaviour). Do you checks logs for script errors?

btw what you wated using `unit.setStun changedValue;`? This change stun value in unit.

First for all if you start with script you should do small steps, like:
a) make script that run on unit creation and make solder psi immune.
b) test if he is psi immune
c) move this logic to other script
d) test if it still work
e) alter script to have more interesting behaviour (instead of total immune give some bigger resistances)
f) test it again
g) use `debug_log "some text" unit "variable" changePerTurn;` (need fresh version of OXCE) to log some script behavior
Title: Re: Help with scripting...
Post by: wcho035 on October 08, 2019, 01:55:59 am
Hi Yankes, I have updated the small error I have overlooked. No change in game or item behaviour. I will attempt to generate some error logs when I test it again
Title: Re: Help with scripting...
Post by: Meridian on October 08, 2019, 09:57:40 am
The nickname is Yankes btw, not Yankee.
Title: Re: Help with scripting...
Post by: wcho035 on October 08, 2019, 10:26:15 am
Sorry, miss type, phone butter fingers. Will correct.
Title: Re: Help with scripting...
Post by: wcho035 on October 08, 2019, 10:51:50 am
Here is the logs from my test game run today.

I am not sure what I am looking for. However, within the logs, I chance upon these lines.

[08-10-2019_14-06-20]   [ERROR]   Unknown argument 'Tag.ITEM_PSISTRENGTH_PER_TURN'
[08-10-2019_14-06-20]   [ERROR]   Error in matching arguments for operator 'RuleItem.getTag'
[08-10-2019_14-06-20]   [ERROR]   Error in parsing script 'newTurnItem' for 'Global Event Script': invalid operation in line: 'itemRuleset.getTag changePerTurn Tag.ITEM_PSISTRENGTH_PER_TURN;'
[08-10-2019_14-06-20]   [ERROR]   Error in tags: 'ITEM_PSISTRENGTH_PER_TURN' unknown tag name not defined in current file

So, this mean the script is not communicating with the C++ codes?

Also to confirm I got the Energy shield working. The item's shield health was low.. that's why I didn't see any effects. PsiStrength is still not working however.

Hi Yankes,

For

a) make script that run on unit creation and make solder psi immune.

I would not know how to start on this.
Title: Re: Help with scripting...
Post by: wcho035 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


Title: Re: Help with scripting...
Post by: The Martian 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.
Title: Re: Help with scripting...
Post by: Yankes 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.
Title: Re: Help with scripting...
Post by: wcho035 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.
Title: Re: Help with scripting...
Post by: Yankes 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.
Title: Re: Help with scripting...
Post by: wcho035 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.
Title: Re: Help with scripting...
Post by: Yankes 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.
Title: Re: Help with scripting...
Post by: wcho035 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.
Title: Re: Help with scripting...
Post by: Yankes 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)

Title: Re: Help with scripting...
Post by: wcho035 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.
Title: Re: Help with scripting...
Post by: Yankes 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.
Title: Re: Help with scripting...
Post by: wcho035 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.