Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberfilth committed Apr 17, 2022
2 parents 3f27ea5 + e5bb98d commit 782a3f3
Show file tree
Hide file tree
Showing 14 changed files with 458 additions and 31 deletions.
11 changes: 10 additions & 1 deletion Axes.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<Units Count="64">
<Units Count="66">
<Unit0>
<Filename Value="Axes.lpr"/>
<IsPartOfProject Value="True"/>
Expand Down Expand Up @@ -390,6 +390,15 @@
<Filename Value="entities\animals\hyena_fungus.pas"/>
<IsPartOfProject Value="True"/>
</Unit63>
<Unit64>
<Filename Value="items\pixie_jar.pas"/>
<IsPartOfProject Value="True"/>
</Unit64>
<Unit65>
<Filename Value="entities\shadowcreature.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="shadowCreature"/>
</Unit65>
</Units>
</ProjectOptions>
<CompilerOptions>
Expand Down
19 changes: 15 additions & 4 deletions entities.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
interface

uses
SysUtils, globalUtils,
SysUtils, globalUtils, player_stats,
{ List of creatures }
cave_rat, giant_cave_rat, blood_bat, green_fungus, redcap_lesser, redcap_lesser_lobber,
small_green_fungus, large_blood_bat, small_hyena, redcap_fungus, mushroom_person, hyena_fungus;
cave_rat, giant_cave_rat, blood_bat, green_fungus, redcap_lesser,
redcap_lesser_lobber, small_green_fungus, large_blood_bat, small_hyena,
redcap_fungus, mushroom_person, hyena_fungus;

