mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -21,7 +21,7 @@ mappings = {
|
||||
{bind = 17, trigger = 341, action = true, bindType = 0, inOptions = true},
|
||||
{bind = 18, trigger = 340, action = true, bindType = 0, inOptions = true},
|
||||
{bind = 19, trigger = 80, action = true, bindType = 0, inOptions = true},
|
||||
{bind = 20, trigger = 67, action = true, bindType = 0, inOptions = true},
|
||||
{bind = 20, trigger = 76, action = true, bindType = 0, inOptions = true},
|
||||
{bind = 21, trigger = 83, action = true, bindType = 0, inOptions = true},
|
||||
{bind = 22, trigger = 48, action = true, bindType = 0, inOptions = true},
|
||||
{bind = 23, trigger = 49, action = true, bindType = 0, inOptions = true},
|
||||
|
||||
@@ -83,7 +83,7 @@ function Player:issueBuildOrder()
|
||||
end
|
||||
|
||||
spawnPoint = self:getSpawnPoint()
|
||||
structure = GameObjectFactory.createUnit(self, 12, spawnPoint, Quaternion:new(1, 0, 0, 0), 0)
|
||||
structure = GameObjectFactory.createUnit(self, 13, 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)
|
||||
|
||||
@@ -1,244 +1,47 @@
|
||||
ProjectileClass = {CRUISE_MISSILE = 0, TORPEDO = 1}
|
||||
|
||||
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}
|
||||
}
|
||||
projectileClass = {
|
||||
ProjectileClass.CRUISE_MISSILE,
|
||||
ProjectileClass.TORPEDO,
|
||||
},
|
||||
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}
|
||||
},
|
||||
{}
|
||||
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"
|
||||
},
|
||||
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"},
|
||||
basePath = {
|
||||
PATH .. "Models/GameObjects/Projectiles/Missiles/",
|
||||
PATH .. "Models/GameObjects/Projectiles/Torpedos/",
|
||||
},
|
||||
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"}
|
||||
"cruiseMissile.xml",
|
||||
"torpedo.xml",
|
||||
},
|
||||
diffuseMapTextPath = {
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{}
|
||||
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}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
--TYPE = {ATTACK = 0, BUILD = 1, MOVE = 2, GARRISON = 3, EJECT = 4, PATROL = 5, LAUNCH = 6};
|
||||
WeaponClass = {HITSCAN = 0, SHELL = 1, TORPEDO = 2, CRUISE_MISSILE = 3}
|
||||
UnitClass = {
|
||||
WAR_MECH = 0,
|
||||
TANK = 1,
|
||||
@@ -8,12 +9,13 @@ UnitClass = {
|
||||
CARGO_SHIP = 5,
|
||||
CRUISER = 6,
|
||||
CARRIER = 7,
|
||||
SUBMARINE = 8,
|
||||
LAND_FACTORY = 9,
|
||||
NAVAL_FACTORY = 10,
|
||||
MARKET = 11,
|
||||
LAB = 12,
|
||||
POINT_DEFENSE = 13
|
||||
MISSILE_SUBMARINE = 8,
|
||||
STEALTH_SUBMARINE = 9,
|
||||
LAND_FACTORY = 10,
|
||||
NAVAL_FACTORY = 11,
|
||||
MARKET = 12,
|
||||
LAB = 13,
|
||||
POINT_DEFENSE = 14
|
||||
}
|
||||
UnitType = {UNDERWATER = 0, SEA_LEVEL = 1, HOVER = 2, LAND = 3, AIR = 4}
|
||||
ArmorType = {CAST = 0, COMBINED = 1, MECHANIC = 2, SHELL = 3, STEEL = 4}
|
||||
@@ -23,6 +25,29 @@ 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 = 3}},
|
||||
{{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 = 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.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}}}
|
||||
},
|
||||
{{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 = 500, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 50, maxRange = 10}},
|
||||
},
|
||||
unitClass = {
|
||||
UnitClass.WAR_MECH,
|
||||
UnitClass.TANK,
|
||||
@@ -35,7 +60,8 @@ units = {
|
||||
UnitClass.CRUISER,
|
||||
UnitClass.CRUISER,
|
||||
UnitClass.CARRIER,
|
||||
UnitClass.SUBMARINE,
|
||||
UnitClass.MISSILE_SUBMARINE,
|
||||
UnitClass.STEALTH_SUBMARINE,
|
||||
UnitClass.LAND_FACTORY,
|
||||
UnitClass.NAVAL_FACTORY,
|
||||
UnitClass.MARKET,
|
||||
@@ -56,6 +82,7 @@ units = {
|
||||
UnitType.SEA_LEVEL,
|
||||
UnitType.SEA_LEVEL,
|
||||
UnitType.UNDERWATER,
|
||||
UnitType.UNDERWATER,
|
||||
UnitType.LAND,
|
||||
UnitType.LAND,
|
||||
UnitType.LAND,
|
||||
@@ -80,18 +107,16 @@ units = {
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{}
|
||||
},
|
||||
|
||||
isVehicle = {
|
||||
true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false
|
||||
true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false
|
||||
},
|
||||
|
||||
health = {500, 600, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500},
|
||||
cost = {500, 600, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500},
|
||||
range = {15, 20, 45, 15, 14, 14, 14, 14, 14, 14, 13, 13, 12, 12, 15, 0, 40},
|
||||
damage = {15, 120, 250, 15, 14, 14, 13, 13, 12, 12, 15, 100, 100},
|
||||
rateOfFire = {50, 2000, 5000, 100, 100, 100, 100, 100, 100, 100, 0, 0, 100},
|
||||
health = {500, 500, 600, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500},
|
||||
cost = {500, 600, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500},
|
||||
garrisonCapacity = {
|
||||
{},
|
||||
{},
|
||||
@@ -105,6 +130,12 @@ units = {
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{}
|
||||
},
|
||||
|
||||
@@ -309,6 +340,16 @@ units = {
|
||||
{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},
|
||||
@@ -521,6 +562,16 @@ units = {
|
||||
{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},
|
||||
@@ -532,9 +583,28 @@ units = {
|
||||
{x = .1, y = .1, z = .1}
|
||||
}
|
||||
},
|
||||
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},
|
||||
},
|
||||
|
||||
unitAxisLength = {8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 5, 5, 8, 8, 7, 2, 2, 2, 2, 2, 2},
|
||||
lineOfSight = {5, 8, 4, 4, 3, 3, 3, 3, 3, 3, 3, 6, 6, 3, 3, 8, 1, 1, 1, 1},
|
||||
unitAxisLength = {8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 5, 5, 8, 8, 7, 2, 2, 2, 2, 2, 2, 2},
|
||||
lineOfSight = {5, 8, 4, 4, 3, 3, 3, 3, 3, 3, 3, 6, 6, 3, 3, 8, 1, 1, 1, 1, 1},
|
||||
name = {
|
||||
'War mech',
|
||||
'Tank',
|
||||
@@ -547,7 +617,8 @@ units = {
|
||||
'Cheap cruiser',
|
||||
'Transport cruiser',
|
||||
'Heavy carrier',
|
||||
'Submarine',
|
||||
'Missile submarine',
|
||||
'Stealth submarine',
|
||||
'Land factory',
|
||||
'Naval factory',
|
||||
'Market',
|
||||
@@ -566,7 +637,8 @@ units = {
|
||||
'cheapCruiser.xml',
|
||||
'transportCruiser.xml',
|
||||
'heavyCarrier.xml',
|
||||
'submarine.xml',
|
||||
'missileSubmarine.xml',
|
||||
'stealthSubmarine.xml',
|
||||
'landFactory.xml',
|
||||
'navalFactory.xml',
|
||||
'market.xml',
|
||||
@@ -586,6 +658,7 @@ units = {
|
||||
PATH .. vehiclePrefix .. 'Cruisers/',
|
||||
PATH .. vehiclePrefix .. 'Carriers/',
|
||||
PATH .. vehiclePrefix .. 'Submarines/',
|
||||
PATH .. vehiclePrefix .. 'Submarines/',
|
||||
PATH .. structurePrefix .. 'LandFactory/',
|
||||
PATH .. structurePrefix .. 'NavalFactory/',
|
||||
PATH .. structurePrefix .. 'Market/',
|
||||
@@ -605,31 +678,13 @@ units = {
|
||||
PATH .. 'Sounds/Units/Cruisers/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',
|
||||
},
|
||||
fireSfx = {
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
PATH .. 'Sounds/Units/Tanks/attack.ogg',
|
||||
PATH .. 'Sounds/Units/Tanks/attack.ogg',
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
PATH .. 'Sounds/Units/Cruisers/fire.ogg',
|
||||
PATH .. 'Sounds/Units/Cruisers/fire.ogg',
|
||||
PATH .. 'Sounds/Units/Cruisers/fire.ogg',
|
||||
PATH .. 'Sounds/Units/Cruisers/fire.ogg',
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
PATH .. 'Sounds/Units/WarMechs/fire.ogg',
|
||||
},
|
||||
deathSfx = {
|
||||
PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||
PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||
@@ -648,5 +703,6 @@ units = {
|
||||
PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||
PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||
PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||
PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
units.speed = {.025, .025, .025, .025, .05, .05, .1, .1, .1, .1, .1, .1, .15}
|
||||
units.destinationOffset = {.75, .75, .75, .75, 1, 1, .1, .1, .1, .1, .1, .5, .5}
|
||||
units.anglePrecision = {.1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, 3, 3}
|
||||
units.maxTurnAngle = {.1, .1, .1, .1, .5, .5, 1, 1, .5, .5, 1, 2, 2}
|
||||
units.garrisonCategory = {1, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3}
|
||||
units.speed = {.025, .025, .025, .025, .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, .5, .5, .75, .75}
|
||||
units.anglePrecision = {.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, 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}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
resources = {
|
||||
num = 1,
|
||||
|
||||
meshPath = {
|
||||
"resource.xml"
|
||||
},
|
||||
@@ -21,5 +19,6 @@ resources = {
|
||||
{x = -1, y = .571, z = 1},
|
||||
{x = 1, y = .571, z = 1}
|
||||
}
|
||||
}
|
||||
},
|
||||
hitboxOffset = {{x = 0, y = 0, z = 0}}
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ set(UTIL util.cpp binds.h)
|
||||
set(CONTROLLERS gameObjectFrameController.cpp cameraController.cpp)
|
||||
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp)
|
||||
set(CORE gameManager.cpp game.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
|
||||
set(PROJECTILES projectile.cpp)
|
||||
set(PROJECTILES projectile.cpp cruiseMissile.cpp)
|
||||
set(FX fx.cpp)
|
||||
set(VEHICLES vehicle.cpp engineer.cpp transport.cpp)
|
||||
set(STRUCTURES structure.cpp factory.cpp pointDefense.cpp)
|
||||
|
||||
+8
-1
@@ -343,7 +343,7 @@ namespace battleship{
|
||||
bool canSelect = canSelectHoveredOnGameObj();
|
||||
bool ownGameObj = (gameObjHoveredOn && gameObjHoveredOn->getPlayer()->getTeam() == mainPlayer->getTeam());
|
||||
|
||||
if(gameObjHoveredOn && (gameObjHoveredOn->getType() == GameObject::Type::UNIT && ownGameObj)){
|
||||
if(gameObjHoveredOn && gameObjHoveredOn->getType() == GameObject::Type::UNIT && ownGameObj && ((Unit*)gameObjHoveredOn)->getNumGarrisonSlots() > 0){
|
||||
bool canGarrison = true;
|
||||
|
||||
for(int i = 0; i < mainPlayer->getNumSelectedUnits(); i++)
|
||||
@@ -407,6 +407,13 @@ namespace battleship{
|
||||
break;
|
||||
case Bind::EJECT_GARRISON:
|
||||
if(isPressed) issueOrder(Order::TYPE::EJECT, vector<Order::Target>{}, shiftPressed);
|
||||
break;
|
||||
case Bind::LAUNCH:
|
||||
if(isPressed){
|
||||
castRayToTerrain();
|
||||
issueOrder(Order::TYPE::LAUNCH, targets, shiftPressed);
|
||||
}
|
||||
|
||||
break;
|
||||
case Bind::TOGGLE_SUB:
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "cruiseMissile.h"
|
||||
#include "player.h"
|
||||
#include "unit.h"
|
||||
#include "map.h"
|
||||
#include "game.h"
|
||||
|
||||
#include <util.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace battleship{
|
||||
using namespace std;
|
||||
using namespace vb01;
|
||||
|
||||
CruiseMissile::CruiseMissile(Unit *unit, Vector3 tp, Vector3 pos, Quaternion rot) : Projectile(unit, 0, pos, rot), targetPoint(tp), flightStage(FlightStage::ASCENT){
|
||||
Vector3 unitDir = unit->getDirVec();
|
||||
Vector3 leftDir = unit->getLeftVec();
|
||||
Vector3 targDir = (Vector3(targetPoint.x, pos.y, targetPoint.z) - pos).norm();
|
||||
|
||||
bool left = (leftDir.getAngleBetween(targDir) < PI / 2);
|
||||
float angle = unitDir.getAngleBetween(targDir) * (left ? 1 : -1);
|
||||
orientAt(Quaternion(angle, Vector3::VEC_J) * rot);
|
||||
}
|
||||
|
||||
void CruiseMissile::pitch(float rotAngle, Vector3 compVec){
|
||||
float minHeight = 20;
|
||||
float angleToCompVec = dirVec.getAngleBetween(compVec);
|
||||
float angle = (angleToCompVec > rotAngle ? rotAngle : angleToCompVec);
|
||||
|
||||
if(flightStage == FlightStage::ASCENT && pos.y - initPos.y > minHeight){
|
||||
orientAt(Quaternion(angle, leftVec) * rot);
|
||||
if(dirVec.y <= 0) flightStage = FlightStage::CRUISE;
|
||||
}
|
||||
else if(flightStage == FlightStage::DESCENT){
|
||||
Vector3 targDir = (Vector3(targetPoint.x, initPos.y, targetPoint.z) - initPos).norm();
|
||||
|
||||
if(dirVec.getAngleBetween(targDir) < PI / 2)
|
||||
orientAt(Quaternion(angle, leftVec) * rot);
|
||||
}
|
||||
}
|
||||
|
||||
void CruiseMissile::cruise(){
|
||||
float minDist = 6;
|
||||
float initDist = Vector3(targetPoint.x, initPos.y, targetPoint.z).getDistanceFrom(initPos);
|
||||
|
||||
if(pos.getDistanceFrom(Vector3(targetPoint.x, pos.y, targetPoint.z)) < minDist)
|
||||
flightStage = FlightStage::DESCENT;
|
||||
}
|
||||
|
||||
void CruiseMissile::checkSurfaceCollision(){
|
||||
Map *map = Map::getSingleton();
|
||||
int cellId = map->getCellId(pos, false);
|
||||
|
||||
if((pos + dirVec * rayLength).y <= map->getCells()[cellId].pos.y){
|
||||
exploded = true;
|
||||
Game::getSingleton()->explode(pos, explosionDamage, explosionRadius, explosionSfx);
|
||||
player->removeProjectile(this);
|
||||
}
|
||||
}
|
||||
|
||||
void CruiseMissile::update(){
|
||||
GameObject::update();
|
||||
placeAt(pos + dirVec * speed);
|
||||
|
||||
switch(flightStage){
|
||||
case FlightStage::ASCENT:
|
||||
pitch(rotAngle, Vector3(dirVec.x, 0, dirVec.z).norm());
|
||||
break;
|
||||
case FlightStage::DESCENT:
|
||||
pitch(rotAngle, -Vector3::VEC_J);
|
||||
break;
|
||||
case FlightStage::CRUISE:
|
||||
cruise();
|
||||
break;
|
||||
}
|
||||
|
||||
if(!exploded && flightStage == FlightStage::DESCENT){
|
||||
checkSurfaceCollision();
|
||||
if(exploded) return;
|
||||
checkUnitCollision();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef CRUISE_MISSILE_H
|
||||
#define CRUISE_MISSILE_H
|
||||
|
||||
#include "projectile.h"
|
||||
|
||||
namespace battleship{
|
||||
class CruiseMissile : public Projectile{
|
||||
public:
|
||||
CruiseMissile(Unit*, vb01::Vector3, vb01::Vector3, vb01::Quaternion);
|
||||
void update();
|
||||
private:
|
||||
enum class FlightStage{ASCENT, CRUISE, DESCENT};
|
||||
FlightStage flightStage;
|
||||
vb01::Vector3 targetPoint;
|
||||
|
||||
void pitch(float, vb01::Vector3);
|
||||
void cruise();
|
||||
void checkSurfaceCollision();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -40,6 +40,7 @@ namespace battleship{
|
||||
VEHICLE_DATA,
|
||||
STRUCTURE_DATA,
|
||||
RESOURCE_DATA,
|
||||
PROJECTILE_DATA,
|
||||
AI_AGENT,
|
||||
PLAYER
|
||||
};
|
||||
@@ -51,6 +52,7 @@ namespace battleship{
|
||||
"Scripts/GameObjects/Units/vehicleData.lua",
|
||||
"Scripts/GameObjects/Units/structureData.lua",
|
||||
"Scripts/GameObjects/resourceData.lua",
|
||||
"Scripts/GameObjects/Projectiles/projectileData.lua",
|
||||
"Scripts/aiAgent.lua",
|
||||
"Scripts/Core/player.lua"
|
||||
};
|
||||
|
||||
+2
-1
@@ -14,8 +14,9 @@ namespace battleship{
|
||||
void build(Order);
|
||||
private:
|
||||
vb01::s64 lastIncrementTime = 0;
|
||||
int buildRate = 100;
|
||||
|
||||
bool canIncrementStructureStatus(){return vb01::getTime() - lastIncrementTime > rateOfFire;}
|
||||
bool canIncrementStructureStatus(){return vb01::getTime() - lastIncrementTime > buildRate;}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "defConfigs.h"
|
||||
|
||||
#include <assetManager.h>
|
||||
#include <particleEmitter.h>
|
||||
|
||||
#include <stateManager.h>
|
||||
|
||||
@@ -79,9 +80,6 @@ namespace battleship{
|
||||
endGame(false);
|
||||
}
|
||||
|
||||
for(Projectile *proj : projectiles)
|
||||
proj->update();
|
||||
|
||||
for(int i = 0; i < fx.size(); i++){
|
||||
if(getTime() - fx[i].initTime > fx[i].vfxTime)
|
||||
removeFx(i, true);
|
||||
@@ -146,4 +144,45 @@ namespace battleship{
|
||||
|
||||
paused = !paused;
|
||||
}
|
||||
|
||||
void Game::explode(Vector3 pos, int damage, float radius, sf::Sound *explosionSfx){
|
||||
if(!(damage == 0 || radius == 0))
|
||||
for(Player *pl : players){
|
||||
for(Unit *un : pl->getUnits()){
|
||||
float distance = un->getPos().getDistanceFrom(pos);
|
||||
|
||||
if(distance < radius)
|
||||
un->takeDamage(int(damage * (1.f - distance / radius)));
|
||||
}
|
||||
}
|
||||
|
||||
Root *root = Root::getSingleton();
|
||||
|
||||
const int numFrames = 1;
|
||||
string p[numFrames];
|
||||
|
||||
for(int i = 0; i < numFrames; i++)
|
||||
p[i] = GameManager::getSingleton()->getPath() + "Textures/Explosion/explosion07.png";
|
||||
|
||||
Texture *tex = new Texture(p, numFrames, false);
|
||||
|
||||
Material *mat = new Material(root->getLibPath() + "particle");
|
||||
mat->addTexUniform("tex", tex, true);
|
||||
|
||||
ParticleEmitter *pe = new ParticleEmitter(1);
|
||||
pe->setMaterial(mat);
|
||||
pe->setLowLife(3);
|
||||
pe->setHighLife(3);
|
||||
pe->setSize(10 * Vector2::VEC_IJ);
|
||||
pe->setSpeed(0);
|
||||
|
||||
Node *node = new Node(pos + Vector3(0, 2, 0));
|
||||
node->attachParticleEmitter(pe);
|
||||
node->lookAt(Vector3::VEC_J, Vector3::VEC_K);
|
||||
root->getRootNode()->attachChild(node);
|
||||
|
||||
Fx fx(50, 2500, explosionSfx, node);
|
||||
fx.activate();
|
||||
addFx(fx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace sf{
|
||||
class Sound;
|
||||
}
|
||||
|
||||
namespace battleship{
|
||||
class Player;
|
||||
class Projectile;
|
||||
@@ -16,9 +20,9 @@ namespace battleship{
|
||||
void togglePause();
|
||||
void removeFx(int, bool);
|
||||
void removeAllElements();
|
||||
void explode(vb01::Vector3, int, float, sf::Sound*);
|
||||
inline void addFx(Fx f){fx.push_back(f);}
|
||||
inline void addPlayer(Player *pl){players.push_back(pl);}
|
||||
inline void addProjectile(Projectile *proj){projectiles.push_back(proj);}
|
||||
inline std::vector<Player*>& getPlayers(){return players;}
|
||||
inline Player* getPlayer(int id){return players[id];}
|
||||
inline int getNumPlayers(){return players.size();}
|
||||
@@ -30,7 +34,6 @@ namespace battleship{
|
||||
bool paused = false, ended = false;
|
||||
std::vector<Fx> fx;
|
||||
std::vector<Player*> players;
|
||||
std::vector<Projectile*> projectiles;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+43
-5
@@ -1,10 +1,13 @@
|
||||
#include "gameObject.h"
|
||||
#include "gameManager.h"
|
||||
#include "defConfigs.h"
|
||||
#include "unit.h"
|
||||
#include "player.h"
|
||||
|
||||
#include <solUtil.h>
|
||||
|
||||
#include <material.h>
|
||||
#include <box.h>
|
||||
|
||||
#include <SFML/Audio.hpp>
|
||||
|
||||
@@ -33,6 +36,27 @@ namespace battleship{
|
||||
rot = rotQuat;
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
hitbox = new Node(Vector3(offsetPosTable["x"], offsetPosTable["y"], offsetPosTable["z"]));
|
||||
hitbox->attachMesh(box);
|
||||
hitbox->setVisible(false);
|
||||
model->attachChild(hitbox);
|
||||
}
|
||||
|
||||
void GameObject::destroyHitbox(){
|
||||
hitbox->dettachMesh(0);
|
||||
model->dettachChild(hitbox);
|
||||
delete hitbox;
|
||||
}
|
||||
|
||||
void GameObject::initProperties(){
|
||||
sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
|
||||
|
||||
@@ -80,13 +104,11 @@ namespace battleship{
|
||||
root->getRootNode()->attachChild(model);
|
||||
}
|
||||
|
||||
//TODO implement death SFX destruction
|
||||
void GameObject::destroySound(){
|
||||
}
|
||||
|
||||
sf::Sound* GameObject::prepareSfx(sf::SoundBuffer *buffer, string key){
|
||||
sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
|
||||
string sfxPath = SOL_LUA_STATE[key][id + 1];
|
||||
|
||||
sf::Sound* GameObject::prepareSfx(sf::SoundBuffer *buffer, string sfxPath){
|
||||
sf::Sound *sfx = nullptr;
|
||||
|
||||
if(buffer->loadFromFile(sfxPath.c_str())){
|
||||
@@ -99,7 +121,8 @@ namespace battleship{
|
||||
|
||||
void GameObject::initSound(){
|
||||
deathSfxBuffer = new sf::SoundBuffer();
|
||||
deathSfx = prepareSfx(deathSfxBuffer, "deathSfx");
|
||||
string sfxPath = generateView()[getGameObjTableName()]["deathSfx"][id + 1];
|
||||
deathSfx = prepareSfx(deathSfxBuffer, sfxPath);
|
||||
}
|
||||
|
||||
string GameObject::getGameObjTableName(){
|
||||
@@ -145,4 +168,19 @@ namespace battleship{
|
||||
float sizeY = cornersOnScreen[bottomMostPointId].y - cornersOnScreen[topMostPointId].y;
|
||||
return Vector2(sizeX, sizeY);
|
||||
}
|
||||
|
||||
void GameObject::updateGameStats(Unit *targetUnit){
|
||||
if(targetUnit->getHealth() <= targetUnit->getDeathHp()){
|
||||
Player *targUnitPlayer = targetUnit->getPlayer();
|
||||
|
||||
if(targetUnit->isVehicle()){
|
||||
player->incVehiclesDestroyed();
|
||||
targUnitPlayer->incVehiclesLost();
|
||||
}
|
||||
else{
|
||||
player->incStructuresDestroyed();
|
||||
targUnitPlayer->incStructuresLost();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -12,6 +12,7 @@ namespace sf{
|
||||
|
||||
namespace battleship{
|
||||
class Player;
|
||||
class Unit;
|
||||
|
||||
class GameObject{
|
||||
public:
|
||||
@@ -25,6 +26,8 @@ namespace battleship{
|
||||
void orientAt(vb01::Quaternion);
|
||||
std::string getGameObjTableName();
|
||||
vb01::Vector2 calculateSelectionRect();
|
||||
void updateGameStats(Unit*);
|
||||
static sf::Sound* prepareSfx(sf::SoundBuffer*, std::string);
|
||||
inline vb01::Vector2 getScreenPos(){return screenPos;}
|
||||
inline vb01::Vector3 getCorner(int i){return corners[i];}
|
||||
inline bool isSelectable(){return selectable;}
|
||||
@@ -42,15 +45,17 @@ namespace battleship{
|
||||
inline vb01::Vector3 getUpVec() {return upVec;}
|
||||
inline int getId() {return id;}
|
||||
inline Type getType(){return type;}
|
||||
inline vb01::Node* getHitbox(){return hitbox;}
|
||||
private:
|
||||
int sortCorners(std::vector<vb01::Vector2>&, bool, bool);
|
||||
protected:
|
||||
virtual void initProperties();
|
||||
virtual void destroyModel();
|
||||
virtual void initModel(bool = true);
|
||||
virtual void initHitbox();
|
||||
virtual void destroyHitbox();
|
||||
virtual void destroySound();
|
||||
virtual void initSound();
|
||||
sf::Sound* prepareSfx(sf::SoundBuffer*, std::string);
|
||||
|
||||
Type type;
|
||||
int id;
|
||||
@@ -58,6 +63,7 @@ namespace battleship{
|
||||
sf::SoundBuffer *deathSfxBuffer;
|
||||
sf::Sound *deathSfx;
|
||||
vb01::Model *model = nullptr;
|
||||
vb01::Node *hitbox = nullptr;
|
||||
vb01::Vector3 pos = vb01::Vector3(0, 0, 0), upVec = vb01::Vector3(0, 1, 0), dirVec = vb01::Vector3(0, 0, 1), leftVec = vb01::Vector3(1, 0, 0), corners[8];
|
||||
vb01::Vector2 screenPos;
|
||||
vb01::Quaternion rot;
|
||||
|
||||
+15
-2
@@ -6,6 +6,7 @@
|
||||
#include "projectile.h"
|
||||
#include "resourceDeposit.h"
|
||||
#include "pointDefense.h"
|
||||
#include "cruiseMissile.h"
|
||||
#include "defConfigs.h"
|
||||
|
||||
#include <solUtil.h>
|
||||
@@ -39,8 +40,20 @@ namespace battleship{
|
||||
}
|
||||
}
|
||||
|
||||
Projectile* GameObjectFactory::createProjectile(Unit *unti, int id, Vector3 pos, Quaternion rot){
|
||||
return nullptr;
|
||||
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];
|
||||
|
||||
switch((ProjectileClass)projectileClass){
|
||||
case ProjectileClass::CRUISE_MISSILE:
|
||||
{
|
||||
Order::Target target = unit->getOrder(0).targets[0];
|
||||
Vector3 targetPos = (target.unit ? target.unit->getPos() : target.pos);
|
||||
return new CruiseMissile(unit, targetPos, pos, rot);
|
||||
}
|
||||
default:
|
||||
return new Projectile(unit, id, pos, rot);
|
||||
}
|
||||
}
|
||||
|
||||
ResourceDeposit* GameObjectFactory::createResourceDeposit(Player *player, int id, Vector3 pos, Quaternion rot){
|
||||
|
||||
@@ -373,7 +373,7 @@ namespace battleship{
|
||||
}
|
||||
|
||||
//TODO replace search with binary search
|
||||
int Map::getCellId(Vector3 pos){
|
||||
int Map::getCellId(Vector3 pos, bool checkUnderwaterCells){
|
||||
int numHorCells = int(mapSize.x / CELL_SIZE.x), horId = -1;
|
||||
|
||||
for(int i = 0; i < numHorCells; i++)
|
||||
@@ -392,7 +392,7 @@ namespace battleship{
|
||||
|
||||
int surfaceCellId = vertId * numHorCells + horId;
|
||||
|
||||
if(cells[surfaceCellId].type == Cell::Type::WATER && !cells[surfaceCellId].underWaterCellIds.empty()){
|
||||
if(checkUnderwaterCells && cells[surfaceCellId].type == Cell::Type::WATER && !cells[surfaceCellId].underWaterCellIds.empty()){
|
||||
int cellId = surfaceCellId;
|
||||
|
||||
for(int i = 0; i <= cells[surfaceCellId].underWaterCellIds.size(); i++){
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace battleship{
|
||||
void update();
|
||||
void load(std::string, bool = false);
|
||||
void unload();
|
||||
int getCellId(vb01::Vector3);
|
||||
int getCellId(vb01::Vector3, bool = true);
|
||||
bool isPointWithinTerrainObject(vb01::Vector3, int);
|
||||
void loadPlayerGameObjects();
|
||||
inline std::string getMapName(){return mapName;}
|
||||
|
||||
+16
@@ -21,6 +21,9 @@ namespace battleship{
|
||||
for(Unit *u : units)
|
||||
u->update();
|
||||
|
||||
for(Projectile *proj : projectiles)
|
||||
proj->update();
|
||||
|
||||
for(ResourceDeposit *rd : resourceDeposits)
|
||||
rd->update();
|
||||
}
|
||||
@@ -119,6 +122,19 @@ namespace battleship{
|
||||
resourceDeposits.erase(resourceDeposits.begin() + id);
|
||||
}
|
||||
|
||||
void Player::removeProjectile(Projectile *proj){
|
||||
for(int i = 0; i < projectiles.size(); i++)
|
||||
if(proj == projectiles[i]){
|
||||
removeProjectile(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Player::removeProjectile(int id){
|
||||
delete projectiles[id];
|
||||
projectiles.erase(projectiles.begin() + id);
|
||||
}
|
||||
|
||||
vector<Unit*> Player::getSelectedUnitsByClass(UnitClass uc){
|
||||
vector<Unit*> selectedUnits = getSelectedUnits(), unitsByClass;
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace battleship{
|
||||
void removeUnit(Unit*);
|
||||
void removeUnit(int);
|
||||
void removeResourceDeposit(int);
|
||||
void removeProjectile(int);
|
||||
void removeProjectile(Projectile*);
|
||||
bool isThisPlayersUnit(GameObject*);
|
||||
std::vector<Unit*> getSelectedUnitsByClass(UnitClass);
|
||||
void selectUnits(std::vector<Unit*>);
|
||||
@@ -32,6 +34,8 @@ namespace battleship{
|
||||
inline std::vector<ResourceDeposit*>& getResourceDeposits(){return resourceDeposits;}
|
||||
inline void addResourceDeposit(ResourceDeposit *rd){resourceDeposits.push_back(rd);}
|
||||
inline int getNumResourceDeposits(){return resourceDeposits.size();}
|
||||
inline void addProjectile(Projectile *proj){projectiles.push_back(proj);}
|
||||
inline int getNumProjectiles(){return projectiles.size();}
|
||||
inline Unit* getUnit(int i){return units[i];}
|
||||
inline std::vector<Unit*>& getUnits(){return units;}
|
||||
inline void setTeam(int t){team = t;}
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ namespace battleship{
|
||||
Unit *targUnit = order.targets[0].unit;
|
||||
Vector3 targDir = (targUnit ? targUnit->getPos() : order.targets[0].pos) - pos;
|
||||
|
||||
if(targDir.getLength() > range){
|
||||
if(targDir.getLength() > weapons[0]->getMaxRange()){
|
||||
removeOrder(0);
|
||||
return;
|
||||
}
|
||||
@@ -20,8 +20,8 @@ namespace battleship{
|
||||
|
||||
if(angleToTarg > .05)
|
||||
rotateTurret(calculateRotation(targDir.norm(), angleToTarg, .1));
|
||||
else if(canFire())
|
||||
fire();
|
||||
else
|
||||
weapons[0]->fire(order);
|
||||
|
||||
Unit::attack(order);
|
||||
}
|
||||
|
||||
+64
-77
@@ -1,9 +1,9 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include <node.h>
|
||||
#include <model.h>
|
||||
#include <material.h>
|
||||
#include <particleEmitter.h>
|
||||
#include <quaternion.h>
|
||||
#include <rayCaster.h>
|
||||
|
||||
#include <stateManager.h>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "unit.h"
|
||||
#include "util.h"
|
||||
#include "projectile.h"
|
||||
#include "resourceDeposit.h"
|
||||
#include "defConfigs.h"
|
||||
#include "inGameAppState.h"
|
||||
#include "fx.h"
|
||||
@@ -19,107 +20,93 @@ using namespace std;
|
||||
using namespace vb01;
|
||||
|
||||
namespace battleship{
|
||||
using namespace vb01;
|
||||
using namespace configData;
|
||||
using namespace gameBase;
|
||||
|
||||
Projectile::Projectile(Unit *unit, Node *node, Vector3 pos, Vector3 dir, Vector3 left, Vector3 up, int id, int weaponTypeId, int weaponId) : GameObject(GameObject::Type::PROJECTILE, id, unit->getPlayer(), pos, Quaternion::QUAT_W){
|
||||
this->unit = unit;
|
||||
this->id = id;
|
||||
this->weaponTypeId = weaponTypeId;
|
||||
this->pos = pos;
|
||||
initPos = pos;
|
||||
|
||||
dirVec = dir;
|
||||
leftVec = left;
|
||||
upVec = up;
|
||||
|
||||
initProperties(weaponId);
|
||||
initModel(node);
|
||||
Projectile::Projectile(Unit *un, int id, Vector3 pos, Quaternion rot) : GameObject(GameObject::Type::PROJECTILE, id, un->getPlayer(), pos, rot), unit(un), initPos(pos){
|
||||
initProperties();
|
||||
initModel();
|
||||
initSound();
|
||||
placeAt(pos);
|
||||
orientAt(rot);
|
||||
}
|
||||
|
||||
Projectile::~Projectile(){
|
||||
}
|
||||
|
||||
void Projectile::initProperties(int weaponId){
|
||||
GameObject::initProperties();
|
||||
|
||||
sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
|
||||
rayLength = SOL_LUA_STATE["rayLength"][id + 1][weaponTypeId + 1][weaponId + 1];
|
||||
damage = SOL_LUA_STATE["damage"][id + 1][weaponTypeId + 1][weaponId + 1];
|
||||
speed = SOL_LUA_STATE["speed"][id + 1][weaponTypeId + 1][weaponId + 1];
|
||||
destroyModel();
|
||||
}
|
||||
|
||||
void Projectile::initModel(Node *node){
|
||||
if(!node){
|
||||
sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
|
||||
string meshPath = SOL_LUA_STATE["meshPath"][id + 1][weaponTypeId + 1];
|
||||
this->node = new Model(meshPath);
|
||||
void Projectile::initProperties(){
|
||||
GameObject::initProperties();
|
||||
|
||||
Material *mat = new Material(Root::getSingleton()->getLibPath() + "texture");
|
||||
mat->addBoolUniform("lightingEnabled", false);
|
||||
|
||||
string diffTexPath = SOL_LUA_STATE["diffuseMapTextPath"][id + 1][weaponTypeId + 1];
|
||||
string f[]{diffTexPath};
|
||||
Texture *diffuseTexture = new Texture(f, 1, false);
|
||||
mat->addTexUniform("textures[0]", diffuseTexture, true);
|
||||
|
||||
this->node->setMaterial(mat);
|
||||
}
|
||||
|
||||
this->node->setPosition(pos);
|
||||
sol::table projTable = generateView()[GameObject::getGameObjTableName()];
|
||||
rayLength = projTable["rayLength"][id + 1];
|
||||
directHitDamage = projTable["directHitDamage"][id + 1];
|
||||
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];;
|
||||
}
|
||||
|
||||
void Projectile::initSound(){
|
||||
GameManager *gm = GameManager::getSingleton();
|
||||
|
||||
sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
|
||||
string unitName = SOL_LUA_STATE["name"][id + 1];
|
||||
string projectileName = SOL_LUA_STATE["projectileName"][id + 1][weaponTypeId + 1];
|
||||
string p1 = gm->getPath() + "Sounds/" + unitName + "s/" + projectileName + ".ogg";
|
||||
string p2 = gm->getPath() + "Sounds/Explosions/explosion03" + to_string(rand() % 4) + ".ogg";
|
||||
|
||||
shotSfxBuffer = new sf::SoundBuffer();
|
||||
explosionSfxBuffer = new sf::SoundBuffer();
|
||||
|
||||
if(shotSfxBuffer->loadFromFile(p1.c_str())){
|
||||
shotSfx = new sf::Sound(*shotSfxBuffer);
|
||||
shotSfx->play();
|
||||
}
|
||||
string p2 = gm->getPath() + "Sounds/SFX/Explosions/explosion0" + to_string(rand() % 4) + ".ogg";
|
||||
|
||||
if(explosionSfxBuffer->loadFromFile(p2.c_str()))
|
||||
explosionSfx = new sf::Sound(*explosionSfxBuffer);
|
||||
}
|
||||
|
||||
|
||||
void Projectile::update() {
|
||||
if(unit->isDebuggable())
|
||||
debug();
|
||||
GameObject::update();
|
||||
placeAt(pos + speed * dirVec);
|
||||
|
||||
checkForCollision();
|
||||
if(!exploded){
|
||||
checkSurfaceCollision();
|
||||
if(exploded) return;
|
||||
checkUnitCollision();
|
||||
}
|
||||
}
|
||||
|
||||
void Projectile::checkForCollision() {
|
||||
}
|
||||
void Projectile::checkUnitCollision(){
|
||||
vector<Player*> players = Game::getSingleton()->getPlayers();
|
||||
vector<Unit*> targetUnits;
|
||||
vector<Node*> targetNodes;
|
||||
|
||||
void Projectile::explode(Node *collNode) {
|
||||
exploded = true;
|
||||
for(Player *pl : players){
|
||||
vector<Unit*> units = pl->getUnits();
|
||||
|
||||
for (Player *p : Game::getSingleton()->getPlayers()) {
|
||||
for (Unit *u : p->getUnits())
|
||||
if (collNode == u->getNode())
|
||||
u->takeDamage(damage);
|
||||
}
|
||||
for(Unit *u : units)
|
||||
if(unit && unit != u){
|
||||
targetUnits.push_back(u);
|
||||
targetNodes.push_back(u->getHitbox());
|
||||
}
|
||||
}
|
||||
|
||||
vector<RayCaster::CollisionResult> results = RayCaster::cast(pos, dirVec, targetNodes, rayLength);
|
||||
|
||||
if(!results.empty()){
|
||||
for(int i = 0; i < targetNodes.size(); i++)
|
||||
if(targetNodes[i]->getMesh(0) == results[0].mesh){
|
||||
exploded = true;
|
||||
targetUnits[i]->takeDamage(directHitDamage);
|
||||
Game::getSingleton()->explode(pos, explosionDamage, explosionRadius, explosionSfx);
|
||||
player->removeProjectile(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Projectile::checkSurfaceCollision(){
|
||||
Map *map = Map::getSingleton();
|
||||
int cellId = map->getCellId(pos, false);
|
||||
|
||||
if(map->getCells()[cellId].type == Map::Cell::LAND){
|
||||
exploded = true;
|
||||
player->removeProjectile(this);
|
||||
}
|
||||
}
|
||||
|
||||
StateManager *sm = GameManager::getSingleton()->getStateManager();
|
||||
InGameAppState *inGameState = ((InGameAppState*)sm->getAppStateByType((int)AppStateType::IN_GAME_STATE));
|
||||
string path = GameManager::getSingleton()->getPath() + "Sounds/Explosions/explosion0" + to_string(rand() % 4) + ".ogg";
|
||||
}
|
||||
|
||||
void Projectile::debug(){
|
||||
}
|
||||
|
||||
void Projectile::orientProjectile(Quaternion rot){
|
||||
node->setOrientation(rot);
|
||||
this->rot = rot;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-22
@@ -3,46 +3,38 @@
|
||||
|
||||
#include <SFML/Audio.hpp>
|
||||
|
||||
#include <vector.h>
|
||||
#include <quaternion.h>
|
||||
|
||||
#include "gameManager.h"
|
||||
#include "gameObject.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace vb01{
|
||||
class Node;
|
||||
class Model;
|
||||
class Mesh;
|
||||
}
|
||||
|
||||
namespace battleship {
|
||||
class Unit;
|
||||
|
||||
enum class ProjectileClass{CRUISE_MISSILE, TORPEDO};
|
||||
class Unit;
|
||||
|
||||
class Projectile : public GameObject{
|
||||
public:
|
||||
Projectile(Unit*, vb01::Node*, vb01::Vector3, vb01::Vector3, vb01::Vector3, vb01::Vector3, int, int, int);
|
||||
Projectile(Unit*, int, vb01::Vector3, vb01::Quaternion);
|
||||
virtual ~Projectile();
|
||||
virtual void update();
|
||||
virtual void debug();
|
||||
void orientProjectile(vb01::Quaternion);
|
||||
inline bool isExploded() {return exploded;}
|
||||
inline Unit* getUnit(){return unit;}
|
||||
private:
|
||||
void initProperties(int);
|
||||
void initModel(vb01::Node*);
|
||||
void initProperties();
|
||||
void initSound();
|
||||
void checkCollision();
|
||||
protected:
|
||||
virtual void checkForCollision();
|
||||
void explode(vb01::Node*);
|
||||
virtual void checkUnitCollision();
|
||||
virtual void checkSurfaceCollision();
|
||||
|
||||
vb01::Model *node = nullptr;
|
||||
bool exploded = false;
|
||||
float speed, rayLength, scale;
|
||||
int damage, id, weaponTypeId;
|
||||
vb01::Vector3 initPos;
|
||||
s64 lastUpdateTime = 0;
|
||||
Unit *unit = nullptr;
|
||||
float speed, rayLength, explosionRadius, rotAngle;
|
||||
int directHitDamage, explosionDamage;
|
||||
vb01::Vector3 initPos;
|
||||
Unit *unit = nullptr;
|
||||
sf::SoundBuffer *shotSfxBuffer, *explosionSfxBuffer;
|
||||
sf::Sound *shotSfx = nullptr, *explosionSfx = nullptr;
|
||||
};
|
||||
|
||||
@@ -6,11 +6,13 @@ namespace battleship{
|
||||
ResourceDeposit::ResourceDeposit(Player *player, int id, Vector3 pos, Quaternion rot) : GameObject(GameObject::Type::RESOURCE_DEPOSIT, id, player, pos, rot){
|
||||
initProperties();
|
||||
initModel();
|
||||
initHitbox();
|
||||
placeAt(pos);
|
||||
orientAt(rot);
|
||||
}
|
||||
|
||||
ResourceDeposit::~ResourceDeposit(){
|
||||
destroyHitbox();
|
||||
destroyModel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "util.h"
|
||||
#include "game.h"
|
||||
#include "vehicle.h"
|
||||
#include "gameObjectFactory.h"
|
||||
#include "activeGameState.h"
|
||||
#include "defConfigs.h"
|
||||
#include "pathfinder.h"
|
||||
@@ -24,6 +25,76 @@ using namespace gameBase;
|
||||
using namespace std;
|
||||
|
||||
namespace battleship{
|
||||
Unit::Weapon::Weapon(Unit *u, sol::table weaponTable) :
|
||||
unit(u),
|
||||
type((Weapon::Type)weaponTable["type"]),
|
||||
rateOfFire(weaponTable["rateOfFire"]),
|
||||
damage(weaponTable["damage"].get_or(0))
|
||||
{
|
||||
maxRange = weaponTable["maxRange"];
|
||||
fireSfxBuffer = new sf::SoundBuffer();
|
||||
string sfxPath = weaponTable["fireSfx"];
|
||||
fireSfx = GameObject::prepareSfx(fireSfxBuffer, sfxPath);
|
||||
|
||||
string projTableKey = "projectile";
|
||||
sol::optional<sol::table> proj = weaponTable[projTableKey];
|
||||
|
||||
if(proj != sol::nullopt){
|
||||
projId = weaponTable[projTableKey]["id"];
|
||||
sol::table projTable = generateView()["projectiles"];
|
||||
ProjectileClass pc = (ProjectileClass)projTable["projectileClass"][projId + 1];
|
||||
|
||||
if(pc == ProjectileClass::CRUISE_MISSILE){
|
||||
minRange = 0;
|
||||
float rotAngle = projTable["rotAngle"][projId + 1];
|
||||
float speed = projTable["speed"][projId + 1];
|
||||
float base = PI / 2, alpha = 0;
|
||||
|
||||
while(base - alpha > .001){
|
||||
minRange += speed * sin(alpha);
|
||||
alpha += (base - alpha > rotAngle ? rotAngle : base - alpha);
|
||||
}
|
||||
|
||||
minRange *= 2;
|
||||
}
|
||||
|
||||
sol::table posTable = weaponTable[projTableKey]["pos"];
|
||||
projPos = Vector3(posTable["x"], posTable["y"], posTable["z"]);
|
||||
sol::table rotTable = weaponTable[projTableKey]["rot"];
|
||||
projRot = Quaternion(rotTable["w"], rotTable["x"], rotTable["y"], rotTable["z"]);
|
||||
}
|
||||
}
|
||||
|
||||
Unit::Weapon::~Weapon(){
|
||||
if(fireSfx){
|
||||
fireSfx->stop();
|
||||
delete fireSfx;
|
||||
delete fireSfxBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::Weapon::fire(Order order){
|
||||
if(!canFire()) return;
|
||||
|
||||
fireSfx->play();
|
||||
Unit *targetUnit = order.targets[0].unit;
|
||||
|
||||
if(targetUnit && projId == -1){
|
||||
targetUnit->takeDamage(damage);
|
||||
unit->updateGameStats(targetUnit);
|
||||
}
|
||||
else if(projId != -1){
|
||||
Vector3 leftVec = unit->getLeftVec();
|
||||
Vector3 upVec = unit->getUpVec();
|
||||
Vector3 dirVec = unit->getDirVec();
|
||||
Vector3 p = unit->getPos() + leftVec * projPos.x + upVec * projPos.y + dirVec * projPos.z;
|
||||
Quaternion r = unit->getRot() * projRot;
|
||||
unit->getPlayer()->addProjectile(GameObjectFactory::createProjectile(unit, projId, p, r));
|
||||
}
|
||||
|
||||
lastFireTime = getTime();
|
||||
}
|
||||
|
||||
Unit::Unit(Player *player, int id, Vector3 pos, Quaternion rot) : GameObject(GameObject::Type::UNIT, id, player, pos, rot){
|
||||
this->id = id;
|
||||
this->player = player;
|
||||
@@ -40,13 +111,17 @@ namespace battleship{
|
||||
removeBar(hpBackgroundNode);
|
||||
removeBar(hpForegroundNode);
|
||||
destroySound();
|
||||
destroyHitbox();
|
||||
destroyModel();
|
||||
destroyWeapons();
|
||||
}
|
||||
|
||||
void Unit::init(){
|
||||
initProperties();
|
||||
initModel();
|
||||
initHitbox();
|
||||
initSound();
|
||||
initWeapons();
|
||||
placeAt(pos);
|
||||
orientAt(rot);
|
||||
}
|
||||
@@ -60,9 +135,6 @@ namespace battleship{
|
||||
health = SOL_LUA_STATE["health"][id + 1];
|
||||
maxHealth = health;
|
||||
|
||||
rateOfFire = SOL_LUA_STATE["rateOfFire"][id + 1];
|
||||
range = SOL_LUA_STATE["range"][id + 1];
|
||||
damage = SOL_LUA_STATE["damage"][id + 1];
|
||||
lineOfSight = SOL_LUA_STATE["lineOfSight"][id + 1];
|
||||
unitClass = (UnitClass)SOL_LUA_STATE["unitClass"][id + 1];
|
||||
type = (UnitType)SOL_LUA_STATE["unitType"][id + 1];
|
||||
@@ -87,35 +159,47 @@ namespace battleship{
|
||||
armorTypes.push_back(arm);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::initWeapons(){
|
||||
sol::state_view SOL_STATE_VIEW = generateView();
|
||||
sol::table unitTable = SOL_STATE_VIEW[GameObject::getGameObjTableName()];
|
||||
|
||||
string varName = "numWeapons", tblName = "weapons";
|
||||
SOL_STATE_VIEW.script(varName + " = #units." + tblName + "[" + to_string(id + 1) + "]");
|
||||
int numWeapons = SOL_STATE_VIEW[varName];
|
||||
|
||||
for(int i = 0; i < numWeapons; i++)
|
||||
weapons.push_back(new Weapon(this, unitTable[tblName][id + 1][i + 1]));
|
||||
}
|
||||
|
||||
void Unit::destroyWeapons(){
|
||||
for(Weapon *weapon : weapons)
|
||||
delete weapon;
|
||||
|
||||
weapons.clear();
|
||||
}
|
||||
|
||||
void Unit::destroySound(){
|
||||
selectionSfx->stop();
|
||||
delete selectionSfx;
|
||||
delete selectionSfxBuffer;
|
||||
|
||||
if(fireSfx){
|
||||
fireSfx->stop();
|
||||
delete fireSfx;
|
||||
delete fireSfxBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::initSound(){
|
||||
GameObject::initSound();
|
||||
|
||||
selectionSfxBuffer = new sf::SoundBuffer();
|
||||
selectionSfx = GameObject::prepareSfx(selectionSfxBuffer, "selectionSfx");
|
||||
|
||||
fireSfxBuffer = new sf::SoundBuffer();
|
||||
fireSfx = prepareSfx(fireSfxBuffer, "fireSfx");
|
||||
string sfxPath = generateView()[getGameObjTableName()]["selectionSfx"][id + 1];
|
||||
selectionSfx = GameObject::prepareSfx(selectionSfxBuffer, sfxPath);
|
||||
}
|
||||
|
||||
void Unit::reinit(){
|
||||
destroySound();
|
||||
destroyHitbox();
|
||||
destroyModel();
|
||||
initModel();
|
||||
initSound();
|
||||
initProperties();
|
||||
initModel();
|
||||
initHitbox();
|
||||
initSound();
|
||||
placeAt(pos);
|
||||
orientAt(rot);
|
||||
}
|
||||
@@ -150,6 +234,19 @@ namespace battleship{
|
||||
delete node;
|
||||
}
|
||||
|
||||
void Unit::launch(Order order){
|
||||
for(Weapon *weapon : weapons){
|
||||
Vector3 targPos = Vector3(order.targets[0].pos.x, pos.y, order.targets[0].pos.z);
|
||||
|
||||
if(weapon->getProjectileId() == 0 && weapon->getMinRange() < targPos.getDistanceFrom(pos)){
|
||||
weapon->fire(order);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
removeOrder(0);
|
||||
}
|
||||
|
||||
float Unit::calculateRotation(Vector3 dir, float angle, float maxTurnAngle){
|
||||
float rotSpeed = (maxTurnAngle > angle ? angle : maxTurnAngle);
|
||||
|
||||
@@ -159,30 +256,6 @@ namespace battleship{
|
||||
return rotSpeed;
|
||||
}
|
||||
|
||||
void Unit::fire(){
|
||||
fireSfx->play();
|
||||
|
||||
Unit *targetUnit = orders[0].targets[0].unit;
|
||||
|
||||
if(targetUnit){
|
||||
targetUnit->takeDamage(damage);
|
||||
|
||||
if(targetUnit->getHealth() <= DEATH_HP){
|
||||
Player *targUnitPlayer = targetUnit->getPlayer();
|
||||
|
||||
if(targetUnit->isVehicle()){
|
||||
player->incVehiclesDestroyed();
|
||||
targUnitPlayer->incVehiclesLost();
|
||||
}
|
||||
else{
|
||||
player->incStructuresDestroyed();
|
||||
targUnitPlayer->incStructuresLost();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastFireTime = getTime();
|
||||
}
|
||||
|
||||
void Unit::initUnitStats(){
|
||||
}
|
||||
@@ -220,41 +293,10 @@ namespace battleship{
|
||||
for(GarrisonSlot &slot : garrisonSlots)
|
||||
displayUnitStats(slot.foreground, slot.background, (int)((bool)slot.vehicle), (int)true, renderSelectables, slot.offset);
|
||||
|
||||
if (health <= DEATH_HP)
|
||||
blowUp();
|
||||
}
|
||||
|
||||
void Unit::blowUp(){
|
||||
Root *root = Root::getSingleton();
|
||||
|
||||
const int numFrames = 1;
|
||||
string p[numFrames];
|
||||
|
||||
for(int i = 0; i < numFrames; i++)
|
||||
p[i] = GameManager::getSingleton()->getPath() + "Textures/Explosion/explosion07.png";
|
||||
|
||||
Texture *tex = new Texture(p, numFrames, false);
|
||||
|
||||
Material *mat = new Material(root->getLibPath() + "particle");
|
||||
mat->addTexUniform("tex", tex, true);
|
||||
|
||||
ParticleEmitter *pe = new ParticleEmitter(1);
|
||||
pe->setMaterial(mat);
|
||||
pe->setLowLife(3);
|
||||
pe->setHighLife(3);
|
||||
pe->setSize(10 * Vector2::VEC_IJ);
|
||||
pe->setSpeed(0);
|
||||
|
||||
Node *node = new Node(pos + Vector3(0, 2, 0));
|
||||
node->attachParticleEmitter(pe);
|
||||
node->lookAt(Vector3::VEC_J, Vector3::VEC_K);
|
||||
root->getRootNode()->attachChild(node);
|
||||
|
||||
Fx fx(50, 2500, deathSfx, node);
|
||||
fx.activate();
|
||||
Game::getSingleton()->addFx(fx);
|
||||
|
||||
player->removeUnit(this);
|
||||
if (health <= DEATH_HP){
|
||||
Game::getSingleton()->explode(pos, 0, 0, deathSfx);
|
||||
player->removeUnit(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::displayUnitStats(Node *foreground, Node *background, int currVal, int maxVal, bool render, Vector2 offset) {
|
||||
|
||||
@@ -55,11 +55,39 @@ namespace battleship{
|
||||
|
||||
enum class MoveDir {LEFT, UP, FORW};
|
||||
enum class Corner {FRONT_LEFT, FRONT_RIGHT, REAR_LEFT, REAR_RIGHT};
|
||||
enum class UnitClass {WAR_MECH, TANK, ARTILLERY, ENGINEER, TRANSPORT, CARGO_SHIP, CRUISER, CARRIER, SUBMARINE, LAND_FACTORY, NAVAL_FACTORY, MARKET, LAB, POINT_DEFENSE};
|
||||
enum class UnitClass {WAR_MECH, TANK, ARTILLERY, ENGINEER, TRANSPORT, CARGO_SHIP, CRUISER, CARRIER, MISSILE_SUBMARINE, STEALTH_SUBMARINE, LAND_FACTORY, NAVAL_FACTORY, MARKET, LAB, POINT_DEFENSE};
|
||||
enum class UnitType {UNDERWATER, SEA_LEVEL, HOVER, LAND, AIR, NONE = -1};
|
||||
|
||||
class Unit : public GameObject{
|
||||
public:
|
||||
class Weapon{
|
||||
public:
|
||||
enum class Type{HITSCAN, SHELL, TORPEDO, CRUISE_MISSILE};
|
||||
|
||||
Weapon(Unit*, sol::table);
|
||||
~Weapon();
|
||||
virtual void fire(Order);
|
||||
inline Type getType(){return type;}
|
||||
inline int getProjectileId(){return projId;}
|
||||
inline int getRateOfFire(){return rateOfFire;}
|
||||
inline int getDamage(){return damage;}
|
||||
inline int getMinRange(){return minRange;}
|
||||
inline int getMaxRange(){return maxRange;}
|
||||
inline Unit* getUnit(){return unit;}
|
||||
private:
|
||||
Type type;
|
||||
int projId = -1, rateOfFire, damage = 0;
|
||||
float minRange = 0, maxRange;
|
||||
vb01::Vector3 projPos;
|
||||
vb01::Quaternion projRot;
|
||||
vb01::s64 lastFireTime = 0;
|
||||
Unit *unit = nullptr;
|
||||
sf::SoundBuffer *fireSfxBuffer;
|
||||
sf::Sound *fireSfx = nullptr;
|
||||
|
||||
inline bool canFire(){return vb01::getTime() - lastFireTime > rateOfFire;}
|
||||
};
|
||||
|
||||
struct GarrisonSlot{
|
||||
Vehicle *vehicle = nullptr;
|
||||
int category;
|
||||
@@ -74,7 +102,6 @@ namespace battleship{
|
||||
Unit(Player*, int, vb01::Vector3, vb01::Quaternion);
|
||||
virtual ~Unit();
|
||||
virtual void update();
|
||||
virtual void blowUp();
|
||||
virtual void halt();
|
||||
void updateGarrison(Vehicle*, bool);
|
||||
virtual void select();
|
||||
@@ -90,7 +117,6 @@ namespace battleship{
|
||||
inline PointDefense* toPointDefense(){return (PointDefense*)this;}
|
||||
inline int getNumGarrisonSlots(){return garrisonSlots.size();}
|
||||
inline const std::vector<GarrisonSlot>& getGarrisonSlots(){return garrisonSlots;}
|
||||
inline vb01::Vector3* getPosPtr() {return &pos;}
|
||||
inline float getLineOfSight() {return lineOfSight;}
|
||||
inline vb01::Model* getNode() {return model;}
|
||||
inline UnitType getType() {return type;}
|
||||
@@ -98,12 +124,17 @@ namespace battleship{
|
||||
inline void takeDamage(int damage) {health -= damage;}
|
||||
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 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();}
|
||||
private:
|
||||
void renderOrderLine(bool);
|
||||
void updateScreenCoordinates();
|
||||
void init();
|
||||
void initWeapons();
|
||||
void destroyWeapons();
|
||||
inline bool canDisplayOrderLine(){return vb01::getTime() - orderLineDispTime < orderVecDispLength;}
|
||||
|
||||
const int orderVecDispLength = 2000, DEATH_HP = 0;
|
||||
@@ -114,13 +145,12 @@ namespace battleship{
|
||||
UnitClass unitClass;
|
||||
UnitType type;
|
||||
std::vector<Order> orders;
|
||||
sf::SoundBuffer *fireSfxBuffer;
|
||||
sf::Sound *fireSfx = nullptr;
|
||||
int health, damage, maxHealth, cost, id, playerId, lenHpBar = 200, rateOfFire;
|
||||
int health, maxHealth, cost, id, playerId, lenHpBar = 200;
|
||||
s64 orderLineDispTime = 0, lastFireTime = 0;
|
||||
float lineOfSight, range;
|
||||
float lineOfSight;
|
||||
std::vector<GarrisonSlot> garrisonSlots;
|
||||
std::vector<Armor> armorTypes;
|
||||
std::vector<Weapon*> weapons;
|
||||
|
||||
std::vector<Player*> getSelectingPlayers();
|
||||
void removeOrder(int);
|
||||
@@ -135,13 +165,11 @@ namespace battleship{
|
||||
virtual void build(Order){}
|
||||
virtual void move(Order){}
|
||||
virtual void patrol(Order){}
|
||||
virtual void launch(Order){}
|
||||
virtual void launch(Order);
|
||||
float calculateRotation(vb01::Vector3, float, float);
|
||||
virtual void fire();
|
||||
void removeBar(vb01::Node*);
|
||||
vb01::Node* createBar(vb01::Vector2, vb01::Vector2, vb01::Vector4);
|
||||
void displayUnitStats(vb01::Node*, vb01::Node*, int, int, bool, vb01::Vector2 offset = vb01::Vector2::VEC_ZERO);
|
||||
inline bool canFire(){return vb01::getTime() - lastFireTime > rateOfFire;}
|
||||
inline std::vector<Armor> getArmorTypes(){return armorTypes;}
|
||||
};
|
||||
}
|
||||
|
||||
+6
-5
@@ -46,7 +46,7 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void Vehicle::addOrder(Order order){
|
||||
if(order.type != Order::TYPE::EJECT){
|
||||
if(!(order.type == Order::TYPE::EJECT || order.type == Order::TYPE::LAUNCH)){
|
||||
Order::Target targ = order.targets[0];
|
||||
Vector3 targPos = (targ.unit ? targ.unit->getPos() : targ.pos);
|
||||
preparePathpoints(order, targPos);
|
||||
@@ -290,7 +290,8 @@ namespace battleship{
|
||||
Order::Target target = order.targets[0];
|
||||
Vector3 targVec = (target.unit ? target.unit->getPos() : target.pos) - pos;
|
||||
float distToTarg = targVec.getLength();
|
||||
float minDist = range;
|
||||
Weapon *weapon = weapons[0];
|
||||
float minDist = weapon->getMaxRange();
|
||||
|
||||
if(distToTarg > minDist)
|
||||
navigateToTarget(.5 * Map::getSingleton()->getCellSize().x);
|
||||
@@ -299,9 +300,9 @@ namespace battleship{
|
||||
|
||||
float angleToTarg = targVec.norm().getAngleBetween(dirVec);
|
||||
|
||||
if(distToTarg <= range){
|
||||
if(angleToTarg <= anglePrecision && canFire())
|
||||
fire();
|
||||
if(distToTarg <= weapon->getMaxRange()){
|
||||
if(angleToTarg <= anglePrecision)
|
||||
weapon->fire(order);
|
||||
else if(angleToTarg > anglePrecision)
|
||||
turn(calculateRotation(targVec.norm(), angleToTarg, maxTurnAngle));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user