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