MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | // MorgenGrauen MUDlib |
| 2 | // |
| 3 | // player/guide.c -- newbie guide handling |
| 4 | // |
| 5 | // $Id: guide.c 7391 2010-01-25 22:52:51Z Zesstra $ |
| 6 | |
| 7 | #pragma strict_types |
| 8 | #pragma save_types |
| 9 | #pragma range_check |
| 10 | #pragma no_clone |
| 11 | #pragma pedantic |
| 12 | |
| 13 | #include <config.h> |
Bugfix | 1ed2507 | 2019-10-01 11:01:55 +0200 | [diff] [blame] | 14 | #include <wizlevels.h> |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 15 | #define NEED_PROTOTYPES |
| 16 | #include <player/user_filter.h> // fuer is_active_guide() |
| 17 | #include <properties.h> |
| 18 | #include <defines.h> |
| 19 | #include <thing/properties.h> |
| 20 | |
| 21 | /* Funktion, die die Guide-Kommandos aktiviert */ |
| 22 | void add_guide_commands() |
| 23 | { |
| 24 | add_action("CiceroneCmd","cicerone"); |
| 25 | // Sollte eigentlich an derselben Stelle moeglich sein. |
| 26 | } |
| 27 | |
| 28 | /* Gibt die Meldung beim Aendern aus*/ |
| 29 | protected int NewbieChangeMsg() { |
| 30 | int cic=QueryProp(P_NEWBIE_GUIDE); |
| 31 | // begrenzen auf 1 Tag, falls jemand da Schrott reingschrieben hat. |
| 32 | if (cic > 86400) { |
| 33 | cic=86400; |
| 34 | SetProp(P_NEWBIE_GUIDE,cic); |
| 35 | } |
| 36 | if (cic<=0) { |
| 37 | write("Du bist jetzt kein Cicerone mehr.\n"); |
| 38 | } |
| 39 | else if (cic < 60) { |
| 40 | write("Du bist jetzt ein Cicerone.\n"); |
| 41 | } |
| 42 | else { |
| 43 | write(break_string( |
| 44 | "Du bist jetzt ein Cicerone, allerdings nur in den Zeiten, " |
| 45 | "in denen Du weniger als " + cic/60 |
| 46 | + ((cic/60)<2 ? " Minute ":" Minuten ") |
| 47 | + "idle bist.\n",78)); |
| 48 | } |
| 49 | return 1; |
| 50 | } |
| 51 | |
| 52 | /* Gibt die Statusmeldung aus */ |
| 53 | protected int NewbieStatusMsg() { |
| 54 | int cic=QueryProp(P_NEWBIE_GUIDE); |
| 55 | // begrenzen auf 1 Tag, falls jemand da Schrott reingschrieben hat. |
| 56 | if (cic > 86400) { |
| 57 | cic=86400; |
| 58 | SetProp(P_NEWBIE_GUIDE,cic); |
| 59 | } |
| 60 | |
| 61 | if (cic <= 0) |
| 62 | write ("Du bist kein Cicerone.\n"); |
| 63 | else if (cic < 60) |
| 64 | write ("Du stehst Neuspielern als Cicerone zur Verfuegung.\n"); |
| 65 | else { |
| 66 | write(break_string( |
| 67 | "Du stehst Neuspielern als Cicerone zur Verfuegung, allerdings " |
| 68 | "nur in den Zeiten, in denen Du weniger als " + cic/60 |
| 69 | + ((cic/60)<2 ? " Minute ":" Minuten ") |
| 70 | + "idle bist.\n",78)); |
| 71 | } |
| 72 | return 1; |
| 73 | } |
| 74 | |
| 75 | /* Fuehrt das eigentliche Kommando aus*/ |
| 76 | |
| 77 | int CiceroneCmd(string str) |
| 78 | { |
Bugfix | 1ed2507 | 2019-10-01 11:01:55 +0200 | [diff] [blame] | 79 | if (QueryProp(P_LEVEL)<20 && !IS_LEARNER(ME)) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 80 | { |
| 81 | write(break_string("Du solltest erst noch ein wenig " |
| 82 | "Erfahrung sammeln, bevor Du Dich " |
| 83 | "als Cicerone zur Verfuegung stellst.",78)); |
| 84 | return 1; |
| 85 | } |
| 86 | // Idlezeit uebergeben? |
| 87 | int idle=to_int(str); |
| 88 | // max. einen Tag (1440 min) zulassen. |
| 89 | if (idle < 0) idle=0; |
| 90 | else if (idle > 1440) idle=1440; |
| 91 | |
| 92 | if (!str) { |
| 93 | return NewbieStatusMsg(); |
| 94 | } |
| 95 | else if (str=="status") { |
| 96 | return NewbieStatusMsg(); |
| 97 | } |
| 98 | // "ein" schaltet einfach generell ein, hierbei steht 1 in der Prop |
| 99 | // fuer "permanent ein". |
| 100 | else if (str=="ein") { |
| 101 | SetProp(P_NEWBIE_GUIDE,1); |
| 102 | return NewbieChangeMsg(); |
| 103 | } |
| 104 | // "aus" oder "0" deaktiviert. |
| 105 | else if (str=="aus") { |
| 106 | SetProp(P_NEWBIE_GUIDE,0); |
| 107 | return NewbieChangeMsg(); |
| 108 | } |
| 109 | // wenn Zahl uebergeben ist, die groesser 0 und kleiner 1440 ist |
| 110 | // (s.o.), wird es als Anzahl an Idle-Minuten aufgefasst, ab der man |
| 111 | // ausgeblendet werden will. |
| 112 | else if (idle) { |
| 113 | SetProp(P_NEWBIE_GUIDE, idle*60); // als Sekunden speichern. |
| 114 | return NewbieChangeMsg(); |
| 115 | } |
| 116 | write(break_string( |
| 117 | "cicerone ein - Du bist Cicerone\n" |
| 118 | "cicerone aus - Du bist kein Cicerone\n" |
| 119 | "cicerone - Status anzeigen\n" |
| 120 | +break_string( |
| 121 | "Du bist Cicerone, aber wenn Du laenger als <zahl> Minuten " |
| 122 | "idle bist, wirst Du automatisch ausgeblendet, bis Du wieder " |
| 123 | "endidelt bist.", |
| 124 | 76,"cicerone zahl - ",BS_INDENT_ONCE), |
| 125 | 78,"Syntaxhilfe:",BS_PREPEND_INDENT|BS_LEAVE_MY_LFS)); |
| 126 | |
| 127 | return 1; |
| 128 | } |
| 129 | |
| 130 | protected string IstSindMsg(string* namen) |
| 131 | { |
| 132 | if (sizeof(namen)==1) |
| 133 | return "ist davon "+namen[0]; |
| 134 | else |
| 135 | return "sind davon "+CountUp(namen); |
| 136 | } |
| 137 | |
| 138 | void NewbieIntroMsg() |
| 139 | { |
| 140 | object* cicerones; |
| 141 | string* namen; |
| 142 | string restext; |
| 143 | |
| 144 | // Nur bis Level 5 wird etwas ausgegeben. |
| 145 | if (QueryProp(P_LEVEL)>5) return; |
| 146 | |
| 147 | // is_active_guide() ist in /std/user_filter.c, welches vom |
| 148 | // Spielerobjekt geerbt wird und damit zur Verfuegung steht. |
| 149 | cicerones=filter(users(),#'is_active_guide); |
| 150 | // uid verwenden, da sonst kleine Spieler einen getarnten |
| 151 | // "Riesen" oder aehnliches anstprechen. |
| 152 | namen=map(cicerones,function string (object o) |
| 153 | { return(capitalize(geteuid(o))); } ); |
| 154 | |
| 155 | if (namen && sizeof(namen)>0) |
| 156 | { |
| 157 | restext="\nEs gibt einige nette Spieler, die bereit sind, Dich " |
| 158 | "auf Deinen ersten Schritten im "MUDNAME |
| 159 | " zu begleiten. \n\nDerzeit " |
| 160 | +IstSindMsg(namen)+" eingeloggt. Du kannst " |
Arathorn | 521b84d | 2016-10-06 19:22:06 +0200 | [diff] [blame] | 161 | "einen oder eine von ihnen ansprechen, " |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 162 | "indem Du z.B. einfach \n" |
| 163 | " 'teile "+ |
| 164 | lower_case(namen[random(sizeof(namen))])+ |
| 165 | " mit Hallo ich bin neu hier, kannst Du " |
| 166 | "mir bitte helfen?'\n" |
| 167 | "eintippst. Nur keine Scheu, diese Spieler " |
| 168 | "haben sich freiwillig dazu bereiterklaert!\n" |
| 169 | "\nDu kannst Dir diese Spieler jederzeit " |
| 170 | "mit 'kwer cicerones' anzeigen lassen.\n\n"; |
| 171 | write(break_string(restext,78,"* ",BS_LEAVE_MY_LFS)); |
| 172 | } |
| 173 | else |
| 174 | { |
| 175 | // Weia, kein Newbie-Guide da. Lieber erstmal nix tun, |
| 176 | // bis uns was besseres einfaellt. |
| 177 | } |
| 178 | return; |
| 179 | } |
| 180 | |
| 181 | |
| 182 | |
| 183 | |