From a444431a26bd6c3ff1bf31064e2360c1575ae55b Mon Sep 17 00:00:00 2001
From: Steve Melenchuk <smelenchuk@gmail.com>
Date: Fri, 29 Nov 2013 20:25:27 -0700
Subject: [PATCH] The +7,+7 lajatang of the Crescent Moon {silver}.

This takes cues from a few places, such as:
- A Tavern thread: https://crawl.develz.org/tavern/viewtopic.php?f=8&t=8222
- wheals' Axe of Law: https://crawl.develz.org/mantis/view.php?id=7767

I've distilled these down into their purest essence and aimed to avoid
duplication of code.
---
 crawl-ref/source/art-data.txt                      |  10 ++++++++++
 crawl-ref/source/art-func.h                        |  22 +++++++++++++++++++++
 crawl-ref/source/dat/descript/unrand.txt           |   5 +++++
 crawl-ref/source/rltiles/dc-player.txt             |   1 +
 .../item/weapon/artefact/urand_crescent_moon.png   | Bin 0 -> 1188 bytes
 .../player/hand1/artefact/crescent_moon.png        | Bin 0 -> 823 bytes
 crawl-ref/source/throw.cc                          |   6 +++---
 crawl-ref/source/throw.h                           |   3 +++
 8 files changed, 44 insertions(+), 3 deletions(-)
 create mode 100644 crawl-ref/source/rltiles/item/weapon/artefact/urand_crescent_moon.png
 create mode 100644 crawl-ref/source/rltiles/player/hand1/artefact/crescent_moon.png

diff --git a/crawl-ref/source/art-data.txt b/crawl-ref/source/art-data.txt
index 55b5f69..126b9fa 100644
--- a/crawl-ref/source/art-data.txt
+++ b/crawl-ref/source/art-data.txt
@@ -1119,6 +1119,16 @@ PLUS:    +2
 BRAND:   SPARM_ARCHMAGI
 STEALTH: -20
 
+ENUM:    CRESCENT_MOON
+NAME:    lajatang of the Crescent Moon
+INSCRIP: silver
+COLOUR:  ETC_SILVER
+TILE:    urand_crescent_moon
+TILE_EQ: crescent_moon
+OBJ:     OBJ_WEAPONS/WPN_LAJATANG
+PLUS:    7/7
+VALUE:   1000
+
 # This is the first of two amulets used to test suppression aura.
 # Together, they confer every randart effect except for a few that are
 # determined explicitly by checking whether a certain amulet is worn
diff --git a/crawl-ref/source/art-func.h b/crawl-ref/source/art-func.h
index 90a741f..9e5f678 100644
--- a/crawl-ref/source/art-func.h
+++ b/crawl-ref/source/art-func.h
@@ -36,6 +36,7 @@
 #include "spl-miscast.h"   // For Staff of Wucad Mu and Scythe of Curses miscasts
 #include "spl-summoning.h" // For Zonguldrok animating dead
 #include "terrain.h"       // For storm bow
