Unit DB

Post here if you want to help developing something for FAF.

Re: Unit DB

Postby pip » 25 May 2014, 09:05

No, I wouldn't think so. I think the projectile splits before impacting the shield. The height of the UEF shield is lower than the height at which the Salvation projectiles split for the third time.

EDIT: I checked in game, each projectile actually splits in 6 and then in 6 again = 36 projectiles.
pip
Supreme Commander
 
Posts: 1826
Joined: 04 Oct 2011, 15:33
Has liked: 191 times
Been liked: 86 times
FAF User Name: pip

Re: Unit DB

Postby arkitect » 25 May 2014, 13:15

ok yes,
Code: Select all
# One initial projectile following same directional path as the original
        self:CreateChildProjectile(ChildProjectileBP):SetVelocity(vx,0.8*vy, vz):SetVelocity(velocity):PassDamageData(self.DamageData)
         
      # Create several other projectiles in a dispersal pattern
              local numProjectiles = 5
              local angle = (2*math.pi) / numProjectiles
              local angleInitial = RandomFloat( 0, angle )
             
              # Randomization of the spread
              local angleVariation = angle * 8 # Adjusts angle variance spread
              local spreadMul = 0.8 # Adjusts the width of the dispersal       
       
        local xVec = 0
        local yVec = vy*0.8
        local zVec = 0

        # Launch projectiles at semi-random angles away from split location


it creates a child projectile on same path as original, and 5 more in random directions so 6x6 = 36.


edit: and yes, the tertiary projectiles detonate above shield heights. I was being retarded and not halving the shield size for radius.
arkitect
Avatar-of-War
 
Posts: 134
Joined: 08 May 2014, 13:40
Has liked: 23 times
Been liked: 81 times
FAF User Name: arkitect

Re: Unit DB

Postby arkitect » 27 May 2014, 03:34

someone was asking for the C# source for the parser:

summary: convert lua to json and use existing json parsers.

Code: Select all
public FAF.UnitDb.Models.Blueprints.UnitBlueprint ParseBlueprintText(string text)
        {

            text = text.Substring(text.IndexOf('{')); // trim off the class name from start of file
            text = text.Replace("\"", ""); //remove quotes
            text = Regex.Replace(text, "= {\r\n *({[^}]+?},\r\n *{[^}]+?},)\r\n *}", "= [ $1 ]", RegexOptions.Singleline); //replace simple arrays with [] around them
            for (int i = 0; i < 3; i++) //wrap arrays of objects with [ ]
                text = Regex.Replace(text, "\\{(([ \r\n]*{((?:[^{}]|(?<counter>\\{)|(?<-counter>\\}))+(?(counter)(?!))\\}[, \r\n]*))+[, \r\n]*)\\}", "[ $1 ]", RegexOptions.Singleline);
            text = Regex.Replace(text, "\\{([^=]+?,[^=^}]+)\\}", "[ $1 ]", RegexOptions.Singleline); //wrap arrays of primitives with [ ]
            text = text.Trim().Replace(" = ", ":"); //replace equals with colon for json
            text = Regex.Replace(text, "([a-z|A-Z|0-9|_]+)\\:", "\"$1\":"); //wrap property names in quotes
            text = text.Replace("'", "\""); //use " instead of ' around strings
            text = Regex.Replace(text, "#[^\n]+", "", RegexOptions.Multiline); //remove comments
            text = Regex.Replace(text, "\": ?([a-z|A-Z|0-9|_|-]+) ?\\{", "\":{"); //remove type name from child object decalaration
            text = Regex.Replace(text, ",([\r\n \t]*?)}", "$1}", RegexOptions.Singleline); //remove trailing commas in array & property lists. most parsers ignore this but technically invalid
            text = Regex.Replace(text, ",([\r\n \t]*?)]", "$1]", RegexOptions.Singleline);
            text = Regex.Replace(text, "([ :])(\\.[0-9]+)", "$1 0$2", RegexOptions.Multiline); //ensure no decimals start with just a period - add leading 0
            text = Regex.Replace(text, "([: ])nil([ \r\n]*)", "$1null$2", RegexOptions.Multiline); //nil in lua = null in json
            text = Regex.Replace(text, "[ |\\t]--.*", "", RegexOptions.Multiline); //sometimes we see -- being used for comments
            text = Regex.Replace(text, "\\{([^\"]*\\{(((?:[^{}]|(?<counter>\\{)|(?<-counter>\\}))+(?(counter)(?!))\\}[^\"^\\}]*))+[^\"^\\}]*?)\\}", "[ $1 ]", RegexOptions.Singleline); //one last check that arrays of objects are wrapped with [ ]
            text = Regex.Replace(text, ";([ \r\n])+", ",$1", RegexOptions.Multiline); //occasionally we see a ; that shouldn't be there
           
            System.Runtime.Serialization.Json.DataContractJsonSerializer ser = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(FAF.UnitDb.Models.Blueprints.UnitBlueprint));
            System.IO.MemoryStream ms = new System.IO.MemoryStream(new System.Text.UTF8Encoding().GetBytes(text));
            ms.Position = 0;
            FAF.UnitDb.Models.Blueprints.UnitBlueprint bp = null;
            try
            {//parse the result
                 bp = (FAF.UnitDb.Models.Blueprints.UnitBlueprint)ser.ReadObject(ms);
            }
            catch (Exception)
            {
                throw;
            }


            if (bp != null)
            {
                if (bp.Description != null && bp.Description.Contains('<')) bp.Description = Regex.Replace(bp.Description, "<[^>]*>", "");
                if (bp.General != null && bp.General.UnitName != null && bp.General.UnitName.Contains('<')) bp.General.UnitName = Regex.Replace(bp.General.UnitName, "<[^>]*>", "");
                if (bp.Categories != null)
                {//need to manually set tech level integer
                    if (bp.Categories.Contains("TECH1")) bp.TechLevel = 1;
                    else if (bp.Categories.Contains("TECH2")) bp.TechLevel = 2;
                    else if (bp.Categories.Contains("TECH3")) bp.TechLevel = 3;
                    else if (bp.Categories.Contains("EXPERIMENTAL")) bp.TechLevel = 4;
                }
            }

            return bp;
        }
