void do_open(dbref player, dbref cause, int key, char *direction, char *links[], int nlinks) { dbref loc, destnum; char *dest, *dir2; char spam_chr[32]; memset(spam_chr, 0, sizeof(spam_chr)); if ( (key & SIDEEFFECT) && !SideFX(player) ) { notify(player, "#-1 FUNCTION DISABLED"); return; } if (Immortal(player) && (*direction == '#')) { dir2 = get_free_num(player, direction); } else { dir2 = direction; } /* Create the exit and link to the destination, if there is one */ if (nlinks >= 1) dest = links[0]; else dest = NULL; if ((key == OPEN_INVENTORY) || ((Typeof(player) == TYPE_ROOM) && (mudconf.rooms_can_open == 1))) loc = player; else { if ( mudstate.store_loc != NOTHING ) loc = mudstate.store_loc; else loc = Location(player); } open_exit(player, loc, dir2, dest, key); /* Open the back link if we can */ if (nlinks >= 2) { destnum = parse_linkable_room(player, dest); if (destnum != NOTHING) { /* For some reason unsafe_tprintf() doesn't work right here */ sprintf(spam_chr, "%d", loc); open_exit(player, destnum, links[1], spam_chr, key); } } }
void do_link(dbref player, dbref cause, int key, char *what, char *where) { dbref thing, room; char *buff; int nomtest; if ( (key & SIDEEFFECT) && !SideFX(player) ) { notify(player, "#-1 FUNCTION DISABLED"); return; } /* Find the thing to link */ init_match(player, what, TYPE_EXIT); match_everything(0); thing = noisy_match_result(); if (thing == NOTHING) return; nomtest = ((NoMod(thing) && !WizMod(player)) || (DePriv(player,Owner(thing),DP_MODIFY,POWER7,NOTHING) && (Owner(thing) != Owner(player))) || (Backstage(player) && NoBackstage(thing) && !Immortal(player))); /* Allow unlink if where is not specified */ if (!where || !*where) { if (!nomtest) do_unlink(player, cause, key, what); else notify(player,"Permission denied."); return; } switch (Typeof(thing)) { case TYPE_EXIT: /* Set destination */ room = parse_linkable_room(player, where); if (room != NOTHING) { if (!nomtest) link_exit(player, thing, room, key); else notify(player,"Permission denied."); } break; case TYPE_PLAYER: case TYPE_THING: /* Set home */ if (!Controls(player, thing) || nomtest) { notify_quiet(player, "Permission denied."); break; } init_match(player, where, NOTYPE); match_everything(MAT_NO_EXITS); room = noisy_match_result(); if (!Good_obj(room)) break; if (!Has_contents(room)) { notify_quiet(player, "Can't link to an exit."); break; } if (!can_set_home(player, thing, room) || !could_doit(player, room, A_LLINK, 1, 0)) { notify_quiet(player, "Permission denied."); } else if (room == HOME) { notify_quiet(player, "Can't set home to home."); } else { s_Home(thing, room); if (!(Quiet(player) || (key & SIDEEFFECT)) ) notify_quiet(player, "Home set."); } break; case TYPE_ROOM: /* Set dropto */ if (!Controls(player, thing) || nomtest) { notify_quiet(player, "Permission denied."); break; } room = parse_linkable_room(player, where); if (!Good_obj(room) && (room != HOME)) { notify_quiet(player, "Permission denied."); break; } if ((room != HOME) && !isRoom(room)) { notify_quiet(player, "That is not a room!"); } else if ((room != HOME) && ((!controls(player, room) && !Link_ok(room)) || !could_doit(player, room, A_LLINK, 1, 0))) { notify_quiet(player, "Permission denied."); } else { s_Dropto(thing, room); if (!Quiet(player)) notify_quiet(player, "Dropto set."); } break; default: STARTLOG(LOG_BUGS, "BUG", "OTYPE") buff = alloc_mbuf("do_link.LOG.badtype"); sprintf(buff, "Strange object type: object #%d = %d", thing, Typeof(thing)); log_text(buff); free_mbuf(buff); ENDLOG } }
static void give_money (dbref giver, dbref recipient, int key, int amount) { dbref aowner; int cost, pcost, rcost, aflags, dpamount; char *str; /* do amount consistency check */ if (amount < 0 && ((!Builder(giver) && !HasPriv(giver,recipient,POWER_STEAL,POWER3,NOTHING)) || DePriv(giver,recipient,DP_STEAL,POWER6,NOTHING))) { notify(giver, unsafe_tprintf("You look through your pockets. Nope, no negative %s.", mudconf.many_coins)); return; } if (!amount) { notify(giver, unsafe_tprintf("You must specify a positive number of %s.", mudconf.many_coins)); return; } dpamount = 0; if (amount < 0) dpamount = DePriv(giver,NOTHING,DP_NOSTEAL,POWER7,POWER_LEVEL_NA); else dpamount = DePriv(giver,NOTHING,DP_NOGOLD,POWER7,POWER_LEVEL_NA); if (dpamount) { if (DPShift(giver)) dpamount--; dpamount = mudconf.money_limit[dpamount]; } else dpamount = -1; if (!Admin(Owner(giver))) { if ((Typeof(recipient) == TYPE_PLAYER) && (Pennies(recipient) + amount > mudconf.paylimit)) { notify(giver, unsafe_tprintf("That player doesn't need that many %s!", mudconf.many_coins)); return; } if ((Typeof(recipient) != TYPE_PLAYER) && (!could_doit(giver, recipient, A_LUSE,1))) { notify(giver, unsafe_tprintf("%s won't take your money.", Name(recipient))); return; } } str = atr_get(Owner(giver), A_PAYLIM, &aowner, &aflags); pcost = atoi(str); free_lbuf(str); if (!Immortal(Owner(giver)) && pcost) { if ((Typeof(recipient) == TYPE_PLAYER) && (amount > 0) && (Pennies(recipient) + amount > pcost)) { notify(giver, unsafe_tprintf("That player doesn't need that many %s!", mudconf.many_coins)); return; } else if (Pennies(recipient) + amount < (-pcost)) { notify(giver,"That player doesn't need that much debt!"); return; } } str = atr_get(Owner(recipient), A_RECEIVELIM, &aowner, &aflags); rcost = atoi(str); free_lbuf(str); if (!Immortal(Owner(giver)) && rcost) { if ((Typeof(recipient) == TYPE_PLAYER) && (amount > 0) && (Pennies(recipient) + amount > rcost)) { notify(giver, unsafe_tprintf("That player doesn't need that many %s!", mudconf.many_coins)); return; } else if (Pennies(recipient) + amount < (-rcost)) { notify(giver,"That player doesn't need that much debt!"); return; } } if (!Immortal(Owner(giver))) { if (dpamount >= 0) { if (amount > 0) { if ((Typeof(recipient) == TYPE_PLAYER) && (Pennies(recipient) + amount > dpamount)) { notify(giver, unsafe_tprintf("That player doesn't need that many %s!", mudconf.many_coins)); return; } else if (amount > dpamount) { notify(giver, "Permission denied."); return; } } else { if ((Typeof(recipient) == TYPE_PLAYER) && (Pennies(recipient) + amount < (-dpamount))) { notify(giver, unsafe_tprintf("That player doesn't need that many %s!", mudconf.many_coins)); return; } else if (amount < (-dpamount)) { notify(giver, "Permission denied."); return; } } } } /* try to do the give */ if (!payfor_give(giver, amount)) { notify(giver, unsafe_tprintf("You don't have that many %s to give!", mudconf.many_coins)); return; } /* Find out cost if an object */ if (Typeof(recipient) == TYPE_THING) { str = atr_pget(recipient, A_COST, &aowner, &aflags); cost = atoi(str); free_lbuf(str); /* Can't afford it? */ if (amount < cost) { notify(giver, "Feeling poor today?"); giveto(giver, amount, NOTHING); return; } /* Negative cost */ if (cost < 0) { return; } } else { cost = amount; } if (!(key & GIVE_QUIET)) { if (amount == 1) { notify(giver, unsafe_tprintf("You give a %s to %s.", mudconf.one_coin, Name(recipient))); notify_with_cause(recipient, giver, unsafe_tprintf("%s gives you a %s.", Name(giver), mudconf.one_coin)); } else { notify(giver, unsafe_tprintf("You give %d %s to %s.", amount, mudconf.many_coins, Name(recipient))); notify_with_cause(recipient, giver, unsafe_tprintf("%s gives you %d %s.", Name(giver), amount, mudconf.many_coins)); } } else { if (amount == 1) { notify(giver, unsafe_tprintf("You give a %s to %s. (quiet)", mudconf.one_coin, Name(recipient))); } else { notify(giver, unsafe_tprintf("You give %d %s to %s. (quiet)", amount, mudconf.many_coins, Name(recipient))); } } /* Report change given */ if((amount - cost) == 1) { notify(giver, unsafe_tprintf("You get 1 %s in change.", mudconf.one_coin)); giveto(giver, 1, NOTHING); } else if (amount != cost) { notify(giver, unsafe_tprintf("You get %d %s in change.", (amount - cost), mudconf.many_coins)); giveto(giver, (amount - cost), NOTHING); } if (pcost && (Pennies(Owner(recipient)) + cost > pcost)) { pcost = pcost - Pennies(Owner(recipient)); if (pcost < 0) pcost = 0; } else pcost = cost; if (!giveto(recipient, pcost, giver)) giveto(giver, cost, NOTHING); /* Transfer the money and run PAY attributes */ /* Rooms should not kick off the PAY attribute */ if ( !isRoom(giver) ) did_it(giver, recipient, A_PAY, NULL, A_OPAY, NULL, A_APAY, (char **)NULL, 0); return; }
void instance_naxxramas::SetData(uint32 uiType, uint32 uiData) { switch(uiType) { case TYPE_ANUB_REKHAN: m_auiEncounter[0] = uiData; DoUseDoorOrButton(m_uiAnubDoorGUID); if (uiData == DONE) { OpenDoor(m_uiAnubGateGUID); m_uiArachnofobiaTimer = 0; m_bIsArachnofobia = true; } break; case TYPE_FAERLINA: m_auiEncounter[1] = uiData; DoUseDoorOrButton(m_uiFaerWebGUID); if (uiData == DONE) { OpenDoor(m_uiFaerDoorGUID); OpenDoor(m_uiMaexOuterGUID); } break; case TYPE_MAEXXNA: m_auiEncounter[2] = uiData; DoUseDoorOrButton(m_uiMaexInnerGUID, uiData); if (uiData == DONE) { DoUseDoorOrButton(m_uiAracEyeRampGUID); DoUseDoorOrButton(m_uiAracEyeGUID); DoRespawnGameObject(m_uiAracPortalGUID, 30*MINUTE); Immortal(); DoTaunt(); // Arachnofobia if(m_uiArachnofobiaTimer <= 20 * 60000 && m_bIsArachnofobia) { Arachnofobia(); m_bIsArachnofobia = false; } } break; case TYPE_NOTH: m_auiEncounter[3] = uiData; DoUseDoorOrButton(m_uiNothEntryDoorGUID); if (uiData == DONE) { OpenDoor(m_uiNothExitDoorGUID); OpenDoor(m_uiHeigEntryDoorGUID); } break; case TYPE_HEIGAN: m_auiEncounter[4] = uiData; DoUseDoorOrButton(m_uiHeigEntryDoorGUID); if (uiData == DONE) { OpenDoor(m_uiHeigExitDoorGUID); OpenDoor(m_uiLoathebDoorGUID); } break; case TYPE_LOATHEB: m_auiEncounter[5] = uiData; DoUseDoorOrButton(m_uiLoathebDoorGUID); if (uiData == DONE) { DoUseDoorOrButton(m_uiPlagEyeRampGUID); DoUseDoorOrButton(m_uiPlagEyeGUID); DoRespawnGameObject(m_uiPlagPortalGUID, 30*MINUTE); DoTaunt(); Immortal(); } break; case TYPE_RAZUVIOUS: m_auiEncounter[6] = uiData; if (uiData == DONE) OpenDoor(m_uiGothikEntryDoorGUID); break; case TYPE_GOTHIK: switch(uiData) { case IN_PROGRESS: DoUseDoorOrButton(m_uiGothikEntryDoorGUID); DoUseDoorOrButton(m_uiGothCombatGateGUID); break; case SPECIAL: DoUseDoorOrButton(m_uiGothCombatGateGUID); break; case FAIL: if (m_auiEncounter[7] == IN_PROGRESS) DoUseDoorOrButton(m_uiGothCombatGateGUID); DoUseDoorOrButton(m_uiGothikEntryDoorGUID); break; case DONE: OpenDoor(m_uiGothikEntryDoorGUID); OpenDoor(m_uiGothikExitDoorGUID); OpenDoor(m_uiHorsemenDoorGUID); OpenDoor(m_uiGothCombatGateGUID); break; } m_auiEncounter[7] = uiData; break; case TYPE_FOUR_HORSEMEN: m_auiEncounter[8] = uiData; DoUseDoorOrButton(m_uiHorsemenDoorGUID); if (uiData == DONE) { DoUseDoorOrButton(m_uiMiliEyeRampGUID); DoUseDoorOrButton(m_uiMiliEyeGUID); DoRespawnGameObject(m_uiMiliPortalGUID, 30*MINUTE); DoRespawnGameObject(m_uiHorsemenChestGUID, 30*MINUTE); DoTaunt(); Immortal(); } break; case TYPE_PATCHWERK: m_auiEncounter[9] = uiData; if (uiData == DONE) OpenDoor(m_uiPathExitDoorGUID); break; case TYPE_GROBBULUS: m_auiEncounter[10] = uiData; break; case TYPE_GLUTH: m_auiEncounter[11] = uiData; if (uiData == DONE) { OpenDoor(m_uiGlutExitDoorGUID); OpenDoor(m_uiThadDoorGUID); } break; case TYPE_THADDIUS: m_auiEncounter[12] = uiData; if(uiData != SPECIAL) DoUseDoorOrButton(m_uiThadDoorGUID, uiData); if(uiData == FAIL) OpenDoor(m_uiThadDoorGUID); if (uiData == DONE) { DoUseDoorOrButton(m_uiConsEyeRampGUID); DoUseDoorOrButton(m_uiConsEyeGUID); DoRespawnGameObject(m_uiConsPortalGUID, 30*MINUTE); DoTaunt(); Immortal(); } break; case TYPE_SAPPHIRON: m_auiEncounter[13] = uiData; if (uiData == DONE) DoUseDoorOrButton(m_uiKelthuzadDoorGUID); break; case TYPE_KELTHUZAD: m_auiEncounter[14] = uiData; DoUseDoorOrButton(m_uiKelthuzadExitDoorGUID); if(uiData == DONE) Immortal(); break; case TYPE_IMMORTAL: m_auiEncounter[15] = uiData; break; //Four Horsemen Chest case TYPE_BLAUMEAUX: if (uiData == DONE) { BlaumeuxDead = true; UpdateCheck = true; Horseman(); } break; case TYPE_RIVENDARE: if (uiData == DONE) { RivendareDead = true; UpdateCheck = true; Horseman(); } break; case TYPE_ZELIEK: if (uiData == DONE) { ZeliekDead = true; UpdateCheck = true; Horseman(); } break; case TYPE_KORTHAZZ: if (uiData == DONE) { KorthazzDead = true; UpdateCheck = true; Horseman(); } break; case TYPE_STALAGG: m_auiStalaggEncounter = uiData; break; case TYPE_FEUGEN: m_auiFeugenEncouter = uiData; break; } if (uiData == DONE) { OUT_SAVE_INST_DATA; std::ostringstream saveStream; saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " " << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " " << m_auiEncounter[6] << " " << m_auiEncounter[7] << " " << m_auiEncounter[8] << " " << m_auiEncounter[9] << " " << m_auiEncounter[10] << " " << m_auiEncounter[11] << " " << m_auiEncounter[12] << " " << m_auiEncounter[13] << " " << m_auiEncounter[14] << " " << m_auiEncounter[15]; strInstData = saveStream.str(); SaveToDB(); OUT_SAVE_INST_DATA_COMPLETE; } }
void do_kill (dbref player, dbref cause, int key, char *what, char *costchar) { dbref victim; char *buf1, *buf2; int cost; init_match(player, what, TYPE_PLAYER); match_neighbor(); match_me(); match_here(); if (Wizard(player)) { match_player(); match_absolute(); } victim = match_result(); switch (victim) { case NOTHING: notify(player, "I don't see that player here."); break; case AMBIGUOUS: notify(player, "I don't know who you mean!"); break; default: if ((Typeof(victim) != TYPE_PLAYER) && (Typeof(victim) != TYPE_THING)) { notify(player, "Sorry, you can only kill players and things."); break; } if ((Haven(Location(victim)) && !Wizard(player)) || (controls(victim, Location(victim)) && !controls(player, Location(victim))) || Immortal(victim)) { notify(player, "Sorry."); break; } if (key == KILL_SLAY) { if (Builder(player) && Builder(victim)) { notify(player, "Sorry."); break; } } /* go for it */ cost = atoi(costchar); if (key == KILL_KILL) { if (HasPriv(victim,player,POWER_NOKILL,POWER4,NOTHING)) { notify(player, "Sorry."); break; } if (cost < mudconf.killmin) cost = mudconf.killmin; if (cost > mudconf.killmax) cost = mudconf.killmax; /* see if it works */ if (!payfor(player, cost)) { notify(player, unsafe_tprintf("You don't have enough %s.", mudconf.many_coins)); return; } } else { cost = 0; } if (!(((random() % mudconf.killguarantee) < cost) || (key == KILL_SLAY)) || Wizard(victim)) { /* Failure: notify player and victim only */ notify(player, "Your murder attempt failed."); buf1 = alloc_lbuf("do_kill.failed"); sprintf(buf1, "%s tried to kill you!", Name(player)); notify_with_cause(victim, player, buf1); if (Suspect(player)) { strcpy(buf1, Name(player)); if (player == Owner(player)) { raw_broadcast(0, WIZARD, "[Suspect] %s tried to kill %s(#%d).", buf1, Name(victim), victim); } else { buf2 = alloc_lbuf("do_kill.SUSP.failed"); strcpy(buf2, Name(Owner(player))); raw_broadcast(0, WIZARD, "[Suspect] %s <via %s(#%d)> tried to kill %s(#%d).", buf2, buf1, player, Name(victim), victim); free_lbuf(buf2); } } free_lbuf(buf1); break; } /* Success! You killed him */ buf1 = alloc_lbuf("do_kill.succ.1"); buf2 = alloc_lbuf("do_kill.succ.2"); if (Suspect(player)) { strcpy(buf1, Name(player)); if (player == Owner(player)) { raw_broadcast(0, WIZARD, "[Suspect] %s killed %s(#%d).", buf1, Name(victim), victim); } else { strcpy(buf2, Name(Owner(player))); raw_broadcast(0, WIZARD, "[Suspect] %s <via %s(#%d)> killed %s(#%d).", buf2, buf1, player, Name(victim), victim); } } sprintf(buf1, "You killed %s!", Name(victim)); sprintf(buf2, "killed %s!", Name(victim)); if (Typeof(victim) != TYPE_PLAYER) if (halt_que(NOTHING, victim) > 0) if (!Quiet(victim)) notify(Owner(victim), "Halted."); did_it(player, victim, A_KILL, buf1, A_OKILL, buf2, A_AKILL, (char **)NULL, 0); /* notify victim */ sprintf(buf1, "%s killed you!", Name(player)); notify_with_cause(victim, player, buf1); /* Pay off the bonus */ if (key == KILL_KILL) { cost /= 2; /* victim gets half */ if (Pennies(Owner(victim)) < mudconf.paylimit) { sprintf(buf1, "Your insurance policy pays %d %s.", cost, mudconf.many_coins); notify(victim, buf1); giveto(Owner(victim), cost, NOTHING); } else { notify(victim, "Your insurance policy has been revoked."); } } free_lbuf(buf1); free_lbuf(buf2); /* send him home */ move_via_generic(victim, HOME, NOTHING, 0); divest_object(victim); break; } }