Mercurial > molko
comparison libmlk-adventure/adventure/item/potion.c @ 286:3991779aaba9
adventure: initial test of spawn
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 23 Dec 2020 15:37:48 +0100 |
parents | |
children | 9948e288925b |
comparison
equal
deleted
inserted
replaced
285:c43e39745cd8 | 286:3991779aaba9 |
---|---|
1 /* | |
2 * potion.h -- give some heal points | |
3 * | |
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #include <math.h> | |
20 | |
21 #include <core/sound.h> | |
22 | |
23 #include <rpg/character.h> | |
24 #include <rpg/item.h> | |
25 | |
26 #include <adventure/adventure_p.h> | |
27 #include <adventure/assets.h> | |
28 | |
29 #include "potion.h" | |
30 | |
31 static void | |
32 exec(const struct item *i, struct character *ch) | |
33 { | |
34 sound_play(&assets_sounds[ASSETS_SOUND_ITEM_POTION], -1, 0); | |
35 ch->hp = fmin(ch->hp + 50, ch->hpmax); | |
36 } | |
37 | |
38 const struct item item_potion = { | |
39 .name = N_("Potion"), | |
40 .description = N_("Recover 50 HP."), | |
41 .exec = exec | |
42 }; |