project-navigation
Personal tools

Author Topic: UFO scripting: guide to changing scriptable parameters  (Read 19105 times)

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
UFO scripting: guide to changing scriptable parameters
« on: June 17, 2012, 03:03:48 pm »
A lot of things in UFO:AI can be easily scripted using simple text files. This topic will tell you where to make changes for different parameters. Only post in this thread to request where to find a parameter you want to change. All other posts will be removed.


What are script files and how do I change them?
UFO:AI's script files can be found in the /base/ufos/ folder under your installation directory. This is where the game's executable and data is stored.

If you don't have a /base/ufos/ folder, you probably have several .pk3 files in /base/. You will need to unpack 0ufos.pk3 to view and modify the UFO files.

Note: On Windows systems, save games and other data is often stored in a different directory, also under a /base/ folder. This is not the directory you want to look in.


How can I change a weapon's damage, accuracy, etc.?
You will find all of the weapons stored in /base/ufos/weapon_*.ufo files. Our wiki contains descriptions of weapon script parameters.


How can I reduce/increase the frequency of UFOs?
You will find a campaign scripting parameter called uforeductionrate in /base/ufos/campaign.ufo. Our wiki contains further details on how this parameter is used.

Note: This feature is only available in version 2.5 and above. It was added to 2.5's development version on 17 June 2012.


How can I reduce/increase the speed of research?
Research is controlled in two places. If you would like to adjust the research time required for a single item, you should look at /base/ufos/research.ufo, find the appropriate research item and change the time) parameter. Our wiki contains further details on research definitions.

If you would like to speed up or slow down all research, you should look at /base/ufos/campaign.ufo and change the researchrate parameter. Our wiki contains further details on how this parameter is used.

Note: The research speed parameter in campaign.ufo is only available in version 2.5 and above. It was added to 2.5's development version on 17 June 2012.


How can I make my new recruits have better stats?
You will find character templates stored in /base/ufos/team_templates.ufo. Our wiki contains further details on how to set their stats.


How can I change the price and stats of my aircraft?
You will find aircraft defined in /base/ufos/aircraftmanagement.ufo. Our wiki contains further details on how to set their price and stats.


How can I change the cost of my base buildings and installations?
You will find base buildings and external installations defined in /base/ufos/basemanagement.ufo. Our wiki contains further details on how to change the costs.


How can I change the layout of my first base?
The base template is defined in /base/ufos/basemanagement.ufo. Our wiki contains further details on base building parameters.


How can I make a certain map stop appearing in my campaign?
The maps are defined in /base/ufos/maps.ufo. To prevent a map from appearing in the campaign, add a campaign parameter set to false. Our wiki contains further details on map parameters.

Warning: Map usage in the campaign is determined based on a set of culture, terrain and population parameters for every spot on the globe. If you remove the only map available in that combination, you are likely to get the backup ufo_crash map which already appears frequently in the campaign.


How can I change the frequency that alien weapons appear?
The percentage chance that weapons will appear in a mission are defined in /base/ufos/equipment_missions.ufo.
« Last Edit: April 22, 2014, 11:07:41 am by H-Hour »

Offline NicSO

  • Rookie
  • ***
  • Posts: 83
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #1 on: February 11, 2014, 03:09:06 pm »
Is it possible to change % of appearances of alien weapons?

In 2.5 I encountered plasma pistol only in first few missions and never again + kerrblade never occured.

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #2 on: February 11, 2014, 08:33:16 pm »
Is it possible to change % of appearances of alien weapons?

/base/ufos/equipment_missions.ufo is the place to go.

In 2.5 I encountered plasma pistol only in first few missions and never again + kerrblade never occured.

