static dcitems.DCItem SelectItem(gamebook.Scenario SC, int IK) { /*Create a menu, then query the user for an item which*/ /*corresponds to the kind IK. Return null if either no*/ /*such items are present in the inventory, or if the user*/ /*cancels item selection.*/ //var // RPM: RPGMenuPtr; /*Our menu.*/ // i: DCItemPtr; // t: Integer; /*Create the menu. It's gonna use the InvWindow.*/ rpgmenus.RPGMenu RPM = rpgmenus.CreateRPGMenu(Crt.Color.Black, Crt.Color.Green, Crt.Color.LightGreen, WDM.InvWin_X, WDM.InvWin_Y, WDM.InvWin_X2, WDM.InvWin_Y2); RPM.dBorColor = Crt.Color.White; RPM.dTexColor = DscColor; RPM.dx1 = WDM.DscWin_X; RPM.dy1 = WDM.DscWin_Y; RPM.dx2 = WDM.DscWin_X2; RPM.dy2 = WDM.DscWin_Y2; /*Add one menu item for each appropriate item in the Inventory.*/ dcitems.DCItem i = SC.PC.inv; int t = 1; while (i != null) { if (i.ikind == IK) { rpgmenus.AddRPGMenuItem(RPM, dcitems.ItemNameLong(i), t, dcitems.ItemDesc(i)); } i = i.next; t += 1; } /*Error check- make sure there are items present in the list!!!*/ if (RPM.firstItem == null) { return(null); } /*Sort the menu alphabetically.*/ rpgmenus.RPMSortAlpha(RPM); /*Next, select the item.*/ t = rpgmenus.SelectMenu(RPM, rpgmenus.RPMNormal); if (t == -1) { i = null; } else { i = dcitems.LocateItem(SC.PC.inv, t); } /*Show the complete inventory list again.*/ rpgmenus.DisplayMenu(InvRPM); return(i); }
static void DropItem(gamebook.Scenario SC, dcitems.DCItem I) { /*The player wants to drop an item.*/ dcitems.DelinkDCItem(ref SC.PC.inv, I); dcitems.PlaceDCItem(SC.gb, SC.ig, I, SC.PC.m.x, SC.PC.m.y); RefreshBackPack(SC); }
static void CreateInvMenu(gamebook.Scenario SC) { /*Create the inventory menu, and store it in InvRPM*/ /*Initialize the menu.*/ InvRPM = rpgmenus.CreateRPGMenu(Crt.Color.Black, Crt.Color.Green, Crt.Color.LightGreen, WDM.InvWin_X, WDM.InvWin_Y, WDM.InvWin_X2, WDM.InvWin_Y2); InvRPM.dBorColor = Crt.Color.White; InvRPM.dTexColor = DscColor; InvRPM.dx1 = WDM.DscWin_X; InvRPM.dy1 = WDM.DscWin_Y; InvRPM.dx2 = WDM.DscWin_X2; InvRPM.dy2 = WDM.DscWin_Y2; /*Add the MenuKeys.*/ rpgmenus.AddRPGMenuKey(InvRPM, BMK_SwitchKey, BMK_SwitchCode); rpgmenus.AddRPGMenuKey(InvRPM, BMK_DropKey, BMK_DropCode); /*Add a MenuItem for each object in the player's inventory.*/ dcitems.DCItem i = SC.PC.inv; int t = 1; while (i != null) { rpgmenus.AddRPGMenuItem(InvRPM, dcitems.ItemNameLong(i), t, dcitems.ItemDesc(i)); i = i.next; t += 1; } /*Sort the menu alphabetically.*/ rpgmenus.RPMSortAlpha(InvRPM); }
static void StashItem(dcchars.DCChar PC, dcitems.DCItem it) { //{ The new PC has been given an item. Decide where to stick it, } //{ and provide whatever accessories it has coming. } if (it.ikind == dcitems.IKIND_Gun) { //{The weapon starts out fully loaded.} it.charge = dcitems.CGuns[it.icode - 1].magazine; //{Give the player some ammo for the gun.} dcitems.DCItem I = new dcitems.DCItem(); I.ikind = dcitems.IKIND_Ammo; I.icode = dcitems.CGuns[it.icode - 1].caliber; //{Decide how many bullets to dole out.} if (dcitems.CGuns[it.icode - 1].caliber >= dcitems.CAL_Energy) { //{Energy, napalm, and other special ammo weapons} //{don't get as many reloads.} I.charge = 3 + rpgdice.Random(6); } else if (it.icode == 9 || it.icode == 14) { //{ Ammo for a shotgun. } I.charge = dcitems.CGuns[it.icode - 1].magazine * 2 + rpgdice.Random(10); } else { I.charge = dcitems.CGuns[it.icode - 1].magazine; if (I.charge < 10) { I.charge = 10; } I.charge = (I.charge * 3) + rpgdice.Random(20); } dcitems.MergeDCItem(ref PC.inv, I); //{ For shotguns, include some scatter ammunition. } if (it.icode == 9 || it.icode == 14) { I = new dcitems.DCItem(); I.ikind = dcitems.IKIND_Ammo; I.icode = 100 + dcitems.CGuns[it.icode - 1].caliber; I.charge = dcitems.CGuns[it.icode - 1].magazine + rpgdice.Random(10); dcitems.MergeDCItem(ref PC.inv, I); } } //{ If equippable, equip the item. Otherwise, stash it. } if (it.ikind > 0 && PC.eqp[it.ikind - 1] == null) { PC.eqp[it.ikind - 1] = it; } else { dcitems.MergeDCItem(ref PC.inv, it); } }
static int IDTarget(dcitems.DCItem I) { //{ Examine item I and return the difficulcy number needed to identify it. } switch (I.ikind) { case dcitems.IKIND_Gun: case dcitems.IKIND_Wep: return(12); case dcitems.IKIND_Cap: case dcitems.IKIND_Armor: case dcitems.IKIND_Glove: case dcitems.IKIND_Shoe: return(9); case dcitems.IKIND_Food: //{ Pills are notoriously difficult to ID. } if (dcitems.CFood[I.icode - 1].fk == 2) { return(16); } return(5); case dcitems.IKIND_Ammo: case dcitems.IKIND_Grenade: return(7); } return(10); }
static void ChangeItem(gamebook.Scenario SC, int Slot) { /*Change the item that's currently equipped in equipment*/ /*slot Slot. If there are other items that could go there,*/ /*select one of them for use. If not, just unequip the item.*/ /*UnEquip the item in the slot.*/ if (SC.PC.eqp[Slot - 1] != null) { UnEquipItem(SC, Slot); } /*Select a new item, of appropriate type, from the menu.*/ dcitems.DCItem I = SelectItem(SC, Slot); /*Equip it. Any item currently in this slot will be sent to*/ /*the Inventory.*/ if (I != null) { EquipItem(SC, I); } RefreshBackPack(SC); DisplayPCStats(SC); }
static void GiveKatana(dcchars.DCChar PC) { //{ All Samurai start the game with a Katana. } dcitems.DCItem I = new dcitems.DCItem(); I.ikind = dcitems.IKIND_Wep; I.icode = 5; StashItem(PC, I); }
static void BPElectronics(gamebook.Scenario SC, dcitems.DCItem I) { /*The PC wants to use item I. Call the procedure to do so,*/ /*and restore the display afterwards.*/ HandyMap(SC); TheDisplay(SC); RefreshBackPack(SC); }
static void BPReadBook(gamebook.Scenario SC, dcitems.DCItem I) { /*The PC wants to read book I. Call the procedure to do so,*/ /*and restore the display afterwards.*/ libram.ReadBook(SC, I.icode); TheDisplay(SC); RefreshBackPack(SC); }
static void EatFood(gamebook.Scenario SC, dcitems.DCItem I) { /*Eat the food. Go for it.*/ /*Error check- make sure we have actual food.*/ if (I.ikind != dcitems.IKIND_Food) { return; } if (SC.PC.carbs + dcitems.CFood[I.icode - 1].carbs < 102) { SC.PC.carbs += dcitems.CFood[I.icode - 1].carbs; if (SC.PC.carbs > 100) { SC.PC.carbs = 100; } /* Display a different message depending upon whether the */ /* food item being eaten is a pill or not. */ if (dcitems.CFood[I.icode - 1].fk == 2) { rpgtext.DCGameMessage("You take the " + dcitems.CFood[I.icode - 1].name + "."); } else { rpgtext.DCGameMessage("You eat the " + dcitems.CFood[I.icode - 1].name + "."); } if (dcitems.CFood[I.icode - 1].fx != null) { zapspell.ProcessSpell(SC, dcitems.CFood[I.icode - 1].fx); } /* Just in case this hasn't been identified yet, ID it now. */ I.ID = true; dcitems.ConsumeDCItem(ref SC.PC.inv, I, 1); } else { /* The PC is too full to eat. Print a message depending upon */ /* whether the food item is a pill or something else. */ if (dcitems.CFood[I.icode - 1].fk == 2) { rpgtext.DCGameMessage("You're too full to take the " + dcitems.CFood[I.icode - 1].name + " now."); } else { rpgtext.DCGameMessage("You're too full to eat the " + dcitems.CFood[I.icode - 1].name + " now."); } } RefreshBackPack(SC); }
public static dcitems.DCItem GenerateItem(gamebook.Scenario SC, int TT) { //{Generate a random item from chart TT.} //{ The ScenarioPtr is used for the PC's tech skill, to see if items } //{ start out identified or not. } //{Decide which chart entry will be generated.} int R = rpgdice.Random(NumTChance) + 1; //{If the ICode listed in -1, jump instead to a different} //{item list, as indicated by the IKind field. Normally} //{item lists can only access item lists which occur after} //{them in the series; a check will be performed here to make} //{sure the procedure can't get stuck in an infinite loop.} dcitems.DCItem i; if (TTChart[TT - 1, R - 1, 1] == -1 && TTChart[TT - 1, R - 1, 0] > TT) { i = GenerateItem(SC, TTChart[TT - 1, R - 1, 0]); } else if (TTChart[TT - 1, R - 1, 1] != -1) { //{Allocate the item.} i = new dcitems.DCItem(); i.ikind = TTChart[TT - 1, R - 1, 0]; i.icode = TTChart[TT - 1, R - 1, 1]; if (TTChart[TT - 1, R - 1, 2] == 0) { i.charge = 0; } else { i.charge = rpgdice.Random(TTChart[TT - 1, R - 1, 2]) + 1; } } else { //{There's apparently an error in our random chart,} //{with one treasure list trying to access an earlier} //{one or somesuch. Let's make sure the error is noticed.} //{Drop 999 bananas.} i = new dcitems.DCItem(); i.ikind = dcitems.IKIND_Food; i.icode = 6; i.charge = 999; } //{ Finally, see whether or not the item is identified by the PC. } AttemptToIdentify(SC, i); return(i); }
public static bool PCPickUp(gamebook.Scenario SC) { /*The PC is gonna pick up something. Return FALSE if there*/ /*is no item present, or if the picking up is canceled.*/ bool it = false; rpgtext.DCGameMessage("Get Item - "); if (SC.ig.g[SC.PC.m.x - 1, SC.PC.m.y - 1] != null) { /*There's at least one item here. See if there's more.*/ if (SC.ig.g[SC.PC.m.x - 1, SC.PC.m.y - 1].next == null) { /*Simple case. There's only one item here.*/ /*Grab it.*/ dcitems.DCItem I = SC.ig.g[SC.PC.m.x - 1, SC.PC.m.y - 1]; rpgtext.DCAppendMessage("Got " + dcitems.ItemNameLong(I) + "."); dcitems.RetrieveDCItem(SC.gb, SC.ig, I, SC.PC.m.x, SC.PC.m.y); dcitems.MergeDCItem(ref SC.PC.inv, I); it = true; } else { /*Difficult case. There's multiple items.*/ /*List through them and prompt for picking up.*/ rpgtext.DCAppendMessage("Multiple items."); dcitems.DCItem I2 = SC.ig.g[SC.PC.m.x - 1, SC.PC.m.y - 1]; while (I2 != null) { dcitems.DCItem I = I2; I2 = I2.next; rpgtext.DCGameMessage("Pick up " + dcitems.ItemNameLong(I) + "? (Y/N)"); if (rpgtext.YesNo()) { dcitems.RetrieveDCItem(SC.gb, SC.ig, I, SC.PC.m.x, SC.PC.m.y); dcitems.MergeDCItem(ref SC.PC.inv, I); rpgtext.DCAppendMessage(" Done."); } else { rpgtext.DCAppendMessage(" Nope."); } } } } else { rpgtext.DCAppendMessage("Not found!"); } return(it); }
static void UnEquipItem(gamebook.Scenario SC, int Slot) { /*UnEquip the item in slot Slot in the PC's equipment list.*/ dcitems.DCItem I = SC.PC.eqp[Slot - 1]; if (I != null) { SC.PC.eqp[Slot - 1] = null; dcitems.MergeDCItem(ref SC.PC.inv, I); RefreshBackPack(SC); DisplayPCStats(SC); } }
public static void ScanUnknownInv(gamebook.Scenario SC) { /* Check through the items in the PC's inventory, and try to ID any */ /* of them that are currently unknown. */ /* Initialize values. */ bool didit = false; dcitems.DCItem I = SC.PC.inv; /* Scan inventory */ while (I != null) { dcitems.DCItem I2 = I.next; /* If this item hasn't been identified, we want to examine it. */ if (!I.ID) { charts.AttemptToIdentify(SC, I); /* If the attempt was successful, merge this item into */ /* the main inventory. */ if (I.ID) { didit = true; dcitems.DelinkDCItem(ref SC.PC.inv, I); dcitems.MergeDCItem(ref SC.PC.inv, I); } } I = I2; } for (int t = 1; t <= dcchars.NumEquipSlots; ++t) { if (SC.PC.eqp[t - 1] != null && !SC.PC.eqp[t - 1].ID) { charts.AttemptToIdentify(SC, SC.PC.eqp[t - 1]); if (SC.PC.eqp[t - 1].ID) { didit = true; } } } if (didit) { rpgtext.DCGameMessage("You learn something about the items you are carrying..."); } }
public static void AttemptToIdentify(gamebook.Scenario SC, dcitems.DCItem I) { //{ The PC will try to figure out what this item is. } if (SC.PC != null) { //{ The PC must make a tech skill roll against the item's } //{ difficulcy number, as calculated above. } I.ID = rpgdice.RollStep(dcchars.PCIDSkill(SC.PC)) >= IDTarget(I); } else { I.ID = false; } }
public static dcitems.DCItem PromptItem(gamebook.Scenario SC, int IK) { /*Create a menu, then query the user for an item which*/ /*corresponds to the kind IK. Return null if either no*/ /*such items are present in the inventory, or if the user*/ /*cancels item selection. Retore map display afterwards.*/ /*Create the menu. It's gonna use the InvWindow.*/ rpgmenus.RPGMenu RPM = rpgmenus.CreateRPGMenu(Crt.Color.LightGray, Crt.Color.Green, Crt.Color.LightGreen, 16, 7, 65, 21); /*Add one menu item for each appropriate item in the Inventory.*/ dcitems.DCItem i = SC.PC.inv; int t = 1; while (i != null) { if (i.ikind == IK) { rpgmenus.AddRPGMenuItem(RPM, dcitems.ItemNameLong(i), t, null); } i = i.next; t += 1; } /*Error check- make sure there are items present in the list!!!*/ if (RPM.firstItem == null) { return(null); } /*Sort the menu alphabetically.*/ rpgmenus.RPMSortAlpha(RPM); /*Next, select the item.*/ t = rpgmenus.SelectMenu(RPM, rpgmenus.RPMNormal); if (t == -1) { i = null; } else { i = dcitems.LocateItem(SC.PC.inv, t); } /*Restore the map display.*/ texmaps.DisplayMap(SC.gb); return(i); }
static void GiveBasicStuff(dcchars.DCChar PC) { //{ All PCs start with a few free items. } //{ 3 Trauma Fixes, 3 Antidotes. } dcitems.DCItem I = new dcitems.DCItem(); I.ikind = dcitems.IKIND_Food; I.icode = 25; I.charge = 3; StashItem(PC, I); I = new dcitems.DCItem(); I.ikind = dcitems.IKIND_Food; I.icode = 30; I.charge = 3; StashItem(PC, I); }
static void PickItemFromChart(dcchars.DCChar PC, int Chart, ref int pts) { //{ Select an item from one of the starting equipment charts, } //{ stash it in the PC's inventory, then decrement PTS by an } //{ appropriate amount. } //{ Decide what item from the chart to generate. } int N = rpgdice.Random(10); //{ Actually create the item record. } dcitems.DCItem I = new dcitems.DCItem(); I.ikind = ItemChart[Chart - 1, N, 0]; I.icode = ItemChart[Chart - 1, N, 1]; pts -= ItemChart[Chart - 1, N, 2]; //{ Stick the item in the PC's inventory. } StashItem(PC, I); }
public static void CritterDeath(gamebook.Scenario SC, critters.Critter C, bool KilledByPC) { //{A critter has died. Deal with it.} if (C == null) { rpgtext.DCGameMessage("SHAZBOT - The attemptes killing of a nonexistant critters."); return; } //{Critters will only drop random treasure if they are killed} //{by the PC.} if (KilledByPC) { if (critters.MonMan[C.crit - 1].TType > 0) { int N = 0; while (N < critters.MonMan[C.crit - 1].TNum && rpgdice.Random(100) < critters.MonMan[C.crit - 1].TDrop) { N += 1; dcitems.DCItem I = charts.GenerateItem(SC, critters.MonMan[C.crit - 1].TType); dcitems.PlaceDCItem(SC.gb, SC.ig, I, C.M.x, C.M.y); } } } if (C.Eqp != null && rpgdice.Random(100) < CDropEqp) { //{The critter dropped whatever it was carrying.} dcitems.PlaceDCItem(SC.gb, SC.ig, C.Eqp, C.M.x, C.M.y); //{Set the Eqp field to Nil, or else the RemoveCritter procedure} //{will delete the item. And mess up our map.} C.Eqp = null; } gamebook.Excommunicate(SC, C.M); critters.RemoveCritter(C, ref SC.CList, SC.gb); }
static void EquipItem(gamebook.Scenario SC, dcitems.DCItem I) { /*Delink this item from the main Inventory list, then stick*/ /*it in the appropriate equipment slot. If there's already*/ /*an item there, unequip it.*/ if (I.ikind > 0 && I.ikind <= dcchars.NumEquipSlots) { /*If something is already equipped, get rid of it.*/ if (SC.PC.eqp[I.ikind - 1] != null) { UnEquipItem(SC, I.ikind); } /*Delink the item we're equipping from the Inventory.*/ dcitems.DelinkDCItem(ref SC.PC.inv, I); /*Link it to the correct inventory slot.*/ SC.PC.eqp[I.ikind - 1] = I; RefreshBackPack(SC); DisplayPCStats(SC); } }
public static dcchars.DCChar RollNewChar() { //{We're going to generate a new game character from scratch.} //{Return NIL if the character creation process was cancelled.} const string instructions = "Select one of the avaliable jobs from the menu. Press ESC to reroll stats, or select Cancel to exit."; //var // pc: dccharptr; // opt: rpgmenuptr; {The menu holding avaliable jobs.} // t,tt: Integer; {Loop counters} // q: boolean; {Apparently, for this procedure, I've forgotten about useful variable names. It's hot and I'm tired.} // I: DCItemPtr; int t, tt; //{Allocate memory for the character.} dcchars.DCChar PC = new dcchars.DCChar(); //{Initilize Job to -1} PC.job = -1; //{Clear the screen} Crt.ClrScr(); //{Display the stat names} Crt.TextColor(Crt.Color.Cyan); for (t = 1; t <= 8; ++t) { Crt.GotoXY(12, t * 2 + 3); Crt.Write(dcchars.StatName[t - 1] + " :"); } //{Start a loop. We'll stay in the loop until a character is selected.} while (PC.job == -1) { //{Give a short message on how to use the character generator} rpgtext.GameMessage(instructions, 2, 1, 79, 4, Crt.Color.Green, Crt.Color.LightBlue); //{Set the text color} Crt.TextColor(Crt.Color.White); //{Roll the character's stats.} RollGHStats(PC, 100 + rpgdice.Random(20)); for (t = 1; t <= 8; ++t) { //{display the stat onscreen.} Crt.GotoXY(35, t * 2 + 3); Crt.Write(" "); Crt.GotoXY(35, t * 2 + 3); Crt.Write(PC.stat[t - 1].ToString()); } //{determine which jobs are open to this character, and} //{add them to our RPGMenu.} //{First, allocate the menu.} rpgmenus.RPGMenu opt = rpgmenus.CreateRPGMenu(Crt.Color.LightBlue, Crt.Color.Blue, Crt.Color.LightCyan, 46, 7, 65, 17); //{Initialize the description elements.} opt.dx1 = 2; opt.dx2 = 79; opt.dy1 = 20; opt.dy2 = 24; opt.dTexColor = Crt.Color.Green; for (t = 1; t <= dcchars.NumJobs; ++t) { //{Initialize q to true} bool q = true; //{Check each stat} for (tt = 1; tt <= 8; ++tt) { if (PC.stat[tt - 1] < dcchars.JobStat[t - 1, tt - 1]) { q = false; } } //{If q is still true, this job may be chosen.} if (q) { rpgmenus.AddRPGMenuItem(opt, dcchars.JobName[t - 1], t, dcchars.JobDesc[t - 1]); } } //{Get the jobs in alphabetical order} rpgmenus.RPMSortAlpha(opt); //{Add a CANCEL to the list} rpgmenus.AddRPGMenuItem(opt, " Cancel", 0, null); //{Ask for a selection} PC.job = rpgmenus.SelectMenu(opt, rpgmenus.RPMNoCleanup); PC.m = null; } //{If the player selected cancel, dispose of the PC record.} if (PC.job == 0) { PC = null; } else { //{Copy skill ranks} for (t = 1; t <= dcchars.NumSkill; t++) { PC.skill[t - 1] = dcchars.JobSkill[PC.job - 1, t - 1]; } //{Set HP, HPMax, and other initial values.} PC.HPMax = PC.stat[dcchars.STAT_Toughness] + dcchars.JobHitDie[PC.job - 1] + dcchars.BaseHP; PC.HP = PC.HPMax; PC.MPMax = PC.stat[dcchars.STAT_Willpower] / 2 + dcchars.JobMojoDie[PC.job - 1] + rpgdice.Random(dcchars.JobMojoDie[PC.job - 1]); PC.MP = PC.MPMax; PC.target = null; PC.carbs = 50; PC.lvl = 1; PC.XP = 0; PC.repCount = 0; PC.inv = null; for (t = 1; t <= dcchars.NumEquipSlots; ++t) { PC.eqp[t - 1] = null; } PC.SF = null; PC.spell = null; //{Give some basic equipment.} DoleEquipment(PC); //{Add the PC's meals.} for (t = 1; t <= 5; ++t) { dcitems.DCItem I = new dcitems.DCItem(); I.ikind = dcitems.IKIND_Food; I.icode = JobXFood[PC.job, rpgdice.Random(10)]; I.charge = 1; dcitems.MergeDCItem(ref PC.inv, I); } //{Add the PC's snacks.} int total = rpgdice.Random(5) + 1; for (t = 1; t <= total; ++t) { dcitems.DCItem I = new dcitems.DCItem(); I.ikind = dcitems.IKIND_Food; //{Decide upon what kind of food to give, based on job.} if (rpgdice.Random(3) == 2) { I.icode = JobXFood[0, rpgdice.Random(10)]; } else { I.icode = JobXFood[PC.job, rpgdice.Random(10)]; } I.charge = rpgdice.Random(3) + 1; dcitems.MergeDCItem(ref PC.inv, I); } //{ Input a name. } rpgtext.GameMessage("NAME: ", 2, 1, 79, 4, Crt.Color.LightGreen, Crt.Color.LightBlue); Crt.GotoXY(9, 2); Crt.CursorOn(); PC.name = rpgtext.ReadLine(); Crt.CursorOff(); if (PC.name != "") { //{ Generate an introduction. } IntroStory(PC); //{Add spells, if appropriate.} if (PC.skill[dcchars.SKILL_LearnSpell] > 0) { SelectPCSpells(PC); } } else { PC = null; } } return(PC); }
public static bool PCTosser(gamebook.Scenario SC) { /*The PC wants to throw a grenade.*/ /*The majority of this unit was simply copied from above.*/ /*Select a grenade to toss.*/ dcitems.DCItem Grn = backpack.PromptItem(SC, dcitems.IKIND_Grenade); if (Grn == null) { return(false); } /*Start the standard firing stuff.*/ rpgtext.DCGameMessage("Throw grenade - Select Target: "); texmaps.Point TP = looker.SelectPoint(SC, true, true, SC.PC.target); /*Check to make sure a target was selected, and also*/ /*the the player isn't trying to shoot himself.*/ if (TP.x == -1) { return(false); } if (TP.x == SC.PC.m.x && TP.y == SC.PC.m.y) { return(false); } /*Check to make sure the target point is within the PC's*/ /*maximum throwing range.*/ if (texmaps.Range(SC.PC.m, TP.x, TP.y) > dcchars.PCThrowRange(SC.PC)) { rpgtext.DCPointMessage("Out of range!"); return(false); } dccombat.AttackRequest AR = new dccombat.AttackRequest(); AR.HitRoll = dcchars.PCThrowSkill(SC.PC); AR.Damage = dcitems.CGrn[Grn.icode - 1].DMG; AR.Range = dcitems.CGrn[Grn.icode - 1].DMG; AR.Attacker = SC.PC.m; AR.TX = TP.x; AR.TY = TP.y; AR.DF = gamebook.DF_Physical; AR.C = Crt.Color.Yellow; AR.ATT = dcitems.CGrn[Grn.icode].ATT; if (AR.ATT.Contains(spells.AA_LineAttack) || AR.ATT.Contains(spells.AA_BlastAttack) || AR.ATT.Contains(spells.AA_SmokeAttack)) { AR.Desc = "throw " + dcitems.ItemNameShort(Grn); } else { AR.Desc = "throw " + dcitems.ItemNameShort(Grn) + " at"; } dccombat.AttackReport Rep = dccombat.ProcessAttack(SC, AR); /*Consume the grenade.*/ dcitems.ConsumeDCItem(ref SC.PC.inv, Grn, 1); return(true); }
static bool InvMenu(gamebook.Scenario SC) { /*This procedure will do all the stuff needed for the*/ /*Inventory menu. Return TRUE to keep doing inventory,*/ /*FALSE otherwise.*/ /*Error Check- if there's nothing present in the inventory,*/ /*boot the player back out to the Equipment menu.*/ if (InvRPM.firstItem == null) { return(true); } int n = -1; do { n = rpgmenus.SelectMenu(InvRPM, rpgmenus.RPMNoCleanup); rpgmenus.DisplayMenu(InvRPM); if (n > -1) { /*An actual item was selected. Do something*/ /*with it.*/ dcitems.DCItem I = dcitems.LocateItem(SC.PC.inv, n); /*Check to see if this is an equippable item.*/ if (I.ikind > 0) { EquipItem(SC, I); } else if (I.ikind == dcitems.IKIND_Ammo) { LoadAmmo(SC, I); } else if (I.ikind == dcitems.IKIND_Food) { EatFood(SC, I); } else if (I.ikind == dcitems.IKIND_Book) { BPReadBook(SC, I); } else if (I.ikind == dcitems.IKIND_Electronics) { BPElectronics(SC, I); } } else if (n == BMK_DropCode) { dcitems.DCItem I = dcitems.LocateItem(SC.PC.inv, rpgmenus.RPMLocateByPosition(InvRPM, InvRPM.selectItem).value); DropItem(SC, I); } /*Check to make sure there are items left in the inventory.*/ if (InvRPM.firstItem == null) { n = -1; } }while (n != -1 && n != BMK_SwitchCode); if (n == BMK_SwitchCode) { return(true); } return(false); }
static void LoadAmmo(gamebook.Scenario SC, dcitems.DCItem I) { /*Load ammunition item I into the currently equipped gun.*/ /*Fill the gun to its full capacity, or as full as it can*/ /*get given the current number of cartridges in inventory.*/ /*If the gun is currently loaded with a different ammo type,*/ /*unload that ammo. If the selected ammo won't fit in the*/ /*current gun, choose a different gun from the inventory.*/ // var //cal,spec: Integer; //gun,ul: DCItemPtr; //N: Integer; //ID: bool; /*Determine the Caliber and Special Type of the ammo.*/ int cal = I.icode % 100; int spec = I.icode / 100; bool ID = I.ID; dcitems.DCItem gun = SC.PC.eqp[dcchars.ES_MissileWeapon - 1]; if (gun == null || dcitems.CGuns[gun.icode - 1].caliber != cal) { /*The gun currently equipped is either inappropriate*/ /*or doesn't exist. Either way, we need to choose a new gun.*/ gun = SelectItem(SC, dcitems.IKIND_Gun); } if (gun == null || dcitems.CGuns[gun.icode - 1].caliber != cal || gun.charge == -1) { return; } /*We have a gun to load. Let's get to it!*/ /*If the gun is currently loaded with a different sort of*/ /*ammunition, unload it.*/ if (gun.state != spec && gun.charge > 0) { if (cal != dcitems.CAL_Energy && cal != dcitems.CAL_Napalm) { dcitems.DCItem UL = new dcitems.DCItem(); UL.ikind = dcitems.IKIND_Ammo; UL.icode = (Math.Abs(gun.state) * 100) + cal; UL.charge = gun.charge; gun.charge = 0; if (gun.state < 0) { UL.ID = false; } dcitems.MergeDCItem(ref SC.PC.inv, UL); } else { gun.charge = 0; gun.state = 0; } } /*Figure out how many rounds are needed to fill the gun.*/ int N = 0; if (dcitems.CGuns[gun.icode - 1].caliber == dcitems.CAL_Energy || dcitems.CGuns[gun.icode - 1].caliber == dcitems.CAL_Napalm) { N = 1; } else { N = dcitems.CGuns[gun.icode - 1].magazine - gun.charge; } if (N > 0) { /*Consume the ammo, add it to the magazine.*/ rpgtext.DCGameMessage("You load " + dcitems.ItemNameShort(gun) + "."); N = dcitems.ConsumeDCItem(ref SC.PC.inv, I, N); if (dcitems.CGuns[gun.icode - 1].caliber == dcitems.CAL_Energy) { /*Energy guns can store a large number of shots,*/ /*depending upon how many E-Cells are loaded*/ /*into them.*/ gun.charge += dcitems.CGuns[gun.icode - 1].magazine; if (ID) { gun.state = spec; } else { gun.state = -spec; } /*If the weapon is overloaded, well that's bad...*/ if (gun.charge > 600 / dcitems.CGuns[gun.icode].DMG) { rpgtext.DCAppendMessage(" Weapon is overcharged!"); gun.charge = 0; gun.state = 0; } } else if (dcitems.CGuns[gun.icode - 1].caliber == dcitems.CAL_Napalm) { /*One cannister reloads the weapon to full capacity.*/ gun.charge = dcitems.CGuns[gun.icode].magazine; if (rpgdice.Random(10) == 7) { rpgtext.DCAppendMessage(" Ready to cook."); } if (ID) { gun.state = spec; } else { gun.state = -spec; } } else { /*In this, the default case, the gun gains*/ /*as many shots as bullets you put into it.*/ gun.charge += N; if (ID) { gun.state = spec; } else { gun.state = -spec; } } } RefreshBackPack(SC); }