body.txt => body.ini

Get some help with creating maps or modding.
Need a map editor or other tools, look here!
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

body.txt => body.ini

Post by NoQ »

Does anybody have an automated converter to turn 2.3/3.1-style body.txt file into a 3.2-style body.ini? If not, how was the body.ini file made, anyway?
Cause i wanted to run it on the Contingency mod to try it out on master.

If nobody has it, making a shell script for this shouldn't be hard, i could try.
Of course it has to look up the names.txt file as well.
User avatar
Iluvalar
Regular
Regular
Posts: 1828
Joined: 02 Oct 2010, 18:44

Re: body.txt => body.ini

Post by Iluvalar »

No ! I have it, or at least I have the scripts to create the converter speedily. But I wont. The reason being : it multiply by 10x the size of the mods unnecessarily.

Asking the devs for the removal of body.ini would be faster and saner than to ask them for a script.
Heretic 2.3 improver and proud of it.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: body.txt => body.ini

Post by NoQ »

faster
srsly?

I repeat: i'm not asking anybody to make a script, i can make one myself, i just don't want to re-do that if it already exists.
User avatar
Iluvalar
Regular
Regular
Posts: 1828
Joined: 02 Oct 2010, 18:44

Re: body.txt => body.ini

Post by Iluvalar »

Per asked me to do it, so I suppose nobody have one...

I guess, diy is always faster than asking for devs XD.

But then, reverting to the 3.1 body reader in your master should still be easier than to write the converting script. (for .ini files that will probably be reverted imho)
Heretic 2.3 improver and proud of it.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: body.txt => body.ini

Post by Per »

I made one out of sed, arp and grep, but I don't have it anymore.

I don't think you can just revert without losing functionality.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: body.txt => body.ini

Post by NoQ »

Ok, will have a try soon (:
User avatar
aubergine
Professional
Professional
Posts: 3462
Joined: 10 Oct 2010, 00:58

Re: body.txt => body.ini

Post by aubergine »

If you make a converter, please let me know as I'll add links to the modding wiki.

I documented the two files a while back if that's any use: body.txt & body.ini

EDIT: Hrm, looks like I didn't actually document body.txt and just pasted in a link to some existing docs. Will try and get my docs updated in next 48 hours.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: body.txt => body.ini

Post by NoQ »

Ok this almost works. Now, how do i guess droidType? I mean, it can't be guessed, right? That's exactly what we loose when we try to get back to .txt?

Code: Select all

#!/bin/bash
BODYTXT="$1"
NAMESTXT="$2"

function catcmd {
	cat $BODYTXT | tr " " "_" | tr "," " " | tail -n +2 | tr -d "\r"
}

function ntharg {
	n=$(( ($1 + 1) ))
	echo ${!n}
}

function getarg {
	echo `ntharg $*` | tr "_" " "
}

LIST=`catcmd | awk '{print $1}'`

for body in $LIST; do
	echo "[$body]"
	name=`cat $NAMESTXT | tr "\t" " " | tr -s [:blank:] | grep ^$body" " | sed s/"$body"// | tr -d '()_'`
	echo "name ="$name
	stats=`catcmd | grep ^$body`
	echo "size = "`getarg 3 $stats`
	echo "buildPower = "`getarg 4 $stats`
	echo "buildPoints = "`getarg 5 $stats`
	echo "weight = "`getarg 6 $stats`
	echo "hitpoints = "`getarg 7 $stats`
	echo "model = "`getarg 8 $stats | tr " " "_"`
	echo "weaponSlots = "`getarg 10 $stats`
	echo "powerOutput = "`getarg 11 $stats`
	echo "armourKinetic = "`getarg 12 $stats`
	echo "armourHeat = "`getarg 13 $stats`
	flameModel=`getarg 24 $stats`;
	if [ "$flameModel" != "0" ]; then
		echo "flameModel = "$flameModel
	fi
	designable=`getarg 25 $stats`
	if [ "$designable" = "1" ]; then
		echo "designable = true"
	else
		echo "designable = false"
	fi
	if [ "`echo $name | grep Transport`" != "" ]; then
		echo "droidType = TRANSPORTER"
	elif [ "`echo $name | grep Engineer`" != "" ]; then
		echo "droidType = CYBORG_CONSTRUCT"
	elif [ "`echo $name | grep Mechanic`" != "" ]; then
		echo "droidType = CYBORG_REPAIR"
	elif [ "`echo $body | grep Cyb | grep Hvy`" != "" ]; then
		echo "droidType = CYBORG_SUPER"
	elif [ "`echo $body | grep Cyb`" != "" ]; then
		echo "droidType = CYBORG"
	elif [ "`echo $body | grep Person`" != "" ]; then
		echo "droidType = PERSON"
	fi
	echo
done
Invocation example:

Code: Select all

~/bin/script.sh stats/body.txt messages/strings/names.txt > stats/body.ini
upd: now this works with the current data, but guessing droidType based on some other mod's data may still be quite inaccurate.

upd: fixed some dos-style newline trouble that caused the script to fail to understand the "designable" property, which is the last one in every line.