arkitect
Avatar-of-War
 
Posts: 134
Joined: 08 May 2014, 13:40
Has liked: 23 times
Been liked: 81 times
FAF User Name: arkitect

Re: Unit DB

Postby nine2 » 27 May 2014, 04:13

solarflare_nz wrote:someone was asking for the C# source for the parser:


That was me, thanks.

Ahh interesting approach, didn't think of regexing to json.

I was using a nuget package called SharpLua where you can actually pass it a string of lua and it will execute it, and it gives you a kind of reflection to iterate through all of the key/values. It's not too bad but I think it's a bit slow and also I had to jump through some hoops ... sometimes the blueprints reference code in other files (eg: meshblueprint) which obviously wouldn't be able to execute without some work, so I had to hack around that sort of thing. .. namely by findreplacing those bits out of the original lua before execution.

One of the things on my todo list is to convert all blueprints to json/xml and release it like that ... way easier for everyone to work with.

Anyhow => nice work!
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Unit DB

Postby arkitect » 27 May 2014, 12:07

This actually stores the output as xml and the page runs off the xml file with no db connected
arkitect
Avatar-of-War
 
Posts: 134
Joined: 08 May 2014, 13:40
Has liked: 23 times
Been liked: 81 times
FAF User Name: arkitect

Re: Unit DB

Postby pip » 29 May 2014, 19:16

Some feedback: the layout is pretty convenient, especially when you want to compare several units at once and not just 2 or 3.

