/** * Tunnel through wall. Assumes valid location. * * Note that it is impossible to "extend" rooms past their * outer walls (which are actually part of the room). * * Attempting to do so will produce floor grids which are not part * of the room, and whose "illumination" status do not change with * the rest of the room. */ static bool twall(int y, int x) { /* Paranoia -- Require a wall or door or some such */ if (!(square_isdiggable(cave, y, x) || square_iscloseddoor(cave, y, x))) return (false); /* Sound */ sound(MSG_DIG); /* Forget the wall */ square_forget(cave, y, x); /* Remove the feature */ square_tunnel_wall(cave, y, x); /* Update the visuals */ player->upkeep->update |= (PU_UPDATE_VIEW | PU_MONSTERS); /* Fully update the flow */ player->upkeep->update |= (PU_FORGET_FLOW | PU_UPDATE_FLOW); /* Result */ return (true); }
void main() { node*root,*root1; clrscr(); gotoxy(1,25); cout<<"enter the tree"; root=new node; gettree(root,40,1); cout<<"the tree loaded"; sound(200); delay(1000); nosound(); getch(); getch(); clrscr(); showtree(root,40,10); getch(); root1=new node; createig(root,root1); clrscr(); showtree(root1,40,10); getch(); }
static bool run_bute_defeated(Object *o, int hp) { if (o->hp <= (1000 - hp)) { if (o->type == OBJ_MESA) { o->ChangeType(OBJ_MESA_DYING); } else { o->x -= (4 << CSF); o->y -= (4 << CSF); o->ChangeType(OBJ_BUTE_DYING); sound(SND_ENEMY_SQUEAK); XMOVE(-0x100); } ai_bute_dying(o); return 1; } return 0; }
void r_touch() { //gedict_t* stemp; //float best; if ( strneq( other->s.v.classname, "player" ) ) return; if ( other->s.v.health <= 0 ) return; self->mdl = self->s.v.model; sound( other, CHAN_VOICE, self->s.v.noise, 1, ATTN_NORM ); stuffcmd( other, "bf\n" ); self->s.v.solid = SOLID_NOT; other->s.v.items = ( ( int ) other->s.v.items ) | IT_INVISIBILITY; self->s.v.model = ""; // do the apropriate action other->invisible_time = 1; other->invisible_finished = self->cnt; G_bprint( PRINT_LOW, "%s recovered a Ring with %d seconds remaining!\n", other->s.v.netname, ( int ) ( other->invisible_finished - g_globalvars.time ) ); /*s=ftos(rint(other->invisible_finished - time)); trap_BPrint (PRINT_LOW, other->s.v.netname); trap_BPrint (PRINT_LOW, " recovered a Ring with "); trap_BPrint (PRINT_LOW, s); trap_BPrint (PRINT_LOW, " seconds remaining!\n"); */ activator = other; SUB_UseTargets(); // fire all targets / killtargets }
void android_main(android_app *app) { app_dummy(); flatbuffers::FlatBufferBuilder builder; auto name = builder.CreateString("Dog"); auto sound = builder.CreateString("Bark"); auto animal_buffer = sample::CreateAnimal(builder, name, sound); builder.Finish(animal_buffer); // We now have a FlatBuffer that can be stored on disk or sent over a network. // ...Code to store on disk or send over a network goes here... // Instead, we're going to access it immediately, as if we just recieved this. auto animal = sample::GetAnimal(builder.GetBufferPointer()); assert(animal->name()->str() == "Dog"); assert(animal->sound()->str() == "Bark"); (void)animal; // To silence "Unused Variable" warnings. __android_log_print(ANDROID_LOG_INFO, "FlatBufferSample", "FlatBuffer successfully created and verified."); }
void QGCAudioWorker::noticeTips(int noticeType, int severity) { if (!muted) { // Prepend high priority text with alert beep /*if (severity < GAudioOutput::AUDIO_SEVERITY_CRITICAL) { beep(); }*/ QString soundPath = ""; getSoundFromType(noticeType,soundPath); if ("" == soundPath)return; QSound sound(QString(":res/")+soundPath); sound.play(); // Wait for the last sound to finish while (!sound.isFinished()) { QGC::SLEEP::msleep(100); } } }
void OmegaBoss::Run(void) { Object *&o = game.stageboss.object; if (omg.defeated) return; switch(o->state) { case 0: break; // waiting for trigger by script case OMG_WAIT: // waits for a moment then go to omg.nextstate { o->state++; omg.timer = 0; } case OMG_WAIT+1: { if (++omg.timer >= OMEGA_WAIT_TIME) { omg.timer = 0; o->state = omg.nextstate; } } break; case OMG_APPEAR: { omg.timer = 0; o->frame = 0; o->state = OMG_MOVE; omg.movedir = -OMEGA_SPEED; o->flags |= FLAG_SOLID_MUSHY; } case OMG_MOVE: // rising up/going back into ground { o->frame = 0; o->y += omg.movedir; game.quaketime = 2; omg.timer++; if ((omg.timer & 3) == 0) sound(SND_QUAKE); if (omg.timer >= omg.movetime) { if (omg.movedir < 0) { // was rising out of ground omg.nextstate = OMG_JAWS_OPEN; o->state = OMG_WAIT; } else { // was going back into ground omg.timer = 0; o->state = OMG_UNDERGROUND; o->flags &= ~(FLAG_SOLID_MUSHY | FLAG_SOLID_BRICK); } } } break; case OMG_JAWS_OPEN: // jaws opening { o->state++; omg.animtimer = 0; sound(SND_JAWS); o->sprite = SPR_OMG_OPENED; // select "open" bounding box } case OMG_JAWS_OPEN+1: { omg.animtimer++; if (omg.animtimer > 2) { omg.animtimer = 0; o->frame++; if (o->frame==3) { o->state = OMG_FIRE; omg.firecounter = 0; o->flags |= FLAG_SHOOTABLE; } } } break; case OMG_FIRE: // throwing out red stuff { omg.firecounter++; if (omg.firecounter > omg.startfiring && omg.firecounter < omg.stopfiring) { if ((omg.firecounter % omg.firefreq)==0) { Object *shot; sound(SND_EM_FIRE); shot = SpawnObjectAtActionPoint(o, OBJ_OMEGA_SHOT); shot->xinertia = random(-omg.shotxspd, omg.shotxspd); shot->yinertia = -0x333; if (omg.form==2 || random(0, 9) < 8) { shot->sprite = SPR_OMG_BULLET_NORMAL; shot->flags = FLAG_SHOOTABLE; } else { shot->sprite = SPR_OMG_BULLET_HARD; shot->flags = (FLAG_SHOOTABLE | FLAG_INVULNERABLE); } shot->timer = (random(0, 7) >= 4) ? random(300, 400):0; shot->damage = 4; } } else if (omg.firecounter >= omg.endfirestate || sound_is_playing(SND_MISSILE_HIT)) { // snap jaws shut omg.animtimer = 0; o->state = OMG_JAWS_CLOSE; sound(SND_JAWS); } } break; case OMG_JAWS_CLOSE: // jaws closing { omg.animtimer++; if (omg.animtimer > 2) { omg.animtimer = 0; o->frame--; if (o->frame == 0) { sound_stop(SND_JAWS); sound(SND_BLOCK_DESTROY); o->sprite = SPR_OMG_CLOSED; // select "closed" bounding box o->flags &= ~FLAG_SHOOTABLE; o->damage = 0; if (omg.form == 1) { // form 1: return to sand o->state = OMG_WAIT; omg.nextstate = OMG_MOVE; omg.movedir = OMEGA_SPEED; omg.movetime = OMEGA_SINK_DEPTH; } else { // form 2: jump sound(SND_FUNNY_EXPLODE); if (o->x < player->x) o->xinertia = 0xC0; else o->xinertia = -0xC0; o->state = OMG_JUMP; o->yinertia = -0x5FF; omg.orgy = o->y; } } } // hurt player if he was standing in the middle when the jaws shut if (player->riding == o) { hurtplayer(OMEGA_DAMAGE); } } break; case OMG_UNDERGROUND: // underground waiting to reappear { if (++omg.timer >= 120) { omg.timer = 0; o->state = OMG_APPEAR; o->x = omg.orgx + (random(-64, 64) << CSF); o->y = omg.orgy; omg.movetime = OMEGA_RISE_HEIGHT; // switch to jumping out of ground when we get low on life if (omg.form==1 && o->hp <= HP_TRIGGER_POINT) { o->flags |= FLAG_SOLID_MUSHY; omg.form = 2; omg.firefreq = 5; omg.shotxspd = 0x155; omg.startfiring = 0; omg.stopfiring = 30; omg.endfirestate = 50; omg.movetime = OMEGA_RISE_HEIGHT+3; } } } break; case OMG_JUMP: // init for jump { omg.orgy = o->y; o->state++; omg.timer = 0; } case OMG_JUMP+1: // jumping { o->yinertia += 0x24; if (o->yinertia > 0x5ff) o->yinertia = 0x5ff; if (o->yinertia > 0) { // coming down pieces[LEFTLEG]->sprite = pieces[RIGHTLEG]->sprite = SPR_OMG_LEG_ONGROUND; // retract legs a little when we hit the ground if (pieces[LEFTLEG]->blockd || pieces[RIGHTLEG]->blockd) { o->xinertia = 0; omg.leg_descend -= o->yinertia; if (++omg.timer >= 3) { o->yinertia = 0; o->state = OMG_JAWS_OPEN; } } // --- squash player if we land on him ------------- // if top of player is higher than bottom of our bounding box // but bottom of player's bounding box is not... if (player->blockd) { int omg_bottom = o->y + (sprites[o->sprite].solidbox.y2 << CSF); if (player->y <= omg_bottom) { if (player->y + (sprites[player->sprite].solidbox.y2 << CSF) >= omg_bottom) { if (hitdetect(o, player)) // easy way to verify the X's are lined up { // SQUISH! hurtplayer(OMEGA_DAMAGE); } } } } } else { // jumping up; extend legs omg.leg_descend = (omg.orgy - o->y) + LEGD_MIN; if (omg.leg_descend > LEGD_MAX) omg.leg_descend = LEGD_MAX; pieces[LEFTLEG]->sprite = pieces[RIGHTLEG]->sprite = SPR_OMG_LEG_INAIR; } } break; /// victory case OMG_EXPLODING: { omg.timer = 0; o->state++; } case OMG_EXPLODING+1: { int x, y; o->xinertia = o->yinertia = 0; x = o->CenterX() + (random(-48, 48)<<CSF); y = o->CenterY() + (random(-48, 24)<<CSF); SmokePuff(x, y); effect(x, y, EFFECT_BOOMFLASH); game.quaketime = 2; if ((omg.timer % 12)==0) sound(SND_ENEMY_HURT_BIG); if (++omg.timer > 100) { omg.timer = 0; starflash.Start(o->CenterX(), o->CenterY()); o->state = OMG_EXPLODED; } else if (omg.timer==24) { StartScript(210); } } break; case OMG_EXPLODED: { game.quaketime = 40; if (++omg.timer > 50) { o->Delete(); for(int i=0;i<NUM_PIECES;i++) pieces[i]->Delete(); omg.defeated = true; return; } } break; } // implement shaking when shot // we do it manually instead of used the usual shared code // because we want all the pieces to shake at once if (o->hp != omg.lasthp && !omg.shaketimer) { omg.shaketimer = 3; // why did I write this? anyway, I'm sure it's important if (o->x > player->x) o->display_xoff = -1; else o->display_xoff = 1; omg.lasthp = o->hp; } if (omg.shaketimer) { int xoff = -o->display_xoff; if (!--omg.shaketimer) xoff = 0; o->display_xoff = xoff; pieces[LEFTLEG]->display_xoff = xoff; pieces[RIGHTLEG]->display_xoff = xoff; pieces[LEFTSTRUT]->display_xoff = xoff; pieces[RIGHTSTRUT]->display_xoff = xoff; } if (o->state) { o->blockl |= pieces[LEFTLEG]->blockl; o->blockr |= pieces[RIGHTLEG]->blockr; pieces[LEFTLEG]->x = o->x - (4 << CSF); pieces[LEFTLEG]->y = o->y + omg.leg_descend; pieces[RIGHTLEG]->x = o->x + (38 << CSF); pieces[RIGHTLEG]->y = o->y + omg.leg_descend; pieces[LEFTSTRUT]->x = o->x + (9 << CSF); pieces[LEFTSTRUT]->y = o->y + (27 << CSF); pieces[RIGHTSTRUT]->x = o->x + (43 << CSF); pieces[RIGHTSTRUT]->y = o->y + (27 << CSF); } }
void Buzzer::soundIfSilence(Buzzer::SoundType s) { if(sound_ == Off) sound(s); }
virtual void Execute(const DataObject &object) { wxASSERT(1 <= object.numItems()); wxInt32 thisTile, corner; boost::tie(thisTile, corner) = Utility::decodeSel(object.read<wxInt32>()); //determine other sides wxInt32 tile2, tile3; wxInt32 corner2, corner3; Utility::otherTiles(GetGame(), thisTile, corner, tile2, corner2, tile3, corner3); bool bPort = false; wxInt32 portTile = -1, port = -1; DataObject input(thisTile), output; RULE.Decide(shLogicTileIsPort, input, output); //check for a port tile if(true == output.read<bool>()) { portTile = thisTile; port = corner; } //check for a port tile input = DataObject(tile2); output.reset(); RULE.Decide(shLogicTileIsPort, input, output); if(true == output.read<bool>()) { portTile = tile2; port = corner2; } //check for a port tile input = DataObject(tile3); output.reset(); RULE.Decide(shLogicTileIsPort, input, output); if(true == output.read<bool>()) { portTile = tile3; port = corner3; } //see if they have built on a port if( (-1 < portTile) && ( (port == tile<wxInt32>(shPort1, portTile)) || (port == tile<wxInt32>(shPort2, portTile)) ) ) { bPort = true; } DataObject sound( bPort ? SOUND_PLACE_SETTLEMENT_ON_PORT : SOUND_PLACE_SETTLEMENT); RULE.Execute(shRulePlaySound, sound); }
/** * Drop (some of) a non-cursed inventory/equipment item "near" the current * location * * There are two cases here - a single object or entire stack is being dropped, * or part of a stack is being split off and dropped */ void inven_drop(struct object *obj, int amt) { int py = player->py; int px = player->px; struct object *dropped; bool none_left = false; bool quiver = false; char name[80]; char label; /* Error check */ if (amt <= 0) return; /* Check it is still held, in case there were two drop commands queued * for this item. This is in theory not ideal, but in practice should * be safe. */ if (!object_is_carried(player, obj)) return; /* Get where the object is now */ label = gear_to_label(obj); /* Is it in the quiver? */ if (object_is_in_quiver(player, obj)) quiver = true; /* Not too many */ if (amt > obj->number) amt = obj->number; /* Take off equipment, don't combine */ if (object_is_equipped(player->body, obj)) inven_takeoff(obj); /* Get the object */ dropped = gear_object_for_use(obj, amt, false, &none_left); /* Describe the dropped object */ object_desc(name, sizeof(name), dropped, ODESC_PREFIX | ODESC_FULL); /* Message */ msg("You drop %s (%c).", name, label); /* Describe what's left */ if (dropped->artifact) { object_desc(name, sizeof(name), dropped, ODESC_FULL | ODESC_SINGULAR); msg("You no longer have the %s (%c).", name, label); } else if (none_left) { /* Play silly games to get the right description */ int number = dropped->number; dropped->number = 0; object_desc(name, sizeof(name), dropped, ODESC_PREFIX | ODESC_FULL); msg("You have %s (%c).", name, label); dropped->number = number; } else { object_desc(name, sizeof(name), obj, ODESC_PREFIX | ODESC_FULL); msg("You have %s (%c).", name, label); } /* Drop it near the player */ drop_near(cave, &dropped, 0, py, px, false); /* Sound for quiver objects */ if (quiver) sound(MSG_QUIVER); event_signal(EVENT_INVENTORY); event_signal(EVENT_EQUIPMENT); }
// --- void PacmanGame::ballEated (QGAMES::Tile* t) { t -> setForm (t -> form (), __BALLEATEDFRAME); // It is turned off to background... _points -> add (__POINTSBALLEATED); sound (__SOUNDCHOMP) -> play (-1); }
void MQTT::on_message(const struct mosquitto_message *message) { std::string topic = message->topic; std::string qMessage = std::string((char*)message->payload, (char*)message->payload + message->payloadlen); _log.Log(LOG_NORM, "MQTT: Topic: %s, Message: %s", topic.c_str(), qMessage.c_str()); if (qMessage.empty()) return; if (topic.find("MyMQTT") != std::string::npos) { //MySensors message ProcessMySensorsMessage(qMessage); return; } else if (topic != TOPIC_IN) return; Json::Value root; Json::Reader jReader; std::string szCommand = "udevice"; std::vector<std::vector<std::string> > result; unsigned long long idx = 0; bool ret = jReader.parse(qMessage, root); if (!ret) goto mqttinvaliddata; if (!root["command"].empty()) { if (!root["command"].isString()) goto mqttinvaliddata; szCommand = root["command"].asString(); } if ((szCommand == "udevice") || (szCommand == "switchlight") || (szCommand == "getdeviceinfo")) { if (root["idx"].empty()) goto mqttinvaliddata; if (!root["idx"].isInt64()) goto mqttinvaliddata; idx = (unsigned long long)root["idx"].asInt64(); //Get the raw device parameters result = m_sql.safe_query("SELECT HardwareID, DeviceID, Unit, Type, SubType FROM DeviceStatus WHERE (ID==%llu)", idx); if (result.empty()) { _log.Log(LOG_ERROR, "MQTT: unknown idx received!"); return; } } else if (szCommand == "switchscene") { if (root["idx"].empty()) goto mqttinvaliddata; if (!root["idx"].isInt64()) goto mqttinvaliddata; idx = (unsigned long long)root["idx"].asInt64(); result = m_sql.safe_query("SELECT Name FROM Scenes WHERE (ID==%llu)", idx); if (result.empty()) { _log.Log(LOG_ERROR, "MQTT: unknown idx received!"); return; } } else if (szCommand == "setuservariable") { if (root["idx"].empty()) goto mqttinvaliddata; if (!root["idx"].isInt64()) goto mqttinvaliddata; idx = (unsigned long long)root["idx"].asInt64(); result = m_sql.safe_query("SELECT Name FROM UserVariables WHERE (ID==%llu)", idx); if (result.empty()) { _log.Log(LOG_ERROR, "MQTT: unknown idx received!"); return; } } if (szCommand == "udevice") { int HardwareID = atoi(result[0][0].c_str()); std::string DeviceID = result[0][1]; int unit = atoi(result[0][2].c_str()); int devType = atoi(result[0][3].c_str()); int subType = atoi(result[0][4].c_str()); bool bnvalue = !root["nvalue"].empty(); bool bsvalue = !root["svalue"].empty(); bool bParseValue = !root["parse"].empty(); if (!bnvalue && !bsvalue) goto mqttinvaliddata; if (bnvalue) { if (!root["nvalue"].isInt()) goto mqttinvaliddata; } if (bsvalue) { if (!root["svalue"].isString()) goto mqttinvaliddata; } int nvalue = (bnvalue) ? root["nvalue"].asInt() : 0; std::string svalue = (bsvalue) ? root["svalue"].asString() : ""; bool bParseTrigger = (bParseValue) ? root["parse"].asBool() : true; int signallevel = 12; int batterylevel = 255; if (!m_mainworker.UpdateDevice(HardwareID, DeviceID, unit, devType, subType, nvalue, svalue, signallevel, batterylevel, bParseTrigger)) { _log.Log(LOG_ERROR, "MQTT: Problem updating sensor (check idx, hardware enabled)"); return; } return; } else if (szCommand == "switchlight") { if (root["switchcmd"].empty()) goto mqttinvaliddata; if (!root["switchcmd"].isString()) goto mqttinvaliddata; std::string switchcmd = root["switchcmd"].asString(); if ((switchcmd != "On") && (switchcmd != "Off") && (switchcmd != "Toggle") && (switchcmd != "Set Level")) goto mqttinvaliddata; int level = 0; if (!root["level"].empty()) { if (root["level"].isString()) level = atoi(root["level"].asString().c_str()); else level = root["level"].asInt(); } if (!m_mainworker.SwitchLight(idx, switchcmd, level, -1, false, 0) == true) { _log.Log(LOG_ERROR, "MQTT: Error sending switch command!"); } return; } else if (szCommand == "switchscene") { if (root["switchcmd"].empty()) goto mqttinvaliddata; if (!root["switchcmd"].isString()) goto mqttinvaliddata; std::string switchcmd = root["switchcmd"].asString(); if ((switchcmd != "On") && (switchcmd != "Off")) goto mqttinvaliddata; if (!m_mainworker.SwitchScene(idx, switchcmd) == true) { _log.Log(LOG_ERROR, "MQTT: Error sending scene command!"); } return; } else if (szCommand == "setuservariable") { if (root["value"].empty()) goto mqttinvaliddata; if (!root["value"].isString()) goto mqttinvaliddata; std::string varvalue = root["value"].asString(); m_sql.SetUserVariable(idx, varvalue, true); return; } else if (szCommand == "addlogmessage") { if (root["message"].empty()) goto mqttinvaliddata; if (!root["message"].isString()) goto mqttinvaliddata; std::string msg = root["message"].asString(); _log.Log(LOG_STATUS, "MQTT MSG: %s", msg.c_str()); return; } else if (szCommand == "sendnotification") { std::string subject(""), body(""), sound(""); int priority = 0; if (!root["subject"].empty()) { if (!root["subject"].isString()) goto mqttinvaliddata; subject = root["subject"].asString(); } if (!root["body"].empty()) { if (!root["body"].isString()) goto mqttinvaliddata; body = root["body"].asString(); } if (!root["priority"].empty()) { if (!root["priority"].isInt()) goto mqttinvaliddata; priority = root["priority"].asInt(); } if (!root["sound"].empty()) { if (!root["sound"].isString()) goto mqttinvaliddata; sound = root["sound"].asString(); } m_notifications.SendMessageEx(NOTIFYALL, subject, body, "", priority, sound, true); std::string varvalue = root["value"].asString(); m_sql.SetUserVariable(idx, varvalue, true); return; } else if (szCommand == "getdeviceinfo") { int HardwareID = atoi(result[0][0].c_str()); SendDeviceInfo(HardwareID, idx, "request device", NULL); return; } else { _log.Log(LOG_ERROR, "MQTT: Unknown command received: %s", szCommand.c_str()); return; } mqttinvaliddata: _log.Log(LOG_ERROR, "MQTT: Invalid data received!"); }
/* * Do an effect, given an object. * Boost is the extent to which skill surpasses difficulty, used as % boost. It * ranges from 0 to 138. */ bool effect_do(effect_type effect, bool *ident, bool aware, int dir, int beam, int boost) { int py = p_ptr->py; int px = p_ptr->px; int dam, chance, dur; if (effect < 1 || effect > EF_MAX) { msg("Bad effect passed to do_effect(). Please report this bug."); return FALSE; } switch (effect) { case EF_POISON: { inc_timed(TMD_POISONED, damroll(2, 7) + 10, TRUE, TRUE); *ident = TRUE; return TRUE; } case EF_BLIND: { inc_timed(TMD_BLIND, damroll(4, 25) + 75, TRUE, TRUE); *ident = TRUE; return TRUE; } case EF_SCARE: { inc_timed(TMD_AFRAID, randint0(10) + 10, TRUE, TRUE); *ident = TRUE; return TRUE; } case EF_CONFUSE: { inc_timed(TMD_CONFUSED, damroll(4, 5) + 10, TRUE, TRUE); *ident = TRUE; return TRUE; } case EF_HALLUC: { inc_timed(TMD_IMAGE, randint0(250) + 250, TRUE, TRUE); *ident = TRUE; return TRUE; } case EF_PARALYZE: { inc_timed(TMD_PARALYZED, randint0(5) + 5, TRUE, TRUE); *ident = TRUE; return TRUE; } case EF_SLOW: { if (inc_timed(TMD_SLOW, randint1(25) + 15, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_POISON: { if (clear_timed(TMD_POISONED, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_BLINDNESS: { if (clear_timed(TMD_BLIND, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_PARANOIA: { if (clear_timed(TMD_AFRAID, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_CONFUSION: { if (clear_timed(TMD_CONFUSED, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_MIND: { if (clear_timed(TMD_CONFUSED, TRUE)) *ident = TRUE; if (clear_timed(TMD_AFRAID, TRUE)) *ident = TRUE; if (clear_timed(TMD_IMAGE, TRUE)) *ident = TRUE; if (!of_has(p_ptr->state.flags, OF_RES_CONFU) && inc_timed(TMD_OPP_CONF, damroll(4, 10), TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_BODY: { if (clear_timed(TMD_STUN, TRUE)) *ident = TRUE; if (clear_timed(TMD_CUT, TRUE)) *ident = TRUE; if (clear_timed(TMD_POISONED, TRUE)) *ident = TRUE; if (clear_timed(TMD_BLIND, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_LIGHT: { if (hp_player(20)) *ident = TRUE; if (clear_timed(TMD_BLIND, TRUE)) *ident = TRUE; if (dec_timed(TMD_CUT, 20, TRUE)) *ident = TRUE; if (dec_timed(TMD_CONFUSED, 20, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_SERIOUS: { if (hp_player(40)) *ident = TRUE; if (clear_timed(TMD_CUT, TRUE)) *ident = TRUE; if (clear_timed(TMD_BLIND, TRUE)) *ident = TRUE; if (clear_timed(TMD_CONFUSED, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_CRITICAL: { if (hp_player(60)) *ident = TRUE; if (clear_timed(TMD_BLIND, TRUE)) *ident = TRUE; if (clear_timed(TMD_CONFUSED, TRUE)) *ident = TRUE; if (clear_timed(TMD_POISONED, TRUE)) *ident = TRUE; if (clear_timed(TMD_STUN, TRUE)) *ident = TRUE; if (clear_timed(TMD_CUT, TRUE)) *ident = TRUE; if (clear_timed(TMD_AMNESIA, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_FULL: { int amt = (p_ptr->mhp * 35) / 100; if (amt < 300) amt = 300; if (hp_player(amt)) *ident = TRUE; if (clear_timed(TMD_BLIND, TRUE)) *ident = TRUE; if (clear_timed(TMD_CONFUSED, TRUE)) *ident = TRUE; if (clear_timed(TMD_POISONED, TRUE)) *ident = TRUE; if (clear_timed(TMD_STUN, TRUE)) *ident = TRUE; if (clear_timed(TMD_CUT, TRUE)) *ident = TRUE; if (clear_timed(TMD_AMNESIA, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_FULL2: { if (hp_player(1200)) *ident = TRUE; if (clear_timed(TMD_BLIND, TRUE)) *ident = TRUE; if (clear_timed(TMD_CONFUSED, TRUE)) *ident = TRUE; if (clear_timed(TMD_POISONED, TRUE)) *ident = TRUE; if (clear_timed(TMD_STUN, TRUE)) *ident = TRUE; if (clear_timed(TMD_CUT, TRUE)) *ident = TRUE; if (clear_timed(TMD_AMNESIA, TRUE)) *ident = TRUE; return TRUE; } case EF_CURE_TEMP: { if (clear_timed(TMD_BLIND, TRUE)) *ident = TRUE; if (clear_timed(TMD_POISONED, TRUE)) *ident = TRUE; if (clear_timed(TMD_CONFUSED, TRUE)) *ident = TRUE; if (clear_timed(TMD_STUN, TRUE)) *ident = TRUE; if (clear_timed(TMD_CUT, TRUE)) *ident = TRUE; return TRUE; } case EF_HEAL1: { if (hp_player(500)) *ident = TRUE; if (clear_timed(TMD_CUT, TRUE)) *ident = TRUE; return TRUE; } case EF_HEAL2: { if (hp_player(1000)) *ident = TRUE; if (clear_timed(TMD_CUT, TRUE)) *ident = TRUE; return TRUE; } case EF_HEAL3: { if (hp_player(500)) *ident = TRUE; if (clear_timed(TMD_STUN, TRUE)) *ident = TRUE; if (clear_timed(TMD_CUT, TRUE)) *ident = TRUE; return TRUE; } case EF_GAIN_EXP: { if (p_ptr->exp < PY_MAX_EXP) { msg("You feel more experienced."); player_exp_gain(p_ptr, 100000L); *ident = TRUE; } return TRUE; } case EF_LOSE_EXP: { if (!check_state(OF_HOLD_LIFE, p_ptr->state.flags) && (p_ptr->exp > 0)) { msg("You feel your memories fade."); player_exp_lose(p_ptr, p_ptr->exp / 4, FALSE); *ident = TRUE; } *ident = TRUE; wieldeds_notice_flag(OF_HOLD_LIFE); return TRUE; } case EF_RESTORE_EXP: { if (restore_level()) *ident = TRUE; return TRUE; } case EF_RESTORE_MANA: { if (p_ptr->csp < p_ptr->msp) { p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; msg("Your feel your head clear."); p_ptr->redraw |= (PR_MANA); *ident = TRUE; } return TRUE; } case EF_GAIN_STR: case EF_GAIN_INT: case EF_GAIN_WIS: case EF_GAIN_DEX: case EF_GAIN_CON: case EF_GAIN_CHR: { int stat = effect - EF_GAIN_STR; if (do_inc_stat(stat)) *ident = TRUE; return TRUE; } case EF_GAIN_ALL: { if (do_inc_stat(A_STR)) *ident = TRUE; if (do_inc_stat(A_INT)) *ident = TRUE; if (do_inc_stat(A_WIS)) *ident = TRUE; if (do_inc_stat(A_DEX)) *ident = TRUE; if (do_inc_stat(A_CON)) *ident = TRUE; if (do_inc_stat(A_CHR)) *ident = TRUE; return TRUE; } case EF_BRAWN: { /* Pick a random stat to decrease other than strength */ int stat = randint0(A_MAX-1) + 1; if (do_dec_stat(stat, TRUE)) { do_inc_stat(A_STR); *ident = TRUE; } return TRUE; } case EF_INTELLECT: { /* Pick a random stat to decrease other than intelligence */ int stat = randint0(A_MAX-1); if (stat >= A_INT) stat++; if (do_dec_stat(stat, TRUE)) { do_inc_stat(A_INT); *ident = TRUE; } return TRUE; } case EF_CONTEMPLATION: { /* Pick a random stat to decrease other than wisdom */ int stat = randint0(A_MAX-1); if (stat >= A_WIS) stat++; if (do_dec_stat(stat, TRUE)) { do_inc_stat(A_WIS); *ident = TRUE; } return TRUE; } case EF_TOUGHNESS: { /* Pick a random stat to decrease other than constitution */ int stat = randint0(A_MAX-1); if (stat >= A_CON) stat++; if (do_dec_stat(stat, TRUE)) { do_inc_stat(A_CON); *ident = TRUE; } return TRUE; } case EF_NIMBLENESS: { /* Pick a random stat to decrease other than dexterity */ int stat = randint0(A_MAX-1); if (stat >= A_DEX) stat++; if (do_dec_stat(stat, TRUE)) { do_inc_stat(A_DEX); *ident = TRUE; } return TRUE; } case EF_PLEASING: { /* Pick a random stat to decrease other than charisma */ int stat = randint0(A_MAX-1); if (do_dec_stat(stat, TRUE)) { do_inc_stat(A_CHR); *ident = TRUE; } return TRUE; } case EF_LOSE_STR: case EF_LOSE_INT: case EF_LOSE_WIS: case EF_LOSE_DEX: case EF_LOSE_CON: case EF_LOSE_CHR: { int stat = effect - EF_LOSE_STR; take_hit(damroll(5, 5), "stat drain"); (void)do_dec_stat(stat, FALSE); *ident = TRUE; return TRUE; } case EF_LOSE_CON2: { take_hit(damroll(10, 10), "poisonous food"); (void)do_dec_stat(A_CON, FALSE); *ident = TRUE; return TRUE; } case EF_RESTORE_STR: case EF_RESTORE_INT: case EF_RESTORE_WIS: case EF_RESTORE_DEX: case EF_RESTORE_CON: case EF_RESTORE_CHR: { int stat = effect - EF_RESTORE_STR; if (do_res_stat(stat)) *ident = TRUE; return TRUE; } case EF_CURE_NONORLYBIG: { msg("You feel life flow through your body!"); restore_level(); (void)clear_timed(TMD_POISONED, TRUE); (void)clear_timed(TMD_BLIND, TRUE); (void)clear_timed(TMD_CONFUSED, TRUE); (void)clear_timed(TMD_IMAGE, TRUE); (void)clear_timed(TMD_STUN, TRUE); (void)clear_timed(TMD_CUT, TRUE); (void)clear_timed(TMD_AMNESIA, TRUE); if (do_res_stat(A_STR)) *ident = TRUE; if (do_res_stat(A_INT)) *ident = TRUE; if (do_res_stat(A_WIS)) *ident = TRUE; if (do_res_stat(A_DEX)) *ident = TRUE; if (do_res_stat(A_CON)) *ident = TRUE; if (do_res_stat(A_CHR)) *ident = TRUE; /* Recalculate max. hitpoints */ update_stuff(); hp_player(5000); *ident = TRUE; return TRUE; } case EF_RESTORE_ALL: { /* Life, above, also gives these effects */ if (do_res_stat(A_STR)) *ident = TRUE; if (do_res_stat(A_INT)) *ident = TRUE; if (do_res_stat(A_WIS)) *ident = TRUE; if (do_res_stat(A_DEX)) *ident = TRUE; if (do_res_stat(A_CON)) *ident = TRUE; if (do_res_stat(A_CHR)) *ident = TRUE; return TRUE; } case EF_RESTORE_ST_LEV: { if (restore_level()) *ident = TRUE; if (do_res_stat(A_STR)) *ident = TRUE; if (do_res_stat(A_INT)) *ident = TRUE; if (do_res_stat(A_WIS)) *ident = TRUE; if (do_res_stat(A_DEX)) *ident = TRUE; if (do_res_stat(A_CON)) *ident = TRUE; if (do_res_stat(A_CHR)) *ident = TRUE; return TRUE; } case EF_TMD_INFRA: { if (inc_timed(TMD_SINFRA, 100 + damroll(4, 25), TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_TMD_SINVIS: { if (clear_timed(TMD_BLIND, TRUE)) *ident = TRUE; if (inc_timed(TMD_SINVIS, 12 + damroll(2, 6), TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_TMD_ESP: { if (clear_timed(TMD_BLIND, TRUE)) *ident = TRUE; if (inc_timed(TMD_TELEPATHY, 12 + damroll(6, 6), TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_ENLIGHTENMENT: { msg("An image of your surroundings forms in your mind..."); wiz_light(); *ident = TRUE; return TRUE; } case EF_ENLIGHTENMENT2: { msg("You begin to feel more enlightened..."); message_flush(); wiz_light(); (void)do_inc_stat(A_INT); (void)do_inc_stat(A_WIS); (void)detect_traps(TRUE); (void)detect_doorstairs(TRUE); (void)detect_treasure(TRUE); identify_pack(); *ident = TRUE; return TRUE; } case EF_HERO: { dur = randint1(25) + 25; if (hp_player(10)) *ident = TRUE; if (clear_timed(TMD_AFRAID, TRUE)) *ident = TRUE; if (inc_timed(TMD_BOLD, dur, TRUE, TRUE)) *ident = TRUE; if (inc_timed(TMD_HERO, dur, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_SHERO: { dur = randint1(25) + 25; if (hp_player(30)) *ident = TRUE; if (clear_timed(TMD_AFRAID, TRUE)) *ident = TRUE; if (inc_timed(TMD_BOLD, dur, TRUE, TRUE)) *ident = TRUE; if (inc_timed(TMD_SHERO, dur, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_RESIST_ACID: { if (inc_timed(TMD_OPP_ACID, randint1(10) + 10, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_RESIST_ELEC: { if (inc_timed(TMD_OPP_ELEC, randint1(10) + 10, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_RESIST_FIRE: { if (inc_timed(TMD_OPP_FIRE, randint1(10) + 10, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_RESIST_COLD: { if (inc_timed(TMD_OPP_COLD, randint1(10) + 10, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_RESIST_POIS: { if (inc_timed(TMD_OPP_POIS, randint1(10) + 10, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_RESIST_ALL: { if (inc_timed(TMD_OPP_ACID, randint1(20) + 20, TRUE, TRUE)) *ident = TRUE; if (inc_timed(TMD_OPP_ELEC, randint1(20) + 20, TRUE, TRUE)) *ident = TRUE; if (inc_timed(TMD_OPP_FIRE, randint1(20) + 20, TRUE, TRUE)) *ident = TRUE; if (inc_timed(TMD_OPP_COLD, randint1(20) + 20, TRUE, TRUE)) *ident = TRUE; if (inc_timed(TMD_OPP_POIS, randint1(20) + 20, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_DETECT_TREASURE: { if (detect_treasure(aware)) *ident = TRUE; return TRUE; } case EF_DETECT_TRAP: { if (detect_traps(aware)) *ident = TRUE; return TRUE; } case EF_DETECT_DOORSTAIR: { if (detect_doorstairs(aware)) *ident = TRUE; return TRUE; } case EF_DETECT_INVIS: { if (detect_monsters_invis(aware)) *ident = TRUE; return TRUE; } case EF_DETECT_EVIL: { if (detect_monsters_evil(aware)) *ident = TRUE; return TRUE; } case EF_DETECT_ALL: { if (detect_all(aware)) *ident = TRUE; return TRUE; } case EF_ENCHANT_TOHIT: { *ident = TRUE; return enchant_spell(1, 0, 0); } case EF_ENCHANT_TODAM: { *ident = TRUE; return enchant_spell(0, 1, 0); } case EF_ENCHANT_WEAPON: { *ident = TRUE; return enchant_spell(randint1(3), randint1(3), 0); } case EF_ENCHANT_ARMOR: { *ident = TRUE; return enchant_spell(0, 0, 1); } case EF_ENCHANT_ARMOR2: { *ident = TRUE; return enchant_spell(0, 0, randint1(3) + 2); } case EF_RESTORE_ITEM: { *ident = TRUE; return restore_item(); } case EF_IDENTIFY: { *ident = TRUE; if (!ident_spell()) return FALSE; return TRUE; } case EF_REMOVE_CURSE: { if (remove_curse()) { if (!p_ptr->timed[TMD_BLIND]) msg("The air around your body glows blue for a moment..."); else msg("You feel as if someone is watching over you."); *ident = TRUE; } return TRUE; } case EF_REMOVE_CURSE2: { remove_all_curse(); *ident = TRUE; return TRUE; } case EF_LIGHT: { if (light_area(damroll(2, 8), 2)) *ident = TRUE; return TRUE; } case EF_SUMMON_MON: { int i; sound(MSG_SUM_MONSTER); for (i = 0; i < randint1(3); i++) { if (summon_specific(py, px, p_ptr->depth, 0, 1)) *ident = TRUE; } return TRUE; } case EF_SUMMON_UNDEAD: { int i; sound(MSG_SUM_UNDEAD); for (i = 0; i < randint1(3); i++) { if (summon_specific(py, px, p_ptr->depth, S_UNDEAD, 1)) *ident = TRUE; } return TRUE; } case EF_TELE_PHASE: { teleport_player(10); *ident = TRUE; return TRUE; } case EF_TELE_LONG: { teleport_player(100); *ident = TRUE; return TRUE; } case EF_TELE_LEVEL: { (void)teleport_player_level(); *ident = TRUE; return TRUE; } case EF_CONFUSING: { if (p_ptr->confusing == 0) { msg("Your hands begin to glow."); p_ptr->confusing = TRUE; *ident = TRUE; } return TRUE; } case EF_MAPPING: { map_area(); *ident = TRUE; return TRUE; } case EF_RUNE: { warding_glyph(); *ident = TRUE; return TRUE; } case EF_ACQUIRE: { acquirement(py, px, p_ptr->depth, 1, TRUE); *ident = TRUE; return TRUE; } case EF_ACQUIRE2: { acquirement(py, px, p_ptr->depth, randint1(2) + 1, TRUE); *ident = TRUE; return TRUE; } case EF_ANNOY_MON: { msg("There is a high pitched humming noise."); aggravate_monsters(0); *ident = TRUE; return TRUE; } case EF_CREATE_TRAP: { /* Hack -- no traps in the town */ if (p_ptr->depth == 0) return TRUE; trap_creation(); msg("You hear a low-pitched whistling sound."); *ident = TRUE; return TRUE; } case EF_DESTROY_TDOORS: { if (destroy_doors_touch()) *ident = TRUE; return TRUE; } case EF_RECHARGE: { *ident = TRUE; if (!recharge(60)) return FALSE; return TRUE; } case EF_BANISHMENT: { *ident = TRUE; if (!banishment()) return FALSE; return TRUE; } case EF_DARKNESS: { if (!check_state(OF_RES_DARK, p_ptr->state.flags)) (void)inc_timed(TMD_BLIND, 3 + randint1(5), TRUE, TRUE); unlight_area(10, 3); wieldeds_notice_flag(OF_RES_DARK); *ident = TRUE; return TRUE; } case EF_PROTEVIL: { if (inc_timed(TMD_PROTEVIL, randint1(25) + 3 * p_ptr->lev, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_SATISFY: { if (set_food(PY_FOOD_MAX - 1)) *ident = TRUE; return TRUE; } case EF_CURSE_WEAPON: { if (curse_weapon()) *ident = TRUE; return TRUE; } case EF_CURSE_ARMOR: { if (curse_armor()) *ident = TRUE; return TRUE; } case EF_BLESSING: { if (inc_timed(TMD_BLESSED, randint1(12) + 6, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_BLESSING2: { if (inc_timed(TMD_BLESSED, randint1(24) + 12, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_BLESSING3: { if (inc_timed(TMD_BLESSED, randint1(48) + 24, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_RECALL: { set_recall(); *ident = TRUE; return TRUE; } case EF_DEEP_DESCENT: { int i, target_depth = p_ptr->depth; /* Calculate target depth */ for (i = 2; i > 0; i--) { if (is_quest(target_depth)) break; if (target_depth >= MAX_DEPTH - 1) break; target_depth++; } if (target_depth > p_ptr->depth) { msgt(MSG_TPLEVEL, "You sink through the floor..."); dungeon_change_level(target_depth); *ident = TRUE; return TRUE; } else { msgt(MSG_TPLEVEL, "You sense a malevolent presence blocking passage to the levels below."); *ident = TRUE; return FALSE; } } case EF_LOSHASTE: { if (speed_monsters()) *ident = TRUE; return TRUE; } case EF_LOSSLEEP: { if (sleep_monsters(aware)) *ident = TRUE; return TRUE; } case EF_LOSSLOW: { if (slow_monsters()) *ident = TRUE; return TRUE; } case EF_LOSCONF: { if (confuse_monsters(aware)) *ident = TRUE; return TRUE; } case EF_LOSKILL: { (void)mass_banishment(); *ident = TRUE; return TRUE; } case EF_EARTHQUAKES: { earthquake(py, px, 10); *ident = TRUE; return TRUE; } case EF_DESTRUCTION2: { destroy_area(py, px, 15, TRUE); *ident = TRUE; return TRUE; } case EF_ILLUMINATION: { if (light_area(damroll(2, 15), 3)) *ident = TRUE; return TRUE; } case EF_CLAIRVOYANCE: { *ident = TRUE; wiz_light(); (void)detect_traps(TRUE); (void)detect_doorstairs(TRUE); return TRUE; } case EF_PROBING: { *ident = probing(); return TRUE; } case EF_STONE_TO_MUD: { if (wall_to_mud(dir)) *ident = TRUE; return TRUE; } case EF_CONFUSE2: { *ident = TRUE; confuse_monster(dir, 20, aware); return TRUE; } case EF_BIZARRE: { *ident = TRUE; ring_of_power(dir); return TRUE; } case EF_STAR_BALL: { int i; *ident = TRUE; for (i = 0; i < 8; i++) fire_ball(GF_ELEC, ddd[i], (150 * (100 + boost) / 100), 3); return TRUE; } case EF_RAGE_BLESS_RESIST: { dur = randint1(50) + 50; *ident = TRUE; (void)hp_player(30); (void)clear_timed(TMD_AFRAID, TRUE); (void)inc_timed(TMD_BOLD, dur, TRUE, TRUE); (void)inc_timed(TMD_SHERO, dur, TRUE, TRUE); (void)inc_timed(TMD_BLESSED, randint1(50) + 50, TRUE, TRUE); (void)inc_timed(TMD_OPP_ACID, randint1(50) + 50, TRUE, TRUE); (void)inc_timed(TMD_OPP_ELEC, randint1(50) + 50, TRUE, TRUE); (void)inc_timed(TMD_OPP_FIRE, randint1(50) + 50, TRUE, TRUE); (void)inc_timed(TMD_OPP_COLD, randint1(50) + 50, TRUE, TRUE); (void)inc_timed(TMD_OPP_POIS, randint1(50) + 50, TRUE, TRUE); return TRUE; } case EF_SLEEPII: { *ident = TRUE; sleep_monsters_touch(aware); return TRUE; } case EF_RESTORE_LIFE: { *ident = TRUE; restore_level(); return TRUE; } case EF_MISSILE: { *ident = TRUE; dam = damroll(3, 4) * (100 + boost) / 100; fire_bolt_or_beam(beam, GF_MISSILE, dir, dam); return TRUE; } case EF_DISPEL_EVIL: { *ident = TRUE; dam = p_ptr->lev * 5 * (100 + boost) / 100; dispel_evil(dam); return TRUE; } case EF_DISPEL_EVIL60: { dam = 60 * (100 + boost) / 100; if (dispel_evil(dam)) *ident = TRUE; return TRUE; } case EF_DISPEL_UNDEAD: { dam = 60 * (100 + boost) / 100; if (dispel_undead(dam)) *ident = TRUE; return TRUE; } case EF_DISPEL_ALL: { dam = 120 * (100 + boost) / 100; if (dispel_monsters(dam)) *ident = TRUE; return TRUE; } case EF_HASTE: { if (!p_ptr->timed[TMD_FAST]) { if (set_timed(TMD_FAST, damroll(2, 10) + 20, TRUE)) *ident = TRUE; } else { (void)inc_timed(TMD_FAST, 5, TRUE, TRUE); } return TRUE; } case EF_HASTE1: { if (!p_ptr->timed[TMD_FAST]) { if (set_timed(TMD_FAST, randint1(20) + 20, TRUE)) *ident = TRUE; } else { (void)inc_timed(TMD_FAST, 5, TRUE, TRUE); } return TRUE; } case EF_HASTE2: { if (!p_ptr->timed[TMD_FAST]) { if (set_timed(TMD_FAST, randint1(75) + 75, TRUE)) *ident = TRUE; } else { (void)inc_timed(TMD_FAST, 5, TRUE, TRUE); } return TRUE; } case EF_FIRE_BOLT: { *ident = TRUE; dam = damroll(9, 8) * (100 + boost) / 100; fire_bolt(GF_FIRE, dir, dam); return TRUE; } case EF_FIRE_BOLT2: { dam = damroll(12, 8) * (100 + boost) / 100; fire_bolt_or_beam(beam, GF_FIRE, dir, dam); *ident = TRUE; return TRUE; } case EF_FIRE_BOLT3: { dam = damroll(16, 8) * (100 + boost) / 100; fire_bolt_or_beam(beam, GF_FIRE, dir, dam); *ident = TRUE; return TRUE; } case EF_FIRE_BOLT72: { dam = 72 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_FIRE, dir, dam, 2); return TRUE; } case EF_FIRE_BALL: { dam = 144 * (100 + boost) / 100; fire_ball(GF_FIRE, dir, dam, 2); *ident = TRUE; return TRUE; } case EF_FIRE_BALL2: { dam = 120 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_FIRE, dir, dam, 3); return TRUE; } case EF_FIRE_BALL200: { dam = 200 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_FIRE, dir, dam, 3); return TRUE; } case EF_COLD_BOLT: { dam = damroll(6, 8) * (100 + boost) / 100; *ident = TRUE; fire_bolt_or_beam(beam, GF_COLD, dir, dam); return TRUE; } case EF_COLD_BOLT2: { dam = damroll(12, 8) * (100 + boost) / 100; *ident = TRUE; fire_bolt(GF_COLD, dir, dam); return TRUE; } case EF_COLD_BALL2: { dam = 200 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_COLD, dir, dam, 3); return TRUE; } case EF_COLD_BALL50: { dam = 50 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_COLD, dir, dam, 2); return TRUE; } case EF_COLD_BALL100: { dam = 100 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_COLD, dir, dam, 2); return TRUE; } case EF_COLD_BALL160: { dam = 160 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_COLD, dir, dam, 3); return TRUE; } case EF_ACID_BOLT: { dam = damroll(5, 8) * (100 + boost) / 100; *ident = TRUE; fire_bolt(GF_ACID, dir, dam); return TRUE; } case EF_ACID_BOLT2: { dam = damroll(10, 8) * (100 + boost) / 100; fire_bolt_or_beam(beam, GF_ACID, dir, dam); *ident = TRUE; return TRUE; } case EF_ACID_BOLT3: { dam = damroll(12, 8) * (100 + boost) / 100; fire_bolt_or_beam(beam, GF_ACID, dir, dam); *ident = TRUE; return TRUE; } case EF_ACID_BALL: { dam = 120 * (100 + boost) / 100; fire_ball(GF_ACID, dir, dam, 2); *ident = TRUE; return TRUE; } case EF_ELEC_BOLT: { dam = damroll(6, 6) * (100 + boost) / 100; *ident = TRUE; fire_beam(GF_ELEC, dir, dam); return TRUE; } case EF_ELEC_BALL: { dam = 64 * (100 + boost) / 100; fire_ball(GF_ELEC, dir, dam, 2); *ident = TRUE; return TRUE; } case EF_ELEC_BALL2: { dam = 250 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_ELEC, dir, dam, 3); return TRUE; } case EF_ARROW: { dam = 150 * (100 + boost) / 100; *ident = TRUE; fire_bolt(GF_ARROW, dir, dam); return TRUE; } case EF_REM_FEAR_POIS: { *ident = TRUE; (void)clear_timed(TMD_AFRAID, TRUE); (void)clear_timed(TMD_POISONED, TRUE); return TRUE; } case EF_STINKING_CLOUD: { dam = 12 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_POIS, dir, dam, 3); return TRUE; } case EF_DRAIN_LIFE1: { dam = 90 * (100 + boost) / 100; if (drain_life(dir, dam)) *ident = TRUE; return TRUE; } case EF_DRAIN_LIFE2: { dam = 120 * (100 + boost) / 100; if (drain_life(dir, dam)) *ident = TRUE; return TRUE; } case EF_DRAIN_LIFE3: { dam = 150 * (100 + boost) / 100; if (drain_life(dir, dam)) *ident = TRUE; return TRUE; } case EF_DRAIN_LIFE4: { dam = 250 * (100 + boost) / 100; if (drain_life(dir, dam)) *ident = TRUE; return TRUE; } case EF_FIREBRAND: { *ident = TRUE; if (!brand_bolts()) return FALSE; return TRUE; } case EF_MANA_BOLT: { dam = damroll(12, 8) * (100 + boost) / 100; fire_bolt(GF_MANA, dir, dam); *ident = TRUE; return TRUE; } case EF_MON_HEAL: { if (heal_monster(dir)) *ident = TRUE; return TRUE; } case EF_MON_HASTE: { if (speed_monster(dir)) *ident = TRUE; return TRUE; } case EF_MON_SLOW: { if (slow_monster(dir)) *ident = TRUE; return TRUE; } case EF_MON_CONFUSE: { if (confuse_monster(dir, 10, aware)) *ident = TRUE; return TRUE; } case EF_MON_SLEEP: { if (sleep_monster(dir, aware)) *ident = TRUE; return TRUE; } case EF_MON_CLONE: { if (clone_monster(dir)) *ident = TRUE; return TRUE; } case EF_MON_SCARE: { if (fear_monster(dir, 10, aware)) *ident = TRUE; return TRUE; } case EF_LIGHT_LINE: { msg("A line of shimmering blue light appears."); light_line(dir); *ident = TRUE; return TRUE; } case EF_TELE_OTHER: { if (teleport_monster(dir)) *ident = TRUE; return TRUE; } case EF_DISARMING: { if (disarm_trap(dir)) *ident = TRUE; return TRUE; } case EF_TDOOR_DEST: { if (destroy_door(dir)) *ident = TRUE; return TRUE; } case EF_POLYMORPH: { if (poly_monster(dir)) *ident = TRUE; return TRUE; } case EF_STARLIGHT: { int i; if (!p_ptr->timed[TMD_BLIND]) msg("Light shoots in all directions!"); for (i = 0; i < 8; i++) light_line(ddd[i]); *ident = TRUE; return TRUE; } case EF_STARLIGHT2: { int k; for (k = 0; k < 8; k++) strong_light_line(ddd[k]); *ident = TRUE; return TRUE; } case EF_BERSERKER: { dur = randint1(50) + 50; if (inc_timed(TMD_BOLD, dur, TRUE, TRUE)) *ident = TRUE; if (inc_timed(TMD_SHERO, dur, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_WONDER: { if (effect_wonder(dir, randint1(100) + p_ptr->lev / 5, beam)) *ident = TRUE; return TRUE; } case EF_WAND_BREATH: { /* table of random ball effects and their damages */ const int breath_types[] = { GF_ACID, 200, GF_ELEC, 160, GF_FIRE, 200, GF_COLD, 160, GF_POIS, 120 }; /* pick a random (type, damage) tuple in the table */ int which = 2 * randint0(sizeof(breath_types) / (2 * sizeof(int))); fire_ball(breath_types[which], dir, breath_types[which + 1], 3); *ident = TRUE; return TRUE; } case EF_STAFF_MAGI: { if (do_res_stat(A_INT)) *ident = TRUE; if (p_ptr->csp < p_ptr->msp) { p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; *ident = TRUE; msg("Your feel your head clear."); p_ptr->redraw |= (PR_MANA); } return TRUE; } case EF_STAFF_HOLY: { dam = 120 * (100 + boost) / 100; if (dispel_evil(dam)) *ident = TRUE; if (inc_timed(TMD_PROTEVIL, randint1(25) + 3 * p_ptr->lev, TRUE, TRUE)) *ident = TRUE; if (clear_timed(TMD_POISONED, TRUE)) *ident = TRUE; if (clear_timed(TMD_AFRAID, TRUE)) *ident = TRUE; if (hp_player(50)) *ident = TRUE; if (clear_timed(TMD_STUN, TRUE)) *ident = TRUE; if (clear_timed(TMD_CUT, TRUE)) *ident = TRUE; return TRUE; } case EF_DRINK_BREATH: { const int breath_types[] = { GF_FIRE, 80, GF_COLD, 80, }; int which = 2 * randint0(N_ELEMENTS(breath_types) / 2); fire_ball(breath_types[which], dir, breath_types[which + 1], 2); *ident = TRUE; return TRUE; } case EF_DRINK_GOOD: { msg("You feel less thirsty."); *ident = TRUE; return TRUE; } case EF_DRINK_DEATH: { msg("A feeling of Death flows through your body."); take_hit(5000, "a potion of Death"); *ident = TRUE; return TRUE; } case EF_DRINK_RUIN: { msg("Your nerves and muscles feel weak and lifeless!"); take_hit(damroll(10, 10), "a potion of Ruination"); player_stat_dec(p_ptr, A_DEX, TRUE); player_stat_dec(p_ptr, A_WIS, TRUE); player_stat_dec(p_ptr, A_CON, TRUE); player_stat_dec(p_ptr, A_STR, TRUE); player_stat_dec(p_ptr, A_CHR, TRUE); player_stat_dec(p_ptr, A_INT, TRUE); *ident = TRUE; return TRUE; } case EF_DRINK_DETONATE: { msg("Massive explosions rupture your body!"); take_hit(damroll(50, 20), "a potion of Detonation"); (void)inc_timed(TMD_STUN, 75, TRUE, TRUE); (void)inc_timed(TMD_CUT, 5000, TRUE, TRUE); *ident = TRUE; return TRUE; } case EF_DRINK_SALT: { msg("The potion makes you vomit!"); (void)set_food(PY_FOOD_STARVE - 1); (void)clear_timed(TMD_POISONED, TRUE); (void)inc_timed(TMD_PARALYZED, 4, TRUE, FALSE); *ident = TRUE; return TRUE; } case EF_FOOD_GOOD: { msg("That tastes good."); *ident = TRUE; return TRUE; } case EF_FOOD_WAYBREAD: { msg("That tastes good."); (void)clear_timed(TMD_POISONED, TRUE); (void)hp_player(damroll(4, 8)); *ident = TRUE; return TRUE; } case EF_SHROOM_EMERGENCY: { (void)set_timed(TMD_IMAGE, rand_spread(250, 50), TRUE); (void)set_timed(TMD_OPP_FIRE, rand_spread(30, 10), TRUE); (void)set_timed(TMD_OPP_COLD, rand_spread(30, 10), TRUE); (void)hp_player(200); *ident = TRUE; return TRUE; } case EF_SHROOM_TERROR: { if (set_timed(TMD_TERROR, rand_spread(100, 20), TRUE)) *ident = TRUE; return TRUE; } case EF_SHROOM_STONE: { if (set_timed(TMD_STONESKIN, rand_spread(80, 20), TRUE)) *ident = TRUE; return TRUE; } case EF_SHROOM_DEBILITY: { int stat = one_in_(2) ? A_STR : A_CON; if (p_ptr->csp < p_ptr->msp) { p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; msg("Your feel your head clear."); p_ptr->redraw |= (PR_MANA); *ident = TRUE; } (void)do_dec_stat(stat, FALSE); *ident = TRUE; return TRUE; } case EF_SHROOM_SPRINTING: { if (inc_timed(TMD_SPRINT, 100, TRUE, TRUE)) *ident = TRUE; return TRUE; } case EF_SHROOM_PURGING: { (void)set_food(PY_FOOD_FAINT - 1); if (do_res_stat(A_STR)) *ident = TRUE; if (do_res_stat(A_CON)) *ident = TRUE; if (clear_timed(TMD_POISONED, TRUE)) *ident = TRUE; return TRUE; } case EF_RING_ACID: { dam = 70 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_ACID, dir, dam, 2); inc_timed(TMD_OPP_ACID, randint1(20) + 20, TRUE, TRUE); return TRUE; } case EF_RING_FLAMES: { dam = 80 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_FIRE, dir, dam, 2); inc_timed(TMD_OPP_FIRE, randint1(20) + 20, TRUE, TRUE); return TRUE; } case EF_RING_ICE: { dam = 75 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_COLD, dir, dam, 2); inc_timed(TMD_OPP_COLD, randint1(20) + 20, TRUE, TRUE); return TRUE; } case EF_RING_LIGHTNING: { dam = 85 * (100 + boost) / 100; *ident = TRUE; fire_ball(GF_ELEC, dir, dam, 2); inc_timed(TMD_OPP_ELEC, randint1(20) + 20, TRUE, TRUE); return TRUE; } case EF_DRAGON_BLUE: { dam = 100 * (100 + boost) / 100; msgt(MSG_BR_ELEC, "You breathe lightning."); fire_ball(GF_ELEC, dir, dam, 2); return TRUE; } case EF_DRAGON_GREEN: { dam = 150 * (100 + boost) / 100; msgt(MSG_BR_GAS, "You breathe poison gas."); fire_ball(GF_POIS, dir, dam, 2); return TRUE; } case EF_DRAGON_RED: { dam = 200 * (100 + boost) / 100; msgt(MSG_BR_FIRE, "You breathe fire."); fire_ball(GF_FIRE, dir, dam, 2); return TRUE; } case EF_DRAGON_MULTIHUED: { static const struct { int msg_sound; const char *msg; int typ; } mh[] = { { MSG_BR_ELEC, "lightning", GF_ELEC }, { MSG_BR_FROST, "frost", GF_COLD }, { MSG_BR_ACID, "acid", GF_ACID }, { MSG_BR_GAS, "poison gas", GF_POIS }, { MSG_BR_FIRE, "fire", GF_FIRE } }; int chance = randint0(5); dam = 250 * (100 + boost) / 100; msgt(mh[chance].msg_sound, "You breathe %s.", mh[chance].msg); fire_ball(mh[chance].typ, dir, dam, 2); return TRUE; } case EF_DRAGON_BRONZE: { dam = 120 * (100 + boost) / 100; msgt(MSG_BR_CONF, "You breathe confusion."); fire_ball(GF_CONFU, dir, dam, 2); return TRUE; } case EF_DRAGON_GOLD: { dam = 130 * (100 + boost) / 100; msgt(MSG_BR_SOUND, "You breathe sound."); fire_ball(GF_SOUND, dir, dam, 2); return TRUE; } case EF_DRAGON_CHAOS: { dam = 220 * (100 + boost) / 100; chance = randint0(2); msgt((chance == 1 ? MSG_BR_CHAOS : MSG_BR_DISEN), "You breathe %s.", ((chance == 1 ? "chaos" : "disenchantment"))); fire_ball((chance == 1 ? GF_CHAOS : GF_DISEN), dir, dam, 2); return TRUE; } case EF_DRAGON_LAW: { dam = 230 * (100 + boost) / 100; chance = randint0(2); msgt((chance == 1 ? MSG_BR_SOUND : MSG_BR_SHARDS), "You breathe %s.", ((chance == 1 ? "sound" : "shards"))); fire_ball((chance == 1 ? GF_SOUND : GF_SHARD), dir, dam, 2); return TRUE; } case EF_DRAGON_BALANCE: { dam = 250 * (100 + boost) / 100; chance = randint0(4); msg("You breathe %s.", ((chance == 1) ? "chaos" : ((chance == 2) ? "disenchantment" : ((chance == 3) ? "sound" : "shards")))); fire_ball(((chance == 1) ? GF_CHAOS : ((chance == 2) ? GF_DISEN : ((chance == 3) ? GF_SOUND : GF_SHARD))), dir, dam, 2); return TRUE; } case EF_DRAGON_SHINING: { dam = 200 * (100 + boost) / 100; chance = randint0(2); msgt((chance == 0 ? MSG_BR_LIGHT : MSG_BR_DARK), "You breathe %s.", ((chance == 0 ? "light" : "darkness"))); fire_ball((chance == 0 ? GF_LIGHT : GF_DARK), dir, dam, 2); return TRUE; } case EF_DRAGON_POWER: { dam = 300 * (100 + boost) / 100; msgt(MSG_BR_ELEMENTS, "You breathe the elements."); fire_ball(GF_MISSILE, dir, dam, 2); return TRUE; } case EF_TRAP_DOOR: { msg("You fall through a trap door!"); if (check_state(OF_FEATHER, p_ptr->state.flags)) { msg("You float gently down to the next level."); } else { take_hit(damroll(2, 8), "a trap"); } wieldeds_notice_flag(OF_FEATHER); dungeon_change_level(p_ptr->depth + 1); return TRUE; } case EF_TRAP_PIT: { msg("You fall into a pit!"); if (check_state(OF_FEATHER, p_ptr->state.flags)) { msg("You float gently to the bottom of the pit."); } else { take_hit(damroll(2, 6), "a trap"); } wieldeds_notice_flag(OF_FEATHER); return TRUE; } case EF_TRAP_PIT_SPIKES: { msg("You fall into a spiked pit!"); if (check_state(OF_FEATHER, p_ptr->state.flags)) { msg("You float gently to the floor of the pit."); msg("You carefully avoid touching the spikes."); } else { int dam = damroll(2, 6); /* Extra spike damage */ if (one_in_(2)) { msg("You are impaled!"); dam *= 2; (void)inc_timed(TMD_CUT, randint1(dam), TRUE, TRUE); } take_hit(dam, "a trap"); } wieldeds_notice_flag(OF_FEATHER); return TRUE; } case EF_TRAP_PIT_POISON: { msg("You fall into a spiked pit!"); if (check_state(OF_FEATHER, p_ptr->state.flags)) { msg("You float gently to the floor of the pit."); msg("You carefully avoid touching the spikes."); } else { int dam = damroll(2, 6); /* Extra spike damage */ if (one_in_(2)) { msg("You are impaled on poisonous spikes!"); (void)inc_timed(TMD_CUT, randint1(dam * 2), TRUE, TRUE); (void)inc_timed(TMD_POISONED, randint1(dam * 4), TRUE, TRUE); } take_hit(dam, "a trap"); } wieldeds_notice_flag(OF_FEATHER); return TRUE; } case EF_TRAP_RUNE_SUMMON: { int i; int num = 2 + randint1(3); msgt(MSG_SUM_MONSTER, "You are enveloped in a cloud of smoke!"); /* Remove trap */ cave->info[py][px] &= ~(CAVE_MARK); cave_set_feat(cave, py, px, FEAT_FLOOR); for (i = 0; i < num; i++) (void)summon_specific(py, px, p_ptr->depth, 0, 1); break; } case EF_TRAP_RUNE_TELEPORT: { msg("You hit a teleport trap!"); teleport_player(100); return TRUE; } case EF_TRAP_SPOT_FIRE: { int dam; msg("You are enveloped in flames!"); dam = damroll(4, 6); dam = adjust_dam(GF_FIRE, dam, RANDOMISE, check_for_resist(GF_FIRE, p_ptr->state.flags, TRUE)); if (dam) { take_hit(dam, "a fire trap"); inven_damage(GF_FIRE, MIN(dam * 5, 300)); } return TRUE; } case EF_TRAP_SPOT_ACID: { int dam; msg("You are splashed with acid!"); dam = damroll(4, 6); dam = adjust_dam(GF_ACID, dam, RANDOMISE, check_for_resist(GF_ACID, p_ptr->state.flags, TRUE)); if (dam) { take_hit(dam, "an acid trap"); inven_damage(GF_ACID, MIN(dam * 5, 300)); } return TRUE; } case EF_TRAP_DART_SLOW: { if (trap_check_hit(125)) { msg("A small dart hits you!"); take_hit(damroll(1, 4), "a trap"); (void)inc_timed(TMD_SLOW, randint0(20) + 20, TRUE, FALSE); } else { msg("A small dart barely misses you."); } return TRUE; } case EF_TRAP_DART_LOSE_STR: { if (trap_check_hit(125)) { msg("A small dart hits you!"); take_hit(damroll(1, 4), "a trap"); (void)do_dec_stat(A_STR, FALSE); } else { msg("A small dart barely misses you."); } return TRUE; } case EF_TRAP_DART_LOSE_DEX: { if (trap_check_hit(125)) { msg("A small dart hits you!"); take_hit(damroll(1, 4), "a trap"); (void)do_dec_stat(A_DEX, FALSE); } else { msg("A small dart barely misses you."); } return TRUE; } case EF_TRAP_DART_LOSE_CON: { if (trap_check_hit(125)) { msg("A small dart hits you!"); take_hit(damroll(1, 4), "a trap"); (void)do_dec_stat(A_CON, FALSE); } else { msg("A small dart barely misses you."); } return TRUE; } case EF_TRAP_GAS_BLIND: { msg("You are surrounded by a black gas!"); (void)inc_timed(TMD_BLIND, randint0(50) + 25, TRUE, TRUE); return TRUE; } case EF_TRAP_GAS_CONFUSE: { msg("You are surrounded by a gas of scintillating colors!"); (void)inc_timed(TMD_CONFUSED, randint0(20) + 10, TRUE, TRUE); return TRUE; } case EF_TRAP_GAS_POISON: { msg("You are surrounded by a pungent green gas!"); (void)inc_timed(TMD_POISONED, randint0(20) + 10, TRUE, TRUE); return TRUE; } case EF_TRAP_GAS_SLEEP: { msg("You are surrounded by a strange white mist!"); (void)inc_timed(TMD_PARALYZED, randint0(10) + 5, TRUE, TRUE); return TRUE; } case EF_XXX: case EF_MAX: break; } /* Not used */ msg("Effect not handled."); return FALSE; }
int running_machine::run(bool firstrun) { int error = MAMERR_NONE; // use try/catch for deep error recovery try { // move to the init phase m_current_phase = MACHINE_PHASE_INIT; // if we have a logfile, set up the callback if (options().log()) { m_logfile = auto_alloc(*this, emu_file(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)); file_error filerr = m_logfile->open("error.log"); assert_always(filerr == FILERR_NONE, "unable to open log file"); add_logerror_callback(logfile_callback); } // then finish setting up our local machine start(); // load the configuration settings and NVRAM bool settingsloaded = config_load_settings(*this); nvram_load(*this); sound().ui_mute(false); // display the startup screens ui_display_startup_screens(*this, firstrun, !settingsloaded); // perform a soft reset -- this takes us to the running phase soft_reset(); // run the CPUs until a reset or exit m_hard_reset_pending = false; while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE) { g_profiler.start(PROFILER_EXTRA); // execute CPUs if not paused if (!m_paused) m_scheduler.timeslice(); // otherwise, just pump video updates through else m_video->frame_update(); // handle save/load if (m_saveload_schedule != SLS_NONE) handle_saveload(); g_profiler.stop(); } // and out via the exit phase m_current_phase = MACHINE_PHASE_EXIT; // save the NVRAM and configuration sound().ui_mute(true); nvram_save(*this); config_save_settings(*this); } catch (emu_fatalerror &fatal) { mame_printf_error("%s\n", fatal.string()); error = MAMERR_FATALERROR; if (fatal.exitcode() != 0) error = fatal.exitcode(); } catch (emu_exception &) { mame_printf_error("Caught unhandled emulator exception\n"); error = MAMERR_FATALERROR; } catch (std::bad_alloc &) { mame_printf_error("Out of memory!\n"); error = MAMERR_FATALERROR; } // call all exit callbacks registered call_notifiers(MACHINE_NOTIFY_EXIT); zip_file_cache_clear(); // close the logfile auto_free(*this, m_logfile); return error; }
//Continous play without stopping previous sound void cplay(int tone, int del){ sound(tone); delay(del); }
void GrappleAnchor() { gedict_t *owner = PROG_TO_EDICT( self->s.v.owner ); if (other == owner) return; // DO NOT allow the grapple to hook to any projectiles, no matter WHAT! // if you create new types of projectiles, make sure you use one of the // classnames below or write code to exclude your new classname so // grapples will not stick to them. if ( streq(other->s.v.classname, "rocket") || streq(other->s.v.classname, "grenade") || streq(other->s.v.classname, "spike" ) || streq(other->s.v.classname, "hook" )) return; if ( other->ct == ctPlayer ) { // grappling players in prewar is annoying if ( match_in_progress != 2 || (tp_num() == 4 && streq(getteam(other), getteam(owner))) ) { GrappleReset( self ); return; } sound ( self, CHAN_WEAPON, "player/axhit1.wav", 1, ATTN_NORM ); // previously 10 damage per hit, but at close range that could be exploited other->deathtype = dtHOOK; T_Damage ( other, self, owner, 1 ); // make hook invisible since we will be pulling directly // towards the player the hook hit. Quakeworld makes it // too quirky to try to match hook's velocity with that of // the client that it hit. setmodel ( self, "" ); } else { sound ( self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM ); // One point of damage inflicted upon impact. Subsequent // damage will only be done to PLAYERS... this way secret // doors and triggers will only be damaged once. if ( other->s.v.takedamage ) { other->deathtype = dtHOOK; T_Damage ( other, self, owner, 1 ); } SetVector( self->s.v.velocity , 0, 0, 0 ); SetVector( self->s.v.avelocity, 0, 0, 0 ); } // conveniently clears the sound channel of the CHAIN1 sound, // which is a looping sample and would continue to play. Tink1 is // the least offensive choice, as NULL.WAV loops and clogs the // channel with silence sound ( owner, CHAN_NO_PHS_ADD + CHAN_WEAPON, "weapons/tink1.wav", 1, ATTN_NORM ); if ( !owner->s.v.button0 ) { GrappleReset( self ); return; } if ( (int)owner->s.v.flags & FL_ONGROUND ) owner->s.v.flags -= FL_ONGROUND; owner->on_hook = true; sound ( owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM ); owner->ctf_sound = true; self->s.v.enemy = EDICT_TO_PROG( other ); self->s.v.think = (func_t) GrappleTrack; self->s.v.nextthink = g_globalvars.time; self->s.v.solid = SOLID_NOT; self->s.v.touch = (func_t) SUB_Null; }
void sounds::ambient_sound( const tripoint &p, int vol, std::string description ) { sound( p, vol, description, true ); }
void World::buildScene() { // Initialize layers for(std::size_t i = 0; i < LayerCount; ++i) { Category::Type type = (i == (int)Entities) ? Category::EntityLayer : Category::None; SceneNode::Ptr layer(new SceneNode(type)); mSceneLayers[i] = layer.get(); mSceneGraph.attachChild(std::move(layer)); } // Background std::unique_ptr<SpriteNode> background(new SpriteNode(mTextures.get(Textures::Background))); background->setScale(sf::Vector2f(2.f, 2.f)); mSceneLayers[Background]->attachChild(std::move(background)); // Tilemap for(int i = 0; i < 8; ++i) { for(int j = 0; j < 8; ++j) { std::unique_ptr<SpriteNode> tile(new SpriteNode(mTextures.get(Textures::Tile))); tile->setPosition(toIsoCoord(j, i)); mSceneLayers[Tilemap]->attachChild(std::move(tile)); } } // Camera std::unique_ptr<CameraNode> camera(new CameraNode(mWorldView)); mSceneGraph.attachChild(std::move(camera)); // Sounds std::unique_ptr<SoundNode> sound(new SoundNode(mSounds)); mSceneLayers[Decorations]->attachChild(std::move(sound)); // Help std::unique_ptr<HelpNode> help(new HelpNode(mTextures)); mSceneGraph.attachChild(std::move(help)); // Add the Traplist Node, that handle trap creation std::unique_ptr<TraplistNode> traplist(new TraplistNode(mTextures, mFonts)); mSceneLayers[Entities]->attachChild(std::move(traplist)); Command cmd; cmd.action = derivedAction<TraplistNode>([](TraplistNode& node, sf::Time dt) { node.generateTraps(5); }); cmd.category = Category::Traplist; mCommandQueue.push(cmd); // Player std::unique_ptr<PlayerEntity> player(new PlayerEntity(mTextures)); player->setPosition(toIsoCoord(1, 1)); player->setGridPosition(sf::Vector2i(1, 1)); mPlayer = player.get(); std::unique_ptr<BubbleNode> bubble(new BubbleNode(mTextures, mFonts)); mPlayer->setBubble(bubble.get()); bubble->setString("KILL KIDS! EXTEMINATE!"); player->attachChild(std::move(bubble)); mSceneLayers[Entities]->attachChild(std::move(player)); // Ennemies /*std::unique_ptr<BasicKidNode> kid(new BasicKidNode(mTextures)); kid->setPosition(toIsoCoord(0, 0)); kid->setGridPosition(sf::Vector2i(0, 0)); mSceneLayers[Entities]->attachChild(std::move(kid)); kid.reset(new BasicKidNode(mTextures)); kid->setPosition(toIsoCoord(0, 2)); kid->setGridPosition(sf::Vector2i(0, 2)); mSceneLayers[Entities]->attachChild(std::move(kid));*/ // Waves & Points std::unique_ptr<WaveGenerator> waves(new WaveGenerator(mTextures, mFonts, mMusic)); waves->nextWave(); mSceneLayers[Entities]->attachChild(std::move(waves)); }
int main() { // GLFWの初期化 if (!glfwInit()) return -1; // GLFW Widnowを用意 GLFWwindow* window = glfwCreateWindow(640, 480, "Play WAV fie", nullptr, nullptr); // Windowsを生成できなければ終了 if (!window) { glfwTerminate(); return -1; } // 用意したWindowsでOpenGLが使えるようにする // これで、OpenGLの命令が有効になる glfwMakeContextCurrent(window); // 描画のタイミングを画面更新と同期 glfwSwapInterval(1); // OpenALの初期化 ALCdevice* device = alcOpenDevice(nullptr); ALCcontext* context = alcCreateContext(device, nullptr); alcMakeContextCurrent(context); // バッファの生成 ALuint buffer_id; alGenBuffers(1, &buffer_id); // WAVデータを読み込む Wav sound("res/lovelive.wav"); // 読み込んだWAVデータの波形をバッファにコピー alBufferData(buffer_id, // ステレオ or モノラル sound.isStereo() ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16, sound.data(), // リニアPCM形式データ sound.size(), // サイズ(バイト数) sound.sampleRate()); // サンプリングレート // ソースの生成 ALuint source_id; alGenSources(1, &source_id); // ソースに再生したいバッファを割り当てる alSourcei(source_id, AL_BUFFER, buffer_id); // ピッチ変更 alSourcef(source_id, AL_PITCH, -1.0); // ループ再生ON alSourcei(source_id, AL_LOOPING, AL_TRUE); // ソースの再生開始 alSourcePlay(source_id); // Windowが閉じられるまで繰り返す while (!glfwWindowShouldClose(window)) { // 描画領域をクリア glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); // 画面とバックバッファを入れ替える glfwSwapBuffers(window); // キー入力などのイベント処理 glfwPollEvents(); } // ソースの破棄 alDeleteSources(1, &source_id); // バッファの破棄 alDeleteBuffers(1, &buffer_id); // OpenALの後始末 alcMakeContextCurrent(nullptr); alcDestroyContext(context); alcCloseDevice(device); // GLFWの後始末 glfwTerminate(); return 0; }
/** * This is a helper function used by do_cmd_throw and do_cmd_fire. * * It abstracts out the projectile path, display code, identify and clean up * logic, while using the 'attack' parameter to do work particular to each * kind of attack. */ static void ranged_helper(int item, int dir, int range, int shots, ranged_attack attack) { /* Get the ammo */ object_type *o_ptr = object_from_item_idx(item); int i, j; byte missile_attr = object_attr(o_ptr); char missile_char = object_char(o_ptr); object_type object_type_body; object_type *i_ptr = &object_type_body; char o_name[80]; int path_n; u16b path_g[256]; int msec = op_ptr->delay_factor; /* Start at the player */ int x = p_ptr->px; int y = p_ptr->py; /* Predict the "target" location */ s16b ty = y + 99 * ddy[dir]; s16b tx = x + 99 * ddx[dir]; bool hit_target = FALSE; /* Check for target validity */ if ((dir == 5) && target_okay()) { int taim; char msg[80]; target_get(&tx, &ty); taim = distance(y, x, ty, tx); if (taim > range) { sprintf (msg, "Target out of range by %d squares. Fire anyway? ", taim - range); if (!get_check(msg)) return; } } /* Sound */ sound(MSG_SHOOT); object_notice_on_firing(o_ptr); /* Describe the object */ object_desc(o_name, sizeof(o_name), o_ptr, ODESC_FULL | ODESC_SINGULAR); /* Actually "fire" the object -- Take a partial turn */ p_ptr->energy_use = (100 / shots); /* Calculate the path */ path_n = project_path(path_g, range, y, x, ty, tx, 0); /* Hack -- Handle stuff */ handle_stuff(p_ptr); /* Start at the player */ x = p_ptr->px; y = p_ptr->py; /* Project along the path */ for (i = 0; i < path_n; ++i) { int ny = GRID_Y(path_g[i]); int nx = GRID_X(path_g[i]); /* Hack -- Stop before hitting walls */ if (!cave_floor_bold(ny, nx)) break; /* Advance */ x = nx; y = ny; /* Only do visuals if the player can "see" the missile */ if (player_can_see_bold(y, x)) { print_rel(missile_char, missile_attr, y, x); move_cursor_relative(y, x); Term_fresh(); if (p_ptr->redraw) redraw_stuff(p_ptr); Term_xtra(TERM_XTRA_DELAY, msec); cave_light_spot(cave, y, x); Term_fresh(); if (p_ptr->redraw) redraw_stuff(p_ptr); } else { /* Delay anyway for consistency */ Term_xtra(TERM_XTRA_DELAY, msec); } /* Handle monster */ if (cave->m_idx[y][x] > 0) break; } /* Try the attack on the monster at (x, y) if any */ if (cave->m_idx[y][x] > 0) { monster_type *m_ptr = cave_monster(cave, cave->m_idx[y][x]); monster_race *r_ptr = &r_info[m_ptr->r_idx]; int visible = m_ptr->ml; bool fear = FALSE; char m_name[80]; const char *note_dies = monster_is_unusual(r_ptr) ? " is destroyed." : " dies."; struct attack_result result = attack(o_ptr, y, x); int dmg = result.dmg; u32b msg_type = result.msg_type; const char *hit_verb = result.hit_verb; if (result.success) { hit_target = TRUE; /* Get "the monster" or "it" */ monster_desc(m_name, sizeof(m_name), m_ptr, 0); object_notice_attack_plusses(o_ptr); /* No negative damage; change verb if no damage done */ if (dmg <= 0) { dmg = 0; hit_verb = "fail to harm"; } if (!visible) { /* Invisible monster */ msgt(MSG_SHOOT_HIT, "The %s finds a mark.", o_name); } else { /* Visible monster */ if (msg_type == MSG_SHOOT_HIT) msgt(MSG_SHOOT_HIT, "The %s %s %s.", o_name, hit_verb, m_name); else if (msg_type == MSG_HIT_GOOD) { msgt(MSG_HIT_GOOD, "The %s %s %s. %s", o_name, hit_verb, m_name, "It was a good hit!"); } else if (msg_type == MSG_HIT_GREAT) { msgt(MSG_HIT_GREAT, "The %s %s %s. %s", o_name, hit_verb, m_name, "It was a great hit!"); } else if (msg_type == MSG_HIT_SUPERB) { msgt(MSG_HIT_SUPERB, "The %s %s %s. %s", o_name, hit_verb, m_name, "It was a superb hit!"); } /* Track this monster */ if (m_ptr->ml) monster_race_track(m_ptr->r_idx); if (m_ptr->ml) health_track(p_ptr, cave->m_idx[y][x]); } /* Complex message */ if (p_ptr->wizard) msg("You do %d (out of %d) damage.", dmg, m_ptr->hp); /* Hit the monster, check for death */ if (!mon_take_hit(cave->m_idx[y][x], dmg, &fear, note_dies)) { message_pain(cave->m_idx[y][x], dmg); if (fear && m_ptr->ml) add_monster_message(m_name, cave->m_idx[y][x], MON_MSG_FLEE_IN_TERROR, TRUE); } } } /* Obtain a local object */ object_copy(i_ptr, o_ptr); object_split(i_ptr, o_ptr, 1); /* See if the ammunition broke or not */ j = breakage_chance(i_ptr, hit_target); /* Drop (or break) near that location */ drop_near(cave, i_ptr, j, y, x, TRUE); if (item >= 0) { /* The ammo is from the inventory */ inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } else { /* The ammo is from the floor */ floor_item_increase(0 - item, -1); floor_item_optimize(0 - item); } }
/** * Add an item to the players inventory. * * If the new item can combine with an existing item in the inventory, * it will do so, using object_similar() and object_absorb(), else, * the item will be placed into the first available gear array index. * * This function can be used to "over-fill" the player's pack, but only * once, and such an action must trigger the "overflow" code immediately. * Note that when the pack is being "over-filled", the new item must be * placed into the "overflow" slot, and the "overflow" must take place * before the pack is reordered, but (optionally) after the pack is * combined. This may be tricky. See "dungeon.c" for info. * * Note that this code removes any location information from the object once * it is placed into the inventory, but takes no responsibility for removing * the object from any other pile it was in. */ void inven_carry(struct player *p, struct object *obj, bool absorb, bool message) { struct object *gear_obj; char o_name[80]; /* Check for combining, if appropriate */ if (absorb) { for (gear_obj = p->gear; gear_obj; gear_obj = gear_obj->next) { /* Can't stack equipment */ if (object_is_equipped(p->body, gear_obj)) continue; /* Check if the two items can be combined */ if (object_similar(gear_obj, obj, OSTACK_PACK)) { /* Increase the weight */ p->upkeep->total_weight += (obj->number * obj->weight); /* Combine the items, and their known versions */ object_absorb(gear_obj->known, obj->known); obj->known = NULL; object_absorb(gear_obj, obj); /* Describe the combined object */ object_desc(o_name, sizeof(o_name), gear_obj, ODESC_PREFIX | ODESC_FULL); /* Recalculate bonuses */ p->upkeep->update |= (PU_BONUS | PU_INVEN); /* Redraw stuff */ p->upkeep->redraw |= (PR_INVEN); /* Inventory will need updating */ update_stuff(player); /* Optionally, display a message */ if (message) msg("You have %s (%c).", o_name, gear_to_label(gear_obj)); /* Sound for quiver objects */ if (object_is_in_quiver(p, gear_obj)) sound(MSG_QUIVER); /* Success */ return; } } } /* Paranoia */ assert(pack_slots_used(p) <= z_info->pack_size); /* Add to the end of the list */ gear_insert_end(obj); /* Apply an autoinscription */ apply_autoinscription(obj); /* Remove cave object details */ obj->held_m_idx = 0; obj->iy = obj->ix = 0; obj->known->iy = obj->known->ix = 0; /* Update the inventory */ p->upkeep->total_weight += (obj->number * obj->weight); p->upkeep->update |= (PU_BONUS | PU_INVEN); p->upkeep->notice |= (PN_COMBINE); p->upkeep->redraw |= (PR_INVEN); /* Inventory will need updating */ update_stuff(player); /* Hobbits ID mushrooms on pickup, gnomes ID wands and staffs on pickup */ if (!object_flavor_is_aware(obj)) { if (player_has(player, PF_KNOW_MUSHROOM) && tval_is_mushroom(obj)) { object_flavor_aware(obj); msg("Mushrooms for breakfast!"); } else if (player_has(player, PF_KNOW_ZAPPER) && tval_is_zapper(obj)) object_flavor_aware(obj); } /* Optionally, display a message */ if (message) { /* Describe the object */ object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL); /* Message */ msg("You have %s (%c).", o_name, gear_to_label(obj)); } /* Sound for quiver objects */ if (object_is_in_quiver(p, obj)) sound(MSG_QUIVER); }
void CSnork::jump(const Fvector &position, float factor) { com_man().script_jump (position, factor); sound().play (MonsterSound::eMonsterSoundAggressive); }
void CShieldSpecialController::process(const std::shared_ptr<Logic::IMessage> &message) { // Solo realizará el cambio de dirección si el anterior cambio que hizo no fue el // mismo que va a realizar (de modo que no esté entrando constántemente al mismo y "tiemble) if (message->getType() == "FALLING" && _lastCollision != "DOWN") { bool isFalling = dynamic_cast<FALLING*>(message.get())->getBool(); if (!isFalling) { _dirPong.y *= -1; _lastCollision = "DOWN"; _numHitsPong++; ///Lanzamos sonido de colision std::shared_ptr<PLAY_SOUND> sound (new PLAY_SOUND()); sound->setSound(std::string("/Armas/Escudo/ReboteEscudo")); _entity->emitMessage(sound, this); } } else if (message->getType() == "UP_COLLISION" && _lastCollision != "UP") { _dirPong.y *= -1; _lastCollision = "UP"; _numHitsPong++; //BaseSubsystems::Log::Debug("UP"); ///Lanzamos sonido de colision std::shared_ptr<PLAY_SOUND> sound (new PLAY_SOUND()); sound->setSound(std::string("/Armas/Escudo/ReboteEscudo")); _entity->emitMessage(sound, this); } else if (message->getType() == "SIDE_COLLISION") { std::string thisCollision; int normal = dynamic_cast<SIDE_COLLISION*>(message.get())->getNormalCollision(); //BaseSubsystems::Log::Debug("SIDE : " + std::to_string(normal)); if (normal != 0) { if (normal == 1) thisCollision = "RIGHT"; else if (normal == -1) thisCollision = "LEFT"; if (thisCollision != _lastCollision) { _lastCollision = thisCollision; _dirPong.x *= -1; _numHitsPong++; ///Lanzamos sonido de colision std::shared_ptr<PLAY_SOUND> sound (new PLAY_SOUND()); sound->setSound(std::string("/Armas/Escudo/ReboteEscudo")); _entity->emitMessage(sound, this); } } } if(message->getType().compare("TOUCHED") == 0) { CEntity* otherEntity = dynamic_cast<TOUCHED*>(message.get())->getEntidad(); if( otherEntity != NULL) { //Si golpeo a un enemigo genero chispa roja, si golpeo la puerta la normal if(otherEntity->getTag() == "enemy") { CEntityFactory::getSingletonPtr()->createEntityByType("ChispaDanhoEnemy",_entity->getPosition(), _entity->getMap()); std::shared_ptr<DAMAGED>m(new DAMAGED()); m->setFloat(_damage); m->setString(_entity->getType()); otherEntity->emitMessage(m, this); std::shared_ptr<PUSH> push (new PUSH()); push->setDirection(_dirPong); push->setSpeed(0.6f); otherEntity->emitMessage(push, this); ///Lanzamos sonido de colision std::shared_ptr<PLAY_SOUND> sound (new PLAY_SOUND()); sound->setSound(std::string("/Armas/Escudo/ReboteEscudo")); _entity->emitMessage(sound, this); sendSET_MATERIAL(_materialSangre); _timeAcum = 0; _countToClean = true; } else if( otherEntity->getTag() == "objetoRompible") { CEntityFactory::getSingletonPtr()->createEntityByType("Chispa",_entity->getPosition(), _entity->getMap()); std::shared_ptr<DAMAGED>m(new DAMAGED()); m->setFloat(_damage); m->setString(_entity->getType()); otherEntity->emitMessage(m, this); ///Lanzamos sonido de colision std::shared_ptr<PLAY_SOUND> sound (new PLAY_SOUND()); sound->setSound(std::string("/Armas/Escudo/ReboteEscudo")); _entity->emitMessage(sound, this); } } //Si golpeo un tile genera chispa normal else { CEntityFactory::getSingletonPtr()->createEntityByType("Chispa",_entity->getPosition(),_entity->getMap()); } } } // process
void Sound_Derapaj(int snd) { sound(snd); delay(8); nosound(); }
void input_poll(void) { SDL_Event evt; int32_t key; int ino;//, key; while(SDL_PollEvent(&evt)) { switch(evt.type) { case SDL_KEYDOWN: case SDL_KEYUP: { key = evt.key.keysym.sym; static uint8_t shiftstates = 0; extern bool freezeframe; if (console.IsVisible() && !IsNonConsoleKey(key)) { if (key == SDLK_LSHIFT) { if (evt.type == SDL_KEYDOWN) shiftstates |= LEFTMASK; else shiftstates &= ~LEFTMASK; } else if (key == SDLK_RSHIFT) { if (evt.type == SDL_KEYDOWN) shiftstates |= RIGHTMASK; else shiftstates &= ~RIGHTMASK; } else { int ch = key; if (shiftstates != 0) { ch = toupper(ch); if (ch == '.') ch = '>'; if (ch == '-') ch = '_'; if (ch == '/') ch = '?'; if (ch == '1') ch = '!'; } if (evt.type == SDL_KEYDOWN) console.HandleKey(ch); else console.HandleKeyRelease(ch); } } else { ino = input_get_action(key);//mappings[key]; if (ino != -1) inputs[ino] = (evt.type == SDL_KEYDOWN); if (evt.type == SDL_KEYDOWN) { if (key == '`') // bring up console { if (!freezeframe) { sound(SND_SWITCH_WEAPON); console.SetVisible(true); } } else { last_sdl_action.key = key; } } } } break; case SDL_QUIT: { inputs[ESCKEY] = true; game.running = false; } break; case SDL_JOYBUTTONDOWN: { Uint8 but = evt.jbutton.button; last_sdl_action.jbut = but; ino = input_get_action_but(but);//mappings[key]; if (ino != -1) inputs[ino] = (evt.jbutton.state == SDL_PRESSED); } break; case SDL_JOYBUTTONUP: { Uint8 but = evt.jbutton.button; ino = input_get_action_but(but);//mappings[key]; if (ino != -1) inputs[ino] = (evt.jbutton.state == SDL_PRESSED); } break; case SDL_JOYHATMOTION: { if (evt.jhat.value != SDL_HAT_CENTERED) { last_sdl_action.jhat = evt.jhat.hat; last_sdl_action.jhat_value = evt.jhat.value; } ino = input_get_action_hat(evt.jhat.hat,evt.jhat.value);//mappings[key]; //cleanup all hat-binded states for (int i=0;i<INPUT_COUNT;i++) { if (mappings[i].jhat!=-1) inputs[i] = false; } if (ino != -1) inputs[ino] = true; } break; case SDL_JOYAXISMOTION: { if (evt.jaxis.value > 20000 || evt.jaxis.value < -20000) //dead zone { last_sdl_action.jaxis = evt.jaxis.axis; last_sdl_action.jaxis_value = evt.jaxis.value; ino = input_get_action_axis(evt.jaxis.axis,evt.jaxis.value);//mappings[key]; for (int i=0;i<INPUT_COUNT;i++) { if (mappings[i].jaxis!=-1) inputs[i] = false; } if (ino != -1) inputs[ino] = true; } } break; } } }
void Claxon() { sound(800); delay(300); nosound(); }
void main (int argc, char *argv[]) { cout << "Squirrel 1.16/release, Adaptive answer Service for USR Voice modems" << endl; cout << "Copyright (c)2000 Eugeniy Gryaznov, Compiled on 02.05.00 at 21:09" << endl; if(argc<2) { cout << " Use <squirrel.exe> <action> [<action param>] [switches]" << endl; cout << " action: PLAY,REC,MAILER,MAIN" << endl; cout << " PLAY f.gsm Play file to speaker(modem)" << endl; cout << " REC f.gsm Record from microphone(modem) to file" << endl; cout << " MAILER Mailer compatible mode" << endl; cout << " MAIN Run in master mode" << endl; cout << " CONV f.gsm Convert GSM ->WAV" << endl; cout << " switches: [/L] [/D] [/P]" << endl; cout << " /L switch Playing/Recording device" << endl; cout << " /D switch Show debug info" << endl; cout << " /P switch close/real_close port" << endl; cout << " /B switch 8/16 bit wave output" << endl; cout << " Ex: squirrel play allo.gsm /L /D" << endl; cout << " squirrel main" << endl; ErrorExit(0,"Help screen"); } // Get default CTL name char ctl[128]; char *ext = "CTL"; strcpy(ctl,argv[0]); strcpy(ctl+strlen(ctl)-3,ext); SetDefault(); // Check ARGV int Task = 0, swch = 0; // 1 - PLAY, 2 - REC, 3 - MAILER, 4 - MAIN char TParam[128],fname[128],*outw; int postdo = 0; // Get task type if (strcmp(strupr(argv[1]),"PLAY")==0) { strcpy(TParam,argv[2]);Task=1; } else if (strcmp(strupr(argv[1]),"REC")==0) { strcpy(TParam,argv[2]);Task=2; } else if (strcmp(strupr(argv[1]),"MAILER")==0) { strcpy(TParam,argv[2]);Task=3; } else if (strcmp(strupr(argv[1]),"MAIN")==0) { strcpy(TParam,argv[2]);Task=4; } else if (strcmp(strupr(argv[1]),"CONV")==0) { strcpy(TParam,argv[2]);Task=5; } else ErrorExit(1,"Unknown action"); if ((Task==1||Task==2||Task==5)&&argc==2) ErrorExit(1,"not enough params"); // Process switches for (int argnum=2;argnum<argc;argnum++){ if ((Task!=1&&Task!=2&&Task!=5)||argnum!=2){ if (strcmp(strupr(argv[argnum]),"/D")==0) swch|=1; else if (strcmp(strupr(argv[argnum]),"/L")==0) swch|=2; else if (strcmp(strupr(argv[argnum]),"/P")==0) swch|=4; else if (strcmp(strupr(argv[argnum]),"/B")==0) swch|=8; else ErrorExit(1,"Unknown switch"); } } cout << "TASK: "; switch(Task){ case 1: cout << "playing file (device <- " << TParam << ")" << endl;break; case 2: cout << "recording file (device -> " << TParam << ")" << endl;break; case 3: cout << "mailer mode" << endl;break; case 4: cout << "master mode" << endl;break; } if (Task<5){ // Read config + FIX switches ReadConfig(ctl); if (swch&1) cfg.debuginfo=(cfg.debuginfo+1)%2; if (swch&2) cfg.pln=(cfg.pln+1)%2; if (swch&4) cfg.realcl=(cfg.realcl+1)%2; if (swch&8) cfg.wav8bit=(cfg.wav8bit+1)%2; // Open COMPort OpenComm(cfg.baud,cfg.ioport,cfg.irq); if(prtst!=-1) ErrorExit(3,"Communication port not found"); // Init screen StartupScr(); // Init modem SendModemStr(&cfg.init,"Initializing modem"); SendModemStr(&cfg.voice,"Voice mode"); } // Start Log if (Task==3||Task==4){ struct time _t; struct date _d; gettime(&_t);getdate(&_d); write_log("\n -- executed on "); write_log_num(_d.da_day);write_log("."); write_log_num(_d.da_mon);write_log("."); write_log_num(_d.da_year);write_log(" at "); write_log_num(_t.ti_hour);write_log(":"); write_log_num(_t.ti_min);write_log(" --\n"); } // Main work switch(Task){ case 1: PlayFile(TParam); break; case 2: cfg.wavout=0; RecFile(TParam,0); break; case 3: if (!cfg.gsmframe) ErrorExit(78,"mailer mode require USE_GSM=1"); cfg.up=0;cfg.pln=0; if (cfg.useaon&1){ AON(); } else { if (cfg.hook){ SendModemStr(&cfg.offhook,"Offhook"); delay(cfg.wallo); } } PlayFile(cfg.sallo); if (cfg.loglev&2) write_log("detecting\n"); switch (Detect()){ case 1: // Modem CreateFlag(cfg.ata); SendModemStr(&cfg.data,"Data mode"); SendModemStr(&cfg.mailinit,"Initializing modem to connect"); write_log("Detected: MODEM\n"); ErrorExit(0,"modem detected"); break; case 2: // Voice write_log("Detected: VOICE\n"); PlayFile(cfg.swait); for (int curring=0;curring<cfg.RTL;curring++){ if (!kbhit()){ if (strlen(cfg.soundfl)) CreateFlag(cfg.soundfl); else sound(cfg.khz); SendModemStr(&cfg.beep,"Beep"); nosound(); } if (kbhit()) break; if (curring+1!=cfg.RTL) delay(cfg.delayring); } ch=0;while (kbhit()) ch=getch(); if (cfg.auto_detect&&ch!=27&&ch!=32){ // check if voice present cout << " ! auto : speach in line" << endl;FixLine(); if (cfg.loglev&2) write_log("detecting\n"); ch=0;cfg.limit=cfg.auto_detect; if ((ch=Detect())==2) ch=32; if (ch==3||ch==4) break; } if (ch!=27) if (ch==32){ cout << " ! autoanswer skipped" << endl;FixLine(); write_log("autoanswer skipped\n"); postdo=1; } else { PlayFile(cfg.sauto); SendModemStr(&cfg.abeep,"aBeep"); generate_name(fname); write_log("Recording: ");write_log(fname);write_log("\n"); RecFile(fname,cfg.rec_time); } break; case 3: write_log("Detected: BUSY\n");break; case 4: write_log("Detected: DIAL TONE\n");break; } SendModemStr(&cfg.onhook,"Onhook"); break; case 4: int wring; char rng[100];cfg.up=0;cfg.pln=0; while(kbhit()) getch(); if (cfg.gsmframe==0&&cfg.useaon!=0) ErrorExit(73,"AON require USE_GSM=1"); while(!kbhit()){ cout << " Waiting for RING ...";rng[0]=0; while(!kbhit()&&strstr(rng,"RING")==NULL){ while(ReadComm(ch)){ rng[strlen(rng)+1]=0; rng[strlen(rng)]=ch; if (strlen(rng)==95) rng[0]=0; } } if (!kbhit()){ cout << endl;FixLine(); cout << " ! RING ."; for(wring=0;wring<(cfg.ring-1);wring++){ if (!WaitFor("RING",7,cfg.debuginfo)) { cout << " <no more rings>" << endl;FixLine();wring=0;break;} else cout << "."; } } if (!kbhit()&&wring){ // Wait cfg.ring cout << endl;FixLine(); if (cfg.useaon&2){ AON(); } else { SendModemStr(&cfg.offhook,"Offhook"); delay(cfg.wallo); } cfg.up=0; PlayFile(cfg.sauto); SendModemStr(&cfg.abeep,"aBeep"); generate_name(fname); RecFile(fname,cfg.rec_time); SendModemStr(&cfg.onhook,"Onhook"); SendModemStr(&cfg.init,"Initializing modem"); SendModemStr(&cfg.voice,"Voice mode"); while(kbhit()) getch(); } } cout << endl;FixLine(); while(kbhit()) getch(); break; case 5: // Open files if (swch&8) cfg.wav8bit=(cfg.wav8bit+1)%2; fp=fopen(TParam,"rb"); if (fp==NULL) ErrorExit(93,"error: .gsm input"); outw=TParam; cout << "GSM->WAV converting: " << TParam << " -> "; while (strchr(outw,'\\')!=NULL) outw=strchr(outw,'\\'); while (strchr(outw,'/')!=NULL) outw=strchr(outw,'/'); if (strlen(outw)==0) ErrorExit(153,"out name error"); if (strchr(outw,'.')!=NULL) *strchr(outw,'.')=0; strcat(strlwr(TParam),".wav"); cout << TParam;if(cfg.wav8bit) cout << " (8bit)";cout << endl; if (!Start_GSM_WAV(TParam,cfg.wav8bit)){ cout << "output file error";exit(1);} while (fread(gsmb,1,33,fp)==33){ decode_block(gsmb,cfg.wav8bit); } // close file fclose(fp); Close_GSM_WAV(); ErrorExit(0,"OK"); } // Deinit SendModemStr(&cfg.data,"Data mode"); SendModemStr(&cfg.deinit,"Deinitializing modem"); if (postdo&&cfg.postspace){ cout << " ! Press any key to return to Mailer"; getch();sound(440);delay(5);nosound(); cout << endl;FixLine(); } // Close COMPort & Exit ErrorExit(0,"All ok"); }
static void handle_input() { bool button_pressed = false; #ifdef CONFIG_USE_TAPS // tap controls { int cx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_MENU].w / 2) - 8; int cy = (Graphics::SCREEN_HEIGHT / 2) - 8; for(int i=0;i<sprites[SPR_MENU].nframes;i++) { RectI r = Sprites::get_sprite_rect(cx, cy, SPR_MENU, i); if (VJoy::ModeAware::wasTap(r)) { if (title.cursel == i) { button_pressed = true; } else { sound(SND_MENU_MOVE); title.cursel = i; } break; } cy += (sprites[SPR_MENU].h + 18); } } #endif // pad control { if (justpushed(DOWNKEY)) { sound(SND_MENU_MOVE); if (++title.cursel >= sprites[SPR_MENU].nframes) title.cursel = 0; } else if (justpushed(UPKEY)) { sound(SND_MENU_MOVE); if (--title.cursel < 0) title.cursel = sprites[SPR_MENU].nframes - 1; } button_pressed = button_pressed || buttonjustpushed(); } if (button_pressed) { sound(SND_MENU_SELECT); int choice = title.cursel; // handle case where user selects Load but there is no savefile, // or the last_save_file is deleted. if (title.cursel == 1) { if (!ProfileExists(settings->last_save_slot)) { bool foundslot = false; for(int i=0;i<MAX_SAVE_SLOTS;i++) { if (ProfileExists(i)) { stat("Last save file %d missing. Defaulting to %d instead.", settings->last_save_slot, i); settings->last_save_slot = i; foundslot = true; } } // there are no save files. Start a new game instead. if (!foundslot) { stat("No save files found. Starting new game instead."); choice = 0; } } } if (choice == 1 && settings->multisave) { title.selchoice = 2; title.seldelay = SELECT_MENU_DELAY; } else { title.selchoice = choice; title.seldelay = SELECT_DELAY; music(0); } } run_konami_code(); }
void ai_missile_shot(Object *o) { int index = o->shot.level + ((o->type == OBJ_SUPERMISSILE_SHOT) ? 3 : 0); MissileSettings *settings = &missile_settings[index]; if (o->state == 0) { o->shot.damage = settings->damage; if (o->shot.level == 2) { // initilize wavey effect if (o->shot.dir == LEFT || o->shot.dir == RIGHT) o->ymark = -0x20; else o->xmark = -0x20; // don't let it explode until the "recoil" effect is over. o->state = STATE_WAIT_RECOIL_OVER; // record position we were fired at (we won't explode until we pass it) o->xmark2 = player->x; o->ymark2 = player->y; } else { o->state = STATE_MISSILE_CAN_EXPLODE; } } // accelerate according to current type and level of missile // don't use LIMITX here as it can mess up recoil of level 3 super missiles switch(o->shot.dir) { case RIGHT: o->xinertia += settings->accel; if (o->xinertia > settings->maxspeed) o->xinertia = settings->maxspeed; break; case LEFT: o->xinertia -= settings->accel; if (o->xinertia < -settings->maxspeed) o->xinertia = -settings->maxspeed; break; case UP: o->yinertia -= settings->accel; if (o->yinertia < -settings->maxspeed) o->yinertia = -settings->maxspeed; break; case DOWN: o->yinertia += settings->accel; if (o->yinertia > settings->maxspeed) o->yinertia = settings->maxspeed; break; } // wavey effect for level 3 // (markx/y is used as a "speed" value here) if (o->shot.level == 2) { if (o->shot.dir == LEFT || o->shot.dir == RIGHT) { o->yinertia += o->ymark; if (o->ymark > 0 && o->yinertia > 0x100) o->ymark = -o->ymark; if (o->ymark < 0 && o->yinertia < -0x100) o->ymark = -o->ymark; } else { o->xinertia += o->xmark; if (o->xmark > 0 && o->xinertia > 0x100) o->xmark = -o->xmark; if (o->xmark < 0 && o->xinertia < -0x100) o->xmark = -o->xmark; } } // check if we hit an enemy // level 3 missiles can not blow up while they are "recoiling" // what we do is first wait until they're traveling in the direction // they're pointing, then wait till they pass the player's original position. switch(o->state) { case STATE_WAIT_RECOIL_OVER: switch(o->shot.dir) { case LEFT: if (o->xinertia <= 0) o->state = STATE_RECOIL_OVER; break; case RIGHT: if (o->xinertia >= 0) o->state = STATE_RECOIL_OVER; break; case UP: if (o->yinertia <= 0) o->state = STATE_RECOIL_OVER; break; case DOWN: if (o->yinertia >= 0) o->state = STATE_RECOIL_OVER; break; } if (o->state != STATE_RECOIL_OVER) break; case STATE_RECOIL_OVER: switch(o->shot.dir) { case LEFT: if (o->x <= o->xmark2-(2<<CSF)) o->state = STATE_MISSILE_CAN_EXPLODE; break; case RIGHT: if (o->x >= o->xmark2+(2<<CSF)) o->state = STATE_MISSILE_CAN_EXPLODE; break; case UP: if (o->y <= o->ymark2-(2<<CSF)) o->state = STATE_MISSILE_CAN_EXPLODE; break; case DOWN: if (o->y >= o->ymark2+(2<<CSF)) o->state = STATE_MISSILE_CAN_EXPLODE; break; } if (o->state != STATE_MISSILE_CAN_EXPLODE) break; case STATE_MISSILE_CAN_EXPLODE: { bool blow_up = false; if (damage_enemies(o)) { blow_up = true; } else { // check if we hit a wall if (o->shot.dir==LEFT && o->blockl) blow_up = true; else if (o->shot.dir==RIGHT && o->blockr) blow_up = true; else if (o->shot.dir==UP && o->blocku) blow_up = true; else if (o->shot.dir==DOWN && o->blockd) blow_up = true; } if (blow_up) { sound(SND_MISSILE_HIT); // create the boom-spawner object for the flashes, smoke, and AoE damage Object *sp = CreateObject(o->CenterX(), o->CenterY(), OBJ_MISSILE_BOOM_SPAWNER); sp->shot.boomspawner.range = settings->boomrange; sp->shot.boomspawner.booms_left = settings->num_booms; sp->shot.damage = settings->boomdamage; o->Delete(); return; } } break; } if (--o->shot.ttl < 0) shot_dissipate(o, EFFECT_STARPOOF); // smoke trails if (++o->timer > 2) { o->timer = 0; Caret *trail = effect(o->CenterX() - o->xinertia, \ o->CenterY() - o->yinertia, EFFECT_SMOKETRAIL); const int trailspd = 0x400; switch(o->shot.dir) { case LEFT: trail->xinertia = trailspd; trail->y -= (2<<CSF); break; case RIGHT: trail->xinertia = -trailspd; trail->y -= (2<<CSF); break; case UP: trail->yinertia = trailspd; trail->x -= (1<<CSF); break; case DOWN: trail->yinertia = -trailspd; trail->x -= (1<<CSF); break; } } }
int main(void) { sound(5); delay(100); sound(10); delay(100); sound(15); delay(100); sound(20); delay(100); sound(25); delay(100); sound(30); delay(100); sound(35); delay(100); sound(40); delay(100); sound(45); delay(100); sound(50); delay(100); sound(55); delay(100); sound(60); delay(100); sound(65); delay(100); sound(70); delay(100); sound(75); delay(100); sound(80); delay(100); sound(85); delay(100); sound(90); delay(100); sound(95); delay(100); sound(100); delay(100); sound(105); delay(100); sound(110); delay(100); sound(115); delay(100); sound(120); delay(100); sound(125); delay(100); sound(130); delay(100); sound(135); delay(100); sound(140); delay(100); sound(145); delay(100); sound(150); delay(100); sound(155); delay(100); sound(160); delay(100); sound(165); delay(100); sound(170); delay(100); sound(175); delay(100); sound(180); delay(100); sound(185); delay(100); sound(190); delay(100); sound(195); delay(100); sound(200); delay(100); sound(205); delay(100); sound(210); delay(100); nosound(); return 0; }