Skip to content

Commit

Permalink
Merge pull request #1310 from drzel/limit-throwflag-lockout-to-thrower
Browse files Browse the repository at this point in the history
Limit throwflag lockout to thrower
  • Loading branch information
drzel authored Mar 20, 2024
2 parents 3b35deb + 3cea3dc commit 43a38d7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 33 deletions.
4 changes: 2 additions & 2 deletions ssqc/actions.qc
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void () TeamFortress_Discard = {
self.ammo_cells = 0;
}
FO_Sound(self, CHAN_AUTO, "weapons/lock4.wav", 1, ATTN_NORM);
newmis.enemy = self;
newmis.health = time;
newmis.dropped_by = self;
newmis.dropped_at = time;
newmis.weapon = 0;
newmis.movetype = MOVETYPE_TOSS;
newmis.solid = SOLID_TRIGGER;
Expand Down
2 changes: 2 additions & 0 deletions ssqc/qw.qc
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ float coop;
.float group_no; // Goal group this goal is in
.float goal_state; // State of this goal
.float owned_by; // The team this goal/item/whatever belongs to
.float dropped_at; // Time when item was dropped
.entity dropped_by; // Entity that last held item

// Goal Activation details
.float goal_activation; // Bitfields. Determines how this goal is activated
Expand Down
30 changes: 12 additions & 18 deletions ssqc/status.qc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ string(entity pl) SentryDetailsToString;
string(entity pl) BuildingToString;
string(float pc) TeamFortress_GetClassName;
entity(float ino) Finditem;
void () tfgoalitem_droptouch;
void () tfgoalitem_dropthink;
void () tfgoalitem_remove;
float (entity ent, string ps_short, string ps_setting, string ps_default) FO_GetUserSetting;
Expand Down Expand Up @@ -665,23 +664,18 @@ void (entity Player, entity Item) UpdateClientFlagStatus = {
if (Item.origin != Item.oldorigin) {
if((Item.nextthink - time) >= 0) {
WriteFloat(MSG_MULTICAST, FLAGINFO_DROPPED);
if(Item.think != tfgoalitem_droptouch) {
if(noreturn) {
WriteFloat(MSG_MULTICAST, -1);
} else {
WriteFloat(MSG_MULTICAST, rint(Item.bubble_count - time));
}
if((Item.think == tfgoalitem_dropthink || Item.think == tfgoalitem_remove) && !Item.owner) {
WriteFloat(MSG_MULTICAST, FLAGINFO_LOCATION);
WriteCoord(MSG_MULTICAST, Item.origin_x);
WriteCoord(MSG_MULTICAST, Item.origin_y);
WriteCoord(MSG_MULTICAST, Item.origin_z);
WriteString(MSG_MULTICAST, getLocationName(Item.origin));
} else {
WriteFloat(MSG_MULTICAST, FLAGINFO_NOLOCATION);
}
} else {
if(noreturn) {
WriteFloat(MSG_MULTICAST, -1);
} else {
WriteFloat(MSG_MULTICAST, rint(Item.bubble_count - time));
}
if((Item.think == tfgoalitem_dropthink || Item.think == tfgoalitem_remove) && !Item.owner) {
WriteFloat(MSG_MULTICAST, FLAGINFO_LOCATION);
WriteCoord(MSG_MULTICAST, Item.origin_x);
WriteCoord(MSG_MULTICAST, Item.origin_y);
WriteCoord(MSG_MULTICAST, Item.origin_z);
WriteString(MSG_MULTICAST, getLocationName(Item.origin));
} else {
WriteFloat(MSG_MULTICAST, FLAGINFO_NOLOCATION);
}
} else {
Expand Down Expand Up @@ -724,7 +718,7 @@ string (entity Player, entity Item, float teamno) GetItemStatus = {
if (Item.origin != Item.oldorigin) {
//When the item is thrown, there is a touch think with a pad of 4.25s before the normal timer kicks in
if((Item.nextthink - time) >= 0) {
if(Item.think != tfgoalitem_droptouch && !noreturn) {
if(!noreturn) {
st = strcat(st, Q"\s: Return: \s", ftos(rint(Item.bubble_count - time)));
} else {
st = strcat(st, Q"\s: Dropped\s");
Expand Down
6 changes: 3 additions & 3 deletions ssqc/tfort.qc
Original file line number Diff line number Diff line change
Expand Up @@ -2237,8 +2237,8 @@ void (float type, float ammo) TeamFortress_DropAmmo = {
newmis.ammo_rockets = ammo;
else if (newmis.weapon == 4)
newmis.ammo_cells = ammo;
newmis.enemy = self;
newmis.health = time;
newmis.dropped_by = self;
newmis.dropped_at = time;
newmis.movetype = 6;
newmis.solid = 1;
newmis.classname = "ammobox";
Expand Down Expand Up @@ -2267,7 +2267,7 @@ void () TeamFortress_AmmoboxTouch = {
local string quantity;

took = 0;
if ((other == self.enemy) && (time < (self.health + 2)))
if ((other == self.dropped_by) && (time < (self.dropped_at + 2)))
return;
if ((other.tfstate & TFSTATE_CANT_MOVE) || (other.tfstate & TFSTATE_AIMING))
return;
Expand Down
19 changes: 9 additions & 10 deletions ssqc/tfortmap.qc
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,7 @@ void () item_tfgoal_touch = {
// units below origin. This restores the correct size.
if (self.classname == "item_tfgoal" && other.classname == "worldspawn") {
setsize(self, self.goal_min, self.goal_max);
return;
}

if (other.classname != "player")
Expand All @@ -2092,6 +2093,8 @@ void () item_tfgoal_touch = {
return;
if (other == self.owner)
return;
if (other == self.dropped_by && time < self.dropped_at + 0.75)
return;

local entity te;
// check if a wall or something is in the way of the flag
Expand Down Expand Up @@ -2525,12 +2528,6 @@ void () tfgoalitem_dropthink = {
}
};

void () tfgoalitem_droptouch = {
self.touch = item_tfgoal_touch;
self.nextthink = time + 4.25;
self.think = tfgoalitem_dropthink;
};

void (entity Item, float PAlive, entity P) tfgoalitem_drop = {
entity oldself;
oldself = self;
Expand Down Expand Up @@ -2565,10 +2562,12 @@ void (entity Item, float PAlive, entity P) tfgoalitem_drop = {
Item.velocity = Item.velocity * 400;
Item.velocity_z = 200;
}
Item.touch = SUB_Null;
Item.nextthink = time + 0.75;
Item.touch = item_tfgoal_touch;
Item.dropped_by = Item.owner;
Item.dropped_at = time;
Item.nextthink = time + 4.25;
Item.bubble_count = time + Item.pausetime + 0.75 + 4.25; //used by the return timer
Item.think = tfgoalitem_droptouch;
Item.think = tfgoalitem_dropthink;
} else {
Item.touch = item_tfgoal_touch;
Item.nextthink = time + 5;
Expand Down Expand Up @@ -2962,7 +2961,7 @@ void () DropGoalItems = {
bprint(PRINT_HIGH, self.netname, Q" \sdropped the enemy's flag!\s\n");
}
}

Status_Print(self, "\n\n\n", "You dropped the flag!");
search = find(world, classname, "player");
while (search) {
Expand Down

0 comments on commit 43a38d7

Please sign in to comment.