diff --git a/quakec/fallout2/cmds.qc b/quakec/fallout2/cmds.qc index 12e7a9e98..a487d308f 100644 --- a/quakec/fallout2/cmds.qc +++ b/quakec/fallout2/cmds.qc @@ -15,7 +15,9 @@ float(string desc) itemtoslot = float(float slotno) DecreaseDestroySlot = { - float it; + local float it; + local float iid; + local float num; it = ItemInSlot(self, slotno); if (ToStatus(it) <= 1) { @@ -24,7 +26,11 @@ float(float slotno) DecreaseDestroySlot = } 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; } }; @@ -122,12 +128,12 @@ void(string arg1, string arg2) Cmd_InvSwap = old1 = ItemInSlot(self, slotno1); old2 = ItemInSlot(self, slotno2); - if (!FitsInSlot(slotno1, old2)) + if (!FitsInSlot(slotno1, ToIID(old2))) { sprint(self, PRINT_HIGH, "Not allowed to exchange items\n"); return; } - if (!FitsInSlot(slotno2, old1)) + if (!FitsInSlot(slotno2, ToIID(old1))) { sprint(self, PRINT_HIGH, "Not allowed to exchange items\n"); return; diff --git a/quakec/fallout2/csqc/invent.qc b/quakec/fallout2/csqc/invent.qc index 11f9605a7..b9a98f8d1 100644 --- a/quakec/fallout2/csqc/invent.qc +++ b/quakec/fallout2/csqc/invent.qc @@ -10,6 +10,8 @@ float showcontextmenu; vector contextpos; float slotnum; +float downslotnum; + vector toppos = '0 32 0'; float k_mouse1; @@ -23,7 +25,13 @@ void() Invent_Draw = 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)); 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 = { local float op; - if (eventtype == 0) + if (eventtype == 0) //key down { if (param1 == 'i') + { show_inventory = !show_inventory; + } else if (!show_inventory) return false; 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) { @@ -73,17 +93,27 @@ float(float eventtype, float param1, float param2) CSQC_InputEvent = } 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; - contextpos = mousepos; + if (getstati(32+slotnum-1) != 0) //if there's actually an item there + { + showcontextmenu = true; //show the context menu + contextpos = mousepos; + } } + else + show_inventory = false; //they clicked outside, fools! } else - show_inventory = false; + { + //they dragged + showcontextmenu = false; + localcmd(strcat("cmd invswap ", ftos(downslotnum), " ", ftos(slotnum), "\nimpulse 1\n")); + } } + downslotnum = 0; } else return false; diff --git a/quakec/fallout2/inventory.qc b/quakec/fallout2/inventory.qc index 89d26d0a1..f7d29f714 100644 --- a/quakec/fallout2/inventory.qc +++ b/quakec/fallout2/inventory.qc @@ -252,6 +252,45 @@ float(entity e, float iid) SlotOfItem = 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 = { if (ToIID(e.islot3) == IID_NONE) @@ -332,6 +371,8 @@ string(float iid) GetItemVModel = { if (iid == IID_NONE) return "progs/v_fist.mdl"; + if (iid == IID_WP_TOOLKIT) + return "progs/v_span.mdl"; if (iid == IID_WP_KNIFE) return "progs/v_knife.mdl"; if (iid == IID_WP_AXE) @@ -773,6 +814,7 @@ string(float iid) GetItemName = if (iid == IID_CHEM_BESERK) return "beserk"; + if (iid == IID_BUILD_MRAMMO) return "mr. ammo"; if (iid == IID_BUILD_SHIELDGEN) @@ -790,6 +832,8 @@ string(float iid) GetItemName = float(float slotno, float iid) FitsInSlot = { + if (!iid) //nothing can be put in every slot. + return true; if (slotno == 1 || slotno == 2) return IsShootable(iid); if (slotno == 3) diff --git a/quakec/fallout2/weapons.qc b/quakec/fallout2/weapons.qc index 89cb76431..786a8c812 100644 --- a/quakec/fallout2/weapons.qc +++ b/quakec/fallout2/weapons.qc @@ -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) FirePistol; void (float dam, float rec, string snd, float rng, float rate) FireSMG; +float() FireToolkit; void () W_PlayerMenu; //void () UseChem; void () Special; @@ -98,7 +99,11 @@ void() W_FireMelee = { local float iid; 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); else if (iid == IID_WP_AXE) FireMelee(10, 64, 0.2); @@ -1105,7 +1110,14 @@ void() W_Attack = else if (weap == IID_GREN_FLASH) player_throw1(); - + else if (weap == IID_WP_TOOLKIT) + { + if (!FireToolkit()) + { + self.attack_finished = time + 0.25; + player_knife1 (); + } + } else if (IsChem(weap)) { self.attack_finished = time + 0.25; @@ -3065,38 +3077,39 @@ void () station_think = 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; - 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); - zz = (te.maxmag1 / 2); - 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; + ammocount = TotalQuantity(te, ammotype); + x = x - ammocount; } else + x = 0; + if (x > 0) { - if (te.current_slot == 2 && te.ammo2 < x) - { - sound (self, CHAN_BODY, "misc/item1.wav", TRUE, ATTN_NORM); - zz = (te.maxmag2 / 2); - zz = ceil (zz); - qq = ftos (zz); - sprint (te, 2, qq); - sprint (te, 2, " ammo was received from the mr.ammo.\n"); - te.ammo2 = te.ammo2 + zz; - te.ammo2 = ceil (te.ammo2); - self.chemcount = self.chemcount - 1; - } + ammocount = WeaponMagQuant(curweap); + if (x > ammocount/2) + x = ammocount/2; + + ammoslot = SlotOfItem(te, ammotype); + if (!ammoslot) + ammoslot = FindEmptySlot(te); + if (ammoslot) + SetItemSlot(te, ammoslot, SlotVal(ammotype, x + ToStatus(ItemInSlot(te, ammoslot)))); + + sprint (te, PRINT_MEDIUM, ftos(ceil(x)), " ammo was received from the mr.ammo.\n"); + + self.chemcount = self.chemcount - 1; } -*/ } te = te.chain; } @@ -3301,11 +3314,69 @@ float (float iid) spawn_station = } self.frame = 4; + self.chemcount = 75; + self = oself; 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 = { local float is_shop; diff --git a/quakec/fallout2/world.qc b/quakec/fallout2/world.qc index ecab98bc2..783c6c794 100644 --- a/quakec/fallout2/world.qc +++ b/quakec/fallout2/world.qc @@ -381,6 +381,7 @@ void() worldspawn = precache_model ("progs/v_axe.mdl"); precache_model ("progs/v_shot.mdl"); + precache_model ("progs/v_span.mdl"); precache_model ("progs/v_nail.mdl"); precache_model ("progs/v_rock.mdl"); precache_model ("progs/v_shot2.mdl");