I spotted these errors in the DB so far :
- lobo too high DPS (projectile splits in 4, not 5)
- zhtuee too high DPS (projectile splits in 5, not 6)
- Neptune lasers too low DPS (it has dual lasers so DPS should be twice higher, I suspect the racksalvosize = 1 to be the missing parameter).
- Cybran T2PD (it shoots 3 beams, not 2, I suspect RackSalvoSize = 1, to be the missing parameter)
- Czar Beam (ground weapon, probably because it has a beamlifetime = 0 and yet there is no line saying ContinuousBeam = true)
- Seraphim Ythota weapons have 0 DPS (don't know why)
- Seraphim t3 tank has a 0 DPS weapon
- all the nuke launchers and t3 sub nuke missiles have no damage
- some units with missiles have damage value instead of DPS value: t2 and t3 Mobile Missile Launchers, Aeon T3 Missile ship. It's also the case for bombers (no DPS, just damage value)
- Cybran Bomber doesn't say there are several bombs
- UEF bombers : their DOT damages are not calculated, for dot weapons, calculation should be : (InitialDamage + (Damage*DotPulses)*muzzlesalvosize)/(1/rate of fire)
pip
Supreme Commander
 
Posts: 1826
Joined: 04 Oct 2011, 15:33
Has liked: 191 times
Been liked: 86 times
FAF User Name: pip

Re: Unit DB

Postby arkitect » 30 May 2014, 05:44

Thanks pip, one the projectiles though, the lua code for OnImpact is:
Code: Select all
        # One initial projectile following same directional path as the original
        self:CreateChildProjectile(ChildProjectileBP):SetVelocity(vx, vy, vz):SetVelocity(velocity):PassDamageData(self.DamageData)
         
      # Create several other projectiles in a dispersal pattern
        local numProjectiles = 4
        local angle = (2*math.pi) / numProjectiles
        local angleInitial = RandomFloat( 0, angle )
       
        # Randomization of the spread
        local angleVariation = angle * 0.35 # Adjusts angle variance spread
        local spreadMul = 0.5 # Adjusts the width of the dispersal       
       
        local xVec = 0
        local yVec = vy
        local zVec = 0

        # Launch projectiles at semi-random angles away from split location
        for i = 0, (numProjectiles -1) do
            xVec = vx + (math.sin(angleInitial + (i*angle) + RandomFloat(-angleVariation, angleVariation))) * spreadMul
            zVec = vz + (math.cos(angleInitial + (i*angle) + RandomFloat(-angleVariation, angleVariation))) * spreadMul
            local proj = self:CreateChildProjectile(ChildProjectileBP)
            proj:SetVelocity(xVec,yVec,zVec)
            proj:SetVelocity(velocity)
            proj:PassDamageData(self.DamageData)                       
        end


it definitely looks to me like it creates 5 projectiles after impact. 1 on same path as original and 4 in random directions?


edit: this is for lobo, TIFFragmentationSensorShell01

edit: do you know where nuke damage is specified? I can't seem to see it.
arkitect
Avatar-of-War
 
Posts: 134
Joined: 08 May 2014, 13:40
Has liked: 23 times
Been liked: 81 times
FAF User Name: arkitect

Re: Unit DB

Postby pip » 30 May 2014, 12:06

Just launch a game and count the projectiles that fall on the ground when you ground fire a lobo and zhtuee, you'll see that the parent projectile doesn't hit the ground.

As for nuke damage, it's all at the bottom of the unit bp, in these parameters (here for the Sera t4 nuke):

NukeInnerRingDamage = 1000001,
NukeInnerRingRadius = 45,
NukeInnerRingTicks = 24,
NukeInnerRingTotalTime = 12,
NukeOuterRingDamage = 7500,
NukeOuterRingRadius = 60,
NukeOuterRingTicks = 20,
NukeOuterRingTotalTime = 5,

To sum up, nuke total damage = Nukeinnerringdamage + nukeouterringdamage and total AOE is nukeinnerringradius + nukeouterringradius.
pip
Supreme Commander
 
Posts: 1826
Joined: 04 Oct 2011, 15:33
Has liked: 191 times
Been liked: 86 times
FAF User Name: pip

Re: Unit DB

Postby arkitect » 30 May 2014, 13:42

pip wrote:Just launch a game and count the projectiles that fall on the ground when you ground fire a lobo and zhtuee, you'll see that the parent projectile doesn't hit the ground.



yip, did that. for lobo there are 5. The initial projectile is destroyed above the ground, and 1 to replace it on the same trajectory is created. 4 more at random trajectories are then also created.Image
arkitect
Avatar-of-War
 
Posts: 134
Joined: 08 May 2014, 13:40
Has liked: 23 times
Been liked: 81 times
FAF User Name: arkitect

Re: Unit DB

Postby pip » 30 May 2014, 14:28

Hehe, it seems that you're right for the lobo, but I rechecked for the zhtuee, and I see only 5 projectiles (also when I shoot at a factory, it deals 225 damages = 45 *5, and not 270). Maybe their code is different.
pip
Supreme Commander
 
Posts: 1826
Joined: 04 Oct 2011, 15:33
Has liked: 191 times
Been liked: 86 times
FAF User Name: pip

PreviousNext

Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest