project-navigation
Personal tools

Author Topic: Couple of questions  (Read 10930 times)

Offline Neonin

  • Rookie
  • ***
  • Posts: 63
    • View Profile
Couple of questions
« on: July 06, 2012, 11:36:06 am »
Just a couple of questions I have regarding the extent of modding capabilities currently available, so I know how far I can go in editing stuff without touching the code files and recompiling:

1 - Is there any way of editing the files that contain ufopaedia text and mail messages? I've found the .mo files in the i18n directory but it doesn't edit properly with Notepad or Wordpad.

2 - Is it possible to add new base defence buildings using tweaked, existing models? I tried and had the building showing up no problem but ran into an issue with assigning the weaponry.

3 - Are the skills hard-coded or is it possible to change them? I can change the name they appear with but the equipment window still shows Skill: Sniper even after it's been changed to Pistols because it seems to be pulling the information from the weapon script file where the skill type is set for that firedef rather than a string from somewhere else.

Having a blast playing around with the modding opportunities even with these queries, so thanks for adding the possibility to the game! :D

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: Couple of questions
« Reply #1 on: July 06, 2012, 12:27:02 pm »
1 - Is there any way of editing the files that contain ufopaedia text and mail messages? I've found the .mo files in the i18n directory but it doesn't edit properly with Notepad or Wordpad.

This is something we've been working on improving, but I'm not sure if it's there yet. Currently, all text is uncompiled .po files which are then compiled into .mo files used by the game. You can edit the .po files but you would have to distribute new, compiled .mo files with your mod -- and these contain all the translations as well, so could limit your mod to just English.

We're hoping to make it possible to put this text directly into the script files or allowing you to use .po files for a mod, but I don't think this has been implemented yet.

2 - Is it possible to add new base defence buildings using tweaked, existing models? I tried and had the building showing up no problem but ran into an issue with assigning the weaponry.

Hmm, I suspect this is a more tricky issue because the base buildings are integrated into click commands that open windows and are used in the backend. That said, it looks like it may be possible to add another laser OR missile battery building. The code for the missile battery is:

Code: [Select]
building building_missile
{
name "_Missile Battery"
image "base/missile"
fixcosts 10000
depends building_command // need to know where to shoot
type "missile"
build_time 3
varcosts 5000
map_name "missile"
tech rs_building_missile
max_count 4
onconstruct "add_battery missile"
onenable "basedef_updatebatteries missile"
ondisable "basedef_updatebatteries missile"
ondestroy "remove_battery missile"
}

Just guessing, but you may be able to add a building like this and just change max_count if you wanted to add more missile batteries per building. But I don't think you could create a new "type" (laser or missile) as that would require changes to the backend.

3 - Are the skills hard-coded or is it possible to change them? I can change the name they appear with but the equipment window still shows Skill: Sniper even after it's been changed to Pistols because it seems to be pulling the information from the weapon script file where the skill type is set for that firedef rather than a string from somewhere else.

Not quite sure if I'm understanding you. The soldier skills -- the possible skills that each soldier has -- are hard coded because they interact with all sorts of things in the battlescape code. I don't think it's possible to create a new skill.

However, you can change which of the existing skills each firemode uses. Here's the sniper weapon and ammo firemodes with comments (/* comment */) to explain a few things:

Code: [Select]
item sniper
{
name "_Sniper Rifle"
model "weapons/sniper/sniper"
weapon true
/* This type parameter does not effect firemode or skill. It only effects how the weapon will be held by the model in-game. */
type "rifle"
animationindex 1
holdtwohanded false
firetwohanded true
shape "2 0 3 1"
shape "0 1 5 1"
center "9 0 3"
scale 1.05
ammo 8
reload 15
reloadsound "weapons/reload-sniper"
price 1300
size 60
is_primary true
}

