summaryrefslogtreecommitdiff
path: root/lib/mods/theme/scpt/misc.lua
blob: a41f928871ac6dcc0988a7b68e7132e2520473f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
-- Neil's automagic statgain script

player.last_rewarded_level = 1
add_loadsave("player.last_rewarded_level", 1)

add_hooks
	{
	[HOOK_PLAYER_LEVEL] = function()
		while player.last_rewarded_level * 5 <= player.lev do
			do_inc_stat(A_STR)
			do_inc_stat(A_INT)
			do_inc_stat(A_WIS)
			do_inc_stat(A_DEX)
			do_inc_stat(A_CON)
			do_inc_stat(A_CHR)
			player.last_rewarded_level = player.last_rewarded_level + 1
			end
		end,
	}

add_hooks
{
   [HOOK_BIRTH_OBJECTS] = function()
      if player.last_rewarded_level >= 1
         then player.last_rewarded_level = 1
      else
      end
   end
}

-- silly function that allows a drunk to take a bottle of wine/ale from the player

function drunk_takes_wine(m_idx, item)

	m_ptr = monster(m_idx)
	o_ptr = get_object(item)

	if (m_ptr.r_idx == test_monster_name("Singing, happy drunk")) 
			and (o_ptr.tval == TV_FOOD) and ((o_ptr.sval == 38) or (o_ptr.sval == 39)) then

		cmsg_print(TERM_YELLOW, "'Hic!'")

		inven_item_increase(item, -1)
		inven_item_optimize(item)

-- HackSmurf: the drunk may drop an empty bottle
		bottle = create_object(TV_BOTTLE,1)
		drop_near(bottle, 50, player.py, player.px)
		return TRUE
	else
		return FALSE
	end
end

add_hook_script(HOOK_GIVE, "drunk_takes_wine", "drunk_takes_wine")

-- A not-too-scummy way of generating junk for ammo
function food_vessel(object)
   if ((object.tval == 80) and (object.sval == 43)) or
	((object.tval == 80) and (object.sval == 44)) then
      local obj = create_object(TV_JUNK, 3)
	obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN)
	inven_carry(obj, FALSE)
	end_object(obj)
	return FALSE
   end
end

add_hook_script(HOOK_EAT, "food_vessel", "food_vessel")

-- Longbottom Leaf *is* a great stress reliever:
function longbottom_leaf(object)
	if (object.tval == 80) and (object.sval == 45) then
		msg_print("What a stress reliever!")
		heal_insanity(1000)
		return FALSE
	end
end
add_hook_script(HOOK_EAT, "longbottom_leaf", "longbottom_leaf")

-- Hobbits like food
function hobbit_food(m_idx, item)

	m_ptr = monster(m_idx)
	o_ptr = get_object(item)

	if (m_ptr.r_idx == test_monster_name("Scruffy-looking hobbit")) 
	and (o_ptr.tval == TV_FOOD) then
		cmsg_print(TERM_YELLOW, "'Yum!'")
		inven_item_increase(item, -1)
		inven_item_optimize(item)
		return TRUE
	else
		return FALSE
	end
end

add_hook_script(HOOK_GIVE, "hobbit_food", "hobbit_food")

-- Smeagol likes rings
function smeagol_ring(m_idx, item)

   m_ptr = monster(m_idx)
   o_ptr = get_object(item)

   if (m_ptr.r_idx == test_monster_name("Smeagol"))
         and (o_ptr.tval == TV_RING) then

      cmsg_print(TERM_YELLOW, "'MY... PRECIOUSSSSS!!!'")

      inven_item_increase(item, -1)
      inven_item_optimize(item)
      return TRUE
   else
      return FALSE
   end
end

add_hook_script(HOOK_GIVE, "smeagol_ring", "smeagol_ring") 

-- functions to check for Map and Key of Thror before proceeding in Erebor
-- Thank you, Massimiliano Marangio :-)
add_hooks
{
   [HOOK_STAIR] = function(direction)
      if ((current_dungeon_idx == 20) and (dun_level == 60) and (direction == "down")) then
            local i
            local mapkey = 0
            for i = 0, INVEN_TOTAL - 1 do
               if ((player.inventory(i).name1 == 209) or (player.inventory(i).name1 == 210)) then
                  mapkey = mapkey + 1
               end
            end

            if (mapkey == 2) then
                msg_print("The moon-letters on the map show you the keyhole! You use the key to enter.")
                return FALSE
            else
                msg_print("You have found a door, but you cannot find a way to enter. Ask in Dale, perhaps?")
                return TRUE
            end
      end
      return FALSE
   end,
}

-- function to make the Dale mayor tell you about how to get to Erebor 61
add_building_action
{
	["index"] =     66,
	["action"] =    function()
		msg_print("You will need Thorin's Key and Thrain's Map to get anywhere in Erebor. One may be found in the Barrow-Downs. The other, in Mirkwood.")
	end
}

-- function to check for Key of Orthanc before proceeding to the final level in Isengard
add_hooks
{
   [HOOK_STAIR] = function(direction)
      if ((current_dungeon_idx == 36) and (dun_level == 39) and (direction == "down")) then
            local i
            local orthkey = 0
            for i = 0, INVEN_TOTAL - 1 do
               if (player.inventory(i).name1 == 15) then
                  orthkey = orthkey + 1
               end
            end

            if (orthkey == 1) then
                msg_print("#BYou have the key to the tower of Orthanc! You may proceed.#w")
                return FALSE
            else
                msg_print("#yYou may not enter Orthanc without the key to the gates!#w Rumours say the key was lost in the Mines of Moria...")
                return TRUE
            end
      end
      return FALSE
   end,
}