2003-10-24 21:43:32 +00:00
|
|
|
#include "common.qh"
|
|
|
|
#include "equip.qh"
|
|
|
|
#include "math.qh"
|
|
|
|
|
2003-10-28 21:20:34 +00:00
|
|
|
.float equip_state;
|
|
|
|
|
|
|
|
..float itemfield;
|
|
|
|
.float itemfield_1;
|
|
|
|
.float itemfield_2;
|
|
|
|
.float itemfield_3;
|
|
|
|
.float itemfield_4;
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
float (entity e, float eid)
|
|
|
|
equip_flag =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
if (eid < 24) {
|
|
|
|
e.itemfield = itemfield_1;
|
|
|
|
} else if (eid < 48) {
|
|
|
|
e.itemfield = itemfield_2;
|
|
|
|
eid -= 24;
|
|
|
|
} else if (eid < 72) {
|
|
|
|
e.itemfield = itemfield_3;
|
|
|
|
eid -= 48;
|
|
|
|
} else if (eid < 96) {
|
|
|
|
e.itemfield = itemfield_4;
|
|
|
|
eid -= 72;
|
|
|
|
}
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
return (1 << eid);
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
float (entity e, float eid)
|
|
|
|
equip_query =
|
|
|
|
{
|
|
|
|
eid = equip_flag (e, eid);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
if (e.(e.itemfield) & eid)
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
float (entity e, float eid)
|
|
|
|
equip_grant =
|
|
|
|
{
|
|
|
|
eid = equip_flag (e, eid);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
if (e.(e.itemfield) & eid)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
e.(e.itemfield) |= eid;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
float (entity e, float eid)
|
|
|
|
equip_remove =
|
|
|
|
{
|
|
|
|
eid = equip_flag (e, eid);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
if (e.(e.itemfield) & eid) {
|
|
|
|
e.(e.itemfield) -= eid;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
|
|
|
float _equip_iter_id;
|
|
|
|
/* Returns EQUIPID_* or -1 when done */
|
2004-02-08 07:34:17 +00:00
|
|
|
float (entity iteme)
|
|
|
|
equip_iter =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
local float ret, flag;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
if (_equip_iter_id >= EQUIPID_LAST) {
|
|
|
|
_equip_iter_id = 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
flag = equip_flag (iteme, _equip_iter_id);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
ret = _equip_iter_id;
|
|
|
|
_equip_iter_id++;
|
|
|
|
|
|
|
|
if (iteme.(iteme.itemfield) & flag)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1; /* Keep compiler from complaining */
|
|
|
|
};
|