type { NPC attitudes }
Tattitudes = (stateNeutral, stateHostile, stateEscape);
Expand Down Expand Up @@ -99,6 +100,8 @@ procedure redrawMapDisplay(id: byte);
procedure newFloorNPCs;
(* Count all living NPC's *)
function countLivingEntities: byte;
(* When the light source goes out *)
procedure outOfView;
(* Call Creatures.takeTurn procedure *)
procedure NPCgameLoop;

Expand Down Expand Up @@ -232,7 +235,7 @@ function isCreatureVisible(x, y: smallint): boolean;
Result := False;
for i := 0 to npcAmount do
if (entityList[i].posX = x) and (entityList[i].posY = y) then
if (entityList[i].inView = True) and (entityList[i].glyph <> '%') then
if (entityList[i].inView = True) and (entityList[i].glyph <> '%') and (player_stats.lightEquipped = True) then
Result := True;
end;

Expand Down Expand Up @@ -275,6 +278,14 @@ function countLivingEntities: byte;
Result := Count;
end;

procedure outOfView;
var
i: smallint;
begin
for i := 1 to npcAmount do
entityList[i].inView := False;
end;

procedure NPCgameLoop;
var
i: smallint;
Expand Down
12 changes: 12 additions & 0 deletions file_handling.pas
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ procedure saveDungeonLevel;
AddElement(DataNode, 'glyph', '*')
else if (itemList[i].glyph = chr(173)) then
AddElement(DataNode, 'glyph', 'i')
else if (itemList[i].glyph = chr(232)) then
AddElement(DataNode, 'glyph', '0')
else
AddElement(DataNode, 'glyph', itemList[i].glyph);

Expand Down Expand Up @@ -371,6 +373,8 @@ procedure loadDungeonLevel(lvl: byte);
items.itemList[i].glyph := chr(7)
else if (ItemsNode.FindNode('glyph').TextContent[1] = 'i') then { pointy stick }
items.itemList[i].glyph := chr(173)
else if (ItemsNode.FindNode('glyph').TextContent[1] = '0') then { Pixie in a jar }
items.itemList[i].glyph := chr(232)
else
items.itemList[i].glyph := char(widechar(ItemsNode.FindNode('glyph').TextContent[1]));

Expand Down Expand Up @@ -536,7 +540,9 @@ procedure loadGame;
player_stats.clanName:=UTF8Encode(PlayerDataNode.FindNode('clanName').TextContent);
player_stats.enchantedWeaponEquipped:=StrToBool(UTF8Encode(PlayerDataNode.FindNode('enchantedWeapon').TextContent));
player_stats.projectileWeaponEquipped:=StrToBool(UTF8Encode(PlayerDataNode.FindNode('projectileWeapon').TextContent));
player_stats.lightEquipped:=StrToBool(UTF8Encode(PlayerDataNode.FindNode('lightEquipped').TextContent));
player_stats.enchWeapType := StrToInt(UTF8Encode(PlayerDataNode.FindNode('enchWeapType').TextContent));
player_stats.lightCounter := StrToInt(UTF8Encode(PlayerDataNode.FindNode('lightCounter').TextContent));

(* Player Inventory *)
player_inventory.initialiseInventory;
Expand All @@ -563,6 +569,8 @@ procedure loadGame;
player_inventory.inventory[i].glyph := chr(7)
else if (InventoryNode.FindNode('glyph').TextContent[1] = 'i') then
player_inventory.inventory[i].glyph := chr(173)
else if (InventoryNode.FindNode('glyph').TextContent[1] = '0') then
player_inventory.inventory[i].glyph := chr(232)
else
player_inventory.inventory[i].glyph := char(widechar(InventoryNode.FindNode('glyph').TextContent[1]));

Expand Down Expand Up @@ -675,7 +683,9 @@ procedure saveGame;
AddElement(DataNode, 'clanName', player_stats.clanName);
AddElement(DataNode, 'enchantedWeapon', BoolToStr(player_stats.enchantedWeaponEquipped));
AddElement(DataNode, 'projectileWeapon', BoolToStr(player_stats.projectileWeaponEquipped));
AddElement(DataNode, 'lightEquipped', BoolToStr(player_stats.lightEquipped));
AddElement(DataNode, 'enchWeapType', IntToStr(player_stats.enchWeapType));
AddElement(DataNode, 'lightCounter', IntToStr(player_stats.lightCounter));

(* Player inventory *)
for i := 0 to 9 do
Expand All @@ -702,6 +712,8 @@ procedure saveGame;
AddElement(DataNode, 'glyph', '*')
else if (inventory[i].glyph = chr(173)) then
AddElement(DataNode, 'glyph', 'i')
else if (inventory[i].glyph = chr(232)) then
AddElement(DataNode, 'glyph', '0')
else
AddElement(DataNode, 'glyph', inventory[i].glyph);

Expand Down
6 changes: 4 additions & 2 deletions items.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ interface
ui;

type
tItem = (itmDrink, itmWeapon, itmArmour, itmQuest, itmProjectile, itmEmptySlot, itmProjectileWeapon, itmAmmo);
tItem = (itmDrink, itmWeapon, itmArmour, itmQuest, itmProjectile, itmEmptySlot,
itmProjectileWeapon, itmAmmo, itmLightSource);

type
tMaterial = (matSteel, matIron, matWood, matLeather, matWool, matPaper, matAlcohol, matStone, matEmpty);
tMaterial = (matSteel, matIron, matWood, matLeather, matWool, matPaper, matAlcohol,
matStone, matGlass, matEmpty);

(* Store information about items *)
type
Expand Down
3 changes: 2 additions & 1 deletion items/item_lookup.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface
{ List of armour }
leather_armour1, cloth_armour1,
{ Quest items }
smugglersMap,
smugglersMap, pixie_jar,
{ Magical items }
staff_minor_scorch,
{ Ammunition }
Expand Down Expand Up @@ -113,6 +113,7 @@ procedure lookupUse(x: smallint; equipped: boolean; id: smallint);
10: short_bow.useItem(equipped);
11: pointy_stick.useItem(equipped);
12: arrow.useItem;
13: pixie_jar.useItem;
end;
end;

Expand Down
65 changes: 65 additions & 0 deletions items/pixie_jar.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
(* A glowing pixie in a jar - Light source *)

unit pixie_jar;

{$mode fpc}{$H+}

interface

(* Create a pixie jar *)
procedure createPixieJar;
(* Item cannot be equipped *)
procedure useItem;

implementation

uses
items, ui, globalUtils, map, player_stats, entities;

procedure createPixieJar;
var
duration, r, c: smallint;
begin
(* Choose random location on the map *)
repeat
r := globalutils.randomRange(3, (MAXROWS - 3));
c := globalutils.randomRange(3, (MAXCOLUMNS - 3));
(* choose a location that is not a wall or occupied *)
until (maparea[r][c].Blocks = False) and (maparea[r][c].Occupied = False);

duration := randomRange(150, 160);
SetLength(itemList, length(itemList) + 1);
with itemList[High(itemList)] do
begin
itemID := High(itemList);
itemName := 'Pixie in a jar';
itemDescription := 'glowing source of light';
itemArticle := 'a';
itemType := itmLightSource;
itemMaterial := matGlass;
useID := 13;
glyph := chr(232);
glyphColour := 'yellow';
inView := False;
posX := c;
posY := r;
NumberOfUses := duration;
onMap := True;
throwable := False;
throwDamage := 0;
dice := 0;
adds := 0;
discovered := False;
Inc(indexID);
end;
end;

procedure useItem;
begin
ui.displayMessage('You pick up the Pixie in the jar.');
if (entityList[0].visionRange < player_stats.maxVisionRange) then
entityList[0].visionRange := player_stats.maxVisionRange;
end;

end.

5 changes: 5 additions & 0 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ procedure newGame;
player_stats.playerLevel := 1;
player_stats.enchantedWeaponEquipped := False;
player_stats.enchWeapType := 0;
player_stats.lightEquipped := True;
player_stats.lightCounter := 250;
scrTargeting.targetX := 0;
scrTargeting.targetY := 0;
scrTargeting.safeX := 0;
Expand Down Expand Up @@ -381,6 +383,9 @@ procedure gameLoop;
if (gameState = stWinAlpha) then
Exit;

(* Light source acts as a timer or 'hunger clock' *)
player_stats.processLight;

(* move NPC's *)
entities.NPCgameLoop;
(* Process status effects *)
Expand Down
65 changes: 59 additions & 6 deletions map.pas
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ procedure descendStairs;
procedure drawTile(c, r: smallint; hiDef: byte);
(* Display explored sections of map when reloading game *)
procedure loadDisplayedMap;
(* Set the whole map to invisible *)
procedure notInView;
(* Setup the current level *)
procedure setupMap;

Expand Down Expand Up @@ -236,12 +238,18 @@ procedure drawTile(c, r: smallint; hiDef: byte);
begin
if (hiDef = 1) then
begin
mapDisplay[r][c].GlyphColour := 'lightGrey';
if (player_stats.lightEquipped = True) then
mapDisplay[r][c].GlyphColour := 'darkGrey'
else
mapDisplay[r][c].GlyphColour := 'lightGrey';
mapDisplay[r][c].Glyph := '.';
end
else
begin
mapDisplay[r][c].GlyphColour := 'darkGrey';
if (player_stats.lightEquipped = True) then
mapDisplay[r][c].GlyphColour := 'darkGrey'
else
mapDisplay[r][c].GlyphColour := 'black';
mapDisplay[r][c].Glyph := '.';
end;
end;
Expand Down Expand Up @@ -275,13 +283,47 @@ procedure drawTile(c, r: smallint; hiDef: byte);
begin
if (hiDef = 1) then
begin
mapDisplay[r][c].GlyphColour := 'brown';
mapDisplay[r][c].Glyph := Chr(177);
if (player_stats.lightEquipped = True) then
begin
if (player_stats.lightCounter <= 20) then
begin
mapDisplay[r][c].GlyphColour := 'grey';
mapDisplay[r][c].Glyph := Chr(177);
end
else
begin
mapDisplay[r][c].GlyphColour := 'brown';
mapDisplay[r][c].Glyph := Chr(177);
end;
end
else
begin
mapDisplay[r][c].GlyphColour := 'grey';
mapDisplay[r][c].Glyph := Chr(177);
end;
end
else
begin
mapDisplay[r][c].GlyphColour := 'brown';
mapDisplay[r][c].Glyph := Chr(176);
if (player_stats.lightEquipped = True) then
begin
begin
if (player_stats.lightCounter <= 20) then
begin
mapDisplay[r][c].GlyphColour := 'darkGrey';
mapDisplay[r][c].Glyph := Chr(176);
end
else
begin
mapDisplay[r][c].GlyphColour := 'brown';
mapDisplay[r][c].Glyph := Chr(176);
end;
end;
end
else
begin
mapDisplay[r][c].GlyphColour := 'darkGrey';
mapDisplay[r][c].Glyph := Chr(176);
end;
end;
end;
end;
Expand All @@ -299,6 +341,17 @@ procedure loadDisplayedMap;
end;
end;

procedure notInView;
begin
for r := 1 to globalUtils.MAXROWS do
begin
for c := 1 to globalUtils.MAXCOLUMNS do
begin
maparea[r, c].Visible := False;
end;
end;
end;

procedure setupMap;
var
(* give each tile a unique ID number *)
Expand Down
Loading

0 comments on commit 782a3f3

Please sign in to comment.