blob: 7f4f89bd728b94f5552b540997adc70423fd5c3d [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// npc/chat.c -- Labernde NPCs
4//
5// $Id: chat.c 6801 2008-03-21 23:34:46Z Zesstra $
6#pragma strong_types
7#pragma save_types
8#pragma range_check
9#pragma no_clone
10#pragma pedantic
11
12#include <properties.h>
13#define NEED_PROTOTYPES
14#include <living/combat.h>
15#include <thing/properties.h>
16#undef NEED_PROTOTYPES
17
18#define ME this_object()
19
20/*
21 * Some simple chat variables
22 */
23
24/*
25 * heart_beat is called so the monster may chat.
26 */
27void SetChats(int chance, mixed strs) {
28 if (!pointerp(strs))
29 return;
30 SetProp(P_CHAT_CHANCE,chance);
31 SetProp(P_CHATS,strs);
32}
33
34void SetAttackChats(int chance, mixed strs) {
35 if (!pointerp(strs))
36 return;
37 SetProp(P_ACHAT_CHANCE,chance);
38 SetProp(P_ACHATS,strs);
39}
40
41void DoAttackChat() {
42 string* c;
43 if (!ME || !environment(ME))
44 return;
45 if (QueryProp(P_DISABLE_ATTACK)>0)return ;
46 if (random(100) < QueryProp(P_ACHAT_CHANCE))
47 if ((c = QueryProp(P_ACHATS)) && sizeof(c))
48 tell_room(environment(ME),
49 process_string(c[random(sizeof(c))]));
50}
51
52void DoChat() {
53 string *c;
54 if (!ME || !environment(ME))
55 return;
56 if (random(100) < QueryProp(P_CHAT_CHANCE))
57 if ((c = QueryProp(P_CHATS)) && sizeof(c))
58 tell_room(environment(ME),
59 process_string(c[random(sizeof(c))]));
60}
61
62protected void heart_beat()
63{
64 if( InFight() ) DoAttackChat();
65 else DoChat();
66}