2006-01-02 02:45:34 +00:00
|
|
|
void(entity e, string s) clientcommand = #440
|
|
|
|
float(string s) tokenize = #441;
|
|
|
|
string(float n) argv = #442;
|
|
|
|
|
2006-01-09 02:52:18 +00:00
|
|
|
string(string s, float start, float length) substring = #116;
|
|
|
|
float(string str, string sub) strstrofs = #221;
|
|
|
|
|
2006-01-02 02:45:34 +00:00
|
|
|
float(string desc) itemtoslot =
|
|
|
|
{
|
|
|
|
local float slot;
|
2006-01-09 02:52:18 +00:00
|
|
|
local float coma;
|
|
|
|
|
|
|
|
while((coma = strstrofs(desc, "+")) > 0)
|
|
|
|
{
|
|
|
|
slot = itemtoslot(substring(desc, 0, coma));
|
|
|
|
if (slot)
|
|
|
|
return slot;
|
|
|
|
desc = substring(desc, coma+1, -1);
|
|
|
|
}
|
|
|
|
|
2006-01-02 02:45:34 +00:00
|
|
|
slot = stof(desc);
|
|
|
|
if (slot >= 1 && slot <= MAXSLOTS)
|
|
|
|
return slot;
|
|
|
|
|
2006-01-09 02:52:18 +00:00
|
|
|
if (desc == "current")
|
|
|
|
return self.current_slot;
|
2006-01-06 01:52:52 +00:00
|
|
|
slot = ItemIDOfName(desc);
|
|
|
|
if (!slot)
|
|
|
|
{
|
|
|
|
sprint(self, PRINT_HIGH, "Not an item name\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-01-06 17:38:51 +00:00
|
|
|
slot = SlotOfItem(self, slot);
|
|
|
|
if (slot)
|
|
|
|
return slot;
|
2006-01-06 01:52:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-01-02 02:45:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
float(float slotno) DecreaseDestroySlot =
|
|
|
|
{
|
2006-01-04 20:45:08 +00:00
|
|
|
local float it;
|
|
|
|
local float iid;
|
|
|
|
local float num;
|
2006-01-02 02:45:34 +00:00
|
|
|
it = ItemInSlot(self, slotno);
|
|
|
|
if (ToStatus(it) <= 1)
|
|
|
|
{
|
|
|
|
SetItemSlot(self, slotno, 0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-01-04 20:45:08 +00:00
|
|
|
iid = ToIID(it);
|
|
|
|
num = ToStatus(it);
|
|
|
|
num = num - 1;
|
|
|
|
it = SlotVal(iid, num);
|
|
|
|
SetItemSlot(self, slotno, it);
|
2006-01-02 02:45:34 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void(string arg1) Cmd_InvUse =
|
|
|
|
{
|
|
|
|
local float it, iid;
|
|
|
|
local float slotno;
|
|
|
|
slotno = itemtoslot(arg1);
|
|
|
|
if (!slotno)
|
|
|
|
{
|
2006-01-09 02:52:18 +00:00
|
|
|
sprint(self, PRINT_MEDIUM, "Can't use - you don't have one\n");
|
2006-01-02 02:45:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
it = ItemInSlot(self, slotno);
|
|
|
|
iid = ToIID(it);
|
|
|
|
|
|
|
|
if (iid == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (WeaponAmmoType(iid))
|
|
|
|
{
|
|
|
|
//weapons are reloaded
|
|
|
|
ReloadWeapon(slotno);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iid == IID_CHEM_STIMPACK ||
|
|
|
|
iid == IID_CHEM_MEDICALBAG ||
|
|
|
|
iid == IID_CHEM_SUPERSTIM)
|
|
|
|
{
|
|
|
|
if (UseHealingChem(iid))
|
|
|
|
DecreaseDestroySlot(slotno);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iid == IID_CHEM_ADRENALINE ||
|
|
|
|
iid == IID_CHEM_PSYCHO ||
|
|
|
|
iid == IID_CHEM_BESERK)
|
|
|
|
{
|
|
|
|
if (UseBoostingChem(iid))
|
|
|
|
DecreaseDestroySlot(slotno);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iid == IID_BUILD_MRAMMO ||
|
|
|
|
iid == IID_BUILD_SHIELDGEN ||
|
|
|
|
iid == IID_BUILD_AUTODOC ||
|
2006-01-09 02:52:18 +00:00
|
|
|
iid == IID_BUILD_ROBOFANG ||
|
2006-01-15 01:38:45 +00:00
|
|
|
iid == IID_BUILD_TTURRET ||
|
|
|
|
iid == IID_BUILD_RTURRET ||
|
|
|
|
iid == IID_BUILD_GTURRET)
|
2006-01-02 02:45:34 +00:00
|
|
|
{
|
|
|
|
if (spawn_station(iid))
|
|
|
|
DecreaseDestroySlot(slotno);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-09 02:52:18 +00:00
|
|
|
if (iid == IID_EQUIP_CLIMBINGGEAR)
|
|
|
|
{
|
|
|
|
if (self.equipment_slot == slotno)
|
|
|
|
{
|
|
|
|
self.equipment_slot = 0;
|
|
|
|
sprint(self, PRINT_HIGH, "Climbing gear deactivated\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self.equipment_slot = slotno;
|
|
|
|
sprint(self, PRINT_HIGH, "Climbing gear activated\n");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2006-01-15 01:38:45 +00:00
|
|
|
if (iid == IID_EQUIP_SPRINTKIT)
|
|
|
|
{
|
|
|
|
if (self.equipment_slot == slotno)
|
|
|
|
{
|
|
|
|
self.equipment_slot = 0;
|
|
|
|
sprint(self, PRINT_HIGH, "What a downer\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self.equipment_slot = slotno;
|
|
|
|
sprint(self, PRINT_HIGH, "SUGAR RUSH!!!\n");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (iid == IID_EQUIP_STEALTHBOY)
|
|
|
|
{
|
|
|
|
if (self.equipment_slot == slotno)
|
|
|
|
{
|
|
|
|
self.equipment_slot = 0;
|
|
|
|
sprint(self, PRINT_HIGH, "stealthboy deactivated\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self.equipment_slot = slotno;
|
|
|
|
sprint(self, PRINT_HIGH, "stealthboy activated, fading into the shadows\n");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (iid == IID_EQUIP_HOVERBOOTS)
|
|
|
|
{
|
|
|
|
if (self.equipment_slot == slotno)
|
|
|
|
{
|
|
|
|
self.equipment_slot = 0;
|
|
|
|
sprint(self, PRINT_HIGH, "Hoverboots deactivated\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self.equipment_slot = slotno;
|
|
|
|
sprint(self, PRINT_HIGH, "Hoverboots activated\n");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2006-01-09 02:52:18 +00:00
|
|
|
|
2006-01-02 02:45:34 +00:00
|
|
|
sprint(self, PRINT_HIGH, "Don't know how to 'use' item\n");
|
|
|
|
};
|
|
|
|
|
|
|
|
void(string arg1) Cmd_InvDrop =
|
|
|
|
{
|
|
|
|
local float it, iid;
|
|
|
|
local float slotno;
|
|
|
|
slotno = itemtoslot(arg1);
|
|
|
|
if (!slotno)
|
|
|
|
{
|
2006-01-09 02:52:18 +00:00
|
|
|
sprint(self, PRINT_MEDIUM, "Can't drop - you don't have one\n");
|
2006-01-02 02:45:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
it = ItemInSlot(self, slotno);
|
|
|
|
iid = ToIID(it);
|
|
|
|
|
|
|
|
if (iid == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
DropFromSlot(slotno, true, false);
|
|
|
|
};
|
|
|
|
|
|
|
|
void(string arg1, string arg2) Cmd_InvSwap =
|
|
|
|
{
|
|
|
|
local float old1, old2;
|
|
|
|
local float slotno1;
|
|
|
|
local float slotno2;
|
|
|
|
slotno1 = itemtoslot(arg1);
|
|
|
|
if (!slotno1)
|
|
|
|
{
|
2006-01-09 02:52:18 +00:00
|
|
|
sprint(self, PRINT_HIGH, "No item\n");
|
2006-01-02 02:45:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
slotno2 = itemtoslot(arg2);
|
|
|
|
if (!slotno2)
|
|
|
|
{
|
2006-01-09 02:52:18 +00:00
|
|
|
sprint(self, PRINT_HIGH, "No item\n");
|
2006-01-02 02:45:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
old1 = ItemInSlot(self, slotno1);
|
|
|
|
old2 = ItemInSlot(self, slotno2);
|
2006-01-09 02:52:18 +00:00
|
|
|
if (old1 == old2)
|
|
|
|
return;
|
|
|
|
|
2006-01-04 20:45:08 +00:00
|
|
|
if (!FitsInSlot(slotno1, ToIID(old2)))
|
2006-01-02 02:45:34 +00:00
|
|
|
{
|
|
|
|
sprint(self, PRINT_HIGH, "Not allowed to exchange items\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-01-04 20:45:08 +00:00
|
|
|
if (!FitsInSlot(slotno2, ToIID(old1)))
|
2006-01-02 02:45:34 +00:00
|
|
|
{
|
|
|
|
sprint(self, PRINT_HIGH, "Not allowed to exchange items\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SetItemSlot(self, slotno1, old2);
|
|
|
|
SetItemSlot(self, slotno2, old1);
|
|
|
|
|
|
|
|
if (slotno1 == self.current_slot || slotno2 == self.current_slot)
|
|
|
|
W_SetCurrentAmmo();
|
2006-01-09 02:52:18 +00:00
|
|
|
|
2006-01-15 01:38:45 +00:00
|
|
|
//swap the equipment_slot over too.
|
|
|
|
if (self.equipment_slot == slotno1)
|
|
|
|
self.equipment_slot = slotno2;
|
|
|
|
else if (self.equipment_slot == slotno2)
|
|
|
|
self.equipment_slot = slotno1;
|
|
|
|
|
2006-01-09 02:52:18 +00:00
|
|
|
self.rtime = time + 2; //we don't check this here though - cost to get into inventory.
|
2006-01-02 02:45:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void(string arg1, float iid, float num) Cmd_InvGive =
|
|
|
|
{
|
|
|
|
local float slotno;
|
|
|
|
slotno = itemtoslot(arg1);
|
|
|
|
if (!slotno)
|
|
|
|
{
|
2006-01-09 02:52:18 +00:00
|
|
|
sprint(self, PRINT_MEDIUM, "Can't give to that slot\n");
|
2006-01-02 02:45:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-15 01:38:45 +00:00
|
|
|
if (!FitsInSlot(slotno, iid))
|
|
|
|
{
|
|
|
|
sprint(self, PRINT_MEDIUM, "Can't give that item in that slot\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-02 02:45:34 +00:00
|
|
|
if (num <= 0)
|
|
|
|
num = 1;
|
|
|
|
SetItemSlot(self, slotno, SlotVal(iid, num));
|
2006-01-02 22:04:05 +00:00
|
|
|
|
|
|
|
if (slotno == self.current_slot)
|
|
|
|
W_SetCurrentAmmo();
|
2006-01-02 02:45:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void(string line) SV_ParseClientCommand =
|
|
|
|
{
|
|
|
|
local string cmd;
|
|
|
|
tokenize(line);
|
|
|
|
|
|
|
|
cmd = argv(0);
|
2006-01-09 02:52:18 +00:00
|
|
|
if (cmd == "invuse")
|
2006-01-02 02:45:34 +00:00
|
|
|
{
|
2006-01-15 22:36:09 +00:00
|
|
|
if (self.deadflag || self.current_slot==0)
|
2006-01-09 02:52:18 +00:00
|
|
|
return;
|
2006-01-02 02:45:34 +00:00
|
|
|
Cmd_InvUse(argv(1));
|
|
|
|
}
|
|
|
|
else if (cmd == "invdrop")
|
|
|
|
{
|
2006-01-15 22:36:09 +00:00
|
|
|
if (self.deadflag || self.current_slot==0)
|
2006-01-09 02:52:18 +00:00
|
|
|
return;
|
2006-01-02 02:45:34 +00:00
|
|
|
Cmd_InvDrop(argv(1));
|
|
|
|
}
|
|
|
|
else if (cmd == "invswap")
|
|
|
|
{
|
2006-01-15 22:36:09 +00:00
|
|
|
if (self.deadflag || self.current_slot==0)
|
2006-01-09 02:52:18 +00:00
|
|
|
return;
|
2006-01-02 02:45:34 +00:00
|
|
|
Cmd_InvSwap(argv(1), argv(2));
|
|
|
|
}
|
|
|
|
else if (cmd == "invgive")
|
|
|
|
{
|
2006-01-15 22:36:09 +00:00
|
|
|
if (self.deadflag || self.current_slot==0)
|
2006-01-09 02:52:18 +00:00
|
|
|
return;
|
2006-01-02 02:45:34 +00:00
|
|
|
Cmd_InvGive(argv(1), stof(argv(2)), stof(argv(3)));
|
|
|
|
}
|
|
|
|
else if (cmd == "god")
|
|
|
|
{
|
|
|
|
sprint(self, PRINT_HIGH, "sorry, but I'm an athiest\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
clientcommand(self, line);
|
|
|
|
};
|