Repository navigation
Expand file tree
/
Copy pathattack.c
More file actions
68 lines (51 loc) · 1.39 KB
/
Copy pathattack.c
File metadata and controls
68 lines (51 loc) · 1.39 KB
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
#include <stdlib.h>
#include "attack.h"
#include "display.h"
#include "player.h"
#include "monst.h"
#include "stats.h"
#include "util.h"
const char *user_attack_text[] = {
"asks you to fix its computer",
"asks you to fix its cupholder",
"asks you to fix its email",
"complains that its computer is slow",
"complains that the Internet is broken",
NULL
};
const char *manager_attack_text[] = {
"tells you to have that report done by Thursday",
"tells you to attend a meeting on productivity",
"tells you to attend a meeting on synergy",
"tells you to wear a tie in future",
NULL
};
void attack_player(struct monst *monster, struct player *player)
{
unsigned int attack_type;
/* This does not support monsters who don't attack */
do {
attack_type = monster->type->attacks[random() % 8];
} while(attack_type == ATTACK_NONE);
switch(attack_type) {
case ATTACK_USER:
msg_printf("The %s %s.",
monster_name(monster),
random_string(user_attack_text));
player_hurt(5);
break;
case ATTACK_MANAGER:
msg_printf("The %s %s.",
monster_name(monster),
random_string(manager_attack_text));
player_hurt(10);
break;
}
}
void attack_monster(struct player *player, struct monst *monster)
{
/* To hit roll */
if(test_stat(&player->stats, STAT_DEX, 0)) {
msg_printf("You hit the %s.", monster_name(monster));
} else msg_printf("You miss the %s.", monster_name(monster));
}