blob: e45637e82139646c8bdc4769787a792965c7d796 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// player/exploration.c -- exploration point management
4//
5// $Id: exploration.c 9142 2015-02-04 22:17:29Z Zesstra $
6#pragma strong_types
7#pragma save_types
8#pragma range_check
9#pragma no_clone
MG Mud User88f12472016-06-24 23:31:02 +020010
11#define NEED_PROTOTYPES
12#include <player/life.h>
13#include <player/base.h>
14#include <thing/properties.h>
15#undef NEED_PROTOTYPES
16
17#include <exploration.h>
18#include <scoremaster.h>
19#include <properties.h>
20#include <new_skills.h>
21
22private string given_scores;
23
MG Mud User88f12472016-06-24 23:31:02 +020024void create() {
25 Set(P_LEP, SECURED|SAVE, F_MODE_AS);
26
27 given_scores = "";
28}
29
30string Forschung()
31{
32 return EPMASTER->QueryForschung();
33}
34
35static string _query_given_scores()
36{
37 return given_scores;
38}
39
40// Hier kommen Funktionen fuer die Levelpunkte
41
42#define XP_FAC ([1:10,2:40,3:150,4:600,5:2250,6:9000,7:35000,8:140000,9:500000])
43
44//#define DEBUG(x,y) printf(x,y)
45#define DEBUG(x,y)
46
47int AddScore(int contributor)
48{
49 mixed info;
50 object po;
51 int drin;
52
53 if (!pointerp(info = SCOREMASTER->QueryNPCbyNumber(contributor)))
54 return -1;
55
56 if ((po = previous_object()) && (object_name(po) == SCOREMASTER))
57 po = previous_object(1);
58
59 if (!po || old_explode(object_name(po),"#")[0] != info[SCORE_KEY])
60 return -2;
61
62 if (!stringp(given_scores))
63 given_scores = " ";
64
65 if (catch(drin = test_bit(given_scores, contributor);publish))
66 return -3;
67
68 if (!drin) {
69 given_scores = set_bit(given_scores, contributor);
70 Set(P_LEP, Query(P_LEP) + info[SCORE_SCORE]);
71 force_save();
72 return info[SCORE_SCORE];
73 }
74 return 0;
75}
76
77int TestScore(int contributor)
78{
79 int ret;
80
81 if (!previous_object() || (object_name(previous_object()) != SCOREMASTER))
82 return 0;
83
84 catch(ret = test_bit(given_scores, contributor);publish);
85
86 return ret;
87}
88
89int SetScoreBit(int contributor)
90{
91 int drin;
92
93 if (!previous_object() || (object_name(previous_object()) != SCOREMASTER))
94 return -1;
95
96 if (catch(drin = test_bit(given_scores, contributor);publish))
97 return -2;
98
99 if (drin) return -3;
100
101 given_scores = set_bit(given_scores, contributor);
102 force_save();
103 return 1;
104}
105
106int ClearScoreBit(int contributor)
107{
108 int drin;
109
110 if (!previous_object() || (object_name(previous_object()) != SCOREMASTER))
111 return -1;
112
113 if (catch(drin = test_bit(given_scores, contributor);publish))
114 return -2;
115
116 if (!drin) return -3;
117
118 given_scores = clear_bit(given_scores, contributor);
119 force_save();
120 return 1;
121}
122