Yep. Thats a problem we met recently.
1st -there was a problem hidden within the auto-equip code (see bugreport). Thanks to DarkRain the fix is already in place.
2nd - The related script files were changed when H-Hour made a huge weapon rebalancing before 2.5 branched. Apparently this needs some further adjustments. For the Kerrblade I made a quick-fix, that should also already work in 2.5.


Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #3 on: May 09, 2014, 02:11:20 pm »
I was looking into the ui/*.ufo scripts, more specifically the scripts controlling the management of soldier equipment. I wanted to create a way to add the selected equipment to all soldiers in the soldierslist panel. However I seem to get stuck since I cannot figure out how to iterate the nodes in the panel. Is there a way to iterate a set of nodes? Are there any examples of this type of behaviour?

I appreciate any help/hints.

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2560
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #4 on: May 10, 2014, 02:06:19 pm »
I was looking into the ui/*.ufo scripts, more specifically the scripts controlling the management of soldier equipment. I wanted to create a way to add the selected equipment to all soldiers in the soldierslist panel. However I seem to get stuck since I cannot figure out how to iterate the nodes in the panel. Is there a way to iterate a set of nodes? Are there any examples of this type of behaviour?

I appreciate any help/hints.

Unfortunately currently there is no way to iterate trough nodes of a panel from the UI scripts. In some cases you could do a counting loop 0..n and assemble node ids from it using the <injection> method but I think it would not work for the soldierlist as it is uses the UCN numbers (IIRC) which are not continuous.

For such functionality you need to write a C callback now. :(

I would be happy to see such a foreach loop possibility in the UI Engine though. If you could implement it, I would be happy to add it to the codebase!

-geever

Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #5 on: May 11, 2014, 10:01:26 pm »
For such functionality you need to write a C callback now. :(

I would be happy to see such a foreach loop possibility in the UI Engine though. If you could implement it, I would be happy to add it to the codebase!

This at least confirms what I already guessed. Unfortunately I only recently started looking at the code base, so I guess it will be a while before I actually have something working.

Based on you mentioning the "UI engine", are you proposing a 'foreach' solution in the script language? Would it not be easier to implement an iterator node that iterates the children of a target node and executes a confunc? This way, if you need an iterator you create a hidden node (e.g. the data node) and use it.

Offline cannonfodder558

  • Rookie
  • ***
  • Posts: 27
    • View Profile
Re: graphical effects/colour of encased plasma rounds
« Reply #6 on: February 13, 2015, 03:09:04 pm »
Hello.

I'd like shots of ep-rounds fired by Phalanx weaponry (the assault rifle, for a beginning) to have the neon blueish colour and aura (not shape) of shots from the alien plasma rifle in battlescape. 8)

Playing 2.5 stable on win 7 32 bit.

Could you please tell me where to find the values of the alien plasma rifle / colour of shots (if this involves only the colour? If not, I'd appreciate your hints), and the values of the assault rifle/ colour of shots of ep rounds?
And secondly of sniper rifle/ machine gun ep shots, too?

I don't mind if the colour can't be changed by ammotype. If not, I'd like to change the colour of shots in general. I won't use standard ammo any more.

I'd also appreciate you tell me in advance if the proposed change is possible, using the information provided here.

I've no clue of coding/ modelling. Hope it can be done by editing values in files with a text editor.

Thank you very much in advance.

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #7 on: February 13, 2015, 06:05:08 pm »
I think the /ufos/ptl_weaponsfx should be a good place to start.

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #8 on: February 14, 2015, 09:55:17 am »
The ammo def describes what particle to use for it. The particle def describes what pic to use.
For the ep-rounds the ammo def can be found in /base/ufos/weapon_plasma.ufo line 372ff (2.6-dev that is) using the 'bullet' - particle (the same one as the normal ammo), which again is defined in  /ufos/ptl_weaponsfx.ufo line 148ff using the image /base/pics/sfx/weapons/bullet1.

The way to go for you would be to make a copy of the particle bullet, naming it like 'bullet_ep', than change the ep ammo to use this particle instead of the normal one. In your new bullet_ep def changing the value of the 'image' parameter to "sfx/weapons/plasmapulse" should result in the assault rifle ep-rounds shown the same way as the plasma shots.

Edit: You might also want to adapt the ligtcolor and lightintensity parameters.
« Last Edit: February 14, 2015, 10:08:06 am by ShipIt »

Offline cannonfodder558

  • Rookie
  • ***
  • Posts: 27
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #9 on: February 14, 2015, 07:13:29 pm »
Thanks a lot for your help, coming into this modding stuff.

It seems that the folder structure and file names are completly different in 2.5 stable.
But I'll try finding my way using this:
http://ufoai.org/wiki/UFO-Scripts

I'll sent pics if my soldiers suddenly have pointed triangular ears, three legs and a green skin  ;)).

Have a nice day.
« Last Edit: February 16, 2015, 02:24:44 pm by cannonfodder558 »

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #10 on: February 15, 2015, 09:15:20 am »
The way I described you give the ep rounds its own projectiles, which you than can change as you like.

As for the files, there were no changes in the structure in ages. Oc, if you are using the installer, you need to unzip the .pk3 files as the very first step.

Offline cannonfodder558

  • Rookie
  • ***
  • Posts: 27
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #11 on: February 15, 2015, 09:24:11 am »
Ah, yes. Thanks.

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #12 on: February 15, 2015, 09:40:47 am »
I am not a 2D-artist by any means, but I think what you want is something like that -

Offline cannonfodder558

  • Rookie
  • ***
  • Posts: 27
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #13 on: February 16, 2015, 12:20:01 pm »
Hi. I like the colour.

Done it. Yeah, baby!!! BURN!
Thanks a lot again, ShipIt. Understood a bit of the basic mechanism.
Cool. Didn't think it's done so fast on my own, after your help.

As the shots are so fast I'm not sure if they are still cuboid - as the bullets seem to be by default -, or more oval like the alien plasmapulse. But cool, nonetheless.

As far as I understood, I would have to create a new pic to mix colour and shape.

If anybody wants it, too, I'd be happy to share it. But I'd need some help to put the extracted ufo folder with the modified files back into a pk3 in the right way (using winzip7 testversion => how at all, compression level, what else...).
« Last Edit: February 16, 2015, 03:15:54 pm by cannonfodder558 »

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: UFO scripting: guide to changing scriptable parameters
« Reply #14 on: February 19, 2015, 07:51:52 pm »
If anybody wants it, too, I'd be happy to share it. But I'd need some help to put the extracted ufo folder with the modified files back into a pk3 in the right way (using winzip7 testversion => how at all, compression level, what else...).

You just need to share the modified/added files. No need to compress them.