[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Improvement to standard backpack touch

Improvement to standard backpack touch

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Improvement to standard backpack touch

Postby Cobalt » Thu Jun 18, 2009 12:15 am

I have been wanting to do this one for a long time, but the proper plan sort of eludes me. Lets say theres a backpack from a fragged player that has (40) shells , (64) nails and (100) cells. The player touches it, and he already has (90) shells (40) nails and (0) Cells.
The ID code merely gives the player (100) shells, (100) nails and (100) cells, and the backpack disappears. I want the player to get the same ammo, but leave the backpack there containing what he cannot carry: (30) shells, (4) nails. Heres the touch function Im using, which I think is pretty much standard. Any help with some good code, or if anyone knows existing code to do this, thanks.


void () BackpackTouch =
{
local string s;
local float best;
local float old;
local float new;
local float bbest;
local entity stemp;
local float acount;

if (((other.classname != "player") && (other.classname != "bot")))
{
return;
}

if ((other.health <= 0))
{
return;
}
if (((other == self.owner) && ((self.nextthink - time) > 118)))
{
return;
}
acount = 0;
if ((cvar ("temp1") < 65535))
{
if ((other.classname == "player"))
{
sprint (other, "You get ");
}
}
stemp = self;
self = other;
best = W_BestWeapon ();
if (self.classname == "bot")
{
if (stemp.altname == "tossedpack")
fBotSayTeam (": Thanks.\n");
else if ((stemp.ammo_shells + stemp.ammo_nails) > 175 || (stemp.ammo_rockets + stemp.ammo_cells) > 100)
{
bprint (self.talkname);
bprint ("º ");
BotSayMiddle ("Nice Pack ");
if (stemp.owner.team != self.team)
BotSayMiddle (stemp.owner.netname);
BotSayEnd ();

}
}

self = stemp;
other.ammo_shells = (other.ammo_shells + self.ammo_shells);
other.ammo_nails = (other.ammo_nails + self.ammo_nails);
other.ammo_rockets = (other.ammo_rockets + self.ammo_rockets);
other.ammo_cells = (other.ammo_cells + self.ammo_cells);
new = self.items;
if (!new)
new = other.weapon;

old = other.items;
other.items = (other.items | new);
bound_other_ammo ();
if ((other.classname == "player"))
{
if ((cvar ("temp1") < 65535))
{
if (self.ammo_shells)
{
if (acount)
{
sprint (other, ", ");
}
acount = WEAPON_SHOTGUN;
s = ftos (self.ammo_shells);
sprint (other, s);
sprint (other, " shells");
}
if (self.ammo_nails)
{
if (acount)
{
sprint (other, ", ");
}
acount = WEAPON_SHOTGUN;
s = ftos (self.ammo_nails);
sprint (other, s);
sprint (other, " nails");
}
if (self.ammo_rockets)
{
if (acount)
{
sprint (other, ", ");
}
acount = WEAPON_SHOTGUN;
s = ftos (self.ammo_rockets);
sprint (other, s);
sprint (other, " rockets");
}
if (self.ammo_cells)
{
if (acount)
{
sprint (other, ", ");
}
acount = WEAPON_SHOTGUN;
s = ftos (self.ammo_cells);
sprint (other, s);
sprint (other, " cells");
}
sprint (other, "\n");
stuffcmd (other, "bf\n");
}
}
if (((deathmatch & DM_START_SMALL) || (deathmatch & DM_START_BIG)))
{
other.health = (other.health + 5);
}
sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, SUB_Db());
remove (self);
self = other;
if ((other.classname == "player"))
{
if ((WeaponCode (new) <= other.best_wep))
{
if ((self.flags & FL_INWATER))
{
if ((new != IT_LIGHTNING))
{
Deathmatch_Weapon (old, new);
}
}
else
{
Deathmatch_Weapon (old, new);
}
}
}
else
{
Deathmatch_Weapon (old, new);
}
W_SetCurrentAmmo ();
};



User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Postby Electro » Fri Jun 19, 2009 9:15 am

Sorry, the lack of formatting is making it impossible for me to even read. :(
Benjamin Darling


Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
Electro
 
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia

Postby Error » Fri Jun 19, 2009 1:25 pm

doesn't using the [code] bbcode fix this?

User avatar
Error
InsideQC Staff
 
Posts: 865
Joined: Fri Nov 05, 2004 5:15 am
Location: VA, USA

Postby lurker » Fri Jun 19, 2009 4:46 pm

Last edited by lurker on Sat Jun 20, 2009 11:29 pm, edited 1 time in total.
lurker
 
Posts: 2
Joined: Sat Jul 29, 2006 8:22 pm

Postby Cobalt » Sat Jun 20, 2009 8:55 pm

User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Postby lurker » Sun Jun 21, 2009 12:23 am

lurker
 
Posts: 2
Joined: Sat Jul 29, 2006 8:22 pm

Postby Cobalt » Mon Jun 22, 2009 3:11 pm

User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Postby frag.machine » Mon Jun 22, 2009 11:57 pm

I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2120
Joined: Sat Nov 25, 2006 1:49 pm

Postby Cobalt » Wed Jun 24, 2009 2:54 am

Ok, finally got your code working with mine ! I used your ammo calculations as they seem to be flawless. I redid the 'you get' sprint, and of course the bf and sound so that it happens only when we have 'taken' something. Still got a bug with the comma popping up when you get just nails, rockets or cells, but it ought to be easy to fix. I took your advise and shortened the nextthink time by 15 if all we have are shells. Lot less packs floating around now.

Its amazing how one change like this alters gameplay for the bots. They have a tendency to hang around the ammo packs now, which seems to make gameplay a little more smoother and fun. It felt like a real CTF game.
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest