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