1
0
Fork 0
forked from fte/fteqw

toolkits, moving inventory items, and mr.ammos work now.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1788 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2006-01-04 20:45:08 +00:00
parent bcc2b38685
commit b8d44415fa
5 changed files with 190 additions and 38 deletions

View file

@ -15,7 +15,9 @@ float(string desc) itemtoslot =
float(float slotno) DecreaseDestroySlot = float(float slotno) DecreaseDestroySlot =
{ {
float it; local float it;
local float iid;
local float num;
it = ItemInSlot(self, slotno); it = ItemInSlot(self, slotno);
if (ToStatus(it) <= 1) if (ToStatus(it) <= 1)
{ {
@ -24,7 +26,11 @@ float(float slotno) DecreaseDestroySlot =
} }
else else
{ {
SetItemSlot(self, slotno, SlotVal(ToIID(it), ToStatus(it)-1)); iid = ToIID(it);
num = ToStatus(it);
num = num - 1;
it = SlotVal(iid, num);
SetItemSlot(self, slotno, it);
return false; return false;
} }
}; };
@ -122,12 +128,12 @@ void(string arg1, string arg2) Cmd_InvSwap =
old1 = ItemInSlot(self, slotno1); old1 = ItemInSlot(self, slotno1);
old2 = ItemInSlot(self, slotno2); old2 = ItemInSlot(self, slotno2);
if (!FitsInSlot(slotno1, old2)) if (!FitsInSlot(slotno1, ToIID(old2)))
{ {
sprint(self, PRINT_HIGH, "Not allowed to exchange items\n"); sprint(self, PRINT_HIGH, "Not allowed to exchange items\n");
return; return;
} }
if (!FitsInSlot(slotno2, old1)) if (!FitsInSlot(slotno2, ToIID(old1)))
{ {
sprint(self, PRINT_HIGH, "Not allowed to exchange items\n"); sprint(self, PRINT_HIGH, "Not allowed to exchange items\n");
return; return;

View file

@ -10,6 +10,8 @@ float showcontextmenu;
vector contextpos; vector contextpos;
float slotnum; float slotnum;
float downslotnum;
vector toppos = '0 32 0'; vector toppos = '0 32 0';
float k_mouse1; float k_mouse1;
@ -23,7 +25,13 @@ void() Invent_Draw =
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
it = getstati(32+i); if (i+1 == downslotnum && slotnum)
op = slotnum-1;
else if (i+1 == slotnum && downslotnum)
op = downslotnum-1;
else
op = i;
it = getstati(32+op);
itname = GetItemName(ToIID(it)); itname = GetItemName(ToIID(it));
drawstring(toppos + (i * '0 8 0'), strcat(itname, " (", ftos(ToStatus(it)), ")"), '8 8 0', '1 1 1', 1); drawstring(toppos + (i * '0 8 0'), strcat(itname, " (", ftos(ToStatus(it)), ")"), '8 8 0', '1 1 1', 1);
} }
@ -49,13 +57,25 @@ void() Invent_Draw =
float(float eventtype, float param1, float param2) CSQC_InputEvent = float(float eventtype, float param1, float param2) CSQC_InputEvent =
{ {
local float op; local float op;
if (eventtype == 0) if (eventtype == 0) //key down
{ {
if (param1 == 'i') if (param1 == 'i')
{
show_inventory = !show_inventory; show_inventory = !show_inventory;
}
else if (!show_inventory) else if (!show_inventory)
return false; return false;
else if (param1 == k_mouse1) else if (param1 == k_mouse1)
{
downslotnum = slotnum;
}
else
return false;
return true;
}
if (eventtype == 1 && show_inventory) //key up
{
if (param1 == k_mouse1)
{ {
if (showcontextmenu) if (showcontextmenu)
{ {
@ -73,17 +93,27 @@ float(float eventtype, float param1, float param2) CSQC_InputEvent =
} }
else else
{ {
if (slotnum >= 1 && slotnum <= MAXSLOTS) if (downslotnum == slotnum) //mouse didn't move away
{ {
if (getstati(32+slotnum-1) != 0) if (slotnum >= 1 && slotnum <= MAXSLOTS)
{ {
showcontextmenu = true; if (getstati(32+slotnum-1) != 0) //if there's actually an item there
contextpos = mousepos; {
showcontextmenu = true; //show the context menu
contextpos = mousepos;
}
} }
else
show_inventory = false; //they clicked outside, fools!
} }
else else
show_inventory = false; {
//they dragged
showcontextmenu = false;
localcmd(strcat("cmd invswap ", ftos(downslotnum), " ", ftos(slotnum), "\nimpulse 1\n"));
}
} }
downslotnum = 0;
} }
else else
return false; return false;

View file

@ -252,6 +252,45 @@ float(entity e, float iid) SlotOfItem =
return 0; return 0;
}; };
float(entity e, float iid) TotalQuantity =
{ //iid must be stackable.
local float ret;
if (ToIID(e.islot1) == iid)
ret += ToStatus(e.islot1);
if (ToIID(e.islot2) == iid)
ret += ToStatus(e.islot2);
if (ToIID(e.islot3) == iid)
ret += ToStatus(e.islot3);
if (ToIID(e.islot4) == iid)
ret += ToStatus(e.islot4);
if (ToIID(e.islot5) == iid)
ret += ToStatus(e.islot5);
if (ToIID(e.islot6) == iid)
ret += ToStatus(e.islot6);
if (ToIID(e.islot7) == iid)
ret += ToStatus(e.islot7);
if (ToIID(e.islot8) == iid)
ret += ToStatus(e.islot8);
if (ToIID(e.islot9) == iid)
ret += ToStatus(e.islot9);
if (ToIID(e.islot10) == iid)
ret += ToStatus(e.islot10);
if (ToIID(e.islot11) == iid)
ret += ToStatus(e.islot11);
if (ToIID(e.islot12) == iid)
ret += ToStatus(e.islot12);
if (ToIID(e.islot13) == iid)
ret += ToStatus(e.islot13);
if (ToIID(e.islot14) == iid)
ret += ToStatus(e.islot14);
if (ToIID(e.islot15) == iid)
ret += ToStatus(e.islot15);
if (ToIID(e.islot16) == iid)
ret += ToStatus(e.islot16);
return ret;
};
float(entity e) FindEmptySlot = float(entity e) FindEmptySlot =
{ {
if (ToIID(e.islot3) == IID_NONE) if (ToIID(e.islot3) == IID_NONE)
@ -332,6 +371,8 @@ string(float iid) GetItemVModel =
{ {
if (iid == IID_NONE) if (iid == IID_NONE)
return "progs/v_fist.mdl"; return "progs/v_fist.mdl";
if (iid == IID_WP_TOOLKIT)
return "progs/v_span.mdl";
if (iid == IID_WP_KNIFE) if (iid == IID_WP_KNIFE)
return "progs/v_knife.mdl"; return "progs/v_knife.mdl";
if (iid == IID_WP_AXE) if (iid == IID_WP_AXE)
@ -773,6 +814,7 @@ string(float iid) GetItemName =
if (iid == IID_CHEM_BESERK) if (iid == IID_CHEM_BESERK)
return "beserk"; return "beserk";
if (iid == IID_BUILD_MRAMMO) if (iid == IID_BUILD_MRAMMO)
return "mr. ammo"; return "mr. ammo";
if (iid == IID_BUILD_SHIELDGEN) if (iid == IID_BUILD_SHIELDGEN)
@ -790,6 +832,8 @@ string(float iid) GetItemName =
float(float slotno, float iid) FitsInSlot = float(float slotno, float iid) FitsInSlot =
{ {
if (!iid) //nothing can be put in every slot.
return true;
if (slotno == 1 || slotno == 2) if (slotno == 1 || slotno == 2)
return IsShootable(iid); return IsShootable(iid);
if (slotno == 3) if (slotno == 3)

View file

@ -9,6 +9,7 @@ void (float rec, float number, float dam, float var, float ran, float auto) W_Fi
void (float dam, float rec, string snd, float rng, float rate) FireAssaultRifle; void (float dam, float rec, string snd, float rng, float rate) FireAssaultRifle;
void (float dam, float rec, string snd, float rng, float rate) FirePistol; void (float dam, float rec, string snd, float rng, float rate) FirePistol;
void (float dam, float rec, string snd, float rng, float rate) FireSMG; void (float dam, float rec, string snd, float rng, float rate) FireSMG;
float() FireToolkit;
void () W_PlayerMenu; void () W_PlayerMenu;
//void () UseChem; //void () UseChem;
void () Special; void () Special;
@ -98,7 +99,11 @@ void() W_FireMelee =
{ {
local float iid; local float iid;
iid = ToIID(self.(SlotField(self.current_slot))); iid = ToIID(self.(SlotField(self.current_slot)));
if (iid == IID_WP_KNIFE) if (iid == IID_NONE)
FireMelee(3, 32, 0.6);
else if (iid == IID_WP_TOOLKIT)
FireMelee(5, 32, 0.2);
else if (iid == IID_WP_KNIFE)
FireMelee(5, 32, 0.2); FireMelee(5, 32, 0.2);
else if (iid == IID_WP_AXE) else if (iid == IID_WP_AXE)
FireMelee(10, 64, 0.2); FireMelee(10, 64, 0.2);
@ -1105,7 +1110,14 @@ void() W_Attack =
else if (weap == IID_GREN_FLASH) else if (weap == IID_GREN_FLASH)
player_throw1(); player_throw1();
else if (weap == IID_WP_TOOLKIT)
{
if (!FireToolkit())
{
self.attack_finished = time + 0.25;
player_knife1 ();
}
}
else if (IsChem(weap)) else if (IsChem(weap))
{ {
self.attack_finished = time + 0.25; self.attack_finished = time + 0.25;
@ -3065,38 +3077,39 @@ void () station_think =
return; return;
} }
sprint (te, 2, "mr.ammo incorporated would like to appologise for any inconvienience caused by this unit being offline.\nOur engineers have diagnosed the fault and will remove the stub whenever they can be arsed.\n"); local float x;
/*
x = 300; x = 300;
if (te.current_slot == 1 && te.ammo2 < x) local float curweap;
local float ammotype;
local float ammocount;
local float ammoslot;
curweap = ToIID(ItemInSlot(te, te.current_slot));
ammotype = WeaponAmmoType(curweap);
if (ammotype)
{ {
sound (self, CHAN_BODY, "misc/item1.wav", TRUE, ATTN_NORM); ammocount = TotalQuantity(te, ammotype);
zz = (te.maxmag1 / 2); x = x - ammocount;
zz = ceil (zz);
qq = ftos (zz);
sprint (te, 2, qq);
sprint (te, 2, " ammo was received from the mr.ammo.\n");
te.ammo1 = te.ammo1 + zz;
te.ammo1 = ceil (te.ammo1);
self.chemcount = self.chemcount - 1;
} }
else else
x = 0;
if (x > 0)
{ {
if (te.current_slot == 2 && te.ammo2 < x) ammocount = WeaponMagQuant(curweap);
{ if (x > ammocount/2)
sound (self, CHAN_BODY, "misc/item1.wav", TRUE, ATTN_NORM); x = ammocount/2;
zz = (te.maxmag2 / 2);
zz = ceil (zz); ammoslot = SlotOfItem(te, ammotype);
qq = ftos (zz); if (!ammoslot)
sprint (te, 2, qq); ammoslot = FindEmptySlot(te);
sprint (te, 2, " ammo was received from the mr.ammo.\n"); if (ammoslot)
te.ammo2 = te.ammo2 + zz; SetItemSlot(te, ammoslot, SlotVal(ammotype, x + ToStatus(ItemInSlot(te, ammoslot))));
te.ammo2 = ceil (te.ammo2);
self.chemcount = self.chemcount - 1; sprint (te, PRINT_MEDIUM, ftos(ceil(x)), " ammo was received from the mr.ammo.\n");
}
self.chemcount = self.chemcount - 1;
} }
*/
} }
te = te.chain; te = te.chain;
} }
@ -3301,11 +3314,69 @@ float (float iid) spawn_station =
} }
self.frame = 4; self.frame = 4;
self.chemcount = 75;
self = oself; self = oself;
return true; return true;
}; };
float() FireToolkit =
{
local float rr;
makevectors (self.v_angle);
traceline (self.origin, self.origin + v_forward*64, FALSE, self);
//track is used for the owning player (without using the .owner field)
if (trace_ent.track == self && trace_ent.classname == "station" && trace_ent.health > 0)
{
if (trace_ent.health >= trace_ent.max_health) //already built - don't whack it!
return true;
//play a random build sound
rr = random ();
if (rr < 0.3)
sound (self, CHAN_WEAPON, "misc/build1.wav", TRUE, ATTN_NORM);
else if (rr < 0.6)
sound (self, CHAN_WEAPON, "misc/build2.wav", TRUE, ATTN_NORM);
else
sound (self, CHAN_WEAPON, "misc/build3.wav", TRUE, ATTN_NORM);
if (!trace_ent.nextthink)
if (trace_ent.health > 200)
trace_ent.frame = 5;
self.attack_finished = time + 0.1 + (random () * 0.1);
trace_ent.health = trace_ent.health + 6;
if (trace_ent.health >= trace_ent.max_health)
{ //it's built!
trace_ent.health = trace_ent.max_health;
if (trace_ent.nextthink)
return true; //already complete
trace_ent.think = station_think;
trace_ent.nextthink = time + 1;
sprint (self, PRINT_MEDIUM, "BUILDING COMPLETED.\n");
if (trace_ent.buildtype == IID_BUILD_ROBOFANG)
{
trace_ent.solid = SOLID_NOT;
trace_ent.think = SUB_Remove;
trace_ent.nextthink = time;
makevectors (self.v_angle);
sprint(self, PRINT_HIGH, "Robofang appears to have malfunctioned\n");
// spawn_dog (self.origin + v_forward * 32);
}
}
return true;
}
return false;
};
void () BuyMenu = void () BuyMenu =
{ {
local float is_shop; local float is_shop;

View file

@ -381,6 +381,7 @@ void() worldspawn =
precache_model ("progs/v_axe.mdl"); precache_model ("progs/v_axe.mdl");
precache_model ("progs/v_shot.mdl"); precache_model ("progs/v_shot.mdl");
precache_model ("progs/v_span.mdl");
precache_model ("progs/v_nail.mdl"); precache_model ("progs/v_nail.mdl");
precache_model ("progs/v_rock.mdl"); precache_model ("progs/v_rock.mdl");
precache_model ("progs/v_shot2.mdl"); precache_model ("progs/v_shot2.mdl");