void do_redit(struct char_data *ch, char *arg, int cmd) { #ifndef TEST_SERVER struct room_data *rp; rp = real_roomp(ch->in_room); #endif if(IS_NPC(ch)) return; if ((IS_NPC(ch)) || (GetMaxLevel(ch)<LOW_IMMORTAL)) return; if (!ch->desc) /* someone is forced to do something. can be bad! */ return; /* the ch->desc->str field will cause problems... */ #ifndef TEST_SERVER if((GetMaxLevel(ch) < 56) && (rp->zone != GET_ZONE(ch))) { send_to_char("Sorry, you are not authorized to edit this zone.\n\r", ch); return; } #endif ch->specials.edit = MAIN_MENU; ch->desc->connected = CON_EDITING; act("$n has begun editing.", FALSE, ch, 0, 0, TO_ROOM); UpdateRoomMenu(ch); }
void do_dthink(struct char_data *ch, char *argument, int cmd) { char buf[MAX_INPUT_LENGTH], mudname[MAX_INPUT_LENGTH]; struct descriptor_data *d; int i; one_argument(argument, mudname); if ((i=matchmud(mudname))!=UNDEFINED) { argument = one_argument(argument, mudname); if ((i=getmud(ch, mudname, TRUE))==UNDEFINED) return; }; while(isspace(*argument)) argument++; if (!*argument) { msg("Sure you have something to think!", ch); return; }; if (!dimd_credit(ch, 1+1*(i==UNDEFINED))) return; if (i!=UNDEFINED) { if (IS_SET(muds[i].flags, DD_NOTHINK)) { msg("They are no longer listening to remote thinks.", ch); return; }; sprintf(buf, "^%s^%s^%d^*^%s\n\r", PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), argument); write_to_descriptor(muds[i].desc, buf); } else { sprintf(buf, "^%s^%s^%d^*g^%s\n\r", PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), argument); for(i=0; muds[i].address; i++) if (IS_SET(muds[i].flags, DD_VERIFIED) && !IS_SET(muds[i].flags, DD_NOTHINK)) write_to_descriptor(muds[i].desc, buf); #if USE_COLOR sprintf(buf, "$kW$n $kLdimension thinks, '%s'", argument); #else sprintf(buf, "$n dimension thinks, '%s'", argument); #endif for(d = descriptor_list; d; d = d->next) if (!d->connected && d->character != ch && GetMaxLevel(d->character) >= DEMIGOD) cact(buf, FALSE, ch, 0, d->character, TO_VICT, CLR_THINK); }; }
void do_medit(struct char_data *ch, char *argument, int cmd) { char name[20]; struct char_data *mob; int i; if(IS_NPC(ch)) return; if ((IS_NPC(ch)) || (GetMaxLevel(ch)<CREATOR)) return; if (!ch->desc) /* someone is forced to do something. can be bad! */ return; /* the ch->desc->str field will cause problems... */ for (i = 0; *(argument + i) == ' '; i++); if (!*(argument + i)) { send_to_char("Medit who?\n\r", ch); return; } argument = one_argument(argument, name); if (!(mob = (struct char_data *)get_char_room_vis(ch, name))) { send_to_char("I don't see that mobile here.\n\r",ch); return; } if(IS_PC(mob)) { send_to_char("You can not mobedit players.\n\r",ch); return; } if (GetMaxLevel(ch) < GOD && !IS_SET(ch->player.user_flags,CAN_MOB_EDIT)) { send_to_char("You do not have access to edit mobiles.\n\r",ch); return; } ch->specials.mobedit=mob; ch->specials.medit = MOB_MAIN_MENU; ch->desc->connected = CON_MOB_EDITING; act("$n has begun editing a mobile.", FALSE, ch, 0, 0, TO_ROOM); GET_POS(ch)=POSITION_SLEEPING; UpdateMobMenu(ch); }
void do_dtell(struct char_data *ch, char *argument, int cmd) { char name[MAX_INPUT_LENGTH], mudname[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH]; int i; /* for (i=0;i<MAX_MOBOBJ;i++) { sprintf(buf,"%s has pos %d",mob_index[i].name, mob_index[i].pos); slog(buf); }*/ argument = one_argument(argument, name); argument = one_argument(argument, mudname); if ((i=getmud(ch, mudname, TRUE))==UNDEFINED) return; while(isspace(*argument)) argument++; if (!*argument) { msg("Surely you have SOMETHING to say ... ?", ch); return; }; if (!dimd_credit(ch, 1)) return; sprintf(buf, "^%s^%s^%d^t^%s^%s\n\r", PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), name, argument); write_to_descriptor(muds[i].desc, buf); }
vector<int> TreeNameParser::GetLevelXParCount(int levelIndex) { int lc = GetMaxLevel(); assert(levelIndex<lc); // OK. now hand <10 levels return tmp_lpc[levelIndex]; }
void Game_Actor::SetLevel(int _level) { GetData().level = min(max(_level, 1), GetMaxLevel()); // Ensure current HP/SP remain clamped if new Max HP/SP is less. SetHp(GetHp()); SetSp(GetSp()); }
void Game_Actor::ChangeExp(int exp, bool level_up_message) { int new_level = GetLevel(); int new_exp = min(max(exp, 0), max_exp_value()); if (new_exp > GetExp()) { for (int i = GetLevel() + 1; i <= GetMaxLevel(); ++i) { if (GetNextExp(new_level) != -1 && GetNextExp(new_level) > new_exp) { break; } new_level++; } } else if (new_exp < GetExp()) { for (int i = GetLevel(); i > 1; --i) { if (new_exp >= GetNextExp(i - 1)) { break; } new_level--; } } SetExp(new_exp); if (new_level != GetLevel()) { ChangeLevel(new_level, level_up_message); } }
void BattleGroundAV::OnCreatureRespawn(Creature* creature) { uint32 level = creature->getLevel(); if (level != 0) level += GetMaxLevel() - 60; // maybe we can do this more generic for custom level - range.. actually it's ok creature->SetLevel(level); }
int Game_Actor::GetNextExp(int level) const { if (level >= GetMaxLevel() || level <= -1) { return -1; } else if (level == 0) { return 0; } else { return exp_list[level]; } }
//returns name of level the given level vector<string> TreeNameParser::GetLevelXParameters(int levelIndex) { int lc = GetMaxLevel();//returns highest level from data if(levelIndex>=lc) { vector<string> empty; return empty; } assert(levelIndex<lc); // OK. now hand <10 levels //make sure level index is no more than //the maximum level return tmp_lp[levelIndex]; }
void do_dwho(struct char_data *ch, char *argument, int cmd) { char buf[MAX_INPUT_LENGTH]; int i; argument = one_argument(argument, buf); if ((i=getmud(ch, buf, TRUE))==UNDEFINED) return; if (!dimd_credit(ch, 2)) return; while(isspace(*argument)) argument++; sprintf(buf, "^%s^%s^%d^w^%s\n\r", PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), argument); write_to_descriptor(muds[i].desc, buf); }
void log_action(struct char_data *ch, char *arg) { char prefix[5]; if (IS_MOB(ch)) return; if (GetMaxLevel(ch)>=IMMORTAL) strcpy(prefix,"IMM:"); else strcpy(prefix,"PLR:"); fprintf(player_log,"%s%s:%s\n",prefix,GET_NAME(ch),arg); if (IS_SET(ch->specials.act,PLR_LOG) && strlen(arg)>2) { if (GET_LEVEL(ch)>=IMMORTAL) vlog(LOG_IMMSPY,"%s:%s",GET_NAME(ch),arg); else vlog(LOG_MORTSPY,"%s:%s",GET_NAME(ch),arg); } fflush(player_log); }
void TreeNameParser::PrintByTH() { int lc = GetMaxLevel(); cerr << "Num of Tree Levels: " << lc << endl; vector<string>::iterator iter_th; // iterator on tree hierarchy for(int li=0; li<lc; li++) // level index { cerr << "--> level "<< li << endl; int jj=0; for(iter_th=tmp_lp[li].begin(); iter_th!=tmp_lp[li].end(); iter_th++) { cerr << tmp_lpc[li][jj] << *iter_th << endl ; jj++; }; // end for(iter_th) cerr << endl; }; // end for(li) }
void logl(int level,char *dl,char *str) { long ct; char *tmstr, buf[MAX_STRING_LENGTH]; struct connection_data *i; ct = time(0); tmstr = asctime(localtime(&ct)); *(tmstr + strlen(tmstr) - 1) = '\0'; fprintf(stderr, "%s :: %s\n", tmstr, str); if (str) sprintf(buf,"%c* %s *%c\n",dl[0],str,dl[1]); for (i = connection_list; i; i = i->next) if (IS_CONN(i) && GetMaxLevel(i->character)>=level && !IS_SET(i->character->specials.act,PLR_VEG) && !IS_SET(i->character->specials.act, PLR_NOVIEWLOG)) write_to_q(buf, &i->output,0); }
void TrapTeleport(struct char_data *v) { int to_room; extern int top_of_world; /* ref to the top element of world */ struct room_data *room; if(DEBUG) dlog("TrapTeleport"); if (saves_spell(v,SAVING_SPELL)) { send_to_char("You feel strange, but the effect fades.\n\r",v); return; } do { to_room = number(0, top_of_world); room = real_roomp(to_room); if(room) { if(IS_SET(room->room_flags,PRIVATE)) room = 0; } } while(!room); act("$n slowly fade out of existence.", FALSE, v,0,0,TO_ROOM); char_from_room(v); char_to_room(v, to_room); act("$n slowly fade in to existence.", FALSE, v,0,0,TO_ROOM); do_look(v, "", 0); if (IS_SET(real_roomp(to_room)->room_flags,DEATH) && GetMaxLevel(v) < LOW_IMMORTAL) { death_cry(v); zero_rent(v); extract_char(v); } }
int TriggerTrap( struct char_data *ch, struct obj_data *i) { int adj, fireperc, roll; struct char_data *v; extern struct dex_app_type dex_app[]; if(DEBUG) dlog("TriggerTrap"); if (ITEM_TYPE(i) == ITEM_TRAP) { if (i->obj_flags.value[TRAP_CHARGES]) { adj = GET_TRAP_LEV(i) - GetMaxLevel(ch); adj -= dex_app[GET_DEX(ch)].reaction * 5; fireperc = 95 + adj; roll = number(1,100); if (roll < fireperc) { /* trap is sprung */ act("You hear a strange noise...", TRUE, ch, 0, 0, TO_ROOM); act("You hear a strange noise...", TRUE, ch, 0, 0, TO_CHAR); GET_TRAP_CHARGES(i) -= 1; if (IS_SET(GET_TRAP_EFF(i),TRAP_EFF_ROOM)) { for (v = real_roomp(ch->in_room)->people;v;v = v->next_in_room) { FindTrapDamage(v,i); } } else { FindTrapDamage(ch,i); } return(TRUE); } } } return(FALSE); }
bool recep_offer(struct char_data *ch, struct char_data *receptionist, struct obj_cost *cost) { int i; char buf[MAX_INPUT_LENGTH]; int hoarder = 0; cost->total_cost = 0; /* Minimum cost */ cost->no_carried = 0; cost->ok = TRUE; /* Use if any "-1" objects */ hoarder = add_obj_cost(ch, receptionist, ch->carrying, cost, hoarder); for(i = 0; i<MAX_WEAR; i++) hoarder = add_obj_cost(ch, receptionist, ch->equipment[i], cost, hoarder); if (!cost->ok) return(FALSE); #if NEW_RENT cost->total_cost = 0; #endif if(hoarder) { cost->total_cost += (int) (ch->points.gold + ch->points.bankgold)/10; } if (cost->no_carried == 0) { if (receptionist) act("$n tells you 'But you are not carrying anything?'",FALSE,receptionist,0,ch,TO_VICT); return(FALSE); } if (cost->no_carried > MAX_OBJ_SAVE) { if (receptionist) { sprintf(buf,"$n tells you 'Sorry, but I can't store more than %d items.", MAX_OBJ_SAVE); act(buf,FALSE,receptionist,0,ch,TO_VICT); } return(FALSE); } if (HasClass(ch, CLASS_MONK)) { if (cost->no_carried > 20) { send_to_char("Your vows forbid you to carry more than 20 items\n\r", ch); return(FALSE); } } if (receptionist) { sprintf(buf, "$n tells you 'It will cost you %d coins per day'", cost->total_cost); act(buf,FALSE,receptionist,0,ch,TO_VICT); if (cost->total_cost > GET_GOLD(ch)) { if (GetMaxLevel(ch) < LOW_IMMORTAL) act("$n tells you 'Which I can see you can't afford'", FALSE,receptionist,0,ch,TO_VICT); else { act("$n tells you 'Well, since you're a God, I guess it's okay'", FALSE,receptionist,0,ch,TO_VICT); cost->total_cost = 0; } } } if ( cost->total_cost > GET_GOLD(ch) ) return(FALSE); else return(TRUE); }
/* * This is my general purpose error handler that spews a time-stamped * message to stderr and a logfile. * The messages are in this format: * <: DATE::(filename,func,line) User[#room]:\n : message\n * * If File, Func, or Line are NULL they will be ommitted. * If BufFile is NULL, stderr will be used alone. * If ch is NULL, User will be left blank. * If Str is NULL, we are just making a PING! * * NOTE! The calling interface is very ugly... it is designed to be very * versitle, not pretty... If you want it to be useful in your source code, * use a macro like this one: * #define log_error(BugFile, ch, Str...) \ * bug_logger(__FILE__, __FUNCTION__, __LINE__, BugFile, ch, Str, ## args) * which can then be used by simply saying: * log_error(BUGLOG, ch, "You died %d times!\n", deaths); * producing as an example: * <: 950219.195642.037 (ack.c;barf,135) Quixadhal [#3001]: * : You died 27 times! * The datestamp is YYMMDD.HHMMSS.MIL format. */ void bug_logger(const char *File, const char *Func, int Line, #ifdef DIKU_CRUD unsigned int Level, #endif unsigned int Type, const char *BugFile, #ifdef DIKU_CRUD struct char_data *ch, #endif const char *Str, ...) { va_list arg; char Result[MAX_STRING_LENGTH]; char Temp[MAX_STRING_LENGTH]; FILE *fp; struct timeb right_now; struct tm *now_part; bzero(Result, MAX_STRING_LENGTH); va_start(arg, Str); if (Str && *Str) { #ifdef DIKU_CRUD struct descriptor_data *i; strcpy(Result, "Notify> "); #endif vsprintf(Temp, Str, arg); #ifdef DIKU_CRUD strcat(Result, Temp); for (i = descriptor_list; i; i = i->next) if ((!i->connected) && (GetMaxLevel(i->character) >= Level) && (IS_SET(i->character->specials.act, PLR_LOGS))) write_to_q(Result, &i->output); bzero(Result, MAX_STRING_LENGTH); #endif } else strcpy(Temp, "PING!"); va_end(arg); ftime(&right_now); now_part = localtime((const time_t *)&right_now); sprintf(Result, "<: %02d%02d%02d.%02d%02d%02d.%03d", now_part->tm_year, now_part->tm_mon + 1, now_part->tm_mday, now_part->tm_hour, now_part->tm_min, now_part->tm_sec, right_now.millitm); if (File || Func || Line) { strcat(Result, " ("); if (File && *File) { strcat(Result, File); } if (Func && *Func) sprintf(Result + strlen(Result), ";%s", Func); if (Line) sprintf(Result + strlen(Result), ",%d)", Line); else strcat(Result, ")"); } #ifdef DIKU_CRUD if (ch && !IS_NPC(ch)) sprintf(Result + strlen(Result), " %s [#%d]\n", ch->player.name, ch->in_room ? ch->in_room : 0); else #endif if (File || Func || Line) strcat(Result, "\n"); strcat(Result, " : "); strcat(Result, Temp); if (BugFile && *BugFile) { if (!(fp = fopen(BugFile, "a"))) { perror(BugFile); #ifdef DIKU_CRUD if (ch) send_to_char("Could not open the file!\n\r", ch); #endif } else { fprintf(fp, "%s\n", Result); fclose(fp); } } fprintf(stderr, "%s\n", Result); }
TreeNameParser::TreeNameParser(char *filename)//Normal.txt { ifstream inf(filename, ios::in); // from the name, get the layer number QString fName(filename); fName.remove(".out"); int idx = fName.lastIndexOf("_"); fName = fName.mid(idx+1,fName.size()-idx); int layerNum=fName.toUInt(); //int bufsize = BUFSIZE * 3; char lineBuf[BUFSIZE3], *token, sToken[BUFSIZE3]; char delim[]="."; // delimited by space int iToken; for(int i=0; i<MAX_LEVEL; i++) resetParCount(i); while(inf) { inf.getline(lineBuf, BUFSIZE3); for(int j = 0; j < BUFSIZE3; ++j)sToken[j] = '\0'; // separate the index and string token sscanf(lineBuf, "%d %s", &iToken, sToken); // save the length int lev= getLevels(sToken), lc=0, wc=0; // lc: level counter ; wc: word counter _lev.push_back(lev); // now everything is 3 if(lev==1) break; // feature. TODO:..last line.. if(lev==2) { char temp[BUFSIZE3]; int i = 0; for(int j = 0; j < BUFSIZE3; ++j)temp[j] = '\0'; for(; sToken[i] != '.'; ++i) temp[i] = sToken[i]; temp[i] = sToken[i]; ++i; for(int j = 0; sToken[j] != '\0'; ++j, ++i) temp[i] = sToken[j]; strcpy(sToken, temp); lev++; } // split by "." _tmpToken.clear(); token = strtok(sToken, delim); if(lev==4) { // get rid of the first level } if(lev == layerNum) { _tmpToken.push_back(token); // keep what it is pushbackLp(lc++, token, _tmpToken); // save to _lp1 } while( (token = strtok(NULL, delim))!=NULL ) { _tmpToken.push_back(token); pushbackLp(lc++, token, _tmpToken); // save to _lp2, _lp3 and _lp4 }; _names.push_back(_tmpToken); // save the last one }; // end while(inf) int lcc= GetMaxLevel(); for(int i=0; i<lcc; i++) { tmp_lpc[i].push_back(parCount[i]); // save the last one } inf.close(); }
void do_dgossip(struct char_data *ch, char *argument, int cmd) { char buf[MAX_INPUT_LENGTH], mudname[MAX_INPUT_LENGTH]; struct descriptor_data *d; int i; if (IS_SET(ch->specials.act, PLR_NOSHOUT)) { msg("Ummm, no one can hear you through that gag!", ch); return; }; if (IS_SET(ch->specials.act, PLR_NOGOSSIP)) { msg("You are not tuned into the gossip channel!", ch); return; }; one_argument(argument, mudname); if ((i=matchmud(mudname))!=UNDEFINED) { argument = one_argument(argument, mudname); if ((i=getmud(ch, mudname, TRUE))==UNDEFINED) return; }; while(isspace(*argument)) argument++; if (!*argument) { msg("Surely you have something to gossip!", ch); return; }; if (!dimd_credit(ch, 2+3*(i==UNDEFINED))) return; if (i!=UNDEFINED) { if (IS_SET(muds[i].flags, DD_NOGOSSIP)) { msg("They are no longer listening to remote gossips.", ch); return; }; sprintf(buf, "^%s^%s^%d^g^%s\n\r", PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), argument); write_to_descriptor(muds[i].desc, buf); } else { sprintf(buf, "^%s^%s^%d^gg^%s\n\r", PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), argument); for(i=0; muds[i].address; i++) if (IS_SET(muds[i].flags, DD_VERIFIED) && !IS_SET(muds[i].flags, DD_NOGOSSIP)) write_to_descriptor(muds[i].desc, buf); #if USE_COLOR sprintf(buf, "$kW$n $kmdimension gossips, '%s'", argument); #else sprintf(buf, "$n dimension gossips, '%s'", argument); #endif for(d = descriptor_list; d; d = d->next) if (!d->connected && d->character != ch && !IS_SET(d->character->pc->comm, COMM_NOGOSSIP) && !check_soundproof(d->character)) cact(buf, FALSE, ch, 0, d->character, TO_VICT, CLR_GOSSIP); }; }
/* * Things we want to have when logging events..... * * BugFile is the filename you want to log to, NULL means stderr * * File, Func, Line can all be provided by the compiler as * __FILE__, __PRETTY_FUNCTION__, and __LINE__ * * Level is the minimum character level which will see the * bug if they're logged in. * * The AreaFile and AreaLine are the file and line number * we were reading while booting the world database. * * Type is the type of error, typically things like * LOG_INFO, LOG_ERROR, LOG_FATAL, LOG_BOOT, LOG_AUTH * * ch is the char_data pointer for the player/mob * obj is an obj_data pointer, if you have one * room is.... the room_data pointer. * * Str is, of course, the message, and it gets printed * using varargs, so you can have this be a printf type * set of macros. */ void bug_logger(unsigned int Type, const char *BugFile, const char *File, const char *Func, int Line, const char *AreaFile, int AreaLine, struct char_data *ch, struct char_data *victim, unsigned int Level, const char *Str, ...) { va_list arg; char Result[MAX_STRING_LENGTH] = "\0\0\0"; char Temp[MAX_STRING_LENGTH] = "\0\0\0"; FILE *fp = NULL; struct timeb right_now; struct tm *now_part = NULL; bzero(Result, MAX_STRING_LENGTH); va_start(arg, Str); if (Str && *Str) { struct descriptor_data *i; snprintf(Result, MAX_STRING_LENGTH, "%s> ", LogNames[Type]); vsnprintf(Temp, MAX_STRING_LENGTH, Str, arg); strlcat(Result, Temp, MAX_STRING_LENGTH); for (i = descriptor_list; i; i = i->next) if ((!i->connected) && (GetMaxLevel(i->character) >= Level) && (IS_SET(i->character->specials.new_act, NEW_PLR_LOGS))) write_to_q(Result, &i->output, 1); bzero(Result, MAX_STRING_LENGTH); } else strlcpy(Temp, "PING!", MAX_STRING_LENGTH); va_end(arg); ftime(&right_now); now_part = localtime((const time_t *)&right_now); snprintf(Result, MAX_STRING_LENGTH, "<: %04d%02d%02d.%02d%02d%02d.%03d", now_part->tm_year + 1900, now_part->tm_mon + 1, now_part->tm_mday, now_part->tm_hour, now_part->tm_min, now_part->tm_sec, right_now.millitm); scprintf(Result, MAX_STRING_LENGTH, " - %s -", LogNames[Type]); if (File || Func || Line) { strlcat(Result, " (", MAX_STRING_LENGTH); if (File && *File) { strlcat(Result, File, MAX_STRING_LENGTH); } if (Func && *Func) scprintf(Result, MAX_STRING_LENGTH, ";%s", Func); if (Line) scprintf(Result, MAX_STRING_LENGTH, ",%d)", Line); else strlcat(Result, ")", MAX_STRING_LENGTH); } if (ch || victim) { if (ch) scprintf(Result, MAX_STRING_LENGTH, " ch \"%s\" [#%d]", NAME(ch), ch->in_room); if (victim) scprintf(Result, MAX_STRING_LENGTH, " victim \"%s\" [#%d]", NAME(victim), victim->in_room); /* if (obj) scprintf(Result, MAX_STRING_LENGTH, " obj \"%s\" [#%d]", SAFE_ONAME(obj), obj->in_room); if (room) scprintf(Result, MAX_STRING_LENGTH, " room \"%s\" [#%d]", room->name?room->name:"", room->number); */ strlcat(Result, "\n", MAX_STRING_LENGTH); } else if (File || Func || Line) strlcat(Result, "\n", MAX_STRING_LENGTH); strlcat(Result, " : ", MAX_STRING_LENGTH); strlcat(Result, Temp, MAX_STRING_LENGTH); if (BugFile && *BugFile) { if (!(fp = fopen(BugFile, "a"))) { perror(BugFile); if (ch) cprintf(ch, "Could not open the file!\r\n"); } else { fprintf(fp, "%s\n", Result); FCLOSE(fp); } } if (stderr) { fprintf(stderr, "%s\n", Result); fflush(stderr); } // Here is where we would log to SQL too! bug_sql(LogNames[Type], File, Func, Line, NULL, 0, ch ? NAME(ch) : NULL, ch ? ch->in_room : 0, victim ? NAME(victim) : NULL, victim ? victim->in_room : 0, Temp); }
void do_dmuse(struct char_data *ch, char *argument, int cmd) { char buf[MAX_INPUT_LENGTH], mudname[MAX_INPUT_LENGTH]; struct descriptor_data *d; int i; if (IS_SET(ch->specials.act, PLR_NOSHOUT)) { msg("The gods are sick of listen to you! You've been gagged!", ch); return; }; if (HUMAN(ch) && IS_SET(ch->pc->comm, COMM_NOMUSE)) { msg("You are not tuned into the muse channel!", ch); return; }; one_argument(argument, mudname); if ((i=matchmud(mudname))!=UNDEFINED) { argument = one_argument(argument, mudname); if ((i=getmud(ch, mudname, TRUE))==UNDEFINED) return; }; while(isspace(*argument)) argument++; if (!*argument) { msg("Sure you have something to muse!", ch); return; }; if (!dimd_credit(ch, 1+2*(i==UNDEFINED))) return; if (i!=UNDEFINED) { if (IS_SET(muds[i].flags, DD_NOMUSE)) { msg("They are no longer listening to remote muses.", ch); return; }; sprintf(buf, "^%s^%s^%d^mg^%s\n\r", PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), argument); write_to_descriptor(muds[i].desc, buf); } else { sprintf(buf, "^%s^%s^%d^mg^%s\n\r", PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), argument); for(i=0; muds[i].address; i++) if (IS_SET(muds[i].flags, DD_VERIFIED) && !IS_SET(muds[i].flags, DD_NOMUSE)) write_to_descriptor(muds[i].desc, buf); #if USE_COLOR sprintf(buf, "$kW$n $kLdimension muses, '%s'", argument); #else sprintf(buf, "$n dimension muses, '%s'", argument); #endif for(d = descriptor_list; d; d = d->next) if (!d->connected && d->character != ch && GetMaxLevel(d->character) >= LOW_IMMORTAL && !IS_SET(d->character->pc->comm, COMM_NOMUSE)) cact(buf, FALSE, ch, 0, d->character, TO_VICT, CLR_MUSE); }; }
void BattleGround::Update(uint32 diff) { if (!GetPlayersSize()) { // BG is empty // if there are no players invited, delete BG // this will delete arena or bg object, where any player entered // [[ but if you use battleground object again (more battles possible to be played on 1 instance) // then this condition should be removed and code: // if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE)) // this->AddToFreeBGObjectsQueue(); // not yet implemented // should be used instead of current // ]] // BattleGround Template instance cannot be updated, because it would be deleted if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE)) delete this; return; } // remove offline players from bg after 5 minutes if (!m_OfflineQueue.empty()) { BattleGroundPlayerMap::iterator itr = m_Players.find(*(m_OfflineQueue.begin())); if (itr != m_Players.end()) { if (itr->second.OfflineRemoveTime <= sWorld.GetGameTime()) { RemovePlayerAtLeave(itr->first, true, true);// remove player from BG m_OfflineQueue.pop_front(); // remove from offline queue // do not use itr for anything, because it is erased in RemovePlayerAtLeave() } } } /*********************************************************/ /*** BATTLEGROUND BALLANCE SYSTEM ***/ /*********************************************************/ // if less then minimum players are in on one side, then start premature finish timer if (GetStatus() == STATUS_IN_PROGRESS && sBattleGroundMgr.GetPrematureFinishTime() && (GetPlayersCountByTeam(ALLIANCE) < GetMinPlayersPerTeam() || GetPlayersCountByTeam(HORDE) < GetMinPlayersPerTeam())) { if (!m_PrematureCountDown) { m_PrematureCountDown = true; m_PrematureCountDownTimer = sBattleGroundMgr.GetPrematureFinishTime(); } else if (m_PrematureCountDownTimer < diff) { // time's up! Team winner = TEAM_NONE; if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam()) winner = ALLIANCE; else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam()) winner = HORDE; EndBattleGround(winner); m_PrematureCountDown = false; } else if (!sBattleGroundMgr.isTesting()) { uint32 newtime = m_PrematureCountDownTimer - diff; // announce every minute if (newtime > (MINUTE * IN_MILLISECONDS)) { if (newtime / (MINUTE * IN_MILLISECONDS) != m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS)) PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING, CHAT_MSG_SYSTEM, NULL, (uint32)(m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS))); } else { // announce every 15 seconds if (newtime / (15 * IN_MILLISECONDS) != m_PrematureCountDownTimer / (15 * IN_MILLISECONDS)) PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS, CHAT_MSG_SYSTEM, NULL, (uint32)(m_PrematureCountDownTimer / IN_MILLISECONDS)); } m_PrematureCountDownTimer = newtime; } } else if (m_PrematureCountDown) m_PrematureCountDown = false; /*********************************************************/ /*** BATTLEGROUND STARTING SYSTEM ***/ /*********************************************************/ if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize()) { ModifyStartDelayTime(diff); if (!(m_Events & BG_STARTING_EVENT_1)) { m_Events |= BG_STARTING_EVENT_1; StartingEventCloseDoors(); SetStartDelayTime(m_StartDelayTimes[BG_STARTING_EVENT_FIRST]); // first start warning - 2 or 1 minute, only if defined if (m_StartMessageIds[BG_STARTING_EVENT_FIRST]) SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_FIRST], CHAT_MSG_BG_SYSTEM_NEUTRAL); } // After 1 minute or 30 seconds, warning is signalled else if (GetStartDelayTime() <= m_StartDelayTimes[BG_STARTING_EVENT_SECOND] && !(m_Events & BG_STARTING_EVENT_2)) { m_Events |= BG_STARTING_EVENT_2; SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_SECOND], CHAT_MSG_BG_SYSTEM_NEUTRAL); } // After 30 or 15 seconds, warning is signalled else if (GetStartDelayTime() <= m_StartDelayTimes[BG_STARTING_EVENT_THIRD] && !(m_Events & BG_STARTING_EVENT_3)) { m_Events |= BG_STARTING_EVENT_3; SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_THIRD], CHAT_MSG_BG_SYSTEM_NEUTRAL); } // delay expired (atfer 2 or 1 minute) else if (GetStartDelayTime() <= 0 && !(m_Events & BG_STARTING_EVENT_4)) { m_Events |= BG_STARTING_EVENT_4; StartingEventOpenDoors(); SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_FOURTH], CHAT_MSG_BG_SYSTEM_NEUTRAL); SetStatus(STATUS_IN_PROGRESS); SetStartDelayTime(m_StartDelayTimes[BG_STARTING_EVENT_FOURTH]); { PlaySoundToAll(SOUND_BG_START); // Announce BG starting if (sWorld.getConfig(CONFIG_BOOL_BATTLEGROUND_QUEUE_ANNOUNCER_START)) { sWorld.SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName(), GetMinLevel(), GetMaxLevel()); } } } } /*********************************************************/ /*** BATTLEGROUND ENDING SYSTEM ***/ /*********************************************************/ if (GetStatus() == STATUS_WAIT_LEAVE) { // remove all players from battleground after 2 minutes m_EndTime -= diff; if (m_EndTime <= 0) { m_EndTime = 0; BattleGroundPlayerMap::iterator itr, next; for (itr = m_Players.begin(); itr != m_Players.end(); itr = next) { next = itr; ++next; // itr is erased here! RemovePlayerAtLeave(itr->first, true, true);// remove player from BG // do not change any battleground's private variables } } } // update start time m_StartTime += diff; }
void dimd_loop(void) { int i, fromlevel, fromgodlevel; fd_set input_set, output_set, exc_set; static char buf[MAX_STRING_LENGTH], extra[MAX_STRING_LENGTH], fromname[MAX_INPUT_LENGTH], fromkeyname[MAX_INPUT_LENGTH], dcommand[MAX_INPUT_LENGTH], toname[MAX_INPUT_LENGTH], *scan; struct char_data *vict; char comm[MAX_INPUT_LENGTH]; struct timeval null_time; struct descriptor_data *d; switch (dimd_state) { /****************************************************************/ case DIMD_OPENING: if ((dimd_local_mud=getlocalmud())==UNDEFINED) { DIMDLOG("Couldn't figure out what this mud's name is! DIMD NOT opened."); dimd_state = DIMD_CLOSED; dimd_on = FALSE; return; }; dimd_port = DIMD_PORT; dimd_s=init_socket(dimd_port); DIMDLOG("DIMD port opened."); for(i=0; muds[i].address; i++) if (IS_SET(muds[i].flags, DD_AUTOTRY)) call_a_mud(i); dimd_state = DIMD_OPEN; break; /****************************************************************/ case DIMD_OPEN: null_time.tv_sec = 0; null_time.tv_usec = 0; FD_ZERO(&input_set); FD_ZERO(&output_set); FD_ZERO(&exc_set); FD_SET(dimd_s, &input_set); for(i=0; muds[i].address; i++) if (IS_SET(muds[i].flags, DD_CONNECTED)) { FD_SET(muds[i].desc, &input_set); FD_SET(muds[i].desc, &exc_set); FD_SET(muds[i].desc, &output_set); }; if (select(maxdesc + 1, &input_set, &output_set, &exc_set, &null_time) < 0) { perror("Tell select poll"); return; }; /* Respond to whatever might be happening */ /* New connection? */ if (FD_ISSET(dimd_s, &input_set)) if (!answer_a_mud()) perror("New connection"); for(i=0; muds[i].address; i++) if (IS_SET(muds[i].flags, DD_CONNECTED)) { if (FD_ISSET(muds[i].desc, &exc_set)) { FD_CLR(muds[i].desc, &input_set); FD_CLR(muds[i].desc, &output_set); hangup_on_a_mud(i); }; }; for(i=0; muds[i].address; i++) if (IS_SET(muds[i].flags, DD_CONNECTED)) { if (FD_ISSET(muds[i].desc, &input_set)) if (process_dimd_input(i) < 0) hangup_on_a_mud(i); }; for(i=0; muds[i].address; i++) if (IS_SET(muds[i].flags, DD_CONNECTED)) { while(get_from_q(&muds[i].input, comm)) { if (!IS_SET(muds[i].flags, DD_VERIFIED)) { if (str_cmp(comm, DIMD_PASSWORD)) { sprintf(buf, "The mud is located at port %d.\n\r", dimd_port-2); write_to_descriptor(muds[i].desc, buf); sprintf(buf, "%s[%s]'s server didn't know our password.", muds[i].formalname, muds[i].host); DIMDLOG(buf); hangup_on_a_mud(i); break; }; SET_BIT(muds[i].flags, DD_VERIFIED); break; }; if (*comm != '^') { if (!(vict=get_char(muds[i].pcname))) { sprintf(buf, "DIMD stream for unknown player %s rejected.", muds[i].pcname); DIMDLOG(buf); DIMDLOG(comm); } else msg(comm, vict); continue; }; scan = comm+1; scan = one_dimd_argument(scan, fromname); scan = one_dimd_argument(scan, fromkeyname); scan = one_dimd_argument(scan, buf); fromlevel = atoi(buf); if (!*fromname || !*fromkeyname || !fromlevel) { write_to_descriptor(muds[i].desc, "Your server isn't working properly."); sprintf(buf, "%s[%s] didn't supply PC names or level.", muds[i].formalname, muds[i].host); DIMDLOG(buf); hangup_on_a_mud(i); break; }; if (fromlevel < muds[i].min_level) sprintf(buf, "You must be at least %d level to use DIMD on %s.", muds[i].min_level, muds[i].formalname); else { fromgodlevel = (fromlevel-muds[i].immort_level) * muds[i].immort_level_mult; scan = one_lc_dimd_argument(scan, dcommand); switch(*dcommand) { case '#': strcpy(muds[i].pcname, fromkeyname); continue; case 'a': switch(*(dcommand+1)) { case 'g': sprintf(buf, "%s is now accepting remote gossips.", muds[i].formalname); REMOVE_BIT(muds[i].flags, DD_NOGOSSIP); break; case 'm': sprintf(buf, "%s is now accepting remote muses.", muds[i].formalname); REMOVE_BIT(muds[i].flags, DD_NOMUSE); break; case 't': sprintf(buf, "%s is now accepting remote thinks.", muds[i].formalname); REMOVE_BIT(muds[i].flags, DD_NOTHINK); break; default: sprintf(buf, "Unknown accept command from %s.", muds[i].formalname); }; DIMDLOG(buf); continue; case 'r': switch(*(dcommand+1)) { case 'g': sprintf(buf, "%s is now refusing remote gossips.", muds[i].formalname); SET_BIT(muds[i].flags, DD_NOGOSSIP); break; case 'm': sprintf(buf, "%s is now refusing remote muses.", muds[i].formalname); SET_BIT(muds[i].flags, DD_NOMUSE); break; case 't': sprintf(buf, "%s is now refusing remote thinks.", muds[i].formalname); SET_BIT(muds[i].flags, DD_NOTHINK); break; default: sprintf(buf, "Unknown refuse command from %s.", muds[i].formalname); }; DIMDLOG(buf); continue; case 'w': sprintf(buf, "Who request from %s at %s served.", fromname, muds[i].formalname); DIMDLOG(buf); /* construct_who_list(buf, 39, NULL, fromgodlevel, scan); */ break; case 't': scan = one_lc_dimd_argument(scan, toname); while(isspace(*scan)) scan++; if (!(vict = get_char(toname)) || !dimd_can_see(fromgodlevel, vict)) strcpy(buf, "No char by that name."); else { #if USE_COLOR sprintf(buf, "$kW%s $kMfrom $kW%s $kMtells you '%s'.", fromname, muds[i].formalname, scan); #else sprintf(buf, "%s from %s tells you '%s'.", fromname, muds[i].formalname, scan); #endif cmsg(buf, vict, CLR_TELL); if (IS_SET(vict->pc->comm, COMM_AFK)) #if USE_COLOR sprintf(buf, "$kMYou tell $kW%s$kM (who is AFK), '%s'", PER(vict), scan); #else sprintf(buf, "You tell %s (who is AFK), '%s'", PER(vict), scan); #endif else #if USE_COLOR sprintf(buf, "$kMYou tell $kW%s$kM, '%s'", PER(vict), scan); #else sprintf(buf, "You tell %s, '%s'", PER(vict), scan); #endif }; break; case 'g': if (!dimd_gossip) { write_to_descriptor(muds[i].desc, "^DIMD^DIMD^110^rg\n\r"); sprintf(buf, "%s is no longer accepting remote gossips.", muds[dimd_local_mud].formalname); break; }; if (*(dcommand+1)=='g') #if USE_COLOR sprintf(buf, "$kW%s $kYfrom $kW%s $kYdimension gossips, '%s'", fromname, muds[i].formalname, scan); #else sprintf(buf, "%s from %s dimension gossips, '%s'", fromname, muds[i].formalname, scan); #endif else #if USE_COLOR sprintf(buf, "$kW%s $kYfrom $kW%s $kYgossips, '%s'", fromname, muds[i].formalname, scan); #else sprintf(buf, "%s from %s gossips, '%s'", fromname, muds[i].formalname, scan); #endif for(d = descriptor_list; d; d = d->next) if (!d->connected && !IS_SET(d->character->pc->comm, COMM_NOGOSSIP) && !check_soundproof(d->character)) cmsg(buf, d->character, CLR_GOSSIP); #if USE_COLOR sprintf(buf, "$kYYou gossip on $kW%s$kY, '%s'", muds[dimd_local_mud].formalname, scan); #else sprintf(buf, "You gossip on %s, '%s'", muds[dimd_local_mud].formalname, scan); #endif break; case 'm': if (!dimd_muse) { write_to_descriptor(muds[i].desc, "^DIMD^DIMD^110^rm\n\r"); sprintf(buf, "%s is no longer accepting remote muses.", muds[dimd_local_mud].formalname); break; }; if (*(dcommand+1)=='g') #if USE_COLOR sprintf(buf, "$kW%s $kLfrom $kW%s $kLdimension muses, '%s'", fromname, muds[i].formalname, scan); #else sprintf(buf, "%s from %s dimension muses, '%s'", fromname, muds[i].formalname, scan); #endif else #if USE_COLOR sprintf(buf, "$kW%s $kLfrom $kW%s $kLmuses, '%s'", fromname, muds[i].formalname, scan); #else sprintf(buf, "%s from %s muses, '%s'", fromname, muds[i].formalname, scan); #endif for(d = descriptor_list; d; d = d->next) if (!d->connected && GetMaxLevel(d->character) >= LOW_IMMORTAL && !IS_SET(d->character->pc->comm, COMM_NOMUSE)) cmsg(buf, d->character, CLR_MUSE); #if USE_COLOR sprintf(buf, "$kLYou muse on $kW%s$kL, '%s'", muds[dimd_local_mud].formalname, scan); #else sprintf(buf, "You muse on %s, '%s'", muds[dimd_local_mud].formalname, scan); #endif break; case '*': if (!dimd_think) { write_to_descriptor(muds[i].desc, "^DIMD^DIMD^110^rt\n\r"); sprintf(buf, "%s is no longer accepting remote thinks.", muds[dimd_local_mud].formalname); break; }; if (*(dcommand+1)=='g') #if USE_COLOR sprintf(buf, "$kW%s $kLfrom $kW%s $kLdimension thinks, '%s'", fromname, muds[i].formalname, scan); #else sprintf(buf, "%s from %s dimension thinks, '%s'", fromname, muds[i].formalname, scan); #endif else #if USE_COLOR sprintf(buf, "$kW%s $kLfrom $kW%s $kLthinks, '%s'", fromname, muds[i].formalname, scan); #else sprintf(buf, "%s from %s thinks, '%s'", fromname, muds[i].formalname, scan); #endif for(d = descriptor_list; d; d = d->next) if (!d->connected && GetMaxLevel(d->character) >= DEMIGOD && !IS_SET(d->character->pc->comm, COMM_NOMUSE)) cmsg(buf, d->character, CLR_THINK); #if USE_COLOR sprintf(buf, "$kLYou think on $kW%s$kL, '%s'", muds[dimd_local_mud].formalname, scan); #else sprintf(buf, "You think on %s, '%s'", muds[dimd_local_mud].formalname, scan); #endif break; default: #if USE_COLOR sprintf(buf, "$kW%s $kRfrom $kW%s $kRissued invalid command '%s'.", fromname, muds[i].formalname, dcommand); #else sprintf(buf, "%s from %s issued invalid command '%s'.", fromname, muds[i].formalname, dcommand); #endif DIMDLOG(buf); #if USE_COLOR strcpy(buf, "$k+BRYour server isn't functioning properly."); #else strcpy(buf, "Your server isn't functioning properly."); #endif }; };
void Client::SendAlternateAdvancementRank(int aa_id, int level) { if(!zone) return; auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa_id, level); auto ability = ability_rank.first; auto rank = ability_rank.second; if(!ability) { return; } if(!(ability->classes & (1 << GetClass()))) { return; } if(!CanUseAlternateAdvancementRank(rank)) { return; } int size = sizeof(AARankInfo_Struct) + (sizeof(AARankEffect_Struct) * rank->effects.size()) + (sizeof(AARankPrereq_Struct) * rank->prereqs.size()); auto outapp = new EQApplicationPacket(OP_SendAATable, size); AARankInfo_Struct *aai = (AARankInfo_Struct*)outapp->pBuffer; aai->id = rank->id; aai->upper_hotkey_sid = rank->upper_hotkey_sid; aai->lower_hotkey_sid = rank->lower_hotkey_sid; aai->title_sid = rank->title_sid; aai->desc_sid = rank->desc_sid; aai->cost = rank->cost; aai->seq = aa_id; aai->type = ability->type; aai->spell = rank->spell; aai->spell_type = rank->spell_type; aai->spell_refresh = rank->recast_time; aai->classes = ability->classes; aai->level_req = rank->level_req; aai->current_level = level; aai->max_level = ability->GetMaxLevel(this); aai->prev_id = rank->prev_id; if((rank->next && !CanUseAlternateAdvancementRank(rank->next)) || ability->charges > 0) { aai->next_id = -1; } else { aai->next_id = rank->next_id; } aai->total_cost = rank->total_cost; aai->expansion = rank->expansion; aai->category = ability->category; aai->charges = ability->charges; aai->grant_only = ability->grant_only; aai->total_effects = rank->effects.size(); aai->total_prereqs = rank->prereqs.size(); outapp->SetWritePosition(sizeof(AARankInfo_Struct)); for(auto &effect : rank->effects) { outapp->WriteSInt32(effect.effect_id); outapp->WriteSInt32(effect.base1); outapp->WriteSInt32(effect.base2); outapp->WriteSInt32(effect.slot); } for(auto &prereq : rank->prereqs) { outapp->WriteSInt32(prereq.first); outapp->WriteSInt32(prereq.second); } QueuePacket(outapp); safe_delete(outapp); }
void board_write_msg(struct char_data *ch, char *arg, int bnum) { int highmessage; char buf[MAX_STRING_LENGTH]; long ct; /* clock time */ char *tmstr; extern struct time_info_data time_info; extern char *month_name[]; if ( bnum == -1 ) { logE("Board special procedure called for non-board object.\r\n"); send_to_char("This board is not in operation at this time.\n\r", ch); return; } curr_board = &boards[bnum]; if (GetMaxLevel(ch) < min_write_level[bnum]) { send_to_char("You pick up a quill to write, but realize you're not powerful enough\n\r",ch); send_to_char("to submit intelligent material to THIS board.\n\r",ch); return; } if ( (curr_board->number) > (MAX_MSGS - 1) ) { send_to_char("The board is full already.\n\r", ch); return; } /* Check for locks, return if lock is found on this board */ if (board_check_locks(bnum, ch)) return; /* skip blanks */ for(; isspace(*arg); arg++); if (!*arg) { send_to_char("The board has now been saved permanently to disk.\n\rTo write a new message, use WRITE followed by a title.\n\r", ch); return; } /* Now we're committed to writing a message. Let's lock the board. */ board_lock[bnum].lock = 1; board_lock[bnum].locked_for = ch; /* Lock set */ highmessage = boards[bnum].number; curr_msg = &curr_board->msg[++highmessage]; if (!(strcmp("Topic",arg))) { curr_msg = &curr_board->msg[0]; free(curr_msg->title); free(curr_msg->text); free(curr_msg->author); free(curr_msg->date); (boards[bnum].number)--; } curr_msg->title = (char *)malloc(strlen(arg)+1); strcpy(curr_msg->title, arg); curr_msg->author = (char *)malloc(strlen(GET_NAME(ch))+1); strcpy(curr_msg->author, GET_NAME(ch)); ct = time(0); tmstr = (char *)asctime(localtime(&ct)); *(tmstr + strlen(tmstr) - 1) = '\0'; sprintf(buf,"%.10s",tmstr); curr_msg->date = (char *)malloc(strlen(buf)+1); strcpy(curr_msg->date, buf); send_to_char("Write your message. Terminate with a @.\n\r\n\r", ch); act("$n starts to write a message.", TRUE, ch, 0, 0, TO_ROOM); /* Take care of free-ing and zeroing if the message text is already allocated previously */ if (curr_msg->text) free (curr_msg->text); curr_msg->text = 0; /* Initiate the string_add procedures from comm.c */ ch->desc->str = &curr_msg->text; ch->desc->max_str = MAX_MESSAGE_LENGTH; (boards[bnum].number)++; if (boards[bnum].number < 0) boards[bnum].number = 0; }
void shopping_buy( const char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char argm[100], buf[MAX_STRING_LENGTH], newarg[100]; int num = 1; struct obj_data *temp1; int i; float mult = 0; if(!(is_ok(keeper,ch,shop_nr))) return; if(keeper->generic != 0) for(i = 0; i <= MAX_TRADE; i++) { if(keeper->generic == FAMINE) if(shop_index[shop_nr].type[i] == ITEM_FOOD) { mult = shop_multiplier; /* we're in a famine, we sell food, so we */ break; /* our prices to hell ;-) -DM */ } if(keeper->generic == DWARVES_STRIKE) if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) { mult = shop_multiplier; break; } } only_argument(arg, argm); if(!(*argm)) { sprintf(buf, "%s what do you want to buy??" ,GET_NAME(ch)); do_tell(keeper,buf,19); return; }; if( ( num = getabunch( argm, newarg ) ) != 0 ) { strcpy(argm,newarg); } if (num == 0) num = 1; if(!( temp1 = get_obj_in_list_vis(ch,argm,keeper->carrying))) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(temp1->obj_flags.cost <= 0) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); extract_obj(temp1); return; } if( GET_GOLD(ch) < (int) (num*(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch) ].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost))) && GetMaxLevel(ch)<DEMIGOD) { sprintf(buf, shop_index[shop_nr].missing_cash2, GET_NAME(ch)); do_tell(keeper,buf,19); switch(shop_index[shop_nr].temper1) { case 0: do_action(keeper,GET_NAME(ch),30); return; case 1: do_emote(keeper,"grins happily",36); return; default: return; } } if ((IS_CARRYING_N(ch) + num) > (CAN_CARRY_N(ch))) { sprintf(buf,"%s : You can't carry that many items.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } if ((IS_CARRYING_W(ch) + (num * temp1->obj_flags.weight)) > CAN_CARRY_W(ch)) { sprintf(buf,"%s : You can't carry that much weight.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } act("$n buys $p.", FALSE, ch, temp1, 0, TO_ROOM); sprintf(buf, shop_index[shop_nr].message_buy, GET_NAME(ch), (int) (num * (temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost)))); do_tell(keeper,buf,19); sprintf(buf,"You now have %s (*%d).\n\r", temp1->short_description,num); send_to_char(buf,ch); while (num-- > 0) { if (GetMaxLevel(ch)<DEMIGOD) GET_GOLD(ch) -= (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch) ].reaction*temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); GET_GOLD(keeper) += (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[(int)GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); /* Test if producing shop ! */ if (shop_producing(temp1,shop_nr)) temp1 = read_object(temp1->item_number, REAL); else { obj_from_char(temp1); if (temp1 == NULL) { send_to_char("Sorry, I just ran out of those.\n\r",ch); GET_GOLD(ch) += (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch) ].reaction * temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); return; } } obj_to_char(temp1,ch); } return; }
int board_remove_msg(struct char_data *ch, char *arg, int bnum) { /* This should now be fixed so that low level chars can remove armor and such. */ int ind, tmessage; char buf[256], number[MAX_INPUT_LENGTH]; one_argument(arg, number); if (!*number || !isdigit(*number)) return(0); if (!(tmessage = atoi(number))) return(0); if ( bnum == -1 ) { logE("Board special procedure called for non-board object.\r\n"); send_to_char("This board is not in operation at this time.\n\r", ch); return 1; } curr_board = &boards[bnum]; if (GetMaxLevel(ch) < min_remove_level[bnum]) { send_to_char("You try and grab one of the notes of the board but get a nasty\n\r",ch); send_to_char("shock. Maybe you'd better leave it alone.\n\r",ch); return 1; } if (curr_board->number < 1) { send_to_char("The board is empty!\n\r", ch); return(1); } if (tmessage < 0 || tmessage > curr_board->number) { send_to_char("That message exists only in your imagination..\n\r", ch); return(1); } /* Check for board locks, return if lock is found */ if (board_check_locks(bnum, ch)) return(1); ind = tmessage; free(curr_board->msg[ind].text); free(curr_board->msg[ind].date); free(curr_board->msg[ind].author); free(curr_board->msg[ind].title); for ( ; ind < (curr_board->number) ; ind++ ) curr_board->msg[ind] = curr_board->msg[ind+1]; /* You MUST do this, or the next message written after a remove will */ /* end up doing a free(curr_board->msg[ind].text) because it's not!! */ /* Causing strange shit to happen, because now the message has a */ /* To a memory location that doesn't exist, and if THAT message gets */ /* Removed, it will destroy what it's pointing to. THIS is the board */ /* Bug we've been looking for! -=>White Gold<=- */ curr_board->msg[curr_board->number].text = NULL; curr_board->msg[curr_board->number].date = NULL; curr_board->msg[curr_board->number].author = NULL; curr_board->msg[curr_board->number].title = NULL; curr_board->number--; send_to_char("Message removed.\n\r", ch); sprintf(buf, "%s just removed message %d.", ch->player.name, tmessage); /* Removal message also repaired */ act(buf, FALSE, ch, 0, 0, TO_ROOM); sprintf((buf+strlen(buf)-1)," from board %d.",bnum); logE(buf); /* Message removals now logged. */ board_save_board(bnum); return(1); }
uint32 BattleGround::GetBonusHonorFromKill(uint32 kills) const { // variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill) return (uint32)MaNGOS::Honor::hk_honor_at_level(GetMaxLevel(), kills); }
void Game_Actor::MakeExpList() { exp_list.resize((size_t)GetMaxLevel()); for (int i = 1; i < (int)exp_list.size(); ++i) { exp_list[i] = CalculateExp(i); } }