|
Atrinik Server 2.5
|
00001 /************************************************************************ 00002 * Atrinik, a Multiplayer Online Role Playing Game * 00003 * * 00004 * Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team * 00005 * * 00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game) * 00007 * and Crossfire (Multiplayer game for X-windows). * 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 * This program is distributed in the hope that it will be useful, * 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00017 * GNU General Public License for more details. * 00018 * * 00019 * You should have received a copy of the GNU General Public License * 00020 * along with this program; if not, write to the Free Software * 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00022 * * 00023 * The author can be reached at admin@atrinik.org * 00024 ************************************************************************/ 00025 00030 #include <global.h> 00031 00032 static godlink *init_godslist(); 00033 static void add_god_to_list(archetype *god_arch); 00034 00037 static godlink *init_godslist() 00038 { 00039 godlink *gl = (godlink *) malloc(sizeof(godlink)); 00040 00041 if (gl == NULL) 00042 { 00043 LOG(llevError, "init_godslist(): Out of memory.\n"); 00044 } 00045 00046 /* How to describe the god to the player */ 00047 gl->name = NULL; 00048 /* Pointer to the archetype of this god */ 00049 gl->arch = NULL; 00050 /* ID of the god */ 00051 gl->id = 0; 00052 /* Next god in this linked list */ 00053 gl->next = NULL; 00054 00055 return gl; 00056 } 00057 00061 void init_gods() 00062 { 00063 archetype *at = NULL; 00064 00065 LOG(llevDebug, "Initializing gods..."); 00066 00067 for (at = first_archetype; at != NULL; at = at->next) 00068 { 00069 if (at->clone.type == GOD) 00070 { 00071 add_god_to_list(at); 00072 } 00073 } 00074 00075 LOG(llevDebug, " done.\n"); 00076 } 00077 00081 static void add_god_to_list(archetype *god_arch) 00082 { 00083 godlink *god; 00084 00085 if (!god_arch) 00086 { 00087 LOG(llevBug, "Tried to add null god to list!\n"); 00088 return; 00089 } 00090 00091 god = init_godslist(); 00092 00093 god->arch = god_arch; 00094 FREE_AND_COPY_HASH(god->name, god_arch->clone.name); 00095 00096 if (!first_god) 00097 { 00098 god->id = 1; 00099 } 00100 else 00101 { 00102 god->id = first_god->id + 1; 00103 god->next = first_god; 00104 } 00105 00106 first_god = god; 00107 00108 #ifdef DEBUG_GODS 00109 LOG(llevDebug, "Adding god %s (%d) to list\n", god->name, god->id); 00110 #endif 00111 } 00112 00116 godlink *get_rand_god() 00117 { 00118 godlink *god = first_god; 00119 int i; 00120 00121 if (god) 00122 { 00123 for (i = RANDOM() % (god->id) + 1; god; god = god->next) 00124 { 00125 if (god->id == i) 00126 { 00127 break; 00128 } 00129 } 00130 } 00131 00132 if (!god) 00133 { 00134 LOG(llevBug, "get_rand_god(): Can't find a random god!\n"); 00135 } 00136 00137 return god; 00138 } 00139 00146 object *pntr_to_god_obj(godlink *godlnk) 00147 { 00148 object *god = NULL; 00149 00150 if (godlnk && godlnk->arch) 00151 god = &godlnk->arch->clone; 00152 00153 return god; 00154 } 00155 00157 void free_all_god() 00158 { 00159 godlink *god, *godnext; 00160 00161 LOG(llevDebug, "Freeing god information.\n"); 00162 00163 for (god = first_god; god; god = godnext) 00164 { 00165 godnext = god->next; 00166 FREE_AND_CLEAR_HASH(god->name); 00167 free(god); 00168 } 00169 } 00170 00173 void dump_gods() 00174 { 00175 godlink *glist; 00176 00177 LOG(llevInfo, "\n"); 00178 00179 for (glist = first_god; glist; glist = glist->next) 00180 { 00181 object *god = pntr_to_god_obj(glist); 00182 char tmpbuf[HUGE_BUF]; 00183 int tmpvar, gifts = 0; 00184 00185 tmpbuf[0] = '\0'; 00186 00187 LOG(llevInfo, "GOD: %s\n", god->name); 00188 LOG(llevInfo, " avatar stats:\n"); 00189 LOG(llevInfo, " S:%d C:%d D:%d I:%d W:%d P:%d\n", god->stats.Str, god->stats.Con, god->stats.Dex, god->stats.Int, god->stats.Wis, god->stats.Pow); 00190 LOG(llevInfo, " lvl:%d speed:%4.2f\n", god->level, god->speed); 00191 LOG(llevInfo, " wc:%d ac:%d hp:%d dam:%d \n", god->stats.wc, god->stats.ac, god->stats.hp, god->stats.dam); 00192 LOG(llevInfo, " enemy: %s\n", god->title ? god->title : "NONE"); 00193 00194 if (god->other_arch) 00195 { 00196 object *serv = &god->other_arch->clone; 00197 LOG(llevInfo, " servant stats: (%s)\n", god->other_arch->name); 00198 LOG(llevInfo, " S:%d C:%d D:%d I:%d W:%d P:%d\n", serv->stats.Str, serv->stats.Con, serv->stats.Dex, serv->stats.Int, serv->stats.Wis, serv->stats.Pow); 00199 LOG(llevInfo, " lvl:%d speed:%4.2f\n", serv->level, serv->speed); 00200 LOG(llevInfo, " wc:%d ac:%d hp:%d dam:%d \n", serv->stats.wc, serv->stats.ac, serv->stats.hp, serv->stats.dam); 00201 } 00202 else 00203 { 00204 LOG(llevInfo, " servant: NONE\n"); 00205 } 00206 00207 LOG(llevInfo, " aligned_race(s): %s\n", god->race); 00208 LOG(llevInfo, " enemy_race(s): %s\n", (god->slaying ? god->slaying : "none")); 00209 LOG(llevInfo, "%s", describe_protections(god, 1)); 00210 00211 strcat(tmpbuf, "\n aura:"); 00212 00213 strcat(tmpbuf, "\n paths:"); 00214 00215 if ((tmpvar = god->path_attuned)) 00216 { 00217 strcat(tmpbuf, "\n "); 00218 DESCRIBE_PATH(tmpbuf, tmpvar, "Attuned"); 00219 } 00220 00221 if ((tmpvar = god->path_repelled)) 00222 { 00223 strcat(tmpbuf, "\n "); 00224 DESCRIBE_PATH(tmpbuf, tmpvar, "Repelled"); 00225 } 00226 00227 if ((tmpvar = god->path_denied)) 00228 { 00229 strcat(tmpbuf, "\n "); 00230 DESCRIBE_PATH(tmpbuf, tmpvar, "Denied"); 00231 } 00232 00233 LOG(llevInfo, "%s\n", tmpbuf); 00234 LOG(llevInfo, " Desc: %s\n", god->msg ? god->msg : "---"); 00235 LOG(llevInfo, " Priest gifts/limitations: "); 00236 00237 if (!QUERY_FLAG(god, FLAG_USE_WEAPON)) 00238 { 00239 gifts = 1; 00240 LOG(llevInfo, "\n weapon use is forbidden"); 00241 } 00242 00243 if (!QUERY_FLAG(god, FLAG_USE_ARMOUR)) 00244 { 00245 gifts = 1; 00246 LOG(llevInfo, "\n no armour may be worn"); 00247 } 00248 00249 if (QUERY_FLAG(god, FLAG_UNDEAD)) 00250 { 00251 gifts = 1; 00252 LOG(llevInfo, "\n is undead"); 00253 } 00254 00255 if (QUERY_FLAG(god, FLAG_SEE_IN_DARK)) 00256 { 00257 gifts = 1; 00258 LOG(llevInfo, "\n has infravision "); 00259 } 00260 00261 if (QUERY_FLAG(god, FLAG_XRAYS)) 00262 { 00263 gifts = 1; 00264 LOG(llevInfo, "\n has X-ray vision"); 00265 } 00266 00267 if (QUERY_FLAG(god, FLAG_REFL_MISSILE)) 00268 { 00269 gifts = 1; 00270 LOG(llevInfo, "\n reflect missiles"); 00271 } 00272 00273 if (QUERY_FLAG(god, FLAG_REFL_SPELL)) 00274 { 00275 gifts = 1; 00276 LOG(llevInfo, "\n reflect spells"); 00277 } 00278 00279 if (QUERY_FLAG(god, FLAG_STEALTH)) 00280 { 00281 gifts = 1; 00282 LOG(llevInfo, "\n is stealthy"); 00283 } 00284 00285 if (QUERY_FLAG(god, FLAG_SEE_INVISIBLE)) 00286 { 00287 gifts = 1; 00288 LOG(llevInfo, "\n is (permanently) invisible"); 00289 } 00290 00291 if (QUERY_FLAG(god, FLAG_BLIND)) 00292 { 00293 gifts = 1; 00294 LOG(llevInfo, "\n is blind"); 00295 } 00296 00297 if (god->last_heal) 00298 { 00299 gifts = 1; 00300 LOG(llevInfo, "\n hp regenerate at %d",god->last_heal); 00301 } 00302 00303 if (god->last_sp) 00304 { 00305 gifts = 1; 00306 LOG(llevInfo, "\n sp regenerate at %d",god->last_sp); 00307 } 00308 00309 if (god->last_eat) 00310 { 00311 gifts = 1; 00312 LOG(llevInfo, "\n digestion is %s (%d)",god->last_eat<0?"slowed":"faster",god->last_eat); 00313 } 00314 00315 if (god->last_grace) 00316 { 00317 gifts = 1; 00318 LOG(llevInfo, "\n grace regenerates at %d",god->last_grace); 00319 } 00320 00321 if (!gifts) 00322 { 00323 LOG(llevInfo, "NONE"); 00324 } 00325 00326 LOG(llevInfo, "\n\n"); 00327 } 00328 }
1.7.4