+#include "throw.h"         // For Crescent Moon silver damage
 
 /*******************
  * Helper functions.
@@ -934,3 +935,24 @@ static void _ELEMENTAL_STAFF_melee_effects(item_def* item, actor* attacker,
          defender->name(DESC_THE).c_str());
     defender->hurt(attacker, d);
 }
+
+///////////////////////////////////////////////////
+
+static void _CRESCENT_MOON_melee_effects(item_def* item, actor* attacker,
+                                         actor* defender, bool mondied, int dam)
+{
+    if (!mondied)
+    {
+        int tempdam = dam;
+        bolt tempbeam;
+        string msg = "";
+        silver_damages_victim(tempbeam, defender, tempdam, msg);
+        if (tempdam > dam)
+        {
+            tempdam -= dam;
+            if (you.can_see(defender))
+                mpr(msg.c_str());
+            defender->hurt(attacker, tempdam);
+        }
+    }
+}
diff --git a/crawl-ref/source/dat/descript/unrand.txt b/crawl-ref/source/dat/descript/unrand.txt
index b730375..de509b6 100644
--- a/crawl-ref/source/dat/descript/unrand.txt
+++ b/crawl-ref/source/dat/descript/unrand.txt
@@ -507,6 +507,11 @@ effects from the residual hexes and magical energies it was once subjected to
 on a daily basis; spellcasters able to get a handle on its power, however, will
 find it enhances their spell power.
 %%%%
+lajatang of the Crescent Moon
+
+A silver-bladed lajatang, perhaps crafted by some devout priest of Zin. Its
+attacks are lethal to all those tainted by chaos.
+%%%%
 milk chocolate
 
 This item is a debugging aid, granting a vast array of mostly beneficial
diff --git a/crawl-ref/source/rltiles/dc-player.txt b/crawl-ref/source/rltiles/dc-player.txt
index a26a87c..e463c82 100644
--- a/crawl-ref/source/rltiles/dc-player.txt
+++ b/crawl-ref/source/rltiles/dc-player.txt
@@ -514,6 +514,7 @@ elemental_staff ELEMENTAL_STAFF
 asmodeus ASMODEUS
 dispater DISPATER
 olgreb OLGREB
+crescent_moon CRESCENT_MOON
 ## axes
 axe_trog AXE_TROG
 arga ARGA
diff --git a/crawl-ref/source/rltiles/item/weapon/artefact/urand_crescent_moon.png b/crawl-ref/source/rltiles/item/weapon/artefact/urand_crescent_moon.png
new file mode 100644
index 0000000000000000000000000000000000000000..7a0906b729b607437fd9bb538c2316e26a91344a
GIT binary patch
diff --git a/crawl-ref/source/rltiles/player/hand1/artefact/crescent_moon.png b/crawl-ref/source/rltiles/player/hand1/artefact/crescent_moon.png
new file mode 100644
index 0000000000000000000000000000000000000000..76b5cf753ac58449433a479ab182cf50a0cf2c22
GIT binary patch
diff --git a/crawl-ref/source/throw.cc b/crawl-ref/source/throw.cc
index 73ab8cd..9c99c22 100644
--- a/crawl-ref/source/throw.cc
+++ b/crawl-ref/source/throw.cc
@@ -612,8 +612,8 @@ static bool _item_penetrates_victim(const bolt &beam, int &used)
     return true;
 }
 
-static bool _silver_damages_victim(bolt &beam, actor* victim, int &dmg,
-                                   string &dmg_msg)
+bool silver_damages_victim(bolt &beam, actor* victim, int &dmg,
+                           string &dmg_msg)
 {
     int mutated = 0;
 
@@ -1201,7 +1201,7 @@ static bool _setup_missile_beam(const actor *agent, bolt &beam, item_def &item,
     ASSERT(beam.flavour == BEAM_MISSILE || !is_artefact(item));
 
     if (silver)
-        beam.damage_funcs.push_back(_silver_damages_victim);
+        beam.damage_funcs.push_back(silver_damages_victim);
     if (poisoned)
         beam.hit_funcs.push_back(_poison_hit_victim);
     if (penetrating)
diff --git a/crawl-ref/source/throw.h b/crawl-ref/source/throw.h
index 32453d4..c413657 100644
--- a/crawl-ref/source/throw.h
+++ b/crawl-ref/source/throw.h
@@ -34,6 +34,9 @@ int get_ammo_to_shoot(int item, dist &target, bool teleport = false);
 void fire_thing(int item = -1);
 void throw_item_no_quiver(void);
 
+bool silver_damages_victim(bolt &beam, actor* victim, int &dmg,
+                           string &dmg_msg);
+
 bool throw_it(bolt &pbolt, int throw_2, bool teleport = false,
               int acc_bonus = 0, dist *target = NULL);
 
-- 
1.8.5.rc1