item sniper_ammo
{
name "_Sniper Rifle Magazine"
model "weapons/sniper/sniper_clip"
type "ammo"
animationindex 0
shape "0 0 1 2"
center "0 0 0"
scale 1.15
price 85
size 8
is_primary true
dmgtype "normal"

weapon_mod
{
weapon sniper
firedef
{
name "_Snap Shot"
/* This skill parameter is where you would change it to one of the pre-existing weapon skill types */
skill "assault"
projtl bullet_sniper
impact bulletImpact
hitbody null
firesnd "weapons/bullet-sniper"
impsnd "impact/bullet-impact"
bodysnd "impact/bullet-bodyimpact"
speed 3600
spread "2.5 2.5"
crouch 1
range 100
shots 1
ammo 1
time 15
damage "130 20"
dmgweight "normal_medium"
reaction true
throughwall 1
}
firedef
{
name "_Aimed Shot"
/* This skill parameter is where you would change it to one of the pre-existing weapon skill types */
skill "sniper"
projtl bullet_sniper
impact bulletImpact
hitbody null
firesnd "weapons/bullet-sniper"
impsnd "impact/bullet-impact"
bodysnd "impact/bullet-bodyimpact"
speed 3600
spread "0.85 0.85"
crouch 0.6
range 100
shots 1
ammo 1
time 20
damage "130 20"
dmgweight "normal_medium"
reaction true
throughwall 1
}
}
}

You can see many of the weapon settings defined in our wiki.
« Last Edit: July 06, 2012, 12:50:56 pm by H-Hour »

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Couple of questions
« Reply #2 on: July 06, 2012, 12:43:23 pm »
2 - Is it possible to add new base defence buildings using tweaked, existing models? I tried and had the building showing up no problem but ran into an issue with assigning the weaponry.

Could you explain it in details? It's not 100% clear what you wanted to achieve, maybe with patches, and details I could help.

-geever

Offline Neonin

  • Rookie
  • ***
  • Posts: 63
    • View Profile
Re: Couple of questions
« Reply #3 on: July 06, 2012, 01:12:57 pm »
Thanks for the responses guys :) I think you've cleared most things up, I'm going to have a fiddle with base defence buildings again and see if I can bodge a workaround using existing types. Basically I was trying to add a new type of battery, I think if I use the existing ones I can get it to work.

As for the skills, here's an example of what I was on about:



As you can see, in the UI I changed how the different skills appear in the soldier skill panels that show up in the game (aircraft equip screen, hire screen, base defence pop-up screen) and then modified the firedef to use the skill I wanted (so pistol weapons use the sniper skill, sniper now uses assault which is renamed to Rifles etc) but the weapon description window shows what skill you've set in the firedef because it pulls it straight from the weapons file and there doesn't seem to be any way for me to change how the string turns up in the UI.

I shall keep playing around with it, though if the skills affect hidden variables in the game engine itself I might revert that change.

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Couple of questions
« Reply #4 on: July 06, 2012, 01:31:08 pm »
...in the UI I changed how the different skills appear in the soldier skill panels that show up in the game (aircraft equip screen, hire screen, base defence pop-up screen) and then modified the firedef to use the skill

Maybe  this is the problem:
http://ufoai.git.sourceforge.net/git/gitweb.cgi?p=ufoai/ufoai;a=blob;f=src/client/cl_inventory_callbacks.cpp#l40

Weapon skills are hardcoded. If you only want to rename them on the UI you can probably do it by translating (translate skill_sniper to Pistols).

-geever

Offline Neonin

  • Rookie
  • ***
  • Posts: 63
    • View Profile
Re: Couple of questions
« Reply #5 on: July 06, 2012, 02:23:51 pm »
If you only want to rename them on the UI you can probably do it by translating (translate skill_sniper to Pistols).

That sounds like what I was trying to do. Is that possible in a script file? I need to find the UI one that calls up that information too in that case!

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Couple of questions
« Reply #6 on: July 06, 2012, 03:10:52 pm »
That sounds like what I was trying to do. Is that possible in a script file? I need to find the UI one that calls up that information too in that case!

By translating, I mean using the translation system to convert the names, for that:
  • download the po file: English
  • get a poedit
  • edit the po file and ask poedit to compile it to a mo (it may does it automatically by default)
  • replace the mo file in the game

-geever

