Skip to content

Commit

Permalink
#36 and #37: added bark recipe from trunks and bark armour. #39: corp…
Browse files Browse the repository at this point in the history
…ses now get the dead creature's letter, including case
  • Loading branch information
fabio-t committed Mar 4, 2018
1 parent 0c25585 commit 64b80ff
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 27 deletions.
2 changes: 2 additions & 0 deletions alone-rl.iml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.github.fabio-t:rlforj-alt:0.3.0" level="project" />
<orderEntry type="library" name="Maven: com.github.fabio-t:terrain-generator:0.1.2" level="project" />
<orderEntry type="library" name="Maven: com.github.trystan:AsciiPanel:372dfbae98" level="project" />
<orderEntry type="library" name="Maven: net.onedaybeard.artemis:artemis-odb:2.1.0" level="project" />
<orderEntry type="library" name="Maven: net.mostlyoriginal.artemis-odb:contrib-core:2.3.0" level="project" />
Expand Down
8 changes: 8 additions & 0 deletions data/crafting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ stone-arrow:
bow:
sources: [trunk, vine]
tools: [stone-axe, stone-knife]

bark:
sources: [trunk]
tools: [stone-axe, stone-knife]

bark-armour:
sources: [bark, vine]
tools: [stone-knife]
21 changes: 21 additions & 0 deletions data/items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,24 @@ bow:
green: 104
blue: 21
alpha: 255

bark:
name: tree bark
sprite:
c: '$'
col:
red: 141
green: 104
blue: 21
alpha: 255

bark-armour:
name: bark armour
wearable:
where: BODY
armour:
defences:
SLASH: 2
BLUNT: 1
POINT: 1
NATURAL: 2
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,20 @@ public void placeObjects()
if (!map.obstacles.isEmpty(x, y))
continue;

sItems.makeItem("tree", x, y);
// 1% of the trees are fallen remains
if (r.nextFloat() < 0.1f)
{
sItems.makeItem("trunk", x, y);

if (r.nextBoolean())
sItems.makeItem("branch", x, y);
if (r.nextBoolean())
sItems.makeItem("vine", x, y);
}
else
{
sItems.makeItem("tree", x, y);
}
}
}
}
Expand Down Expand Up @@ -353,26 +366,6 @@ public void placeObjects()
}
}

// add random trunks and branches
for (x = 0; x < Options.MAP_SIZE_X; x++)
{
for (y = 0; y < Options.MAP_SIZE_Y; y++)
{
final MapSystem.Cell cell = sMap.get(x, y);

if ((cell.type.equals(TerrainType.GRASS) && r.nextGaussian() > 3f) ||
(cell.type.equals(TerrainType.LAND) && r.nextGaussian() > 3.5f))
{
if (!map.items.isEmpty(x, y))
continue;

sItems.makeItem("trunk", x, y);
sItems.makeItem("branch", x, y);
sItems.makeItem("vine", x, y);
}
}
}

log.info("initialised");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.artemis.EntityEdit;
import com.artemis.systems.IteratingSystem;
import com.github.fabioticconi.alone.components.*;
import com.github.fabioticconi.alone.components.attributes.Skin;
import rlforj.math.Point;

import java.awt.*;
Expand All @@ -36,6 +37,8 @@ public class DeadSystem extends IteratingSystem
ComponentMapper<Position> mPos;
ComponentMapper<Size> mSize;
ComponentMapper<Name> mName;
ComponentMapper<Sprite> mSprite;
ComponentMapper<Skin> mSkin;

MapSystem map;

Expand All @@ -51,6 +54,10 @@ protected void process(final int entityId)
final Size size = mSize.get(entityId);
final Name name = mName.get(entityId);

final Skin oldSkin = mSkin.get(entityId);
final Sprite oldSprite = mSprite.get(entityId);
final char c = size.value > 0 ? Character.toUpperCase(oldSprite.c) : oldSprite.c;

// remove dead creature from the world
map.obstacles.del(p.x, p.y);
world.delete(entityId);
Expand All @@ -62,9 +69,10 @@ protected void process(final int entityId)
final EntityEdit edit = world.edit(corpseId);

edit.create(Position.class).set(p2.x, p2.y);
edit.create(Sprite.class).set('$', Color.RED.darker().darker(), false);
edit.create(Sprite.class).set(c, Color.RED.darker().darker(), false);
edit.create(Corpse.class);
edit.create(Health.class).set(size.value + 3);
edit.create(Skin.class).value = oldSkin.value;
edit.add(new Name(name.name + "'s corpse", "corpse"));

map.items.set(corpseId, p2.x, p2.y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ public void doAction()

final Health health = mHealth.get(targetId);

if (health == null)
return;

// remove 25% hunger (or less) and decrease food health accordingly

final float food = Math.min(h.maxValue * 0.25f, h.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ public int makeItem(final String tag)
edit.add(template.cuttable);
if (template.ammo != null)
edit.add(template.ammo);
if (template.armour != null)
edit.add(template.armour);

return id;
}
Expand Down Expand Up @@ -332,6 +334,7 @@ public static class ItemTemplate
public Crushable crushable;
public Cuttable cuttable;
public Ammo ammo;
public Armour armour;
}

public class GetAction extends ActionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.github.fabioticconi.alone.systems;

import com.artemis.ComponentMapper;
import com.artemis.annotations.Wire;
import com.github.fabioticconi.alone.components.Cuttable;
import com.github.fabioticconi.alone.components.Position;
import com.github.fabioticconi.alone.components.Speed;
Expand All @@ -32,6 +33,7 @@
import org.slf4j.LoggerFactory;

import java.util.EnumSet;
import java.util.Random;

/**
* Author: Fabio Ticconi
Expand All @@ -51,6 +53,9 @@ public class TreeSystem extends PassiveSystem
MessageSystem msg;
MapSystem map;

@Wire
Random r;

public CutAction cut(final int entityId, final int treeId)
{
final CutAction c = new CutAction();
Expand Down Expand Up @@ -111,8 +116,12 @@ public void doAction()
world.delete(treeId);

sItem.makeItem("trunk", p.x, p.y);
sItem.makeItem("branch", p.x, p.y);
sItem.makeItem("vine", p.x, p.y);

if (r.nextBoolean())
sItem.makeItem("branch", p.x, p.y);

if (r.nextBoolean())
sItem.makeItem("vine", p.x, p.y);

// consume a fixed amount of stamina
sStamina.consume(actorId, cost);
Expand Down

0 comments on commit 64b80ff

Please sign in to comment.