- Added autouse, Hitting a build with a spanner will now automagically

do what you want! For unhacked enemy builds it will dismantle. For other
  builds it will first repair, then recharge/refill as appropriate.
  For dispensers it refills armor first, for sentries it refills shells first.

- There's now a cap on how much you can repair or recharge your builds each
  time (can be turned off with setinfo instant_repair/setinfo ir).

- Fixed some code which caused warnings, including putting coop.qc back into
  progs.src (because we need it for DoorShouldOpen)
This commit is contained in:
Finny Merrill 2003-11-27 12:11:55 +00:00
parent f8e5f0ce58
commit dcf26d4d2f
8 changed files with 181 additions and 36 deletions

View file

@ -737,6 +737,14 @@ void() DecodeLevelParms =
}
}
}
st = infokey(NIL, "ir");
if (!st)
st = infokey(NIL, "instant_repair");
if (st == "1" || st == "on")
instant_repair = TRUE;
else
instant_repair = FALSE;
}
if (parm11)
@ -2778,7 +2786,7 @@ void() PlayerPreThink =
if (self.tf_items & NIT_HOVER_BOOTS_UPGRADE) {
if (self.hover_time > (MAX_HOVER_FUEL * 2))
self.hover_time = (MAX_HOVER_FUEL * 2);
if (self.hover_time < (MAX_HOVER_FUEL / 2) && self.ammo_cells > (self.maxammo_cells * 0.8)) {
if (self.hover_time < (MAX_HOVER_FUEL * 0.5) && self.ammo_cells > (self.maxammo_cells * 0.8)) {
self.hover_time++;
self.ammo_cells--;
}

View file

@ -1135,3 +1135,4 @@ float deathmsg; // Global, which is set before every T_Damage, to indicate
float no_pogo_stick;
float last_team_no;
float instant_repair;

17
defs.qh
View file

@ -564,6 +564,23 @@
#define BUILD_HEALTH_TELEPORTER 300
#define BUILD_HEALTH_FIELDGEN 300 //
// Amount of CELLS you can repair something in one go (NOT HEALTH! health is 5x this)
// this is going to be tweaked a lot
#define BUILD_DISPENSER_REPAIR 15 // 3 repairs
#define BUILD_SENTRYGUN_REPAIR 20 // 3 repairs
#define BUILD_TESLA_REPAIR 30 // a lot of repairs for many teslas, 2 for regular ones
#define BUILD_CAMERA_REPAIR 50 // 2 repairs
#define BUILD_SENSOR_REPAIR 50 // 1 repair (these things get attacked a lot)
#define BUILD_TELEPORT_REPAIR 30 // 2 or 3
#define BUILD_FIELDGEN_REPAIR 30 // also 2 or 3, decheapening here
// same, but for amount you can recharge. this is the same as the number of cells used
#define BUILD_TESLA_RECHARGE 100
#define BUILD_TELEPORT_RECHARGE 100
#define BUILD_FIELDGEN_RECHARGE 50
// Building screwups
#define SCREWUP_ONE 1
#define SCREWUP_TWO 2

View file

@ -1353,10 +1353,6 @@ void(entity gun) Engineer_UseSentryGun =
self.building = gun;
//dodgy
if (teamplay != 0 && !Teammate(self.building.real_owner.team_no,self.team_no)) {
Menu_EngineerFix_SentryGun_Input(5);
return;
}
// Start a Distance checker, which removes the menu if the player
// gets too far away from the sentry.
@ -1456,12 +1452,6 @@ void(entity gun) Engineer_UseTesla =
self.building = gun;
// dodgy
if (teamplay != 0 && !Teammate(self.building.real_owner.team_no, self.team_no)) {
Menu_EngineerFix_Tesla_Input(8);
return;
}
// Start a Distance checker, which removes the menu if the player
// gets too far away from the tesla.
dist_checker = spawn();
@ -1491,11 +1481,6 @@ void(entity cam) Engineer_UseSensor =
self.building = cam;
if (teamplay != 0 && !Teammate(self.building.real_owner.team_no, self.team_no)) {
Menu_EngineerFix_Sensor_Input(3);
return;
}
// Start a Distance checker, which removes the menu if the player
// gets too far away from the camera.
dist_checker = spawn();
@ -1526,11 +1511,6 @@ void(entity cam) Engineer_UseCamera =
self.building = cam;
if (teamplay != 0 && !Teammate(self.building.real_owner.team_no,self.team_no)) {
Menu_EngineerFix_Camera_Input(3);
return;
}
// Start a Distance checker, which removes the menu if the player
// gets too far away from the camera.
dist_checker = spawn();
@ -1612,3 +1592,114 @@ void() CheckDistance =
self.nextthink = time + 0.3;
};
void() Engineer_AutoUse =
{
local float repair_amt = 0;
local entity targ = self.building;
if (self.building.real_owner != self && !Teammate(self.team_no,self.building.real_owner.team_no))
{
// Auto Dismantle
if (CheckEnemyDismantle() == FALSE)
return;
else if (self.building.classname == "building_dispenser")
Menu_EngineerFix_Dispenser_Input(4);
else if (self.building.classname == "building_sentrygun")
Menu_EngineerFix_SentryGun_Input(5);
else if (self.building.classname == "building_tesla")
Menu_EngineerDismantle_Tesla();
else if (self.building.classname == "building_camera")
Menu_EngineerFix_Camera_Input(3);
else if (self.building.classname == "building_sensor")
Menu_EngineerFix_Sensor_Input(3);
else if (self.building.classname == "building_fieldgen")
Menu_EngineerFix_FieldGen_Input(4);
else if (self.building.classname == "building_teleporter")
Menu_EngineerFix_Teleporter_Input(4);
} else if (self.building.health < self.building.max_health) {
// Auto Repair
if (self.building.classname == "building_dispenser")
repair_amt = BUILD_DISPENSER_REPAIR;
else if (self.building.classname == "building_sentrygun")
repair_amt = BUILD_SENTRYGUN_REPAIR;
else if (self.building.classname == "building_tesla")
repair_amt = BUILD_TESLA_REPAIR;
else if (self.building.classname == "building_teleporter")
repair_amt = BUILD_TELEPORT_REPAIR;
else if (self.building.classname == "building_camera")
repair_amt = BUILD_CAMERA_REPAIR;
else if (self.building.classname == "building_sensor")
repair_amt = BUILD_SENSOR_REPAIR;
else if (self.building.classname == "building_fieldgen")
repair_amt = BUILD_FIELDGEN_REPAIR;
else
{
RPrint ("BUG BUG BUG! Engineer_AutoUse called on unknown building!");
repair_amt = 0;
}
if (repair_amt*5 > (self.building.max_health - self.building.health))
repair_amt = ceil((self.building.max_health - self.building.health) / 5);
if (repair_amt > self.ammo_cells)
repair_amt = self.ammo_cells;
self.building.health += repair_amt * 5;
if (self.building.health > self.building.max_health)
self.building.health = self.building.max_health;
self.ammo_cells -= repair_amt;
sprint(self, PRINT_HIGH, ftos(self.building.health) + "/" + ftos(self.building.max_health) + " health\n");
W_SetCurrentAmmo();
} else {
// Auto Recharge / refill
if (self.building.classname == "building_tesla")
repair_amt = BUILD_TESLA_RECHARGE;
else if (self.building.classname == "building_teleporter")
repair_amt = BUILD_TELEPORT_RECHARGE;
else if (self.building.classname == "building_fieldgen")
repair_amt = BUILD_FIELDGEN_RECHARGE;
if (repair_amt) {
if (repair_amt > self.building.maxammo_cells - self.building.ammo_cells)
repair_amt = self.building.maxammo_cells - self.building.ammo_cells;
if (repair_amt > self.ammo_cells)
repair_amt = self.ammo_cells;
self.building.ammo_cells += repair_amt;
self.ammo_cells -= repair_amt;
sprint(self, PRINT_HIGH, ftos(self.building.ammo_cells) + "/"
+ftos(self.building.maxammo_cells) + " cells\n");
W_SetCurrentAmmo();
} else if (self.building.classname == "building_dispenser") {
sprint(self, PRINT_HIGH, "Filling armor...");
local float oldarmor = self.armorvalue;
Menu_EngineerFix_Dispenser_Input(2);
self.building = targ;
if (self.armorvalue == oldarmor)
{
sprint(self, PRINT_HIGH, "full. Filling ammo...\n");
Menu_EngineerFix_Dispenser_Input(1);
self.building = targ;
} else
sprint(self, PRINT_HIGH, "\n");
} else if (self.building.classname == "building_sentrygun") {
Menu_EngineerFix_SentryGun_Input(1);
self.building = targ;
sprint(self, PRINT_HIGH, ftos(self.building.ammo_shells) + "/"
+ftos(self.building.maxammo_shells) + " shells ");
if (self.building.weapon >= 3)
sprint(self, PRINT_HIGH, ftos(self.building.ammo_rockets) + "/"
+ftos(self.building.maxammo_rockets) + " rockets");
sprint(self, PRINT_HIGH, "\n");
}
}
};

View file

@ -748,7 +748,7 @@ void() GuerillaExplode =
// if has_tesla is 1 print nothing, as this is set by DetonateMines() and GuerillaThink
if (time < self.heat + ACTIVATE_TIME) //If not charged, do less damage when blowing up
T_RadiusDamage (self, self.martyr_enemy, MINE_DMG / 2, NIL); //- damage was 80
T_RadiusDamage (self, self.martyr_enemy, MINE_DMG * 0.5, NIL); //- damage was 80
else
T_RadiusDamage (self, self.martyr_enemy, MINE_DMG, NIL); //- damage was 160

45
menu.qc
View file

@ -1477,6 +1477,8 @@ void(float inp) Menu_EngineerFix_Dispenser_Input =
if (metalcost > self.ammo_cells)
metalcost = self.ammo_cells;
if (!instant_repair && metalcost > BUILD_DISPENSER_REPAIR) // don't allow instant repairs
metalcost = BUILD_DISPENSER_REPAIR;
self.ammo_cells = self.ammo_cells - metalcost;
self.building.health = self.building.health + (metalcost * 5);
@ -1557,7 +1559,8 @@ void(float inp) Menu_EngineerFix_SentryGun_Input =
self.building.ammo_shells = self.building.ammo_shells + am;
// If it's level 3, put some rockets in too
if (self.building.weapon == 3)
// GR But not at the same time as the shells
if (self.building.weapon == 3 && am == 0)
{
am = (DROP_ROCKETS * 2);
if (am > self.ammo_rockets)
@ -1621,6 +1624,8 @@ void(float inp) Menu_EngineerFix_SentryGun_Input =
if (metalcost > self.ammo_cells)
metalcost = self.ammo_cells;
if (!instant_repair && metalcost > BUILD_SENTRYGUN_REPAIR) // disallow instant repairs
metalcost = BUILD_SENTRYGUN_REPAIR;
self.ammo_cells = self.ammo_cells - metalcost;
self.building.health = self.building.health + (metalcost * 5);
@ -1731,6 +1736,8 @@ void(float inp) Menu_EngineerFix_Sensor_Input =
if (metalcost > self.ammo_cells)
metalcost = self.ammo_cells;
if (!instant_repair && metalcost > BUILD_SENSOR_REPAIR)
metalcost = BUILD_SENSOR_REPAIR;
self.ammo_cells = self.ammo_cells - metalcost;
self.building.health = self.building.health + (metalcost * 10);
@ -1788,6 +1795,9 @@ void(float inp) Menu_EngineerFix_Camera_Input =
if (metalcost > self.ammo_cells)
metalcost = self.ammo_cells;
if (!instant_repair && metalcost > BUILD_CAMERA_REPAIR)
metalcost = BUILD_CAMERA_REPAIR;
self.ammo_cells = self.ammo_cells - metalcost;
self.building.health = self.building.health + (metalcost * 10);
}
@ -1843,6 +1853,8 @@ void(float inp) Menu_EngineerFix_Teleporter_Input =
if (metalcost > self.ammo_cells)
metalcost = ceil(self.ammo_cells);
if (!instant_repair && metalcost > BUILD_TELEPORT_REPAIR)
metalcost = BUILD_TELEPORT_REPAIR;
self.ammo_cells = self.ammo_cells - metalcost;
self.building.health = self.building.health + (metalcost * 5);
@ -1853,6 +1865,9 @@ void(float inp) Menu_EngineerFix_Teleporter_Input =
if (metalcost > self.ammo_cells)
metalcost = ceil(self.ammo_cells);
if (!instant_repair && metalcost > BUILD_TELEPORT_RECHARGE)
metalcost = BUILD_TELEPORT_RECHARGE;
self.ammo_cells = self.ammo_cells - metalcost;
self.building.ammo_cells = self.building.ammo_cells + metalcost;
if (self.building.ammo_cells > self.building.maxammo_cells)
@ -1912,6 +1927,8 @@ void(float inp) Menu_EngineerFix_FieldGen_Input =
if (metalcost > self.ammo_cells)
metalcost = ceil(self.ammo_cells);
if (!instant_repair && metalcost > BUILD_FIELDGEN_REPAIR)
metalcost = BUILD_FIELDGEN_REPAIR;
self.ammo_cells = self.ammo_cells - metalcost;
self.building.health = self.building.health + (metalcost * 5);
@ -1922,6 +1939,9 @@ void(float inp) Menu_EngineerFix_FieldGen_Input =
if (metalcost > self.ammo_cells)
metalcost = ceil(self.ammo_cells);
if (!instant_repair && metalcost > BUILD_FIELDGEN_RECHARGE)
metalcost = BUILD_FIELDGEN_RECHARGE;
self.ammo_cells = self.ammo_cells - metalcost;
self.building.ammo_cells = self.building.ammo_cells + metalcost;
if (self.building.ammo_cells > self.building.maxammo_cells)
@ -2163,21 +2183,24 @@ void() Menu_EngineerRepair_Tesla =
cost = (self.building.max_health - self.building.health) / 2;
if (cost > self.ammo_cells)
cost = self.ammo_cells;
if (!instant_repair && cost > BUILD_TESLA_REPAIR)
cost = BUILD_TESLA_REPAIR;
self.ammo_cells = self.ammo_cells - cost;
self.ammo_cells = self.ammo_cells - cost;
self.building.health = self.building.health + (cost * 2);
if (self.building.health >= self.building.max_health)
self.building.health = self.building.max_health;
} else { // don't allow repair and recharge at the same time
maxcells = self.building.maxammo_cells;
cost = maxcells - self.building.ammo_cells;
if (cost > self.ammo_cells) cost = self.ammo_cells;
if (!instant_repair && cost > BUILD_TESLA_RECHARGE) cost = BUILD_TESLA_RECHARGE;
self.ammo_cells = self.ammo_cells - cost;
self.building.ammo_cells = self.building.ammo_cells + cost;
if (self.building.ammo_cells >= maxcells)
self.building.ammo_cells = maxcells;
}
maxcells = self.building.maxammo_cells;
cost = maxcells - self.building.ammo_cells;
if (cost > self.ammo_cells) cost = self.ammo_cells;
self.ammo_cells = self.ammo_cells - cost;
self.building.ammo_cells = self.building.ammo_cells + cost;
if (self.building.ammo_cells >= maxcells)
self.building.ammo_cells = maxcells;
};
void() Menu_EngineerDismantle_Tesla =
{

View file

@ -74,3 +74,4 @@ spectate.qc
ofnents.qc
waypoint.qc
coop.qc

View file

@ -110,6 +110,7 @@ void(entity gun) Engineer_UseTesla;
void(entity cam) Engineer_UseCamera;
void(entity tele) Engineer_UseTeleporter;
void(entity field) Engineer_UseFieldGen;
void() Engineer_AutoUse;
void(entity spy) Spy_RemoveDisguise;
@ -415,8 +416,11 @@ void() W_FireSpanner =
}
if (trace_ent.takedamage) {
// Engineer can repair/use his buildings
if (trace_ent.classname == "building_dispenser") {
// auto-repair/dismantle if hit twice
if (trace_ent == self.building) {
Engineer_AutoUse();
return;
} else if (trace_ent.classname == "building_dispenser") {
Engineer_UseDispenser(trace_ent);
return;
} else if (trace_ent.classname == "building_sentrygun") {
@ -4098,7 +4102,7 @@ void() W_WeaponFrame =
player_run ();
}
if (self.current_weapon == WEAP_AUTO_RIFLE)
if (self.current_weapon == WEAP_AUTO_RIFLE) // BUG BUG BUG! GIVES ADVANTAGE TO HIGH FPSERS
self.heat -= 100;
// check for attack
if (self.button0 && !(self.fire_held_down)) {