Should fix buying ammo, chems, grenades.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1789 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
b8d44415fa
commit
dc93cdfca4
3 changed files with 108 additions and 49 deletions
|
@ -87,7 +87,7 @@ float IID_BUILD_ROBOFANG = 353;
|
||||||
|
|
||||||
#define IsShootable(iid) (IsMelee(iid) || IsRanged(iid) || IsGrenade(iid))
|
#define IsShootable(iid) (IsMelee(iid) || IsRanged(iid) || IsGrenade(iid))
|
||||||
|
|
||||||
|
float(float slotno, float iid) FitsInSlot;
|
||||||
|
|
||||||
//slot1 and slot2 are the two hand slots
|
//slot1 and slot2 are the two hand slots
|
||||||
//slot3 is the armour slot.
|
//slot3 is the armour slot.
|
||||||
|
@ -325,6 +325,60 @@ float(entity e) FindEmptySlot =
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
float(entity e, float iid) FindSuitableEmptySlot =
|
||||||
|
{
|
||||||
|
if (ToIID(e.islot1) == IID_NONE)
|
||||||
|
if (FitsInSlot(1, iid))
|
||||||
|
return 1;
|
||||||
|
if (ToIID(e.islot2) == IID_NONE)
|
||||||
|
if (FitsInSlot(2, iid))
|
||||||
|
return 2;
|
||||||
|
if (ToIID(e.islot3) == IID_NONE)
|
||||||
|
if (FitsInSlot(3, iid))
|
||||||
|
return 3;
|
||||||
|
if (ToIID(e.islot4) == IID_NONE)
|
||||||
|
if (FitsInSlot(4, iid))
|
||||||
|
return 4;
|
||||||
|
if (ToIID(e.islot5) == IID_NONE)
|
||||||
|
if (FitsInSlot(5, iid))
|
||||||
|
return 5;
|
||||||
|
if (ToIID(e.islot6) == IID_NONE)
|
||||||
|
if (FitsInSlot(6, iid))
|
||||||
|
return 6;
|
||||||
|
if (ToIID(e.islot7) == IID_NONE)
|
||||||
|
if (FitsInSlot(7, iid))
|
||||||
|
return 7;
|
||||||
|
if (ToIID(e.islot8) == IID_NONE)
|
||||||
|
if (FitsInSlot(8, iid))
|
||||||
|
return 8;
|
||||||
|
if (ToIID(e.islot9) == IID_NONE)
|
||||||
|
if (FitsInSlot(9, iid))
|
||||||
|
return 9;
|
||||||
|
if (ToIID(e.islot10) == IID_NONE)
|
||||||
|
if (FitsInSlot(10, iid))
|
||||||
|
return 10;
|
||||||
|
if (ToIID(e.islot11) == IID_NONE)
|
||||||
|
if (FitsInSlot(11, iid))
|
||||||
|
return 11;
|
||||||
|
if (ToIID(e.islot12) == IID_NONE)
|
||||||
|
if (FitsInSlot(12, iid))
|
||||||
|
return 12;
|
||||||
|
if (ToIID(e.islot13) == IID_NONE)
|
||||||
|
if (FitsInSlot(13, iid))
|
||||||
|
return 13;
|
||||||
|
if (ToIID(e.islot14) == IID_NONE)
|
||||||
|
if (FitsInSlot(14, iid))
|
||||||
|
return 14;
|
||||||
|
if (ToIID(e.islot15) == IID_NONE)
|
||||||
|
if (FitsInSlot(15, iid))
|
||||||
|
return 15;
|
||||||
|
if (ToIID(e.islot16) == IID_NONE)
|
||||||
|
if (FitsInSlot(16, iid))
|
||||||
|
return 16;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
typedef .float slot_t;
|
typedef .float slot_t;
|
||||||
slot_t(float slot) SlotField =
|
slot_t(float slot) SlotField =
|
||||||
{
|
{
|
||||||
|
@ -825,7 +879,7 @@ string(float iid) GetItemName =
|
||||||
return "robofang";
|
return "robofang";
|
||||||
|
|
||||||
bprint(PRINT_MEDIUM, ftos(iid), " without a name!\n");
|
bprint(PRINT_MEDIUM, ftos(iid), " without a name!\n");
|
||||||
return "unknown";
|
return strcat("unknown", ftos(iid));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -422,17 +422,25 @@ void() armor_touch =
|
||||||
/*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
|
/*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void() item_armor1 =
|
void() item_armor1_finish =
|
||||||
{
|
{
|
||||||
|
SUB_UseTargets ();
|
||||||
|
|
||||||
|
|
||||||
self.touch = SUB_Null;
|
self.touch = SUB_Null;
|
||||||
self.solid = SOLID_BBOX;
|
self.solid = SOLID_BBOX;
|
||||||
precache_model ("progs/enforcer.mdl");
|
|
||||||
setmodel (self, "progs/enforcer.mdl");
|
setmodel (self, "progs/enforcer.mdl");
|
||||||
self.skin = 0;
|
self.skin = 0;
|
||||||
setsize (self, '-16 -16 -24', '16 16 32');
|
setsize (self, '-16 -16 -24', '16 16 32');
|
||||||
setorigin(self, self.origin + '0 0 24');
|
setorigin(self, self.origin + '0 0 24');
|
||||||
self.classname = "merchant";
|
self.classname = "merchant";
|
||||||
};
|
};
|
||||||
|
void() item_armor1 =
|
||||||
|
{
|
||||||
|
precache_model ("progs/enforcer.mdl");
|
||||||
|
self.think = item_armor1_finish;
|
||||||
|
self.nextthink = time + 0.1;
|
||||||
|
};
|
||||||
|
|
||||||
/*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
|
/*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
|
|
||||||
|
void(entity to, float iid, float count) AddStackable =
|
||||||
|
{
|
||||||
|
local float slot;
|
||||||
|
|
||||||
|
slot = SlotOfItem(to, iid);
|
||||||
|
if (!slot)
|
||||||
|
slot = FindSuitableEmptySlot(to, iid);
|
||||||
|
if (slot)
|
||||||
|
SetItemSlot(to, slot, SlotVal(iid, count + ToStatus(ItemInSlot(to, slot))));
|
||||||
|
}
|
||||||
|
|
||||||
void(float cost, float type) BuyGrenade =
|
void(float cost, float type) BuyGrenade =
|
||||||
{
|
{
|
||||||
|
@ -32,14 +41,7 @@ void(float cost, float type) BuyGrenade =
|
||||||
//put grenade in inventory
|
//put grenade in inventory
|
||||||
//finds existing grenades, otherwise, empty slot
|
//finds existing grenades, otherwise, empty slot
|
||||||
|
|
||||||
x = SlotOfItem(self, y);
|
AddStackable(self, y, 1);
|
||||||
|
|
||||||
if (x != 0) //found existing grenades
|
|
||||||
SetItemSlot(self, x, SlotVal(y, 1));
|
|
||||||
if (x == 0)
|
|
||||||
x = FindEmptySlot(self);
|
|
||||||
|
|
||||||
SetItemSlot(self, x, SlotVal(y, 1));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void() BuyBandages =
|
void() BuyBandages =
|
||||||
|
@ -78,9 +80,9 @@ void() BuyBandages =
|
||||||
|
|
||||||
void(float cost, float type) BuyChem =
|
void(float cost, float type) BuyChem =
|
||||||
{
|
{
|
||||||
/*
|
local string chemname;
|
||||||
local string x;
|
local float max;
|
||||||
local float y;
|
local float alreadygot;
|
||||||
|
|
||||||
if (self.ammo_shells < cost)
|
if (self.ammo_shells < cost)
|
||||||
{
|
{
|
||||||
|
@ -88,18 +90,19 @@ void(float cost, float type) BuyChem =
|
||||||
sprint(self, PRINT_HIGH, "not enough money.\n");
|
sprint(self, PRINT_HIGH, "not enough money.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type >= 2 && self.class != 1)
|
if (type != IID_CHEM_STIMPACK && self.class != 1)
|
||||||
{
|
{
|
||||||
self.currentmenu = "none";
|
self.currentmenu = "none";
|
||||||
sprint(self, PRINT_HIGH, "not a medic.\n");
|
sprint(self, PRINT_HIGH, "not a medic.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self.equipment == 1)
|
if (self.equipment == 1)
|
||||||
y = 4;
|
max = 4;
|
||||||
else
|
else
|
||||||
y = 2;
|
max = 2;
|
||||||
|
|
||||||
if (self.chemcount >= y)
|
alreadygot = TotalQuantity(self, type);
|
||||||
|
if (alreadygot >= max)
|
||||||
{
|
{
|
||||||
self.currentmenu = "none";
|
self.currentmenu = "none";
|
||||||
sprint(self, PRINT_HIGH, "you can't hold any more chems.\n");
|
sprint(self, PRINT_HIGH, "you can't hold any more chems.\n");
|
||||||
|
@ -107,13 +110,11 @@ void(float cost, float type) BuyChem =
|
||||||
}
|
}
|
||||||
|
|
||||||
sound (self, CHAN_BODY, "misc/item1.wav", 1, ATTN_NORM);
|
sound (self, CHAN_BODY, "misc/item1.wav", 1, ATTN_NORM);
|
||||||
self.chemcount = y;
|
|
||||||
self.chem = type;
|
|
||||||
self.ammo_shells = self.ammo_shells - cost;
|
self.ammo_shells = self.ammo_shells - cost;
|
||||||
x = GetChemName();
|
chemname = GetItemName(type);
|
||||||
sprint (self, PRINT_HIGH, x);
|
sprint(self, PRINT_HIGH, chemname);
|
||||||
sprint(self, PRINT_HIGH, " purchased.\n");
|
sprint(self, PRINT_HIGH, " purchased.\n");
|
||||||
*/
|
AddStackable(self, type, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
void(string type) ChangeAmmo =
|
void(string type) ChangeAmmo =
|
||||||
|
@ -173,8 +174,10 @@ void() BuyScraps =
|
||||||
|
|
||||||
void (float wt, float cost, float wid) BuyWeapon =
|
void (float wt, float cost, float wid) BuyWeapon =
|
||||||
{
|
{
|
||||||
local string z;
|
local string itname;
|
||||||
local float x, y;
|
local float ammotype, ammocount;
|
||||||
|
local float slotnum;
|
||||||
|
local float curweap;
|
||||||
|
|
||||||
if (self.ammo_shells < cost)
|
if (self.ammo_shells < cost)
|
||||||
{
|
{
|
||||||
|
@ -189,34 +192,28 @@ void (float wt, float cost, float wid) BuyWeapon =
|
||||||
|
|
||||||
sprint(self, PRINT_HIGH, "you bought ");
|
sprint(self, PRINT_HIGH, "you bought ");
|
||||||
|
|
||||||
z = GetItemName(wid);
|
itname = GetItemName(wid);
|
||||||
sprint(self, PRINT_HIGH, z);
|
sprint(self, PRINT_HIGH, itname);
|
||||||
sprint(self, PRINT_HIGH, ".\n");
|
sprint(self, PRINT_HIGH, ".\n");
|
||||||
|
|
||||||
//put new weapon in current slot
|
//put new weapon in current slot
|
||||||
//put old weapon in empty slot
|
//put old weapon in empty slot (but not armor slot!)
|
||||||
//otherwise, drop it.
|
//otherwise, drop it.
|
||||||
|
|
||||||
x = SlotOfItem(self, IID_NONE);
|
curweap = ItemInSlot(self, self.current_slot);
|
||||||
|
slotnum = FindSuitableEmptySlot(self, ToIID(curweap));
|
||||||
|
|
||||||
if (x == 0)//no more room
|
if (slotnum == 0)//no more room
|
||||||
DropFromSlot (self.current_slot, 1, 0);
|
DropFromSlot (self.current_slot, 1, 0);
|
||||||
else //found a place to stick old weapon
|
else //found a place to stick old weapon
|
||||||
SetItemSlot(self, x, SlotVal(self.current_slot, 1));
|
SetItemSlot(self, slotnum, curweap);
|
||||||
|
|
||||||
SetItemSlot(self, self.current_slot, SlotVal(wid, 1));
|
ammocount = WeaponMagQuant(wid);//load weapon with full ammo (may be changed)
|
||||||
|
SetItemSlot(self, self.current_slot, SlotVal(wid, ammocount));
|
||||||
|
|
||||||
x = WeaponMagQuant(wid);//load weapon with full ammo (may be changed)
|
|
||||||
if (self.current_slot == 1)
|
|
||||||
self.islot1 = SlotVal(wid, x + ToStatus(1));
|
|
||||||
if (self.current_slot == 2)
|
|
||||||
self.islot2 = SlotVal(wid, x + ToStatus(2));
|
|
||||||
|
|
||||||
x = SlotOfItem(self, IID_NONE); //give ammo
|
|
||||||
|
|
||||||
if (x != 0)
|
|
||||||
SetItemSlot(self, x, WeaponAmmoType(wid));
|
|
||||||
|
|
||||||
|
ammotype = WeaponAmmoType(wid);//load weapon with full ammo (may be changed)
|
||||||
|
AddStackable(self, ammotype, ammocount*3);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -668,17 +665,17 @@ void() W_PlayerMenu =
|
||||||
if (self.currentmenu == "shop_chems")
|
if (self.currentmenu == "shop_chems")
|
||||||
{
|
{
|
||||||
if (self.impulse == 1)
|
if (self.impulse == 1)
|
||||||
BuyChem(3, 1); //cost, item
|
BuyChem(3, IID_CHEM_STIMPACK); //cost, item
|
||||||
if (self.impulse == 2)
|
if (self.impulse == 2)
|
||||||
BuyChem(5, 2); //cost, item
|
BuyChem(5, IID_CHEM_MEDICALBAG); //cost, item
|
||||||
if (self.impulse == 3)
|
if (self.impulse == 3)
|
||||||
BuyChem(10, 3); //cost, item
|
BuyChem(10, IID_CHEM_SUPERSTIM); //cost, item
|
||||||
if (self.impulse == 4)
|
if (self.impulse == 4)
|
||||||
BuyChem(12, 4); //cost, item
|
BuyChem(12, IID_CHEM_ADRENALINE); //cost, item
|
||||||
if (self.impulse == 5)
|
if (self.impulse == 5)
|
||||||
BuyChem(18, 5); //cost, item
|
BuyChem(18, IID_CHEM_PSYCHO); //cost, item
|
||||||
if (self.impulse == 6)
|
if (self.impulse == 6)
|
||||||
BuyChem(21, 6); //cost, item
|
BuyChem(21, IID_CHEM_BESERK); //cost, item
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.currentmenu == "shop_other")
|
if (self.currentmenu == "shop_other")
|
||||||
|
|
Loading…
Reference in a new issue