diff --git a/Assets/Scripts/Core/player.lua b/Assets/Scripts/Core/player.lua index 64c549a..8195c91 100644 --- a/Assets/Scripts/Core/player.lua +++ b/Assets/Scripts/Core/player.lua @@ -83,7 +83,7 @@ function Player:issueBuildOrder() end spawnPoint = self:getSpawnPoint() - structure = GameObjectFactory.createUnit(self, 15, spawnPoint, Quaternion:new(1, 0, 0, 0), 0) + structure = GameObjectFactory.createUnit(self, UnitId.LAND_FACTORY, spawnPoint, Quaternion:new(1, 0, 0, 0), 0) self:addUnit(structure) self:issueOrder(1, Vector3:new(0, 0, 0), {Target:new(structure, Vector3:new(0, 0, 0))}, false) diff --git a/Assets/Scripts/GameObjects/Projectiles/projectileData.lua b/Assets/Scripts/GameObjects/Projectiles/projectileData.lua index 9fd6e1a..b2415d4 100644 --- a/Assets/Scripts/GameObjects/Projectiles/projectileData.lua +++ b/Assets/Scripts/GameObjects/Projectiles/projectileData.lua @@ -1,47 +1,28 @@ +ProjectileId = {CRUISE_MISSILE = 0, TORPEDO = 1} ProjectileClass = {CRUISE_MISSILE = 0, TORPEDO = 1} projectiles = { - projectileClass = { - ProjectileClass.CRUISE_MISSILE, - ProjectileClass.TORPEDO, + { + projectileClass = ProjectileClass.CRUISE_MISSILE, + size = {x = 1.2, y = 2.7, z = .54}, + speed = .5, + rotAngle = .1, + explosion = {damage = 100, radius = 20}, + directHitDamage = 450, + rayLength = 1.25, + name = "Cruise missile", + basePath = PATH .. "Models/GameObjects/Projectiles/Missiles/", + meshPath = "cruiseMissile.xml", }, - speed = {.5, .06}, - rotAngle = {.1, 0}, - explosion = {{damage = 100, radius = 20}, {damage = 20, radius = 3}}, - rayLength = {1.25, .75}, - directHitDamage = {450, 300}, - name = { - "Cruise missile", - "Torpedo" - }, - basePath = { - PATH .. "Models/GameObjects/Projectiles/Missiles/", - PATH .. "Models/GameObjects/Projectiles/Torpedos/", - }, - meshPath = { - "cruiseMissile.xml", - "torpedo.xml", - }, - unitCornerPoints = { - { - {x = .592, y = -1.3475, z = -.2755}, - {x = -.592, y = -1.3475, z = -.2755}, - {x = -.592, y = -1.3475, z = .2755}, - {x = .592, y = -1.3475, z = .2755}, - {x = .592, y = 1.3475, z = -.2755}, - {x = -.592, y = 1.3475, z = -.2755}, - {x = -.592, y = 1.3475, z = .2755}, - {x = .592, y = 1.3475, z = .2755} - }, - { - {x = .1, y = -.796, z = -.1}, - {x = -.1, y = -.796, z = -.1}, - {x = -.1, y = -.796, z = .1}, - {x = .1, y = -.796, z = .1}, - {x = .1, y = .796, z = -.1}, - {x = -.1, y = .796, z = -.1}, - {x = -.1, y = .796, z = .1}, - {x = .1, y = .796, z = .1} - } + { + projectileClass = ProjectileClass.TORPEDO, + size = {x = .2, y = 1.6, z = .2}, + speed = .06, + explosion = {damage = 20, radius = 3}, + directHitDamage = 450, + rayLength = .75, + name = "Torpedo", + basePath = PATH .. "Models/GameObjects/Projectiles/Torpedos/", + meshPath = "torpedo.xml", } } diff --git a/Assets/Scripts/GameObjects/Units/structureData.lua b/Assets/Scripts/GameObjects/Units/structureData.lua deleted file mode 100644 index addffda..0000000 --- a/Assets/Scripts/GameObjects/Units/structureData.lua +++ /dev/null @@ -1 +0,0 @@ -maxUnevenness = 0.5 diff --git a/Assets/Scripts/GameObjects/Units/unitData.lua b/Assets/Scripts/GameObjects/Units/unitData.lua index 44e70f4..4cc9115 100644 --- a/Assets/Scripts/GameObjects/Units/unitData.lua +++ b/Assets/Scripts/GameObjects/Units/unitData.lua @@ -1,4 +1,28 @@ --TYPE = {ATTACK = 0, BUILD = 1, MOVE = 2, GARRISON = 3, EJECT = 4, PATROL = 5, LAUNCH = 6}; +UnitId = { + WAR_MECH = 0, + TANK = 1, + ARTILLERY = 2, + ENGINEER = 3, + SCOUT_TRANSPORT = 4, + HOVER_TRANSPORT = 5, + RESOURCE_ROVER = 6, + TACTICAL_CRUISER = 7, + DEFENSIVE_CRUISER = 8, + CHEAP_CRUISER = 9, + TRANSPORT_CRUISER = 10, + HEAVY_CARRIER = 11, + CHAMPION_CARRIER = 12, + MISSILE_SUBMARINE = 13, + STEALTH_SUBMARINE = 14, + LAND_FACTORY = 15, + NAVAL_FACTORY = 16, + MARKET = 17, + LAB = 18, + POINT_DEFENSE = 19, + EXTRACTOR = 19, + REFINERY = 20 +} WeaponClass = {HITSCAN = 0, SHELL = 1, TORPEDO = 2, CRUISE_MISSILE = 3} UnitClass = { WAR_MECH = 0, @@ -9,15 +33,14 @@ UnitClass = { RESOURCE_ROVER = 5, CRUISER = 6, CARRIER = 7, - MISSILE_SUBMARINE = 8, - STEALTH_SUBMARINE = 9, - LAND_FACTORY = 10, - NAVAL_FACTORY = 11, - MARKET = 12, - LAB = 13, - POINT_DEFENSE = 14, - EXTRACTOR = 15, - REFINERY = 16 + SUBMARINE = 8, + LAND_FACTORY = 9, + NAVAL_FACTORY = 10, + MARKET = 11, + LAB = 12, + POINT_DEFENSE = 13, + EXTRACTOR = 14, + REFINERY = 15 } UnitType = {UNDERWATER = 0, SEA_LEVEL = 1, HOVER = 2, LAND = 3, AIR = 4} ArmorType = {CAST = 0, COMBINED = 1, MECHANIC = 2, SHELL = 3, STEEL = 4} @@ -27,770 +50,472 @@ vehiclePrefix = modelPrefix .. "Units/Vehicles/" structurePrefix = modelPrefix .. "Units/Structures/" units = { - weapons = { - {{type = WeaponClass.HITSCAN, rateOfFire = 100, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 50, maxRange = 10}}, - {{type = WeaponClass.HITSCAN, rateOfFire = 500, fireSfx = PATH .. 'Sounds/Units/Tanks/attack.ogg', damage = 200, maxRange = 20}}, - {{type = WeaponClass.HITSCAN, rateOfFire = 2000, fireSfx = PATH .. 'Sounds/Units/Tanks/attack.ogg', damage = 5000, maxRange = 45}}, - {}, - {{type = WeaponClass.HITSCAN, rateOfFire = 2000, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 50, maxRange = 20}}, - {{type = WeaponClass.HITSCAN, rateOfFire = 2000, fireSfx = PATH .. 'Sounds/Units/Tanks/attack.ogg', damage = 100, maxRange = 25}}, - {}, - {{type = WeaponClass.HITSCAN, rateOfFire = 200, fireSfx = PATH .. 'Sounds/Units/Cruisers/fire.ogg', damage = 300, maxRange = 15}}, - {{type = WeaponClass.HITSCAN, rateOfFire = 200, fireSfx = PATH .. 'Sounds/Units/Cruisers/fire.ogg', damage = 300, maxRange = 15}}, - {{type = WeaponClass.HITSCAN, rateOfFire = 200, fireSfx = PATH .. 'Sounds/Units/Cruisers/fire.ogg', damage = 300, maxRange = 15}}, - {{type = WeaponClass.HITSCAN, rateOfFire = 200, fireSfx = PATH .. 'Sounds/Units/Cruisers/fire.ogg', damage = 300, maxRange = 15}}, - { - {type = WeaponClass.HITSCAN, rateOfFire = 100, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 80, maxRange = 100}, - }, - { + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 100, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 50, maxRange = 10}}, + unitClass = UnitClass.WAR_MECH, + unitType = UnitType.LAND, + armor = {ArmorType.MECHANIC}, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2.9, y = 8.22, z = 2.42}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'War mech', + basePath = PATH .. vehiclePrefix .. 'WarMechs/', + meshPath = 'warMech.xml', + selectionSfx = PATH .. 'Sounds/Units/WarMechs/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 1 + }, + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 500, fireSfx = PATH .. 'Sounds/Units/Tanks/attack.ogg', damage = 200, maxRange = 20}}, + unitClass = UnitClass.TANK, + unitType = UnitType.LAND, + armor = {ArmorType.STEEL}, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2.9, y = 8.22, z = 2.42}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Tank', + basePath = PATH .. vehiclePrefix .. 'Tanks/', + meshPath = 'tank.xml', + selectionSfx = PATH .. 'Sounds/Units/Tanks/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 2 + }, + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 2000, fireSfx = PATH .. 'Sounds/Units/Tanks/attack.ogg', damage = 5000, maxRange = 45}}, + unitClass = UnitClass.ARTILLERY, + unitType = UnitType.LAND, + armor = {ArmorType.MECHANIC}, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2.9, y = 8.22, z = 2.42}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Artillery', + basePath = PATH .. vehiclePrefix .. 'Artillery/', + meshPath = 'artillery.xml', + selectionSfx = PATH .. 'Sounds/Units/Tanks/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 2 + }, + { + weapons = {}, + unitClass = UnitClass.ENGINEER, + unitType = UnitType.HOVER, + armor = {ArmorType.MECHANIC}, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 1, y = 8, z = 13.45}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Engineer', + basePath = PATH .. vehiclePrefix .. 'Engineers/', + meshPath = 'engineer.xml', + selectionSfx = PATH .. 'Sounds/Units/Engineers/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 + }, + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 2000, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 50, maxRange = 20}}, + unitClass = UnitClass.TRANSPORT, + unitType = UnitType.HOVER, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2, y = 8.25, z = 2}, + garrisonCapacity = {2, 2, 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Scout transport', + basePath = PATH .. vehiclePrefix .. 'Transports/', + meshPath = 'scoutTransport.xml', + selectionSfx = PATH .. 'Sounds/Units/Transports/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 + }, + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 2000, fireSfx = PATH .. 'Sounds/Units/Tanks/attack.ogg', damage = 100, maxRange = 25}}, + unitClass = UnitClass.TRANSPORT, + unitType = UnitType.HOVER, + armor = {ArmorType.MECHANIC}, + isVehicle = true, + health = 500, + cost = 500, + garrisonCapacity = {2, 2, 2}, + size = {x = 2, y = 8.25, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Hover transport', + basePath = PATH .. vehiclePrefix .. 'Transports/', + meshPath = 'hoverTransport.xml', + selectionSfx = PATH .. 'Sounds/Units/Transports/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 + }, + { + weapons = {}, + unitClass = UnitClass.RESOURCE_ROVER, + unitType = UnitType.SEA_LEVEL, + armor = {ArmorType.CAST}, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2, y = 8.25, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Cargo ship', + basePath = PATH .. vehiclePrefix .. 'Cargoships/', + meshPath = 'cargoship.xml', + selectionSfx = PATH .. 'Sounds/Units/Cargoships/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 + }, + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 200, fireSfx = PATH .. 'Sounds/Units/Cruisers/fire.ogg', damage = 300, maxRange = 15}}, + unitClass = UnitClass.CRUISER, + unitType = UnitType.SEA_LEVEL, + armor = {ArmorType.STEEL}, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2, y = 8.25, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Tactical cruiser', + basePath = PATH .. vehiclePrefix .. 'Cruisers/', + meshPath = 'tacticalCruiser.xml', + selectionSfx = PATH .. 'Sounds/Units/Cruisers/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 + }, + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 200, fireSfx = PATH .. 'Sounds/Units/Cruisers/fire.ogg', damage = 300, maxRange = 15}}, + unitClass = UnitClass.CRUISER, + unitType = UnitType.SEA_LEVEL, + armor = {ArmorType.CAST}, + isVehicle = true, + health = 500, + cost = 500, + garrisonCapacity = {2, 2, 2}, + size = {x = 2, y = 8.25, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Defensive cruiser', + basePath = PATH .. vehiclePrefix .. 'Cruisers/', + meshPath = 'defensiveCruiser.xml', + selectionSfx = PATH .. 'Sounds/Units/Cruisers/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 + }, + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 200, fireSfx = PATH .. 'Sounds/Units/Cruisers/fire.ogg', damage = 300, maxRange = 15}}, + unitClass = UnitClass.CRUISER, + unitType = UnitType.SEA_LEVEL, + armor = {ArmorType.CAST}, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2, y = 8.25, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Cheap cruiser', + basePath = PATH .. vehiclePrefix .. 'Cruisers/', + meshPath = 'cheapCruiser.xml', + selectionSfx = PATH .. 'Sounds/Units/Cruisers/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 + }, + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 200, fireSfx = PATH .. 'Sounds/Units/Cruisers/fire.ogg', damage = 300, maxRange = 15}}, + unitClass = UnitClass.CRUISER, + unitType = UnitType.SEA_LEVEL, + armor = {ArmorType.STEEL, ArmorType.COMBINED}, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2, y = 8.25, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Transport cruiser', + basePath = PATH .. vehiclePrefix .. 'Cruisers/', + meshPath = 'transportCruiser.xml', + selectionSfx = PATH .. 'Sounds/Units/Cruisers/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 + }, + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 100, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 80, maxRange = 100}}, + unitClass = UnitClass.CARRIER, + unitType = UnitType.SEA_LEVEL, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2, y = 8.25, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Heavy carrier', + basePath = PATH .. vehiclePrefix .. 'Carriers/', + meshPath = 'heavyCarrier.xml', + selectionSfx = PATH .. 'Sounds/Units/Carriers/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 + }, + { + weapons = { {type = WeaponClass.HITSCAN, rateOfFire = 300, fireSfx = PATH .. 'Sounds/Units/Tanks/attack.ogg', damage = 500, maxRange = 100}, - {type = WeaponClass.CRUISE_MISSILE, rateOfFire = 500, fireSfx = PATH .. 'Sounds/Units/Submarines/missile.ogg', maxRange = 30, projectile = {id = 0, pos = {x = 0, y = 1, z = 0}, rot = {w = .707, x = -.707, y = 0, z = 0}}} + { + type = WeaponClass.CRUISE_MISSILE, + rateOfFire = 500, + fireSfx = PATH .. 'Sounds/Units/Submarines/missile.ogg', + maxRange = 30, + projectile = {id = ProjectileId.CRUISE_MISSILE, pos = {x = 0, y = 1, z = 0}, rot = {w = .707, x = -.707, y = 0, z = 0}} + } }, - { - {type = WeaponClass.TORPEDO, rateOfFire = 500, fireSfx = PATH .. 'Sounds/Units/Submarines/fire.ogg', damage = 200, maxRange = 20, projectile = {id = 1, pos = {x = 0, y = -.27, z = 4.6}, rot = {w = 1, x = 0, y = 0, z = 0}}}, - {type = WeaponClass.CRUISE_MISSILE, rateOfFire = 500, fireSfx = PATH .. 'Sounds/Units/Submarines/missile.ogg', maxRange = 30, projectile = {id = 0, pos = {x = 0, y = 2.44, z = -3.5}, rot = {w = .707, x = -.707, y = 0, z = 0}}} + unitClass = UnitClass.CARRIER, + unitType = UnitType.SEA_LEVEL, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2, y = 8.25, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Champion carrier', + basePath = PATH .. vehiclePrefix .. 'Carriers/', + meshPath = 'championCarrier.xml', + selectionSfx = PATH .. 'Sounds/Units/Carriers/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 + }, + { + weapons = { + { + type = WeaponClass.TORPEDO, + rateOfFire = 500, + fireSfx = PATH .. 'Sounds/Units/Submarines/fire.ogg', + damage = 200, + maxRange = 20, + projectile = {id = ProjectileId.TORPEDO, pos = {x = 0, y = -.27, z = 4.6}, rot = {w = 1, x = 0, y = 0, z = 0}} + }, + { + type = WeaponClass.CRUISE_MISSILE, + rateOfFire = 500, + fireSfx = PATH .. 'Sounds/Units/Submarines/missile.ogg', + maxRange = 30, + projectile = {id = ProjectileId.CRUISE_MISSILE, pos = {x = 0, y = 2.44, z = -3.5}, rot = {w = .707, x = -.707, y = 0, z = 0}} + }, }, - {{type = WeaponClass.TORPEDO, rateOfFire = 500, fireSfx = PATH .. 'Sounds/Units/Submarines/fire.ogg', damage = 200, maxRange = 20, projectile = {id = 1, pos = {x = 0, y = -.27, z = 4.6}, rot = {w = 1, x = 0, y = 0, z = 0}}}}, - {}, - {}, - {}, - {}, - {{type = WeaponClass.HITSCAN, rateOfFire = 100, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 50, maxRange = 50}}, - {}, - {} + unitClass = UnitClass.SUBMARINE, + unitType = UnitType.UNDERWATER, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 2, y = 8.25, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Missile submarine', + basePath = PATH .. vehiclePrefix .. 'Submarines/', + meshPath = 'missileSubmarine.xml', + selectionSfx = PATH .. 'Sounds/Units/Submarines/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 }, - unitClass = { - UnitClass.WAR_MECH, - UnitClass.TANK, - UnitClass.ARTILLERY, - UnitClass.ENGINEER, - UnitClass.TRANSPORT, - UnitClass.TRANSPORT, - UnitClass.RESOURCE_ROVER, - UnitClass.CRUISER, - UnitClass.CRUISER, - UnitClass.CRUISER, - UnitClass.CRUISER, - UnitClass.CARRIER, - UnitClass.CARRIER, - UnitClass.MISSILE_SUBMARINE, - UnitClass.STEALTH_SUBMARINE, - UnitClass.LAND_FACTORY, - UnitClass.NAVAL_FACTORY, - UnitClass.MARKET, - UnitClass.LAB, - UnitClass.POINT_DEFENSE, - UnitClass.EXTRACTOR, - UnitClass.REFINERY, + { + weapons = { + { + type = WeaponClass.TORPEDO, + rateOfFire = 500, + fireSfx = PATH .. 'Sounds/Units/Submarines/fire.ogg', + damage = 200, + maxRange = 20, + projectile = {id = ProjectileId.TORPEDO, pos = {x = 0, y = -.27, z = 4.6}, rot = {w = 1, x = 0, y = 0, z = 0}} + } + }, + unitClass = UnitClass.SUBMARINE, + unitType = UnitType.UNDERWATER, + isVehicle = true, + health = 500, + cost = 500, + size = {x = 1, y = 1.15, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Stealth submarine', + basePath = PATH .. vehiclePrefix .. 'Submarines/', + meshPath = 'stealthSubmarine.xml', + selectionSfx = PATH .. 'Sounds/Units/Submarines/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', + speed = .1, + destinationOffset = .1, + anglePrecision = .1, + maxTurnAngle = .1, + garrisonCategory = 3 }, - - unitType = { - UnitType.LAND, - UnitType.LAND, - UnitType.LAND, - UnitType.LAND, - UnitType.HOVER, - UnitType.HOVER, - UnitType.HOVER, - UnitType.SEA_LEVEL, - UnitType.SEA_LEVEL, - UnitType.SEA_LEVEL, - UnitType.SEA_LEVEL, - UnitType.SEA_LEVEL, - UnitType.SEA_LEVEL, - UnitType.UNDERWATER, - UnitType.UNDERWATER, - UnitType.LAND, - UnitType.LAND, - UnitType.LAND, - UnitType.LAND, - UnitType.LAND, - UnitType.LAND, - UnitType.LAND + { + unitClass = UnitClass.LAND_FACTORY, + unitType = UnitType.LAND, + isVehicle = false, + health = 500, + cost = 500, + size = {x = 1, y = 1.15, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Land factory', + basePath = PATH .. structurePrefix .. 'LandFactories/', + meshPath = 'landFactory.xml', + selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', }, - - armor = { - {ArmorType.MECHANIC}, - {ArmorType.STEEL}, - {ArmorType.MECHANIC}, - {ArmorType.MECHANIC}, - {}, - {}, - {ArmorType.MECHANIC}, - {ArmorType.CAST}, - {ArmorType.STEEL}, - {ArmorType.CAST}, - {ArmorType.CAST}, - {ArmorType.STEEL, ArmorType.COMBINED}, - {}, - {}, - {}, - {}, - {}, - {}, - {}, - {} + { + unitClass = UnitClass.NAVAL_FACTORY, + unitType = UnitType.SEA_LEVEL, + isVehicle = false, + health = 500, + cost = 500, + size = {x = 1, y = 1.15, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Naval factory', + basePath = PATH .. structurePrefix .. 'NavalFactories/', + meshPath = 'navalFactory.xml', + selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', }, - - isVehicle = { - true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false + { + unitClass = UnitClass.MARKET, + unitType = UnitType.LAND, + isVehicle = false, + health = 500, + cost = 500, + size = {x = 1, y = 1.15, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Market', + basePath = PATH .. structurePrefix .. 'Markets/', + meshPath = 'market.xml', + selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', }, - - health = {500, 500, 600, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 200, 600}, - cost = {500, 600, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500}, - garrisonCapacity = { - {}, - {}, - {}, - {}, - {2, 2, 2}, - {2, 2, 2}, - {}, - {}, - {2, 2, 2}, - {}, - {}, - {}, - {}, - {}, - {}, - {}, - {}, - {}, - {}, - {}, - {}, - {} + { + unitClass = UnitClass.LAB, + unitType = UnitType.LAND, + isVehicle = false, + health = 500, + cost = 500, + size = {x = 1, y = 1.15, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Lab', + basePath = PATH .. structurePrefix .. 'Labs/', + meshPath = 'lab.xml', + selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', }, - - unitCornerPoints = { - { - {x = 1.45, y = -4.11, z = -1.21}, - {x = -1.45, y = -4.11, z = -1.21}, - {x = -1.45, y = -4.11, z = 1.21}, - {x = 1.45, y = -4.11, z = 1.21}, - {x = 1.45, y = 4.11, z = -1.21}, - {x = -1.45, y = 4.11, z = -1.21}, - {x = -1.45, y = 4.11, z = 1.21}, - {x = 1.45, y = 4.11, z = 1.21} - }, - { - {x = 1.45, y = -4.11, z = -1.21}, - {x = -1.45, y = -4.11, z = -1.21}, - {x = -1.45, y = -4.11, z = 1.21}, - {x = 1.45, y = -4.11, z = 1.21}, - {x = 1.45, y = 4.11, z = -1.21}, - {x = -1.45, y = 4.11, z = -1.21}, - {x = -1.45, y = 4.11, z = 1.21}, - {x = 1.45, y = 4.11, z = 1.21} - }, - { - {x = 1.45, y = -4.11, z = -1.21}, - {x = -1.45, y = -4.11, z = -1.21}, - {x = -1.45, y = -4.11, z = 1.21}, - {x = 1.45, y = -4.11, z = 1.21}, - {x = 1.45, y = 4.11, z = -1.21}, - {x = -1.45, y = 4.11, z = -1.21}, - {x = -1.45, y = 4.11, z = 1.21}, - {x = 1.45, y = 4.11, z = 1.21} - }, - { - {x = .5, y = -.5, z = -7.05}, - {x = -.5, y = -.5, z = -7.05}, - {x = -.5, y = -.5, z = 6.4}, - {x = .5, y = -.5, z = 6.4}, - {x = .5, y = 3, z = -7.05}, - {x = -.5, y = 3, z = -7.05}, - {x = -.5, y = 3, z = 6.4}, - {x = .5, y = 3, z = 6.4} - }, - { - {x = 1, y = -.25, z = -1}, - {x = -1, y = -.25, z = -1}, - {x = -1, y = -.25, z = 1}, - {x = 1, y = -.25, z = 1}, - {x = 1, y = .8, z = -1}, - {x = -1, y = .8, z = -1}, - {x = -1, y = .8, z = 1}, - {x = 1, y = .8, z = 1} - }, - { - {x = 1, y = -.25, z = -1}, - {x = -1, y = -.25, z = -1}, - {x = -1, y = -.25, z = 1}, - {x = 1, y = -.25, z = 1}, - {x = 1, y = .8, z = -1}, - {x = -1, y = .8, z = -1}, - {x = -1, y = .8, z = 1}, - {x = 1, y = .8, z = 1} - }, - { - {x = 1, y = -.25, z = -1}, - {x = -1, y = -.25, z = -1}, - {x = -1, y = -.25, z = 1}, - {x = 1, y = -.25, z = 1}, - {x = 1, y = .8, z = -1}, - {x = -1, y = .8, z = -1}, - {x = -1, y = .8, z = 1}, - {x = 1, y = .8, z = 1} - }, - { - {x = 1, y = -.25, z = -1}, - {x = -1, y = -.25, z = -1}, - {x = -1, y = -.25, z = 1}, - {x = 1, y = -.25, z = 1}, - {x = 1, y = .8, z = -1}, - {x = -1, y = .8, z = -1}, - {x = -1, y = .8, z = 1}, - {x = 1, y = .8, z = 1} - }, - { - {x = 1, y = -.25, z = -1}, - {x = -1, y = -.25, z = -1}, - {x = -1, y = -.25, z = 1}, - {x = 1, y = -.25, z = 1}, - {x = 1, y = .8, z = -1}, - {x = -1, y = .8, z = -1}, - {x = -1, y = .8, z = 1}, - {x = 1, y = .8, z = 1} - }, - { - {x = .7, y = -.3, z = -4}, - {x = -.7, y = -.3, z = -4}, - {x = -.7, y = -.3, z = 3.4}, - {x = .7, y = -.3, z = 3.4}, - {x = .7, y = 2.9, z = -4}, - {x = -.7, y = 2.9, z = -4}, - {x = -.7, y = 2.9, z = 3.4}, - {x = .7, y = 2.9, z = 3.4} - }, - { - {x = .5, y = -.5, z = -6.1}, - {x = -.5, y = -.5, z = -6.1}, - {x = -.5, y = -.5, z = 5.2}, - {x = .5, y = -.5, z = 5.2}, - {x = .5, y = 2.2, z = -6.1}, - {x = -.5, y = 2.2, z = -6.1}, - {x = -.5, y = 2.2, z = 5.2}, - {x = .5, y = 2.2, z = 5.2} - }, - { - {x = 2, y = -.5, z = -10}, - {x = -2, y = -.5, z = -10}, - {x = -2, y = -.5, z = 9}, - {x = 2, y = -.5, z = 9}, - {x = 2, y = 5.5, z = -10}, - {x = -2, y = 5.5, z = -10}, - {x = -2, y = 5.5, z = 9}, - {x = 2, y = 5.5, z = 9} - }, - { - {x = 2, y = -1, z = -10}, - {x = -2, y = -1, z = -10}, - {x = -2, y = -1, z = 9}, - {x = 2, y = -1, z = 9}, - {x = 2, y = 4.5, z = -10}, - {x = -2, y = 4.5, z = -10}, - {x = -2, y = 4.5, z = 9}, - {x = 2, y = 4.5, z = 9} - }, - { - {x = .25, y = -.5, z = -2}, - {x = -.25, y = -.5, z = -2}, - {x = -.25, y = -.5, z = 3}, - {x = .25, y = -.5, z = 3}, - {x = .25, y = .7, z = -2}, - {x = -.25, y = .7, z = -2}, - {x = -.25, y = .7, z = 3}, - {x = .25, y = .7, z = 3} - }, - { - {x = .6, y =-.1, z =-1.3}, - {x = -.6, y =-.1, z =-1.3}, - {x = -.6, y =-.1, z =.8}, - {x = .6, y =-.1, z =.8}, - {x = .6, y =.3, z =-1.3}, - {x = -.6, y =.3, z =-1.3}, - {x = -.6, y =.3, z =.8}, - {x = .6, y =.3, z =.8} - }, - { - {x = .5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =.7}, - {x = .5, y =-.1, z =.7}, - {x = .5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =.7}, - {x = .5, y =.15, z =.7} - }, - { - {x = .5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =.7}, - {x = .5, y =-.1, z =.7}, - {x = .5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =.7}, - {x = .5, y =.15, z =.7} - }, - { - {x = .5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =.7}, - {x = .5, y =-.1, z =.7}, - {x = .5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =.7}, - {x = .5, y =.15, z =.7} - }, - { - {x = .5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =.7}, - {x = .5, y =-.1, z =.7}, - {x = .5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =.7}, - {x = .5, y =.15, z =.7} - }, - { - {x = .5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =.7}, - {x = .5, y =-.1, z =.7}, - {x = .5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =.7}, - {x = .5, y =.15, z =.7} - }, - { - {x = .5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =.7}, - {x = .5, y =-.1, z =.7}, - {x = .5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =.7}, - {x = .5, y =.15, z =.7} - }, - { - {x = 2, y =-.1, z =-2}, - {x = -2, y =-.1, z =-2}, - {x = -2, y =-.1, z =2}, - {x = 2, y =-.1, z =2}, - {x = 2, y =.15, z =-2}, - {x = -2, y =.15, z =-2}, - {x = -2, y =.15, z =2}, - {x = 2, y =.15, z =2} - }, - { - {x = .5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =-1.3}, - {x = -.5, y =-.1, z =.7}, - {x = .5, y =-.1, z =.7}, - {x = .5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =-1.3}, - {x = -.5, y =.15, z =.7}, - {x = .5, y =.15, z =.7} - } + { + weapons = {{type = WeaponClass.HITSCAN, rateOfFire = 100, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 50, maxRange = 50}}, + unitClass = UnitClass.POINT_DEFENSE, + unitType = UnitType.LAND, + isVehicle = false, + health = 500, + cost = 500, + size = {x = 2, y = 10, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Point defense', + basePath = PATH .. structurePrefix .. 'PointDefenses/', + meshPath = 'pointDefense.xml', + selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', }, - unitCuboidDimensions = { - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1}, - {x = 1, y = 1, z = 1} - }, - { - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1} - }, - { - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1} - }, - { - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1} - }, - { - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1} - }, - { - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1} - }, - { - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1} - }, - { - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1} - }, - { - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1} - }, - { - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1} - }, - { - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1}, - {x = .1, y = .1, z = .1} - } + { + unitClass = UnitClass.EXTRACTOR, + unitType = UnitType.LAND, + isVehicle = false, + health = 500, + cost = 500, + size = {x = 4, y = 1.15, z = 4}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Extractor', + basePath = PATH .. structurePrefix .. 'Extractors/', + meshPath = 'extractor.xml', + selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', }, - hitboxOffset = { - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, + { + unitClass = UnitClass.REFINERY, + unitType = UnitType.LAND, + isVehicle = false, + health = 500, + cost = 500, + size = {x = 1, y = 1.15, z = 2}, + hitboxOffset = {x = 0, y = 0, z = 0}, + lineOfSight = 5, + name = 'Refinery', + basePath = PATH .. structurePrefix .. 'Refineries/', + meshPath = 'refinery.xml', + selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg', + deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', }, - - unitAxisLength = {8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 5, 5, 8, 8, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2}, - lineOfSight = {5, 8, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 6, 6, 3, 3, 8, 1, 1, 1, 1, 1, 1, 1}, - name = { - 'War mech', - 'Tank', - 'Artillery', - 'Engineer', - 'Scout transport', - 'Hover transport', - 'Cargo ship', - 'Tactical cruiser', - 'Defensive cruiser', - 'Cheap cruiser', - 'Transport cruiser', - 'Heavy carrier', - 'Champion carrier', - 'Missile submarine', - 'Stealth submarine', - 'Land factory', - 'Naval factory', - 'Market', - 'Lab', - 'Point defense', - 'Extractor', - 'Refinery', - }, - meshPath = { - 'warMech.xml', - 'tank.xml', - 'artillery.xml', - 'engineer.xml', - 'scoutTransport.xml', - 'hoverTransport.xml', - 'cargoship.xml', - 'tacticalCruiser.xml', - 'defensiveCruiser.xml', - 'cheapCruiser.xml', - 'transportCruiser.xml', - 'heavyCarrier.xml', - 'championCarrier.xml', - 'missileSubmarine.xml', - 'stealthSubmarine.xml', - 'landFactory.xml', - 'navalFactory.xml', - 'market.xml', - 'lab.xml', - 'pointDefense.xml', - 'extractor.xml', - 'refinery.xml', - }, - basePath = { - PATH .. vehiclePrefix .. 'WarMechs/', - PATH .. vehiclePrefix .. 'Tanks/', - PATH .. vehiclePrefix .. 'Artillery/', - PATH .. vehiclePrefix .. 'Engineers/', - PATH .. vehiclePrefix .. 'Transports/', - PATH .. vehiclePrefix .. 'Transports/', - PATH .. vehiclePrefix .. 'Cargoships/', - PATH .. vehiclePrefix .. 'Cruisers/', - PATH .. vehiclePrefix .. 'Cruisers/', - PATH .. vehiclePrefix .. 'Cruisers/', - PATH .. vehiclePrefix .. 'Cruisers/', - PATH .. vehiclePrefix .. 'Carriers/', - PATH .. vehiclePrefix .. 'Carriers/', - PATH .. vehiclePrefix .. 'Submarines/', - PATH .. vehiclePrefix .. 'Submarines/', - PATH .. structurePrefix .. 'LandFactories/', - PATH .. structurePrefix .. 'NavalFactories/', - PATH .. structurePrefix .. 'Markets/', - PATH .. structurePrefix .. 'Labs/', - PATH .. structurePrefix .. 'PointDefenses/', - PATH .. structurePrefix .. 'Extractors/', - PATH .. structurePrefix .. 'Refineries/' - }, - selectionSfx = { - PATH .. 'Sounds/Units/WarMechs/selection.ogg', - PATH .. 'Sounds/Units/Tanks/selection.ogg', - PATH .. 'Sounds/Units/Tanks/selection.ogg', - PATH .. 'Sounds/Units/Engineers/selection.ogg', - PATH .. 'Sounds/Units/Transports/selection.ogg', - PATH .. 'Sounds/Units/Transports/selection.ogg', - PATH .. 'Sounds/Units/Cargoships/selection.ogg', - PATH .. 'Sounds/Units/Cruisers/selection.ogg', - PATH .. 'Sounds/Units/Cruisers/selection.ogg', - PATH .. 'Sounds/Units/Cruisers/selection.ogg', - PATH .. 'Sounds/Units/Cruisers/selection.ogg', - PATH .. 'Sounds/Units/Carriers/selection.ogg', - PATH .. 'Sounds/Units/Carriers/selection.ogg', - PATH .. 'Sounds/Units/Submarines/selection.ogg', - PATH .. 'Sounds/Units/Submarines/selection.ogg', - PATH .. 'Sounds/Units/Sample/selection.ogg', - PATH .. 'Sounds/Units/Sample/selection.ogg', - PATH .. 'Sounds/Units/Sample/selection.ogg', - PATH .. 'Sounds/Units/Sample/selection.ogg', - PATH .. 'Sounds/Units/Sample/selection.ogg', - PATH .. 'Sounds/Units/Sample/selection.ogg', - PATH .. 'Sounds/Units/Sample/selection.ogg', - }, - deathSfx = { - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - PATH .. 'Sounds/SFX/Explosions/explosion01.ogg', - } } diff --git a/Assets/Scripts/GameObjects/Units/vehicleData.lua b/Assets/Scripts/GameObjects/Units/vehicleData.lua deleted file mode 100644 index 70ee9d1..0000000 --- a/Assets/Scripts/GameObjects/Units/vehicleData.lua +++ /dev/null @@ -1,5 +0,0 @@ -units.speed = {.025, .025, .025, .025, .05, .05, .05, .1, .1, .1, .1, .1, .1, .15, .1, .1, .1} -units.destinationOffset = {.75, .75, .75, .75, 1, 1, 1, .1, .1, .1, .1, .1, .5, .5, .75, .75} -units.anglePrecision = {.1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .2, .2, .1, .1, .1, .1, .1} -units.maxTurnAngle = {.1, .1, .1, .1, .5, .5, .5, 1, 1, .5, .5, 1, 2, 2, .5, .5, .5, .5, .5} -units.garrisonCategory = {1, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3} diff --git a/Assets/Scripts/GameObjects/resourceData.lua b/Assets/Scripts/GameObjects/resourceData.lua index 0a3099d..b6ae446 100644 --- a/Assets/Scripts/GameObjects/resourceData.lua +++ b/Assets/Scripts/GameObjects/resourceData.lua @@ -1,24 +1,9 @@ resources = { - meshPath = { - "resource.xml" - }, - name = { - "Resource", - }, - basePath = { - PATH .. 'Models/GameObjects/Resources/' - }, - unitCornerPoints = { - { - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - {x = 0, y = 0, z = 0}, - } - }, - hitboxOffset = {{x = 0, y = 0, z = 0}} + { + name = 'Resource', + size = {x = 0, y = 0, z = 0}, + hitboxOffset = {x = 0, y = 0, z = 0}, + basePath = PATH .. 'Models/GameObjects/Resources/', + meshPath = 'resource.xml', + } } diff --git a/Assets/Scripts/Gui/engineerCommands.lua b/Assets/Scripts/Gui/engineerCommands.lua index 311817a..5555244 100644 --- a/Assets/Scripts/Gui/engineerCommands.lua +++ b/Assets/Scripts/Gui/engineerCommands.lua @@ -6,51 +6,46 @@ gui = { { pos = {x = res.x - 200, y = res.y - 200}, size = Size, - name = 'Land factory', imagePath = '', guiType = GuiType.BUTTON, buttonType = ButtonType.BUILD, trigger = 76, - structureId = 8 + structureId = UnitId.LAND_FACTORY }, { pos = {x = res.x - Size.x - 200, y = res.y - 200}, size = Size, - name = 'Naval factory', imagePath = '', guiType = GuiType.BUTTON, buttonType = ButtonType.BUILD, trigger = 78, - structureId = 9 + structureId = UnitId.NAVAL_FACTORY }, { pos = {x = res.x - 2 * Size.x - 200, y = res.y - 200}, size = {x = 100, y = 100}, - name = 'Market', imagePath = '', guiType = GuiType.BUTTON, buttonType = ButtonType.BUILD, trigger = 77, - structureId = 10 + structureId = UnitId.MARKET }, { pos = {x = res.x - 3 * Size.x - 200, y = res.y - 200}, size = Size, - name = 'Lab', imagePath = '', guiType = GuiType.BUTTON, buttonType = ButtonType.BUILD, trigger = 84, - structureId = 11 + structureId = UnitId.LAB }, { pos = {x = res.x - 4 * Size.x - 200, y = res.y - 200}, size = Size, - name = 'Point defense', imagePath = '', guiType = GuiType.BUTTON, buttonType = ButtonType.BUILD, trigger = 68, - structureId = 12 + structureId = UnitId.POINT_DEFENSE } } diff --git a/Assets/Scripts/Gui/landFactoryCommands.lua b/Assets/Scripts/Gui/landFactoryCommands.lua index ee5a327..abece5c 100644 --- a/Assets/Scripts/Gui/landFactoryCommands.lua +++ b/Assets/Scripts/Gui/landFactoryCommands.lua @@ -6,21 +6,19 @@ gui = { { pos = {x = res.x - 200, y = res.y - 200}, size = Size, - name = 'Tank', imagePath = '', guiType = GuiType.BUTTON, buttonType = ButtonType.LAND_FACTORY_TRAIN, trigger = 84, - unitId = 1 + unitId = UnitId.TANK }, { pos = {x = res.x - Size.x - 200, y = res.y - 200}, size = Size, - name = 'Artillery', imagePath = '', guiType = GuiType.BUTTON, buttonType = ButtonType.LAND_FACTORY_TRAIN, trigger = 65, - unitId = 2 + unitId = UnitId.ARTILLERY } } diff --git a/Assets/Scripts/Gui/navalFactoryCommands.lua b/Assets/Scripts/Gui/navalFactoryCommands.lua index 1347f79..2ffedbd 100644 --- a/Assets/Scripts/Gui/navalFactoryCommands.lua +++ b/Assets/Scripts/Gui/navalFactoryCommands.lua @@ -5,11 +5,10 @@ gui = { { pos = {x = res.x - 200, y = res.y - 200}, size = {x = 100, y = 100}, - name = 'Transport', imagePath = '', guiType = GuiType.BUTTON, buttonType = ButtonType.NAVAL_FACTORY_TRAIN, trigger = 66, - unitId = 4 + unitId = UnitId.SCOUT_TRANSPORT } } diff --git a/Assets/Scripts/projectileData.lua b/Assets/Scripts/projectileData.lua deleted file mode 100644 index 42677b7..0000000 --- a/Assets/Scripts/projectileData.lua +++ /dev/null @@ -1,244 +0,0 @@ -projectiles = { - numberOfTypesOfWeapons = 2, - g = 2.2, - speed = { - { - {10,10,10,10,10,10,10,10,10,10,10} - }, - { - {10,10,10,10,10,10,10,10,10,10,10} - }, - { - {10, 10, 10, 10} - }, - { - {10, 10, 10, 10} - }, - { - {5,5} - }, - { - {7,7,7,7,7} - }, - {}, - {}, - {.05}, - { - {.1, .1}, - {.1, .1} - } - }, - length = { - { - {1,1,1,1,1,1,1,1,1,1,1,1,1} - }, - { - {1,1,1,1,1,1,1,1,1,1,1,1,1} - }, - { - {1,1,1,1} - }, - { - {1,1,1,1} - }, - { - {1,1} - }, - { - {1,1,1,1,1} - }, - {}, - {}, - { - {.5} - }, - { - {1,1}, - {1,1} - }, - {} - }, - scale = { - { - {1, 1, 1, .5, .5, .5, .5, .5, .5, .5, .5, .5, .5} - }, - { - {1, 1, 1, .23, .23, .23, .23, .23, .23, .23, .23, .23, .23} - }, - { - {.45, .45, .45, .45} - }, - { - {.5, .5, .5, .5} - }, - { - {.95, .95} - }, - { - {.6, .6, .6, .6, .6} - } - }, - pos = { - { - { - {x = 0, y = 0, z = 1.05}, - {x = 0, y = 0, z = 1.05}, - {x = 0, y = 0, z = 1.05}, - {x = 0, y = 0, z = 1.5}, - {x = 0, y = 0, z = 2.5}, - {x = 0, y = 0, z = 2.5}, - {x = 0, y = 0, z = 2.5}, - {x = 0, y = 0, z = 2.5}, - {x = 0, y = 0, z = 2.5}, - {x = 0, y = 0, z = 2.5}, - {x = 0, y = 0, z = 2.5}, - {x = 0, y = 0, z = 2.5}, - {x = 0, y = 0, z = 2.5} - } - }, - { - { - {x = 0, y = 0, z = 0.79254}, - {x = 0, y = 0, z = 0.79254}, - {x = 0, y = 0, z = 0.79254}, - {x = 0, y = 0, z = 0.17723}, - {x = 0, y = 0, z = 0.17723}, - {x = 0, y = 0, z = 0.17723}, - {x = 0, y = 0, z = 0.17723}, - {x = 0, y = 0, z = 0.17723}, - {x = 0, y = 0, z = 0.17723}, - {x = 0, y = 0, z = 0.17723}, - {x = 0, y = 0, z = 0.17723}, - {x = 0, y = 0, z = 0.17723}, - {x = 0, y = 0, z = 0.17723} - } - }, - { - { - {x = 0, y = 0, z = -0.36178}, - {x = 0, y = 0, z = -0.36178}, - {x = 0, y = 0, z = -0.36178}, - {x = 0, y = 0, z = -0.36178} - }, - {x = 0, y = -3, z = 0} - }, - { - { - {x = 0, y = 0, z = -0.30074}, - {x = 0, y = 0, z = -0.30074}, - {x = 0, y = 0, z = -0.30074}, - {x = 0, y = 0, z = -0.30074} - }, - {x = 0, y = -2, z = 0} - }, - { - { - {x = 0, y = 0, z = -0.62118}, - {x = 0, y = 0, z = -0.62118} - }, - { - {x = 0.24482, y = 1.14985, z = 1.32775}, - {x = 0.24482, y = 1.14985, z = 1.62698}, - {x = 0.24482, y = 1.14985, z = 1.88017}, - {x = -0.24482, y = 1.14985, z = 1.32775}, - {x = -0.24482, y = 1.14985, z = 1.62698}, - {x = -0.24482, y = 1.14985, z = 1.88017} - } - }, - { - { - {x = 0, y = 0, z = -0.59117}, - {x = 0, y = 0, z = -0.59117}, - {x = 0, y = 0, z = -0.59117}, - {x = 0, y = 0, z = -0.59117}, - {x = 0, y = 0, z = -0.59117} - }, - {{x = 0.17192, y = 0.57858, z = 0.64471}, {x = -0.17192, y = 0.57858, z = 0.64471}} - }, - {}, - {}, - { - {x = 0, y =-.3, z =-1.5} - }, - { - { - {x = -.25, y =0, z =0}, - {x = .25, y =0, z =0} - }, - { - {x = -.25, y =0, z =0}, - {x = .25, y =0, z =0} - } - }, - {} - }, - damage = { - { - {50, 50, 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10} - }, - { - {50, 50, 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10} - }, - { - {50,50,50,50}, - {50} - }, - { - {50,50,50,50}, - {50} - }, - { - {10,10}, - {} - }, - { - {10,10,10,10,10}, - {} - }, - {}, - {}, - { - {} - }, - { - {50,50}, - {50,50} - }, - {} - }, - projectileName = { - {"shell"}, - {"shell"}, - {"shell"}, - {"shell"}, - {"shell","guidedMissile"}, - {"shell","guidedMissile"}, - {""}, - {""}, - {"torpedo"}, - {"missile","missile"}, - }, - meshPath = { - {PATH .. "Models/GameObjects/Shell/shell.x"}, - {PATH .. "Models/GameObjects/Shell/shell.x"}, - {PATH .. "Models/GameObjects/Shell/shell.x", PATH .. "Models/GameObjects/Depth charge/depthCharge.x"}, - {PATH .. "Models/GameObjects/Shell/shell.x", PATH .. "Models/GameObjects/Depth charge/depthCharge.x"}, - {PATH .. "Models/GameObjects/Shell/shell.x", PATH .. "Models/GameObjects/Guided missile/guidedMissile.x"}, - {PATH .. "Models/GameObjects/Shell/shell.x", PATH .. "Models/GameObjects/Guided missile/guidedMissile.x"}, - {}, - {}, - {PATH .. "Models/GameObjects/Torpedo/torpedo.x"}, - {PATH .. "Models/GameObjects/Jets/aam.x", PATH .. "Models/GameObjects/Jets/awm.x"} - }, - diffuseMapTextPath = { - {}, - {}, - {}, - {}, - {}, - {}, - {}, - {}, - {} - } -} diff --git a/addUnitCommand.cpp b/addUnitCommand.cpp index 8f3c00c..d3d0f51 100644 --- a/addUnitCommand.cpp +++ b/addUnitCommand.cpp @@ -12,6 +12,7 @@ namespace battleship{ using namespace gameBase; using namespace vb01; + using namespace std; //TODO implement structure build status argument void AddUnitCommand::validate(){ @@ -26,8 +27,9 @@ namespace battleship{ unitId = atoi(arguments[1].c_str()); sol::state_view SOL_LUA_VIEW = generateView(); - SOL_LUA_VIEW.script("numUnits = #units.unitClass"); - int numUnits = SOL_LUA_VIEW["numUnits"]; + string varName = "numUnits"; + SOL_LUA_VIEW.script(varName + " = #units"); + int numUnits = SOL_LUA_VIEW[varName]; if(!(0 <= unitId && unitId <= numUnits)) return; diff --git a/concreteGuiManager.cpp b/concreteGuiManager.cpp index df50aa0..08db6ae 100644 --- a/concreteGuiManager.cpp +++ b/concreteGuiManager.cpp @@ -51,7 +51,9 @@ namespace battleship{ sol::table sizeTable = guiTable["size"]; Vector2 size = Vector2(sizeTable["x"], sizeTable["y"]); - string name = guiTable["name"]; + string nk = "name"; + sol::optional nameOpt = guiTable[nk]; + string name = (nameOpt != sol::nullopt ? (string)guiTable[nk] : ""); ButtonType type = (ButtonType)guiTable["buttonType"]; Button *button = nullptr; @@ -160,14 +162,26 @@ namespace battleship{ break; } case BUILD: - button = new BuildButton(pos, size, (int)guiTable["structureId"], name, (int)guiTable["trigger"], (string)guiTable["imagePath"]); + { + int strId = guiTable["structureId"]; + string buttonName = SOL_LUA_STATE["units"][strId + 1]["name"]; + button = new BuildButton(pos, size, strId, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"]); break; + } case LAND_FACTORY_TRAIN: - button = new TrainButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)UnitClass::LAND_FACTORY, (int)guiTable["unitId"]); + { + int unitId = guiTable["unitId"]; + string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"]; + button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)SOL_LUA_STATE["UnitId"]["LAND_FACTORY"], unitId); break; + } case NAVAL_FACTORY_TRAIN: - button = new TrainButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)UnitClass::NAVAL_FACTORY, (int)guiTable["unitId"]); + { + int unitId = guiTable["unitId"]; + string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"]; + button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)SOL_LUA_STATE["UnitId"]["NAVAL_FACTORY"], unitId); break; + } case STATISTICS: button = new StatsButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"]); break; diff --git a/defConfigs.h b/defConfigs.h index fe878ab..347bbd5 100755 --- a/defConfigs.h +++ b/defConfigs.h @@ -36,11 +36,9 @@ namespace battleship{ CORE_MAIN, GUI_MAIN, OPTIONS, - UNIT_DATA, - VEHICLE_DATA, - STRUCTURE_DATA, RESOURCE_DATA, PROJECTILE_DATA, + UNIT_DATA, AI_AGENT, PLAYER }; @@ -48,11 +46,9 @@ namespace battleship{ "Scripts/Core/main.lua", "Scripts/Gui/main.lua", "Scripts/Core/options.lua", - "Scripts/GameObjects/Units/unitData.lua", - "Scripts/GameObjects/Units/vehicleData.lua", - "Scripts/GameObjects/Units/structureData.lua", "Scripts/GameObjects/resourceData.lua", "Scripts/GameObjects/Projectiles/projectileData.lua", + "Scripts/GameObjects/Units/unitData.lua", "Scripts/aiAgent.lua", "Scripts/Core/player.lua" }; diff --git a/gameObject.cpp b/gameObject.cpp index 3a64bc5..d066674 100644 --- a/gameObject.cpp +++ b/gameObject.cpp @@ -38,13 +38,12 @@ namespace battleship{ //TODO remove neccessity to create a material for an invisible mesh void GameObject::initHitbox(){ - sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()]; - sol::table offsetPosTable = SOL_LUA_STATE["hitboxOffset"][id + 1]; - Box *box = new Box(Vector3(width, height, length)); box->setMaterial(new Material(Root::getSingleton()->getLibPath() + "texture")); box->setWireframe(false); + sol::table gameObjTable = generateView()[GameObject::getGameObjTableName()][id + 1]; + sol::table offsetPosTable = gameObjTable["hitboxOffset"]; hitbox = new Node(Vector3(offsetPosTable["x"], offsetPosTable["y"], offsetPosTable["z"])); hitbox->attachMesh(box); hitbox->setVisible(false); @@ -58,16 +57,10 @@ namespace battleship{ } void GameObject::initProperties(){ - sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()]; - - for(int i = 0; i < 8; i++){ - sol::table cornerTable = SOL_LUA_STATE["unitCornerPoints"][id + 1][i + 1]; - corners[i] = Vector3(cornerTable["x"], cornerTable["y"], cornerTable["z"]); - } - - width = corners[0].x - corners[1].x; - height = corners[4].y - corners[0].y; - length = corners[3].z - corners[0].z; + sol::table sizeTable = generateView()[GameObject::getGameObjTableName()][id + 1]["size"]; + width = sizeTable["x"]; + height = sizeTable["y"]; + length = sizeTable["z"]; } void GameObject::destroyModel(){ @@ -76,9 +69,9 @@ namespace battleship{ } void GameObject::initModel(bool textured){ - sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()]; - string basePath = SOL_LUA_STATE["basePath"][id + 1]; - string meshPath = SOL_LUA_STATE["meshPath"][id + 1]; + sol::table gameObjTable = generateView()[GameObject::getGameObjTableName()][id + 1]; + string basePath = gameObjTable["basePath"]; + string meshPath = gameObjTable["meshPath"]; model = new Model(basePath + meshPath); Root *root = Root::getSingleton(); @@ -121,7 +114,7 @@ namespace battleship{ void GameObject::initSound(){ deathSfxBuffer = new sf::SoundBuffer(); - string sfxPath = generateView()[getGameObjTableName()]["deathSfx"][id + 1]; + string sfxPath = generateView()[getGameObjTableName()][id + 1]["deathSfx"]; deathSfx = prepareSfx(deathSfxBuffer, sfxPath); } @@ -152,6 +145,17 @@ namespace battleship{ Vector2 GameObject::calculateSelectionRect(){ const int NUM_CORNERS = 8; + Vector3 corners[NUM_CORNERS]{ + Vector3(-.5 * width, -.5 * height, -.5 * length), + Vector3(-.5 * width, -.5 * height, .5 * length), + Vector3(.5 * width, -.5 * height, .5 * length), + Vector3(.5 * width, -.5 * height, -.5 * length), + Vector3(-.5 * width, .5 * height, -.5 * length), + Vector3(-.5 * width, .5 * height, .5 * length), + Vector3(.5 * width, .5 * height, .5 * length), + Vector3(.5 * width, .5 * height, -.5 * length) + }; + vector cornersOnScreen; for(int i = 0; i < NUM_CORNERS; i++){ diff --git a/gameObjectFactory.cpp b/gameObjectFactory.cpp index 3e2a581..4905fd6 100644 --- a/gameObjectFactory.cpp +++ b/gameObjectFactory.cpp @@ -20,8 +20,8 @@ namespace battleship{ using namespace gameBase; Unit* GameObjectFactory::createUnit(Player *player, int id, Vector3 pos, Quaternion rot, int buildStatus){ - sol::state_view SOL_LUA_STATE = generateView(); - int unitClass = SOL_LUA_STATE["units"]["unitClass"][id + 1]; + sol::state_view SOL_LUA_VIEW = generateView(); + int unitClass = SOL_LUA_VIEW["units"][id + 1]["unitClass"]; switch((UnitClass)unitClass){ case UnitClass::LAND_FACTORY: @@ -45,8 +45,8 @@ namespace battleship{ } Projectile* GameObjectFactory::createProjectile(Unit *unit, int id, Vector3 pos, Quaternion rot){ - sol::state_view SOL_LUA_STATE = generateView(); - int projectileClass = SOL_LUA_STATE["projectiles"]["projectileClass"][id + 1]; + sol::state_view SOL_LUA_VIEW = generateView(); + int projectileClass = SOL_LUA_VIEW["projectiles"][id + 1]["projectileClass"]; switch((ProjectileClass)projectileClass){ case ProjectileClass::CRUISE_MISSILE: diff --git a/gameObjectFrameController.cpp b/gameObjectFrameController.cpp index 9862e76..ca48228 100644 --- a/gameObjectFrameController.cpp +++ b/gameObjectFrameController.cpp @@ -61,7 +61,7 @@ namespace battleship{ MeshData::Vertex *verts = meshData.vertices; int numVerts = 3 * meshData.numTris; - float maxUnevenness = generateView()["maxUnevenness"], unevenness = 0; + float maxUnevenness = .5, unevenness = 0; for(int i = 0; i < numVerts; i++){ float diffX = fabs(s.getPos().x - verts[i].pos.x); @@ -101,9 +101,8 @@ namespace battleship{ if(results.empty()) return; Vector3 newPos, rowEnd; - sol::table unitTable = generateView()[gameObjectFrames[0].getGameObjTableName()]["unitCornerPoints"][gameObjectFrames[0].getId() + 1]; - float width = (float)unitTable[1]["x"] - (float)unitTable[2]["x"]; - float length = (float)unitTable[4]["z"] - (float)unitTable[1]["z"]; + sol::table sizeTable = generateView()[gameObjectFrames[0].getGameObjTableName()][gameObjectFrames[0].getId() + 1]["size"]; + float width = sizeTable["x"], length = sizeTable["z"]; if(paintSelecting) paintSelect(results[0].pos, width, length); diff --git a/projectile.cpp b/projectile.cpp index 43d4728..9c4c905 100755 --- a/projectile.cpp +++ b/projectile.cpp @@ -39,14 +39,15 @@ namespace battleship{ void Projectile::initProperties(){ GameObject::initProperties(); - sol::table projTable = generateView()[GameObject::getGameObjTableName()]; - rayLength = projTable["rayLength"][id + 1]; - directHitDamage = projTable["directHitDamage"][id + 1]; + sol::table projTable = generateView()[GameObject::getGameObjTableName()][id + 1]; + rayLength = projTable["rayLength"]; + directHitDamage = projTable["directHitDamage"]; + string explKey = "explosion"; - explosionDamage = projTable[explKey][id + 1]["damage"]; - explosionRadius = projTable[explKey][id + 1]["radius"]; - speed = projTable["speed"][id + 1]; - rotAngle = projTable["rotAngle"][id + 1];; + explosionDamage = projTable[explKey]["damage"]; + explosionRadius = projTable[explKey]["radius"]; + speed = projTable["speed"]; + rotAngle = projTable["rotAngle"].get_or(0.0); } void Projectile::initSound(){ diff --git a/trainButton.cpp b/trainButton.cpp index 3017873..3bb3ab1 100644 --- a/trainButton.cpp +++ b/trainButton.cpp @@ -18,7 +18,7 @@ namespace battleship{ void TrainButton::onClick(){ ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE)); Player *player = activeState->getPlayer(); - UnitClass facClass = (UnitClass)generateView()["units"]["unitClass"][factoryId + 1]; + UnitClass facClass = (UnitClass)generateView()["units"][factoryId + 1]["unitClass"]; vector factories = player->getSelectedUnitsByClass(facClass); for(Unit *fac : factories) diff --git a/unit.cpp b/unit.cpp index 385d8a6..3f37f3a 100755 --- a/unit.cpp +++ b/unit.cpp @@ -42,12 +42,12 @@ namespace battleship{ if(proj != sol::nullopt){ projId = weaponTable[projTableKey]["id"]; sol::table projTable = generateView()["projectiles"]; - ProjectileClass pc = (ProjectileClass)projTable["projectileClass"][projId + 1]; + ProjectileClass pc = (ProjectileClass)projTable[projId + 1]["projectileClass"]; if(pc == ProjectileClass::CRUISE_MISSILE){ minRange = 0; - float rotAngle = projTable["rotAngle"][projId + 1]; - float speed = projTable["speed"][projId + 1]; + float rotAngle = projTable[projId + 1]["rotAngle"]; + float speed = projTable[projId + 1]["speed"]; float base = PI / 2, alpha = 0; while(base - alpha > .001){ @@ -130,46 +130,66 @@ namespace battleship{ GameObject::initProperties(); sol::state_view SOL_LUA_VIEW = generateView(); - sol::table SOL_LUA_STATE = SOL_LUA_VIEW[GameObject::getGameObjTableName()]; - string name = SOL_LUA_STATE["name"][id + 1]; - health = SOL_LUA_STATE["health"][id + 1]; + string objType = GameObject::getGameObjTableName(); + sol::table unitTable = SOL_LUA_VIEW[objType][id + 1]; + string name = unitTable["name"]; + health = unitTable["health"]; + vehicle = unitTable["isVehicle"]; maxHealth = health; - lineOfSight = SOL_LUA_STATE["lineOfSight"][id + 1]; - unitClass = (UnitClass)SOL_LUA_STATE["unitClass"][id + 1]; - type = (UnitType)SOL_LUA_STATE["unitType"][id + 1]; + lineOfSight = unitTable["lineOfSight"]; + unitClass = (UnitClass)unitTable["unitClass"]; + type = (UnitType)unitTable["unitType"]; - SOL_LUA_VIEW.script("numGarrisonSlots = #units.garrisonCapacity[" + to_string(id + 1) + "]"); - int numGarrisonSlots = SOL_LUA_VIEW["numGarrisonSlots"]; + string tblName = "garrisonCapacity"; + sol::optional gc = unitTable[tblName]; - for(int i = 0; i < numGarrisonSlots; i++){ - Vector2 size = 10 * Vector2::VEC_IJ; - Vector2 pos = Vector2(1.5 * size.x * i, 20); - Node *bg = createBar(pos, size, Vector4(0, 0, 0, 1)); - Node *fg = createBar(pos, size, Vector4(0, 1, 0, 1)); - int category = SOL_LUA_STATE["garrisonCapacity"][id + 1][i + 1]; - garrisonSlots.push_back(GarrisonSlot(bg, fg, pos, category)); + if(gc != sol::nullopt){ + string varName = "numGarrisonSlots"; + SOL_LUA_VIEW.script(varName + " = #" + objType + "[" + to_string(id + 1) + "]." + tblName); + int numGarrisonSlots = SOL_LUA_VIEW[varName]; + + for(int i = 0; i < numGarrisonSlots; i++){ + Vector2 size = 10 * Vector2::VEC_IJ; + Vector2 pos = Vector2(1.5 * size.x * i, 20); + Node *bg = createBar(pos, size, Vector4(0, 0, 0, 1)); + Node *fg = createBar(pos, size, Vector4(0, 1, 0, 1)); + int category = unitTable[tblName][i + 1]; + garrisonSlots.push_back(GarrisonSlot(bg, fg, pos, category)); + } } - SOL_LUA_VIEW.script("numArmorTypes = #units.armor[" + to_string(id + 1) + "]"); - int numArmorTypes = SOL_LUA_VIEW["numArmorTypes"]; + tblName = "armor"; + sol::optional at = unitTable[tblName]; - for(int i = 0; i < numArmorTypes; i++){ - Armor arm = (Armor)SOL_LUA_STATE["armor"][id + 1][i + 1]; - armorTypes.push_back(arm); + if(at != sol::nullopt){ + string varName = "numArmorTypes"; + SOL_LUA_VIEW.script(varName + " = #" + objType + "[" + to_string(id + 1) + "]." + tblName); + int numArmorTypes = SOL_LUA_VIEW[varName]; + + for(int i = 0; i < numArmorTypes; i++){ + Armor arm = (Armor)unitTable[tblName][i + 1]; + armorTypes.push_back(arm); + } } } void Unit::initWeapons(){ sol::state_view SOL_STATE_VIEW = generateView(); - sol::table unitTable = SOL_STATE_VIEW[GameObject::getGameObjTableName()]; + string objType = GameObject::getGameObjTableName(); + sol::table unitTable = SOL_STATE_VIEW[objType][id + 1]; - string varName = "numWeapons", tblName = "weapons"; - SOL_STATE_VIEW.script(varName + " = #units." + tblName + "[" + to_string(id + 1) + "]"); - int numWeapons = SOL_STATE_VIEW[varName]; + string tblName = "weapons"; + sol::optional wt = unitTable[tblName]; - for(int i = 0; i < numWeapons; i++) - weapons.push_back(new Weapon(this, unitTable[tblName][id + 1][i + 1])); + if(wt != sol::nullopt){ + string varName = "numWeapons"; + SOL_STATE_VIEW.script(varName + " = #" + objType + "[" + to_string(id + 1) + "]." + tblName); + int numWeapons = SOL_STATE_VIEW[varName]; + + for(int i = 0; i < numWeapons; i++) + weapons.push_back(new Weapon(this, unitTable[tblName][i + 1])); + } } void Unit::destroyWeapons(){ @@ -188,7 +208,7 @@ namespace battleship{ void Unit::initSound(){ GameObject::initSound(); selectionSfxBuffer = new sf::SoundBuffer(); - string sfxPath = generateView()[getGameObjTableName()]["selectionSfx"][id + 1]; + string sfxPath = generateView()[getGameObjTableName()][id + 1]["selectionSfx"]; selectionSfx = GameObject::prepareSfx(selectionSfxBuffer, sfxPath); } diff --git a/unit.h b/unit.h index 19737a6..a57c42d 100755 --- a/unit.h +++ b/unit.h @@ -64,8 +64,7 @@ namespace battleship{ RESOURCE_ROVER, CRUISER, CARRIER, - MISSILE_SUBMARINE, - STEALTH_SUBMARINE, + SUBMARINE, LAND_FACTORY, NAVAL_FACTORY, MARKET, @@ -141,7 +140,7 @@ namespace battleship{ inline int getPlayerId() {return playerId;} inline int getHealth(){return health;} inline int getDeathHp(){return DEATH_HP;} - inline bool isVehicle(){return gameBase::generateView()["units"]["isVehicle"][id + 1];} + inline bool isVehicle(){return vehicle;} inline bool isTargetToTheRight(vb01::Vector3 dir, vb01::Vector3 lv){return lv.getAngleBetween(dir) > vb01::PI / 2;} inline Order getOrder(int i){return orders[i];} inline int getNumOrders(){return orders.size();} @@ -157,6 +156,7 @@ namespace battleship{ sf::SoundBuffer *selectionSfxBuffer; sf::Sound *selectionSfx = nullptr; vb01::Node *hpBackgroundNode = nullptr, *hpForegroundNode = nullptr; + bool vehicle; protected: UnitClass unitClass; UnitType type; diff --git a/vehicle.cpp b/vehicle.cpp index a96c6ba..d147c85 100644 --- a/vehicle.cpp +++ b/vehicle.cpp @@ -83,14 +83,13 @@ namespace battleship{ } void Vehicle::initProperties(){ - sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()]; - maxTurnAngle = SOL_LUA_STATE["maxTurnAngle"][id + 1]; - speed = SOL_LUA_STATE["speed"][id + 1]; - anglePrecision = SOL_LUA_STATE["anglePrecision"][id + 1]; - garrisonCategory = SOL_LUA_STATE["garrisonCategory"][id + 1]; + sol::table unitTable = generateView()[GameObject::getGameObjTableName()][id + 1]; + maxTurnAngle = unitTable["maxTurnAngle"]; + speed = unitTable["speed"]; + anglePrecision = unitTable["anglePrecision"]; + garrisonCategory = unitTable["garrisonCategory"]; } - void Vehicle::navigate(float destOffset){ Vector3 hypVec = (pathPoints[0] - pos); float hypAngle = hypVec.norm().getAngleBetween(upVec) - PI / 2;