entities.def -> entities.ent convereter script beginning
authorRudolf Polzer <divverent@alientrap.org>
Sun, 5 Dec 2010 15:47:37 +0000 (16:47 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 5 Dec 2010 15:47:37 +0000 (16:47 +0100)
scripts/entities.def2ent
scripts/turrets.def

index 9de5aa2c6cb5379cb63831a792ec64b8acfb5342..d7e11f2e1e6ce42d245b39550b7e3ac62f9fe7c1 100644 (file)
@@ -3,6 +3,105 @@
 use strict;
 use warnings;
 
+my %types;
+my %types_override;
+
+open my $fh, '<', '../../xonotic-data.pk3dir/qcsrc/server/qc.asm'
+       or die "must have qc.asm in server qc";
+while(<$fh>)
+{
+       chomp;
+       if(/^\.(\w+) (\w+);$/)
+       {
+               if($1 eq "float")
+               {
+                       $types{$2} = "real";
+               }
+               elsif($1 eq "string")
+               {
+                       $types{$2} = "string";
+               }
+               elsif($1 eq "vector")
+               {
+                       $types{$2} = "real3";
+               }
+       }
+}
+
+# specialization
+$types{angle} = "angle";
+$types{angles} = "angles";
+$types{_color} = "color";
+$types{colormod} = "color";
+$types{killtarget} = "target";
+$types{model2} = "model";
+$types{model} = "model";
+$types{noise} = "sound";
+$types{noise1} = "sound";
+$types{noise2} = "sound";
+$types{noise3} = "sound";
+$types{target2} = "target";
+$types{target3} = "target";
+$types{target4} = "target";
+$types{targetname} = "targetname";
+$types{target} = "target";
+
+# missing definition in QC, q3map2 only
+$types{_ambient} = "real";
+$types{_anglescale} = "real";
+$types{author} = "string";
+$types{_blocksize} = "integer3";
+$types{_castshadows} = "boolean";
+$types{_celshader} = "texture";
+$types{_clonename} = "targetname";
+$types{_clone} = "target";
+$types{_description} = "string";
+$types{_deviance} = "real";
+$types{fade} = "real";
+$types{_farplanedist} = "real";
+$types{_filterradius} = "real";
+$types{_floodlight} = "string";
+$types{_frame} = "real";
+$types{gridsize} = "integer3";
+$types{_ignoreleaks} = "boolean";
+$types{_indexmap} = "texture";
+$types{key1} = "string";
+$types{key2} = "string";
+$types{_layers} = "integer";
+$types{_lightmapscale} = "real";
+$types{light} = "real";
+$types{max} = "real3";
+$types{_mingridlight} = "real";
+$types{_minlight} = "real";
+$types{min} = "real3";
+$types{modelscale_vec} = "real3";
+$types{_noshadersun} = "boolean";
+$types{_offsets} = "string";
+$types{_receiveshadows} = "boolean";
+$types{_remap} = "array";
+$types{_samples} = "integer";
+$types{_scale} = "real";
+$types{_shader} = "texture";
+$types{_sun} = "boolean";
+
+# XML types:
+# angle           specialisation of real - Yaw angle
+# angles          specialisation of real3 - Pitch Yaw Roll
+# array           an array of strings - value is a semi-colon-delimited string
+# boolean         an integer - shows as a checkbox - true = non-zero
+# color           specialisation of real3 - RGB floating-point colour
+# direction       specialisation of real - Yaw angle, -1 = down, -2 = up
+# integer2        two integer values
+# integer3        three integer values
+# integer         an integer value
+# model           the VFS path to a model file
+# skin            the VFS path to a skin file
+# sound           the VFS path to a sound file
+# target          a string that uniquely identifies an entity or group of entities
+# targetname      a string that uniquely identifies an entity or group of entities
+# texture         the VFS path to a texture file or a shader name
+
+
 print <<EOF;
 <?xml version="1.0"?>
 <classes>
@@ -10,6 +109,7 @@ EOF
 
 my $closetag;
 my @spawnflags;
+my $class;
 while(<STDIN>)
 {
        chomp;
@@ -19,12 +119,14 @@ while(<STDIN>)
        s/"/&quot;/g;
        if(/^\/\*QUAKED (\S+) \((\S+ \S+ \S+)\) \((\S+ \S+ \S+)\) \((\S+ \S+ \S+)\) ?(.*)/)
        {
+               $class = $1;
                print "<point name=\"$1\" color=\"$2\" box=\"$3 $4\">\n";
                $closetag = "</point>";
                @spawnflags = split / /, $5;
        }
        elsif(/^\/\*QUAKED (\S+) \((\S+ \S+ \S+)\) \? ?(.*)/)
        {
+               $class = $1;
                print "<group name=\"$1\" color=\"$2\">\n";
                $closetag = "</group>";
                @spawnflags = split / /, $3;
@@ -35,7 +137,10 @@ while(<STDIN>)
        }
        elsif(/^([0-9a-z_]*): +(.*)/)
        {
-               print "<string key=\"$1\" name=\"$1\">$2</string>\n";
+               my $type = $types_override{$class}{$1} || $types{$1};
+               warn "No type for $1"
+                       if not defined $type;
+               print "<$type key=\"$1\" name=\"$1\">$2</$type>\n";
        }
        elsif(/^([0-9A-Z_]*): +(.*)/)
        {
index dbc3a3556721c995ac9c2ea302ae45204aef4825..6ed2e286c8241f110f01af7e4948b5c2eaf8fa10 100644 (file)
@@ -184,8 +184,7 @@ turret_scale_refire: 2 = doubble refire (SLOWER!), 0.5 = half (FASTER!)
 turret_scale_ammo:   2 = doubble ammo carry & regen, 0.5 = half ammo carry & regen
 turret_scale_aim:    2 = aim twice as fast, 0,5 = aim at half speed
 turret_scale_health: 2 = double health, 0.5 = half
-
-team : 5=red, 14=blue
+team: 5=red, 14=blue
 -----------SPAWNFLAGS-----------
 ---------NOTES----------
 
@@ -204,8 +203,7 @@ turret_scale_refire: 2 = doubble refire (SLOWER!), 0.5 = half (FASTER!)
 turret_scale_ammo:   2 = doubble ammo carry & regen, 0.5 = half ammo carry & regen
 turret_scale_aim:    2 = aim twice as fast, 0,5 = aim at half speed
 turret_scale_health: 2 = double health, 0.5 = half
-
-team : 5=red, 14=blue
+team: 5=red, 14=blue
 -----------SPAWNFLAGS-----------
 ---------NOTES----------
 
@@ -225,4 +223,4 @@ wait:   Pause at this point # seconds.
 ---------NOTES----------
 If a loop is of targets are formed, any unit entering this loop will patrol it indefinitly.
 If the checkpoint chain in not looped, the unit will go "Roaming" when the last point is reached.
-*/
\ No newline at end of file
+*/