Skip to content

Commit

Permalink
Allow tube load time to be altered by scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
StarryWisdom authored and daid committed Aug 24, 2020
1 parent b5392d2 commit cfd01d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/spaceObjects/spaceship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ REGISTER_SCRIPT_SUBCLASS_NO_CREATE(SpaceShip, ShipTemplateBasedObject)
/// Returns the size of the tube
/// Example: local size = ship:getTubeSize(0)
REGISTER_SCRIPT_CLASS_FUNCTION(SpaceShip, getTubeSize);
// Returns the time for a tube load
// Example: load_time = ship:getTubeLoadTime(0)
REGISTER_SCRIPT_CLASS_FUNCTION(SpaceShip, getTubeLoadTime);
// Sets the load time for a tube
// Example ship:setTubeLoadTime(0, 15)
REGISTER_SCRIPT_CLASS_FUNCTION(SpaceShip, setTubeLoadTime);
/// Set the icon to be used for this ship on the radar.
/// For example, ship:setRadarTrace("RadarBlip.png") will show a dot instead of an arrow for this ship.
/// Note: Icon is only shown after scanning, before the ship is scanned it is always shown as an arrow.
Expand Down Expand Up @@ -1272,6 +1278,22 @@ EMissileSizes SpaceShip::getTubeSize(int index)
return weapon_tube[index].getSize();
}

float SpaceShip::getTubeLoadTime(int index)
{
if (index < 0 || index >= max_weapon_tubes) {
return 0;
}
return weapon_tube[index].getLoadTimeConfig();
}

void SpaceShip::setTubeLoadTime(int index, float time)
{
if (index < 0 || index >= max_weapon_tubes) {
return;
}
weapon_tube[index].setLoadTimeConfig(time);
}

void SpaceShip::addBroadcast(int threshold, string message)
{
if ((threshold < 0) || (threshold > 2)) //if an invalid threshold is defined, alert and default to ally only
Expand Down
2 changes: 2 additions & 0 deletions src/spaceObjects/spaceship.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ class SpaceShip : public ShipTemplateBasedObject
void setWeaponTubeSize(int index, EMissileSizes size);
void setTubeSize(int index, EMissileSizes size);
EMissileSizes getTubeSize(int index);
void setTubeLoadTime(int index, float time);
float getTubeLoadTime(int index);

void setRadarTrace(string trace) { radar_trace = trace; }

Expand Down

0 comments on commit cfd01d3

Please sign in to comment.