Offline Neonin

  • Rookie
  • ***
  • Posts: 63
    • View Profile
Re: Couple of questions
« Reply #7 on: July 06, 2012, 04:38:15 pm »
Oh I see! Sorry, feeling a bit dense today...

If that process will let me edit the text in the game without recompiling the whole thing that'll be exactly what I need for the skill and the tech descriptions because I can just distribute the .mo file with the mod, assuming that putting it in the mod directory (so mod/neotweaks/i18n/uk/LC_MESSAGES/ufoai.mo) will work. That'll certainly be better than a load of techs and items with "No description" in the UFOpaedia. Thanks geever! :)

Offline Neonin

  • Rookie
  • ***
  • Posts: 63
    • View Profile
Re: Couple of questions
« Reply #8 on: July 07, 2012, 01:32:22 am »
Ok, after looking at the base defence buildings a bit more and playing around with the scripts for a bit I've discovered it IS possible to add new batteries to existing buildings, so for example I can make the Laser Battery building pick from a bunch of different possible weapons and each one has its own characteristics. The inability to add a "type" other than laser or missile stops you from creating a building specifically for a certain type of weapon though, but at least it's possible to add some of what I wanted! :)

Offline Neonin

  • Rookie
  • ***
  • Posts: 63
    • View Profile
Re: Couple of questions
« Reply #9 on: July 07, 2012, 06:48:10 pm »
This is something we've been working on improving, but I'm not sure if it's there yet. Currently, all text is uncompiled .po files which are then compiled into .mo files used by the game. You can edit the .po files but you would have to distribute new, compiled .mo files with your mod -- and these contain all the translations as well, so could limit your mod to just English.

While I'm not too concerned with limiting the mod to English (at least with regards to the descriptions etc) I've had a look at editing the .po file to make a.mo file and while it's possible, you have to overwrite the one in the base/i18n folder because the game ignores anything in the mod/neotweaks/i18n folder. As this takes the mod beyond the scope of script changes and would mean the descriptions took effect even with an unmodded game, I shall be leaving them out for now. Hopefully some smart person will figure out a way to let modders edit it without overwriting unmodded game files at some point :)

Also, editing the .po file only allows you to change the current strings, not add new ones as far as I can see, so no new tech descriptions etc as it currently stands.

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Couple of questions
« Reply #10 on: July 07, 2012, 06:54:25 pm »
Also, editing the .po file only allows you to change the current strings, not add new ones as far as I can see, so no new tech descriptions etc as it currently stands.

You can add strings too. (Not sure if poedit supports it though.

-geever

Offline Neonin

  • Rookie
  • ***
  • Posts: 63
    • View Profile
Re: Couple of questions
« Reply #11 on: July 07, 2012, 07:10:24 pm »
Ahh yes, if you open up the .po file in Wordpad you can add stuff in from the looks of things. Now all you guys need to do is make the game pay attention to a .mo file in a mod folder :P

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: Couple of questions
« Reply #12 on: July 07, 2012, 07:35:42 pm »
Don't use Wordpad. Use a basic text editor, like Notepad or Notepad++ if you want some more features. Normal word processors or document editors like Wordpad can insert stuff into the text that can make it incompatible with the game.

Offline Neonin

  • Rookie
  • ***
  • Posts: 63
    • View Profile
Re: Couple of questions
« Reply #13 on: July 07, 2012, 10:11:08 pm »
Wordpad was just the thing I used to open the .po file and have a look, not sure why cause I normally use Notepad :) Thanks for the warning though, I'll make doubly sure from now on!

Offline Duque Atreides

  • Rookie
  • ***
  • Posts: 80
    • View Profile
Re: Couple of questions
« Reply #14 on: July 15, 2012, 08:39:14 pm »
I opened a .po file http://ufoai.git.sourceforge.net/git/gitweb.cgi?p=ufoai/ufoai;a=blob_plain;f=src/po/ufoai-en.po with Notepad ++, to create new features. But, when i save the file and try to open it with Poedit, it send me the message "failed to conver file.....to unicode.

What im doing bad?