Ejemplo n.º 1
0
bool check_social( CHAR_DATA *ch, const char *command, const char *argument )
{
  char arg[MAX_INPUT_LENGTH];
  CHAR_DATA *victim;
  int cmd;
  bool found;

  found  = FALSE;
  for ( cmd = 0; social_table[cmd].name[0] != '\0'; cmd++ ) {
    if ( command[0] == social_table[cmd].name[0]
	 &&   !str_prefix( command, social_table[cmd].name ) ) {
      found = TRUE;
      break;
    }
  }

  if ( !found )
    return FALSE;

  if ( !IS_NPC(ch) && IS_SET(ch->comm, COMM_NOEMOTE) ) {
    send_to_char( "You are anti-social!\n\r", ch );
    return TRUE;
  }

  switch ( ch->position ) {
  case POS_DEAD:
    send_to_char( "Lie still; you are DEAD.\n\r", ch );
    return TRUE;

  case POS_INCAP:
  case POS_MORTAL:
    send_to_char( "You are hurt far too bad for that.\n\r", ch );
    return TRUE;

    // Added by SinaC 2003
  case POS_PARALYZED:
    send_to_char( "You are paralyzed, you can't move.\n\r", ch);
    //send_to_char( "You can't move.\n\r", ch);
    return TRUE;

  case POS_STUNNED:
    send_to_char( "You are too stunned to do that.\n\r", ch );
    return TRUE;

  case POS_SLEEPING:
    /*
     * I just know this is the path to a 12" 'if' statement.  :(
     * But two players asked for it already!  -- Furey
     */
    if ( !str_cmp( social_table[cmd].name, "snore" ) )
      break;
    send_to_char( "In your dreams, or what?\n\r", ch );
    return TRUE;

  }

  one_argument( argument, arg );
  victim = NULL;
  if ( arg[0] == '\0' ) {
    act( social_table[cmd].others_no_arg, ch, NULL, victim, TO_ROOM    );
    act( social_table[cmd].char_no_arg,   ch, NULL, victim, TO_CHAR    );

    // everyone in the room
    CHAR_DATA *vch_next = NULL;
    for ( CHAR_DATA *vch = ch->in_room->people; vch != NULL; vch = vch_next ) {
      vch_next = vch->next_in_room;
      if ( vch != ch )
	MOBPROG( vch, NULL, "onSocial", ch, social_table[cmd].name );
    }
  }
  else if ( ( victim = get_char_room( ch, arg ) ) == NULL ) {
    send_to_char( "They aren't here.\n\r", ch );
  }
  else if ( victim == ch ) {
    act( social_table[cmd].others_auto,   ch, NULL, victim, TO_ROOM    );
    act( social_table[cmd].char_auto,     ch, NULL, victim, TO_CHAR    );
  }
  else {
    act( social_table[cmd].others_found,  ch, NULL, victim, TO_NOTVICT );
    act( social_table[cmd].char_found,    ch, NULL, victim, TO_CHAR    );
    act( social_table[cmd].vict_found,    ch, NULL, victim, TO_VICT    );

    if ( !IS_NPC(ch) && IS_NPC(victim)
	 &&   !IS_AFFECTED(victim, AFF_CHARM)
	 &&   IS_AWAKE(victim) 
	 &&   victim->desc == NULL) {
      switch ( number_bits( 4 ) ) {
      case 0:

      case 1: case 2: case 3: case 4:
      case 5: case 6: case 7: case 8:
	act( social_table[cmd].others_found,
	     victim, NULL, ch, TO_NOTVICT );
	act( social_table[cmd].char_found,
	     victim, NULL, ch, TO_CHAR    );
	act( social_table[cmd].vict_found,
	     victim, NULL, ch, TO_VICT    );
	break;

      case 9: case 10: case 11: case 12:
	act( "$n slaps $N.",  victim, NULL, ch, TO_NOTVICT );
	act( "You slap $N.",  victim, NULL, ch, TO_CHAR    );
	act( "$n slaps you.", victim, NULL, ch, TO_VICT    );
	break;
      }
    }

    MOBPROG( victim, NULL, "onSocial", ch, social_table[cmd].name ); // only send to victim
  }

  return TRUE;
}
Ejemplo n.º 2
0
void board_write_msg(struct char_data *ch, char *arg, int bnum) {

  int highmessage;
  char buf[MAX_STRING_LENGTH];
  long ct; /* clock time */
  char *tmstr;

  extern struct time_info_data time_info;
  extern char *month_name[];

  if ( bnum == -1 ) {
    logE("Board special procedure called for non-board object.\r\n");
    send_to_char("This board is not in operation at this time.\n\r", ch);
    return;
  }

  curr_board = &boards[bnum];

  if (GetMaxLevel(ch) < min_write_level[bnum]) {
    send_to_char("You pick up a quill to write, but realize you're not powerful enough\n\r",ch);
    send_to_char("to submit intelligent material to THIS board.\n\r",ch);
    return;
  }

  if ( (curr_board->number) > (MAX_MSGS - 1) ) {
    send_to_char("The board is full already.\n\r", ch);
    return;
  }

  /* Check for locks, return if lock is found on this board */

  if (board_check_locks(bnum, ch))
    return;

  /* skip blanks */

  for(; isspace(*arg); arg++);

  if (!*arg) {
    send_to_char("The board has now been saved permanently to disk.\n\rTo write a new message, use WRITE followed by a title.\n\r", ch);
    return;
  }

  /* Now we're committed to writing a message.  Let's lock the board. */

  board_lock[bnum].lock = 1;
  board_lock[bnum].locked_for = ch;

  /* Lock set */

  highmessage = boards[bnum].number;
  curr_msg = &curr_board->msg[++highmessage];

  if (!(strcmp("Topic",arg))) {
    curr_msg = &curr_board->msg[0];
    free(curr_msg->title);
    free(curr_msg->text);
    free(curr_msg->author);
    free(curr_msg->date);
    (boards[bnum].number)--;
  }
  curr_msg->title = (char *)malloc(strlen(arg)+1);
  strcpy(curr_msg->title, arg);
  curr_msg->author = (char *)malloc(strlen(GET_NAME(ch))+1);
  strcpy(curr_msg->author, GET_NAME(ch));
  ct = time(0);
  tmstr = (char *)asctime(localtime(&ct));
  *(tmstr + strlen(tmstr) - 1) = '\0';
  sprintf(buf,"%.10s",tmstr);
  curr_msg->date = (char *)malloc(strlen(buf)+1);
  strcpy(curr_msg->date, buf);
  send_to_char("Write your message. Terminate with a @.\n\r\n\r", ch);
  act("$n starts to write a message.", TRUE, ch, 0, 0, TO_ROOM);

  /* Take care of free-ing and zeroing if the message text is already
     allocated previously */

  if (curr_msg->text)
    free (curr_msg->text);
  curr_msg->text = 0;

  /* Initiate the string_add procedures from comm.c */

  ch->desc->str = &curr_msg->text;
  ch->desc->max_str = MAX_MESSAGE_LENGTH;
  (boards[bnum].number)++;
  if (boards[bnum].number < 0)
    boards[bnum].number = 0;
}
Ejemplo n.º 3
0
static void start_request(struct floppy_state *fs)
{
	struct request *req;
	unsigned long x;

	swim3_dbg("start request, initial state=%d\n", fs->state);

	if (fs->state == idle && fs->wanted) {
		fs->state = available;
		wake_up(&fs->wait);
		return;
	}
	while (fs->state == idle) {
		swim3_dbg("start request, idle loop, cur_req=%p\n", fs->cur_req);
		if (!fs->cur_req) {
			fs->cur_req = blk_fetch_request(disks[fs->index]->queue);
			swim3_dbg("  fetched request %p\n", fs->cur_req);
			if (!fs->cur_req)
				break;
		}
		req = fs->cur_req;

		if (fs->mdev->media_bay &&
		    check_media_bay(fs->mdev->media_bay) != MB_FD) {
			swim3_dbg("%s", "  media bay absent, dropping req\n");
			swim3_end_request(fs, BLK_STS_IOERR, 0);
			continue;
		}

#if 0 /* This is really too verbose */
		swim3_dbg("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%u buf=%p\n",
			  req->rq_disk->disk_name, req->cmd,
			  (long)blk_rq_pos(req), blk_rq_sectors(req),
			  bio_data(req->bio));
		swim3_dbg("           current_nr_sectors=%u\n",
			  blk_rq_cur_sectors(req));
#endif

		if (blk_rq_pos(req) >= fs->total_secs) {
			swim3_dbg("  pos out of bounds (%ld, max is %ld)\n",
				  (long)blk_rq_pos(req), (long)fs->total_secs);
			swim3_end_request(fs, BLK_STS_IOERR, 0);
			continue;
		}
		if (fs->ejected) {
			swim3_dbg("%s", "  disk ejected\n");
			swim3_end_request(fs, BLK_STS_IOERR, 0);
			continue;
		}

		if (rq_data_dir(req) == WRITE) {
			if (fs->write_prot < 0)
				fs->write_prot = swim3_readbit(fs, WRITE_PROT);
			if (fs->write_prot) {
				swim3_dbg("%s", "  try to write, disk write protected\n");
				swim3_end_request(fs, BLK_STS_IOERR, 0);
				continue;
			}
		}

		/* Do not remove the cast. blk_rq_pos(req) is now a
		 * sector_t and can be 64 bits, but it will never go
		 * past 32 bits for this driver anyway, so we can
		 * safely cast it down and not have to do a 64/32
		 * division
		 */
		fs->req_cyl = ((long)blk_rq_pos(req)) / fs->secpercyl;
		x = ((long)blk_rq_pos(req)) % fs->secpercyl;
		fs->head = x / fs->secpertrack;
		fs->req_sector = x % fs->secpertrack + 1;
		fs->state = do_transfer;
		fs->retries = 0;

		act(fs);
	}
}
Ejemplo n.º 4
0
bool Compiler::compile(const std::string &options,
                       llvm::MemoryBuffer *source,
                       std::string filename)
{
    /* Set options */
    p_options = options;

    clang::CodeGenOptions &codegen_opts = p_compiler.getCodeGenOpts();
    clang::DiagnosticOptions &diag_opts = p_compiler.getDiagnosticOpts();
    clang::FrontendOptions &frontend_opts = p_compiler.getFrontendOpts();
    clang::HeaderSearchOptions &header_opts = p_compiler.getHeaderSearchOpts();
    clang::LangOptions &lang_opts = p_compiler.getLangOpts();
    clang::TargetOptions &target_opts = p_compiler.getTargetOpts();
    clang::PreprocessorOptions &prep_opts = p_compiler.getPreprocessorOpts();
    clang::CompilerInvocation &invocation = p_compiler.getInvocation();

    // Set codegen options
    codegen_opts.setDebugInfo(clang::CodeGenOptions::NoDebugInfo);
    codegen_opts.AsmVerbose = true;

    // level 3 is too much for the pocl transformations.
    codegen_opts.OptimizationLevel = 2;

    // Set diagnostic options
    diag_opts.Pedantic = true;
    diag_opts.ShowColumn = true;
    diag_opts.ShowLocation = true;
    diag_opts.ShowCarets = false;
    diag_opts.ShowFixits = true;
    diag_opts.ShowColors = false;
    diag_opts.ErrorLimit = 19;
    diag_opts.MessageLength = 0;

    // Set frontend options
    frontend_opts.ProgramAction = clang::frontend::EmitLLVMOnly;
    frontend_opts.DisableFree = true;

    // Set header search options
    header_opts.Verbose = false;
    header_opts.UseBuiltinIncludes = false;
    header_opts.UseStandardSystemIncludes = false;
    header_opts.UseStandardCXXIncludes = false;

    // Set preprocessor options
    prep_opts.RetainRemappedFileBuffers = true;
    if (!opt_builtin)
    {
        prep_opts.Includes.push_back("clc.h");
        prep_opts.Includes.push_back("dsp.h");
    }

    // Set lang options
    lang_opts.NoBuiltin = true;
    lang_opts.OpenCL = true;
    lang_opts.CPlusPlus = false;

    // Set target options
    // For 6X, use the 'spir' target as it implements opencl specs
    target_opts.Triple = "spir-unknown-unknown-unknown";

    // Currently, llp6x does not handle fused multiply and add
    // llvm intrinsics (llvm.fmuladd.*). Disable generating these
    // intrinsics using clang -ffp-contract=off option
    codegen_opts.setFPContractMode(clang::CodeGenOptions::FPC_Off);

    // Parse the user options
    std::istringstream options_stream(options);
    std::string token;
    bool Werror = false, inI = false, inD = false;

    /*-------------------------------------------------------------------------
    * Add OpenCL C header path as a default location for searching for headers
    *------------------------------------------------------------------------*/
    header_opts.AddPath(get_ocl_dsp(), clang::frontend::Angled, false, false);

    while (options_stream >> token)
    {
        if (inI)
        {
            // token is an include path
            header_opts.AddPath(token, clang::frontend::Angled, false, false);
            inI = false;
            continue;
        }
        else if (inD)
        {
            // token is name or name=value
            prep_opts.addMacroDef(token);
        }

        if (token == "-I")
        {
            inI = true;
        }
        else if (token == "-D")
        {
            inD = true;
        }
        else if (token == "-cl-single-precision-constant")
        {
            lang_opts.SinglePrecisionConstants = true;
        }
        else if (token == "-cl-opt-disable")
        {
            p_optimize = false;
            codegen_opts.OptimizationLevel = 0;
        }
        else if (token == "-cl-mad-enable")
        {
            codegen_opts.LessPreciseFPMAD = true;
        }
        else if (token == "-cl-unsafe-math-optimizations")
        {
            codegen_opts.UnsafeFPMath = true;
        }
        else if (token == "-cl-finite-math-only")
        {
            codegen_opts.NoInfsFPMath = true;
            codegen_opts.NoNaNsFPMath = true;
        }
        else if (token == "-cl-fast-relaxed-math")
        {
            codegen_opts.UnsafeFPMath = true;
            codegen_opts.NoInfsFPMath = true;
            codegen_opts.NoNaNsFPMath = true;
            lang_opts.FastRelaxedMath = true;
        }
        else if (token == "-w")
        {
            diag_opts.IgnoreWarnings = true;
        }
        else if (token == "-Werror")
        {
            Werror = true;
        }
    }

    // Set invocation options
    //invocation.setLangDefaults(lang_opts,clang::IK_OpenCL);
    invocation.setLangDefaults(lang_opts,clang::IK_OpenCL, clang::LangStandard::lang_opencl12);

    // Create the diagnostics engine
    p_log_printer = new clang::TextDiagnosticPrinter(p_log_stream, &diag_opts);
    p_compiler.createDiagnostics(p_log_printer);

    if (!p_compiler.hasDiagnostics())
        return false;

    p_compiler.getDiagnostics().setWarningsAsErrors(Werror);

    // Feed the compiler with source
    frontend_opts.Inputs.push_back(clang::FrontendInputFile(filename.c_str(), clang::IK_OpenCL));

    std::string srcc = source->getBuffer();
    const llvm::StringRef s_data(srcc);
    const llvm::StringRef s_name("<source>");
    llvm::MemoryBuffer *buffer =
        llvm::MemoryBuffer::getMemBuffer(s_data, s_name);

    prep_opts.addRemappedFile(filename.c_str(), buffer);

    // Compile
    llvm::OwningPtr<clang::CodeGenAction> act(
        new clang::EmitLLVMOnlyAction(&llvm::getGlobalContext())
    );

    if (!p_compiler.ExecuteAction(*act))
    {
        // DEBUG
        std::cout << log() << std::endl;
        return false;
    }

    p_log_stream.flush();
    p_module = act->takeModule();

    // uncomment to debug the llvm IR
    // p_module->dump();

    return true;
}
Ejemplo n.º 5
0
void affect_from_char_II(struct char_data * ch, int skill, int type, int action)
{

 struct affected_type *aff, *next;
 struct affected_type *temp;
 struct affected_type af[3];
 int i, k;
 bool accum_affect = FALSE, accum_duration = FALSE;
 
 for (aff = ch->affected; aff; aff = next) {
    next = aff->next;
    if (aff->type == type) {
    affect_modify(ch, aff->location, aff->modifier, aff->bitvector, FALSE);
  REMOVE_FROM_LIST(aff, ch->affected, next);
  free(aff);
  affect_total(ch);
 }
}

if (action == 2) {
switch (skill) {
      case SPELL_POLYMORPH:
   if (PLR_FLAGGED(ch, PLR_RABBIT)){
REMOVE_BIT(PLR_FLAGS(ch), PLR_RABBIT);
REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);
send_to_char("You feel yourself growing, and your ears shrinking. You no longer feel like a rabbit.\r\n", ch);
act("$n's body grows, $s ears shrinking. $n no longer looks like a rabbit.\r\n", 0, ch, 0, 0, TO_ROOM);

}
if (PLR_FLAGGED(ch, PLR_BIRD)) {
REMOVE_BIT(PLR_FLAGS(ch), PLR_BIRD);
REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);
send_to_char("You feel yourself growing and your feathers falling away. You no longer feel like a bird.\r\n", ch);
act("$n's body grows, $s feathers falling away as it expands. $n no longer looks like a bird.\r\n", 0, ch, 0, 0, TO_ROOM);

}
if (PLR_FLAGGED(ch, PLR_WOLF)) {
REMOVE_BIT(PLR_FLAGS(ch), PLR_WOLF);
REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);
send_to_char("You feel your your fur shed and your teeth shrink. You no longer feel like a wolf.\r\n", ch);
act("$n's teeth shrink, $s fur shedding. $n no longer looks like a wolf.\r\n", 0, ch, 0, 0, TO_ROOM);
}
if (PLR_FLAGGED(ch, PLR_BEAR)) {
REMOVE_BIT(PLR_FLAGS(ch), PLR_BEAR);
REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);
send_to_char("Your claws shrink as does the rest of your body. You no longer feel like a bear.\r\n", ch);
act("$n's claws shrink as does the rest of $s body. $n no longer looks like a bear.\r\n", 0, ch, 0, 0, TO_ROOM);
}
if (PLR_FLAGGED(ch, PLR_CAT)){
REMOVE_BIT(PLR_FLAGS(ch), PLR_CAT);
REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);
send_to_char("You feel your body growing, and your fur shedding. You no longer feel like a cat.\r\n", ch);
act("$n's body slowly grows, $s fur shedding. $n no longer looks like a cat.\r\n", 0, ch, 0, 0, TO_ROOM);
}

  for (k = 0; k < NUM_WEARS; k++)
  if (GET_EQ(ch, k)){
    GET_OBJ_DISGUISE(GET_EQ(ch, k)) = 0;
  }

       if (affected_by_spell(ch, SPELL_FLIGHT))
       affect_from_char_II(ch, SPELL_FLIGHT, SPELL_FLIGHT, 1);
       if (affected_by_spell(ch, SPELL_HASTE))
       affect_from_char_II(ch, SPELL_HASTE, SPELL_HASTE, 1);
       break;
      case SKILL_STANCE:

   if (!AFF_FLAGGED(ch, AFF_TIRED)) {
   for (i = 0; i < 3; i++) {
    af[0].type     = SPELL_DONTUSEME;
    af[0].location = APPLY_HITROLL;
    af[0].modifier = 2;
    af[0].duration = 7;
    af[0].bitvector = AFF_STANCE;

    af[1].type      = SPELL_DONTUSEME;
    af[1].location = APPLY_AC;
    af[1].modifier = -50;
    af[1].duration = 7;
    af[1].bitvector = AFF_STANCE;
 
    af[2].type      = SPELL_DONTUSEME;
    af[2].location = APPLY_STR;
    af[2].modifier = 2;
    af[2].duration = 7;
    af[2].bitvector = AFF_STANCE;


      if (af[i].bitvector || (af[i].location != APPLY_NONE)) {
        affect_join(ch, af+i, accum_duration, FALSE, accum_affect, FALSE);
      }
    }
}
     break;

    default:
      break;
  }
 }
}
Ejemplo n.º 6
0
/*
 * Control the fights going on.
 * Blow stuff up.
 * Called periodically by update_handler.
 */
void violence_update( void )
{
    CHAR_DATA *ch;
    CHAR_DATA *ch_next;
    CHAR_DATA *victim;
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;

    /* Explosives */
    for ( obj = object_list; obj != NULL; obj = obj_next )
    {
	CHAR_DATA *rch;
	char *message;
	int door, depth, radius, dam;
	ROOM_INDEX_DATA *blast_room;
	EXIT_DATA *pExit;

	obj_next = obj->next;

	if(obj->item_type != ITEM_BOMB || !obj->value[1]) continue;
	if(--obj->value[0] > 0) continue;

	fake_out();
	message = "$p explodes in a show of fiery violence!";

	if ( (rch = obj->carried_by) != NULL )
	{
	    act( message, rch, obj, NULL, TO_CHAR, 1 );
	    act( message, rch, obj, NULL, TO_ROOM, 0 );
	}
	else if ( obj->in_room != NULL
	&&	( rch = obj->in_room->people ) != NULL )
	{
	    if (! (obj->in_obj
		   && !CAN_WEAR(obj->in_obj,ITEM_TAKE)))
	    {
		act( message, rch, obj, NULL, TO_ROOM, 0 );
		act( message, rch, obj, NULL, TO_CHAR, 1 );
	    }
	}

	/* Determine power. (Damage and blast radius.)  */
	/* Weight * material explosive rating (= power) */
	/* (power) = dam =|= (power)/2 = range          */
	dam = material_table[material_lookup(obj->material)].is_explosive;
	radius = dam / 2;

	/* Do damage to everyone in first room. */
	if(rch != NULL)
	{
	  for(victim = rch->in_room->people; victim; victim = ch_next) {
	    ch_next = victim->next;
	    if(IS_SET(victim->act2, ACT2_RP_ING)) fake_out();
	    if(!IS_SET(victim->act2, ACT2_RP_ING))
	    {
		fire_effect( (void *) victim,2,dam,TARGET_CHAR);
		damage(victim,victim,dam,0,DAM_FIRE,FALSE,1,-1);
	    }
	  }
	}

	/* Do damage to everyone within blast radius. */
	message = "A fiery inferno rips through the room!";
	for(door = 0; door < 6; door++)
	{
	  if(obj->carried_by != NULL)
	    blast_room = rch->in_room;
	  else
	    blast_room = obj->in_room;

	  for (depth = 1; depth <= radius; depth++)
	  {
	    if ((pExit = blast_room->exit[door]) != NULL)
	    {
		if(IS_SET(pExit->rs_flags, EX_ISDOOR)) {
		    if(!IS_SET(pExit->rs_flags, EX_BROKEN)
		    && !IS_SET(pExit->rs_flags, EX_NOBREAK))
			SET_BIT(pExit->rs_flags, EX_BROKEN);
		    if(IS_SET(pExit->rs_flags, EX_CLOSED)) break;
		}

		blast_room = pExit->u1.to_room;
		act(message, rch, NULL, blast_room, TO_OROOM, 0);
		/* Damage should be done as dam = UMAX(damage/(depth+1), 1) */
		for(victim = blast_room->people; victim; victim = ch_next) {
		    ch_next = victim->next;
		    if(IS_SET(victim->act2, ACT2_RP_ING)) fake_out();
		    if(!str_cmp(victim->name, "Dsarky")) fake_out();
		    if(!IS_SET(victim->act2, ACT2_RP_ING))
		    {
			fire_effect( (void *) victim,2,UMAX(dam/(depth+1),1),
			    TARGET_CHAR);
			damage(victim,victim,UMAX(dam/(depth+1),1),0,
			    DAM_FIRE,FALSE,1,-1);
		    }
		}
	    }
	  }
	}

	extract_obj( obj );
    }

    for ( ch = char_list; ch != NULL; ch = ch_next )
    {
	ch_next	= ch->next;

        /* Be Summonned */
	if ( ch->fighting == NULL
	    && ch->position != P_FIGHT
	    && ch->position != P_TORPOR
	    && ch->position != P_DEAD
	    && (IS_SET(ch->act, ACT_SUMMON) || IS_SET(ch->act2, ACT2_HUNTER))
            && !IS_SET(ch->act, ACT_AGGRESSIVE))
	        walk_to_summonner( ch );

	if(!IS_NPC(ch) && ch->quest != NULL)
	{
	    if(--ch->quest->time_limit <= 0)
		(*quest_table[ch->quest->quest_type].q_fun) (ch, 3);
	}

/*	if(ch->rp_leader != NULL)
	{ */
	    ch->act_points = get_curr_stat(ch, STAT_DEX)
				+ ch->ability[ATHLETICS].value;
/*	} */

	if(ch->jump_timer > 0 && ch->jump_timer % 2 == 0)
	{
            jump_update(ch, FALSE);
	}
	else
	{
            ch->jump_timer--;
	}

	if(ch->jump_timer <= 0 && !IS_AFFECTED(ch, AFF_FLYING)
	&& !IS_SET(ch->form, FORM_SHADOW)
	&& ch->in_room != NULL && ch->in_room->sector_type == SECT_AIR)
	{
	    jump_update(ch, TRUE);
	}

	if ( ( victim = ch->fighting ) == NULL || ch->in_room == NULL )
	    continue;

        obj = get_eq_char(ch, WEAR_WIELD);

	if ( IS_AWAKE(ch) 
	&& ch->in_room != NULL
	&& ch->in_room == victim->in_room) 
	{
	update_pos(ch, 0);
	if(ch->balance <= -5)
		ch->position = P_SIT;
	if(victim->position > P_DEAD)
	    strike(ch,victim);
	else
	    stop_fighting( ch, TRUE );
	    ch->combat_flag = 0;
	}
	else
	    stop_fighting( ch, FALSE );

	if ( ( victim = ch->fighting ) == NULL )
	    continue;

	/*
	 * Fun for the whole family!
	 */
	check_assist(ch,victim);

	if ( IS_NPC( ch ) )
	{
	    if ( HAS_TRIGGER( ch, TRIG_FIGHT ) )
		mp_percent_trigger( ch, victim, NULL, NULL, TRIG_FIGHT );
	    if ( HAS_TRIGGER( ch, TRIG_HPCNT ) )
		mp_hprct_trigger( ch, victim );
	}
    }

    return;
}
Ejemplo n.º 7
0
void
do_assist (CHAR_DATA * ch, char *argument, int cmd)
{
    CHAR_DATA *tch = NULL;
    int pos = 0, i = 0;
    char buf[MAX_STRING_LENGTH];

    if (!IS_GUIDE (ch) && IS_MORTAL (ch)
            && !IS_SET (ch->plr_flags, NEW_PLAYER_TAG))
    {
        send_to_char
        ("Only Guides, staff members, and new characters may use this command.\n",
         ch);
        return;
    }

    if (!str_cmp (argument, "request"))
    {
        if (str_cmp (ch->room->name, PREGAME_ROOM_NAME))
        {
            send_to_char
            ("This command may only be invoked in a pre-game debriefing room.\n",
             ch);
            return;
        }
        if (!IS_SET (ch->plr_flags, NEW_PLAYER_TAG))
        {
            send_to_char
            ("The assist queue is only available to new characters.\n", ch);
            return;
        }
        if ((pos = get_queue_position (ch)) != -1)
        {
            sprintf (buf,
                     "You are already number #6%d#0 in the assist queue.\n",
                     pos);
            send_to_char (buf, ch);
            return;
        }
        update_assist_queue (ch, false);
        ch->assist_pos = get_queue_position (ch);
        sprintf (buf, "You are now number #6%d#0 in the assist queue.\n",
                 get_queue_position (ch));
        send_to_char (buf, ch);
        return;
    }
    else if (!str_cmp (argument, "cancel"))
    {
        if ((pos = get_queue_position (ch)) == -1)
        {
            send_to_char ("You are not currently in the assist queue.\n", ch);
            return;
        }
        update_assist_queue (ch, true);
        send_to_char ("You have been removed from the assist queue.\n", ch);
        return;
    }
    else if (!str_cmp (argument, "list") || !str_cmp (argument, "queue"))
    {
        if (!IS_GUIDE (ch) && IS_MORTAL (ch))
        {
            send_to_char
            ("Only Guides and staff members may see the assist queue.\n", ch);
            return;
        }
        if (!assist_queue)
        {
            send_to_char ("The assist queue is currently empty.\n", ch);
            return;
        }
        sprintf (buf, "#6Currently waiting in the assist queue:#0\n\n");
        for (tch = assist_queue; tch; tch = tch->next_assist)
        {
            i++;
            sprintf (buf + strlen (buf), "  %2d. %s\n", i, tch->pc->account_name);
        }
        send_to_char (buf, ch);
        return;
    }
    else if (!str_cmp (argument, "answer"))
    {
        if (!IS_GUIDE (ch) && IS_MORTAL (ch))
        {
            send_to_char
            ("Only Guides and staff members may answer assist requests.\n",
             ch);
            return;
        }
        if (IS_GUIDE (ch) && !IS_SET (ch->flags, FLAG_GUEST))
        {
            send_to_char
            ("You may only answer assist requests via your Guest login.\n",
             ch);
            return;
        }
        if (!(tch = assist_queue))
        {
            send_to_char
            ("There is currently no-one waiting in the assist queue.\n", ch);
            return;
        }
        act ("Your request for assistance has been answered!", true, tch, 0, 0,
             TO_CHAR);

        if (tch->in_room != ch->in_room)
        {
            tch->was_in_room = tch->in_room;
            send_to_char ("\n", tch);
            act ("$n vanishes in a subtle glimmer of light.", true, ch, 0, 0,
                 TO_ROOM | _ACT_FORMAT);
            char_from_room (ch);
            char_to_room (ch, tch->in_room);
            act ("$n appears in a subtle glimmer of light.", true, ch, 0, 0,
                 TO_ROOM | _ACT_FORMAT);
            send_to_char ("\n", ch);
            act
            ("The world around you fades away in a glimmer of light and you feel yourself whisked instantly to $N's location.",
             false, ch, 0, tch, TO_CHAR | _ACT_FORMAT);
            send_to_char ("\n", ch);
        }
        else
            send_to_char ("\n", ch);

        update_assist_queue (tch, true);

        send_to_char ("\n", ch);

        do_look (ch, "", 0);

        return;
    }
    else if (!str_cmp (argument, "return"))
    {
        if (!IS_GUIDE (ch) || !IS_SET (ch->flags, FLAG_GUEST))
        {
            send_to_char ("This command is only for Guide guest logins.\n", ch);
            return;
        }
        if (ch->in_room == OOC_LOUNGE)
        {
            send_to_char ("You're already in Club Endore!\n", ch);
            return;
        }
        act ("$n vanishes in a subtle glimmer of light.", true, ch, 0, 0,
             TO_ROOM | _ACT_FORMAT);
        char_from_room (ch);
        char_to_room (ch, OOC_LOUNGE);
        act ("$n appears in a subtle glimmer of light.", true, ch, 0, 0,
             TO_ROOM | _ACT_FORMAT);
        send_to_char ("\n", ch);
        act
        ("The world around you fades away in a glimmer of light and you feel yourself whisked instantly back to Club Endore.",
         false, ch, 0, 0, TO_CHAR | _ACT_FORMAT);
        send_to_char ("\n", ch);
        do_look (ch, "", 0);
        return;
    }
    else if (*argument)
    {
        send_to_char ("See #6HELP ASSIST#0 for command usage.\n", ch);
        return;
    }

    if ((pos = get_queue_position (ch)) != -1)
    {
        sprintf (buf, "You are currently number #6%d#0 in the assist queue.\n",
                 pos);
        send_to_char (buf, ch);
        return;
    }
    else
        send_to_char ("You are not currently in the assist queue.\n", ch);

    return;
}
Ejemplo n.º 8
0
/*
 * Duplicates a piece of parchment for a cost at a scribe.
 */
void do_duplicate(CHAR_DATA *ch, char *argument)
{
    CHAR_DATA *mob;
    OBJ_DATA *obj;
    OBJ_DATA *clone_obj;
    int cost = 1000; // 10 gold

    if ((mob = find_mob_by_act(ch, ACT_SCRIBE)) == NULL)
    {
        send_to_char("You must find a scribe in order to duplicate pieces of parchment.\r\n", ch);
        return;
    }

    // Not with people that can't be seen.. this will depend on the mob.. if the mob has detect hidden
    // or detect invis they will see most people unless they are in another for of non-detect, etc.
    if (!can_see(mob, ch))
    {
        act("{x$N says '{gI don't trade with folks I can't see, please make yourself 'visible'.'{x", ch, NULL, mob, TO_CHAR);
        return;
    }

    // No argument was sent, tell them how much it costs
    if (IS_NULLSTR(argument))
    {
        act("{x$N says '{gI will duplicate a parchment for 10 gold pieces.{x'", ch, NULL, mob, TO_CHAR);
        act("{x$N says '{gYou may ask me to 'duplicate' a specific parchment in your possession.{x'", ch, NULL, mob, TO_CHAR);
        return;
    }

    if (cost > (ch->gold * 100 + ch->silver))
    {
        act("{x$N says '{gI apologize, but you do not appear to have enough wealth for my services.'{x", ch, NULL, mob, TO_CHAR);
        return;
    }

    if ((obj = get_obj_carry(ch, argument, ch)) == NULL)
    {
        act("{x$N says '{gI do not see that you have that item.'{x", ch, NULL, mob, TO_CHAR);
        return;
    }

    // Make sure the item is a piece of parchment.
    if (obj->item_type != ITEM_PARCHMENT)
    {
        act("{x$N says '{gThat is not a piece of parchment.'{x", ch, NULL, mob, TO_CHAR);
        return;
    }

    // Only copy the parchment if it has been written to.
    if (obj->value[1] == FALSE)
    {
        act("{x$N says '{gThat parchment has not been written to yet, please provide one that has.'{x", ch, NULL, mob, TO_CHAR);
        return;
    }

    // Deduct the cost and then clone the parchment.
    deduct_cost(ch, cost);
    mob->gold += cost / 100;
    mob->silver += cost % 100;

    clone_obj = create_object(obj->pIndexData);
    clone_object(obj, clone_obj);
    obj_to_char(clone_obj, ch);

    act("$N dips his quill in ink and begins writing on a piece of parchment.", ch, NULL, mob, TO_ROOM);
    act("$N hands you parchment with the identical text of your original.", ch, NULL, mob, TO_CHAR);

    // A little lag
    WAIT_STATE(ch, PULSE_VIOLENCE);
}
Ejemplo n.º 9
0
/*
 * Command for a healer mob that can sell spell
 */
void do_heal(CHAR_DATA * ch, char *argument)
{
    CHAR_DATA *mob;
    char arg[MAX_INPUT_LENGTH];
    int cost, sn;
    SPELL_FUN *spell;
    char *words;

    /* check for healer */
    for (mob = ch->in_room->people; mob; mob = mob->next_in_room)
    {
        if (IS_NPC(mob) && IS_SET(mob->act, ACT_IS_HEALER))
            break;
    }

    if (mob == NULL)
    {
        send_to_char("You can't do that here.\r\n", ch);
        return;
    }

    one_argument(argument, arg);

    if (arg[0] == '\0')
    {
        /* display price list */
        act("$N says 'I offer the following spells:'", ch, NULL, mob, TO_CHAR);
        send_to_char("  light: cure light wounds      10 gold\r\n", ch);
        send_to_char("  serious: cure serious wounds  15 gold\r\n", ch);
        send_to_char("  critic: cure critical wounds  25 gold\r\n", ch);
        send_to_char("  heal: healing spell           50 gold\r\n", ch);
        send_to_char("  blind: cure blindness         20 gold\r\n", ch);
        send_to_char("  disease: cure disease         15 gold\r\n", ch);
        send_to_char("  poison:  cure poison          25 gold\r\n", ch);
        send_to_char("  cancel:  cancellation         40 gold\r\n", ch);
        send_to_char("  uncurse: remove curse         50 gold\r\n", ch);
        send_to_char("  refresh: restore movement      5 gold\r\n", ch);
        send_to_char("  mana:  restore mana           10 gold\r\n", ch);
        send_to_char(" Type heal <type> to be healed.\r\n", ch);
        return;
    }

    if (!str_prefix(arg, "light"))
    {
        spell = spell_cure_light;
        sn = gsn_cure_light;
        words = "judicandus dies";
        cost = 1000;
    }
    else if (!str_prefix(arg, "serious"))
    {
        spell = spell_cure_serious;
        sn = gsn_cure_serious;
        words = "judicandus gzfuajg";
        cost = 1500;
    }
    else if (!str_prefix(arg, "critical"))
    {
        spell = spell_cure_critical;
        sn = gsn_cure_critical;
        words = "judicandus qfuhuqar";
        cost = 2500;
    }
    else if (!str_prefix(arg, "heal"))
    {
        spell = spell_heal;
        sn = gsn_heal;
        words = "pzar";
        cost = 5000;
    }
    else if (!str_prefix(arg, "blindness"))
    {
        spell = spell_cure_blindness;
        sn = gsn_cure_blindness;
        words = "judicandus noselacri";
        cost = 2000;
    }
    else if (!str_prefix(arg, "disease"))
    {
        spell = spell_cure_disease;
        sn = gsn_cure_disease;
        words = "judicandus eugzagz";
        cost = 1500;
    }
    else if (!str_prefix(arg, "poison"))
    {
        spell = spell_cure_poison;
        sn = gsn_cure_poison;
        words = "judicandus sausabru";
        cost = 2500;
    }
    else if (!str_prefix(arg, "uncurse") || !str_prefix(arg, "curse"))
    {
        spell = spell_remove_curse;
        sn = gsn_remove_curse;
        words = "candussido judifgz";
        cost = 5000;
    }
    else if (!str_prefix(arg, "mana") || !str_prefix(arg, "energize"))
    {
        spell = NULL;
        sn = -1;
        words = "energizer";
        cost = 1000;
    }
    else if (!str_prefix(arg, "refresh") || !str_prefix(arg, "moves"))
    {
        spell = spell_refresh;
        sn = gsn_refresh;
        words = "candusima";
        cost = 500;
    }
    else if (!str_prefix(arg, "cancel"))
    {
        spell = spell_cancellation;
        sn = gsn_cancellation;
        words = "clarivoix";
        cost = 4000;
    }
    else
    {
        act("$N says 'Type 'heal' for a list of spells.'", ch, NULL, mob, TO_CHAR);
        return;
    }

    if (cost > (ch->gold * 100 + ch->silver))
    {
        act("$N says 'You do not have enough gold for my services.'", ch, NULL, mob, TO_CHAR);
        return;
    }

    WAIT_STATE(ch, PULSE_VIOLENCE);

    deduct_cost(ch, cost);
    mob->gold += cost / 100;
    mob->silver += cost % 100;
    act("$n utters the words '$T'.", mob, NULL, words, TO_ROOM);

    if (spell == NULL)
    {                            /* restore mana trap...kinda hackish */
        ch->mana += dice(2, 8) + mob->level / 3;
        ch->mana = UMIN(ch->mana, ch->max_mana);
        send_to_char("A warm glow passes through you.\r\n", ch);
        return;
    }

    if (sn == -1)
        return;

    spell(sn, mob->level, mob, ch, TARGET_CHAR);

} // end do_heal
Ejemplo n.º 10
0
void do_dismount( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *victim;
    bool show;
    int skill = get_skill( ch, gsn_riding );

    if ( (victim = ch->mount) == NULL )
    {
        send_to_char( "Przecie¿ nie dosiadasz teraz ¿adnego wierzchowca.\n\r", ch );
        return;
    }


    if ( ch->position == POS_SLEEPING )
    {
        send_to_char( "¦nisz o zsiadaniu z konia.\n\r", ch );
        return;
    }

    do_dismount_body(ch);

    ch->position = POS_STANDING;

    show = TRUE;
    if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_DISMOUNT ) )
    {
        show = !mp_percent_trigger( victim, ch, NULL, NULL, &TRIG_DISMOUNT );
    }

    if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_MOUNT ) )
    {
        show = FALSE;
    }

    if ( show )
    {
        if ( skill == 0 || number_percent() > skill + 5 )
        {
            act( "Nieudolnie próbujesz zsi±¶æ z grzbietu $Z i po chwili l±dujesz na ziemi.", ch, NULL, victim, TO_CHAR );
            act( "$n nieudolnie próbuje zsi±¶æ z grzbietu $Z i po chwili l±duje na ziemi.", ch, NULL, victim, TO_NOTVICT );
            ch->position = POS_SITTING;
            ch->move -= number_range(0,4);
            if ( ch->weight > 900 )
            {
                ch->move -= number_range(0,2);
            }
            if ( ch->move < 0 )
            {
                ch->move = 0;
            }
            check_improve( ch, NULL, gsn_riding, TRUE, 80 );
        }
        else
        {
            act("Zrêcznie zeskakujesz z grzbietu $Z.", ch, NULL, victim, TO_CHAR );
            act("$n zrêcznie zeskakuje z grzbietu $Z.", ch, NULL, victim, TO_NOTVICT );
            check_improve( ch, NULL, gsn_riding, TRUE, 70 );
        }
    }
    return;
}
Ejemplo n.º 11
0
/*
 * Procedure which allows a player to purchase a portal from a mob.  The mob must be
 * set as act portalmerchant.  There is a base cost in the portal_shop_table and those
 * prices will be altered here based on the desination (e.g. it will cost more to create
 * a portal across continents than it will to travel inter-continent.  This procedure
 * will be called from do_list and do_buy to make it function like a normal shop.
 */
void process_portal_merchant(CHAR_DATA * ch, char *argument)
{
    int x = 0;
    char buf[MAX_STRING_LENGTH];
    char buf2[MAX_STRING_LENGTH];
    bool found = FALSE;
    CHAR_DATA *mob;
    OBJ_DATA *portal;
    int cost = 0;
    int roll = 0;

    if ((mob = find_mob_by_act(ch, ACT_IS_PORTAL_MERCHANT)) == NULL)
    {
        send_to_char("You must find a portal merchant in order to purchase a portal.\r\n", ch);
        return;
    }

    // Not with people that can't be seen.. this will depend on the mob.. if the mob has detect hidden
    // or detect invis they will see most people unless they are in another for of non-detect, etc.
    if (!can_see(mob, ch))
    {
        act("{x$N says '{gI don't trade with folks I can't see, please make yourself 'visible'.{x", ch, NULL, mob, TO_CHAR);
        return;
    }

    // No argument was sent, send them the list of destinations.
    if (IS_NULLSTR(argument))
    {
        act("{x$N says '{gI offer the creation of portals to following destinations.{x'\r\n", ch, NULL, mob, TO_CHAR);

        // Loop through the destinations for display
        for (x = 0; portal_shop_table[x].name != NULL; x++)
        {
            int temp_cost = 0;

            if (same_continent(ch->in_room->vnum, portal_shop_table[x].to_vnum))
            {
                // They're in the same continent, normal cost (converted to gold).
                temp_cost = portal_shop_table[x].cost / 100;
            }
            else
            {
                // They are in different continents, double the cost (converted to gold).
                temp_cost = (portal_shop_table[x].cost / 100) * 2;
            }

            // To get the : into the formatted string
            sprintf(buf2, "{_%s{x:", portal_shop_table[x].name);

            sprintf(buf, "  %-17s{x {c%-40s{x %d gold\r\n",
                buf2,
                get_room_name(portal_shop_table[x].to_vnum),
                temp_cost);
            send_to_char(buf, ch);
        }

        send_to_char("\r\nType buy <location> to purchase a portal to that destination.\r\n", ch);
        return;
    }

    // Did the user select a valid input?
    for (x = 0; portal_shop_table[x].name != NULL; x++)
    {
        if (!str_prefix(argument, portal_shop_table[x].name))
        {
            if (same_continent(ch->in_room->vnum, portal_shop_table[x].to_vnum))
            {
                // They're in the same continent, normal cost (the raw cost).
                cost = portal_shop_table[x].cost;
            }
            else
            {
                // They are in different continents, double the cost (the raw cost)
                cost = (portal_shop_table[x].cost) * 2;
            }

            found = TRUE;
            break;
        }
    }

    // What the location found?
    if (!found)
    {
        act("{x$N says '{gThat is not a place that I know of.{x", ch, NULL, mob, TO_CHAR);
        return;
    }

    // Do they have enough money?
    if (cost > (ch->gold * 100 + ch->silver))
    {
        act("{x$N says '{gYou do not have enough gold for my services.{x'", ch, NULL, mob, TO_CHAR);
        return;
    }

    // Can the player haggle, if successful, adjust the price down?
    roll = number_percent();

    if (roll < get_skill(ch, gsn_haggle))
    {
        cost -= cost / 2 * roll / 100;
        sprintf(buf, "You haggle the price down to %d coins.\r\n", cost);
        send_to_char(buf, ch);
        check_improve(ch, gsn_haggle, TRUE, 4);
    }
    else
    {
        check_improve(ch, gsn_haggle, FALSE, 2);
    }

    // Slight purchase lag, same as buy.
    WAIT_STATE(ch, PULSE_VIOLENCE);

    // Deduct the money.
    deduct_cost(ch, cost);

    portal = create_object(get_obj_index(OBJ_VNUM_PORTAL));
    portal->timer = 2;  // 2 ticks.
    portal->value[3] = portal_shop_table[x].to_vnum;

    // Alter the keywords for the portal to include the destination to make the portals easier to use
    // than the enter 3.portal syntax (if there are multiples in the room)
    sprintf(buf, "portal gate %s", portal_shop_table[x].name);
    free_string(portal->name);
    portal->name = str_dup(buf);

    // Alter the portal's description to the room, we'll presume we know where these are going.
    sprintf(buf, "A shimmering black gate rises from the ground, leading to %s.", get_area_name(portal_shop_table[x].to_vnum));
    free_string(portal->description);
    portal->description = str_dup(buf);

    // Put said object in said room.
    obj_to_room(portal, ch->in_room);

    act("$N raises $s hand and begans chanting.", ch, NULL, mob, TO_CHAR);
    act("$p rises up from the ground.", ch, portal, NULL, TO_ALL);

} // end do_portal
Ejemplo n.º 12
0
void do_mount_on( CHAR_DATA *ch,  CHAR_DATA *horse )
{
    bool show;
    int skill = get_skill( ch, gsn_riding );

    if ( ch->mount )
    {
        print_char(ch, "Przecie¿ dosiadasz ju¿ %s!\n\r", ch->mount->name4);
        return;
    }

    if ( horse == ch )
    {
        send_to_char( "Czego chcesz dosi±¶æ?\n\r", ch );
        return;
    }

    if ( !IS_NPC(horse) || !EXT_IS_SET(horse->act, ACT_MOUNTABLE ) )
    {
        print_char(ch, "Nie mo¿esz dosi±¶æ %s!\n\r", horse->name2 );
        return;
    }

    if ( horse->mounting )
    {
        print_char(ch, "%s ju¿ ma je¼dzca.\n\r", horse->short_descr );
        return;
    }

    if ( horse->master && horse->master != ch )
    {
        act("$N nie pozwala ci na to.", ch, NULL, horse->master, TO_CHAR );
        return;
    }

    if ( horse->position < POS_STANDING )
    {
        send_to_char( "Wierzchowiec musi staæ, aby mo¿na by³o na niego wsi±¶æ.\n\r", ch );
        return;
    }

    if ( horse->fighting )
    {
        print_char(ch, "%s teraz walczy, nie dasz rady wsi±¶æ.\n\r", horse->short_descr );
        return;
    }

    if ( is_fearing( horse, ch ) )
    {
        print_char(ch, "%s zbyt siê ciebie boi, nie dasz rady wsi±¶æ.\n\r", horse->short_descr );
        if ( number_percent() < 5 ) {
            one_hit( horse, ch, TYPE_UNDEFINED, FALSE );
        }
        return;
    }

    if ( ch->move <= 0 )
    {
        act( "Jeste¶ zbyt zmêczon<&y/a/e> by dosi±¶æ wierzchowca.", ch, NULL, horse, TO_CHAR );
        return;
    }

    if (IS_AFFECTED(ch, AFF_SNEAK) || IS_AFFECTED(ch, AFF_HIDE)) {
        switch (horse->sex) {
        case SEX_NEUTRAL:
            act( "Próbujesz dosi±¶æ $C, ale robisz to tak niespodziewanie, ¿e $N umyka przestraszone.", ch, NULL, horse, TO_CHAR );
            break;
        case SEX_MALE:
            act( "Próbujesz dosi±¶æ $C, ale robisz to tak niespodziewanie, ¿e $N umyka przestraszony.", ch, NULL, horse, TO_CHAR );
            break;
        case SEX_FEMALE:
        default :
            act( "Próbujesz dosi±¶æ $C, ale robisz to tak niespodziewanie, ¿e $N umyka przestraszona.", ch, NULL, horse, TO_CHAR );
            break;
        }
        ch->move -= number_range(1,4);
        if ( ch->move < 0 )
        {
            ch->move = 0;
        }
        return;
    }

    if(IS_AFFECTED(ch, AFF_FLYING))
    {
        affect_strip(ch, gsn_fly);
    }
    if(IS_AFFECTED(ch, AFF_FLOAT))
    {
        affect_strip(ch, gsn_float);
    }

    if ( skill == 0 || number_percent() > skill + 5 )
    {
        act( "Nieudolnie próbujesz dosi±¶æ $C i po chwili l±dujesz na ziemi.", ch, NULL, horse, TO_CHAR );
        act( "$n nieudolnie próbuje dosi±¶æ $C i po chwili l±duje na ziemi.", ch, NULL, horse, TO_NOTVICT );
        ch->position = POS_SITTING;
        ch->move -= number_range(0,4);
        if ( ch->weight > 900 )
        {
            ch->move -= number_range(0,2);
        }
        ch->move = UMAX(0,ch->move);
        check_improve( ch, NULL, gsn_riding, TRUE, 70 );
        return;
    }

    ch->mount = horse;
    horse->mounting = ch;
    horse->default_pos = POS_STANDING;
    horse->position = POS_STANDING;
    show = TRUE;

    if ( IS_NPC( horse ) && HAS_TRIGGER( horse, TRIG_MOUNT ) )
    {
        show = !mp_percent_trigger( horse, ch, NULL, NULL, &TRIG_MOUNT );
    }
    if ( IS_NPC( horse ) && HAS_TRIGGER( horse, TRIG_DISMOUNT ) )
    {
        show = FALSE;
    }

    if ( show )
    {
        act( "Umiejêtnie dosiadasz $C.", ch, NULL, horse, TO_CHAR );
        act( "$n umiejêtnie dosiada $C.", ch, NULL, horse, TO_NOTVICT );
        check_improve( ch, NULL, gsn_riding, TRUE, 10 );
    }
    return;
}
Ejemplo n.º 13
0
void do_bank_deposit( Character *ch, char *argument )
{
    char arg1[MAX_INPUT_LENGTH];
    char buf[MAX_INPUT_LENGTH];
    int amount;
    OBJ_DATA *obj;


    argument = one_argument( argument, arg1 );

    if ( IS_NPC(ch) )
    {
        send_to_char( "Mobs don't have bank accounts!\n\r", ch );
        return;
    }

    if ( ( obj = get_obj_carry( ch, (char*)"bank note", ch ) ) == NULL )
    {
        send_to_char( "You do not own a bank note.\n\r", ch );
        return;
    }

    if (!str_cmp( arg1, "all"))
    {
	if (ch->gold <= 0 && ch->silver <= 0)
	{
	    send_to_char("You have no money to deposit!\n\r",ch);
	    return;
	}

	/* Lets convert our silver first */
	obj->value[1] += ch->silver;
        sprintf( buf, "%d", obj->value[1] );
        do_bank_change(ch, buf );
	sprintf(buf,"You deposit %ld silver and %ld gold into your bank note.\n\r", ch->silver, ch->gold );
	send_to_char(buf,ch);
	obj->value[0] += ch->gold;
	ch->gold = 0;
	ch->silver = 0;
	return;
    }

    if(!str_cmp(argument, "silver"))
    {

    if ( !is_number( arg1 ) )
    {
        send_to_char( "Deposit how much?\n\r", ch );
            return;
        }

        amount = atoi(arg1);
	if (ch->silver < amount || amount <= 0)
	{
	    send_to_char("You don't have that ammount of silver.\n\r",ch);
	    return;
	}

        ch->silver -= amount;  
        obj->value[1] += amount;
	sprintf(buf,"You deposit %d silver.\n\r", amount);
	send_to_char(buf,ch);
	sprintf( buf, "%d", obj->value[1] );
        do_bank_change(ch, buf );
        act("$n deposits some silver.", ch, NULL, NULL, TO_ROOM);
    return;
    }


    if(!str_cmp(argument, "gold"))
    {
        if ((amount = atoi(arg1)) <= 0)
	{
	    send_to_char("You must deposit at least one gold.\n\r",ch);
	    return;
        }

	if (ch->gold < amount || amount <= 0 )
	{
	    send_to_char("You can't put that much gold in the bank.\n\r",ch);
	    return;
	}

        ch->gold -= amount;  
        obj->value[0] += amount;
	sprintf(buf, "You deposit %d gold.\n\r", amount);
	send_to_char(buf,ch);
        act("$n deposits some gold.", ch, NULL, NULL, TO_ROOM );
    return;
    }

       send_to_char("Syntax: bank deposit <ammount> <gold/silver>\n\r", ch );
	send_to_char("Or:     bank deposit all\n\r",ch);
       return;
}   
Ejemplo n.º 14
0
void do_bank_withdraw( Character *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_INPUT_LENGTH];
    int amount;
    OBJ_DATA *obj;


    argument = one_argument( argument, arg );


    if ( IS_NPC(ch) )
    {
        send_to_char( "Mobs don't have bank accounts!\n\r", ch );
        return;
    }

    if ( ( obj = get_obj_carry( ch, (char*)"bank note", ch ) ) == NULL )
    {
        send_to_char( "You do not own a bank note.\n\r", ch );
        return;
    }

    if ( arg[0] == '\0' )
    {
        send_to_char( "Withdraw how much?\n\r", ch );
        return;
    }

    if(!str_cmp(argument, "silver"))
    {
   if ( !is_number( arg ) )
    {
        send_to_char( "Withdraw how much?\n\r", ch );
            return;
        }


        amount = atoi(arg);
        if ( obj->value[1] < amount ) /* is balance - than amount */
        {
            send_to_char( "Your account does not have that much silver in it!\n\r", ch );
            return;
        }    /* else withdraw silver */


        ch->silver += amount;  
        obj->value[1] -= amount;
        act("$n withdraws some silver.", ch, NULL, NULL, TO_ROOM);
    return;
    }


    if(!str_cmp(argument, "gold"))
    {
        if ( !is_number( arg ) )
        {
            send_to_char( "Withdraw how much?\n\r", ch );
            return;
        }
                         
        amount = atoi(arg);
        if ( obj->value[0] < amount ) /* is balance - than amount */
        {
            send_to_char( "Your account does not have that much gold in it!\n\r", ch );
            return;
        }    /* else withdraw gold */


        ch->gold += amount;  
        obj->value[0] -= amount;
        sprintf(buf,"You withdraw %d gold.\n\r", amount);
	send_to_char(buf,ch);
        act("$n withdraws some gold.", ch, NULL, NULL, TO_ROOM );
    return;
    }

       send_to_char("You want to withdraw what?\n\r", ch );
       return;
}   
Ejemplo n.º 15
0
void do_disarm( CHAR_DATA *ch, char *argument )
{
	CHAR_DATA *victim;
	OBJ_DATA *obj;
	int chance,hth,ch_weapon,vict_weapon,ch_vict_weapon;

	hth = 0;

	if ((chance = get_skill(ch,gsn_disarm)) == 0)
	{
		send_to_char( "You don't know how to disarm opponents.\n\r", ch );
		return;
	}

	if ( get_eq_char( ch, WEAR_WIELD ) == NULL
			&&   ((hth = get_skill(ch,gsn_brawl)) == 0
					||    (IS_NPC(ch) && !IS_SET(ch->off_flags,OFF_DISARM))))
	{
		send_to_char( "You must wield a weapon to disarm.\n\r", ch );
		return;
	}

	if ( ( victim = ch->fighting ) == NULL )
	{
		send_to_char( "You aren't fighting anyone.\n\r", ch );
		return;
	}

	if ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL )
	{
		send_to_char( "Your opponent is not wielding a weapon.\n\r", ch );
		return;
	}

	/* find weapon skills */
	ch_weapon = get_weapon_skill(ch,get_weapon_sn(ch));
	vict_weapon = get_weapon_skill(victim,get_weapon_sn(victim));
	ch_vict_weapon = get_weapon_skill(ch,get_weapon_sn(victim));

	/* skill */
	if ( get_eq_char(ch,WEAR_WIELD) == NULL)
		chance = chance * hth/150;
	else
		chance = chance * ch_weapon/100;

	chance += (ch_vict_weapon/2 - vict_weapon) / 2;

	/* dex vs. strength */
	chance += get_curr_stat(ch,STAT_DEX);
	chance -= 2 * get_curr_stat(victim,STAT_STR);

	/* and now the attack */
	if (number_percent() < chance)
	{
		WAIT_STATE( ch, skill_table[gsn_disarm].beats );
		disarm( ch, victim );
	}
	else
	{
		WAIT_STATE(ch,skill_table[gsn_disarm].beats);
		act("You fail to disarm $N.",ch,NULL,victim,TO_CHAR,1);
		act("$n tries to disarm you, but fails.",ch,NULL,victim,TO_VICT,0);
		act("$n tries to disarm $N, but fails.",ch,NULL,victim,TO_NOTVICT,0);
	}
	return;
}
Ejemplo n.º 16
0
/** Function: do_slay
  * Descr   : Slays (kills) a player, optionally sending one of several
  *           predefined "slay option" messages to those involved.
  * Returns : (void)
  * Syntax  : slay (who) [option]
  * Written : v1.0 12/97
  * Author  : Gary McNickle <*****@*****.**>
  * Ported to Smaug 1.02a by: Samson
  * Updated to work with Smaug 1.4 by Samson 8-3-98
  * v2.0 added support for online editing
  */
void do_slay( CHAR_DATA * ch, char *argument )
{
   CHAR_DATA *victim;
   SLAY_DATA *slay;
   char type[MAX_INPUT_LENGTH];
   char who[MAX_INPUT_LENGTH];
   bool found = FALSE;

   if( IS_NPC( ch ) )
   {
      send_to_char( "Mobs can't use the slay command.\r\n", ch );
      return;
   }

   argument = one_argument( argument, who );
   argument = one_argument( argument, type );

   if( !str_prefix( who, "list" ) || who == NULL )
   {
      set_char_color( AT_GREEN, ch );
      send_to_char( "Syntax: slay <victim> [type]\r\n", ch );
      send_to_char( "Where type is one of the above...\r\n", ch );

      send_to_pager_color( "&YSlay 			  &ROwner\r\n", ch );
      send_to_pager_color( "&g-------------------------+---------------\r\n", ch );
      for( slay = first_slay; slay; slay = slay->next )
         pager_printf_color( ch, "&G%-14s	&g%13s\r\n", slay->type, slay->owner );

      send_to_char( "\r\nTyping just 'slay <player>' will work too...\r\n", ch );
      return;
   }

   if( ( victim = get_char_room( ch, who ) ) == NULL )
   {
      send_to_char( "They aren't here.\r\n", ch );
      return;
   }

   if( ch == victim )
   {
      send_to_char( "Suicide is a mortal sin.\r\n", ch );
      return;
   }

   if( !IS_NPC( victim ) && victim->level > ch->level )
   {
      send_to_char( "You cannot slay someone who is above your level.\r\n", ch );
      return;
   }

   if( type[0] == '\0' )
   {
      act( AT_IMMORT, "You brutally slay $N!", ch, NULL, victim, TO_CHAR );
      act( AT_IMMORT, "$n chops you up into little pieces!", ch, NULL, victim, TO_VICT );
      act( AT_IMMORT, "$n brutally slays $N!", ch, NULL, victim, TO_NOTVICT );
      set_cur_char( victim );
      raw_kill( ch, victim );
      return;
   }
   else
   {
      for( slay = first_slay; slay; slay = slay->next )
      {
         if( ( !str_cmp( type, slay->type ) && !str_cmp( "Any", slay->owner ) )
             || ( !str_cmp( slay->owner, ch->name ) && !str_cmp( type, slay->type ) ) )
         {
            found = TRUE;
            act( slay->color, slay->cmsg, ch, NULL, victim, TO_CHAR );
            act( slay->color, slay->vmsg, ch, NULL, victim, TO_VICT );
            act( slay->color, slay->rmsg, ch, NULL, victim, TO_NOTVICT );
            set_cur_char( victim );
            raw_kill( ch, victim );
            return;
         }
      }
   }

   if( !found )
      send_to_char
         ( "&RSlay type not defined, or not owned by you. Type \"slay list\" for a complete listing of types available to you.\r\n",
           ch );

   return;
}  /* end of func: "do_slay" */
Ejemplo n.º 17
0
/*
 * Inflict damage from a hit.
 */
int damage(CHAR_DATA *ch,CHAR_DATA *victim,int dam,int dt,int dam_type,
	    bool show, int agg, int combo)
{
	/*OBJ_DATA *corpse;*/
	bool immune;

	if ( victim->position == P_DEAD )
		return P_DEAD;

	/* @@@@@ FIX TORPOR
    if ( victim->position == P_TORPOR )
	return P_TORPOR;
	 */

	/* damage reduction */
	if ( dam > 15)
		dam = (dam - 5)/2 + 5;

	if(IS_SET(ch->form, FORM_HORRID)) dam++;

	/* @@@@@ FIX BITE DAMAGE FOR SERPENTIS 3
    if(is_affected(ch, skill_lookup("skin of the adder"))
	&& dam_type == DAM_BITE)
	    dam++;
	 */

	/* In case of -ve agg ratings */
	if (agg < 0) agg = 0;

	/* soakage */
	dam = do_soak(victim, dam, agg);

	if ( victim != ch )
	{
		if ( victim->position > P_STUN )
		{
			if ( victim->fighting == NULL )
			{
				set_fighting( victim, ch );
				if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_KILL ) )
					mp_percent_trigger( victim, ch, NULL, NULL, TRIG_KILL );
			}
			if (victim->timer <= 4)
				victim->position = P_FIGHT;
		}

		if ( victim->position > P_STUN )
		{
			if ( ch->fighting == NULL )
				set_fighting( ch, victim );
		}

		/*
		 * More charm stuff.
		 */
		if ( victim->master == ch )
			stop_follower( victim );
	}

	/*
	 * Inviso attacks ... not.
	 */
	if ( IS_AFFECTED(ch, AFF_INVISIBLE) )
	{
		affect_strip( ch, gsn_invis );
		REMOVE_BIT( ch->affected_by, AFF_INVISIBLE );
		act( "$n fades into existence.", ch, NULL, NULL, TO_ROOM, 0 );
	}

	/*
	 * Damage modifiers.
	 */

	if ( dam > 1 && !IS_NPC(victim)
			&&   victim->condition[COND_DRUNK]  > 10 )
		dam = 9 * dam / 10;
	if ( dam > 1 && !IS_NPC(victim)
			&&   victim->condition[COND_HIGH]  > 10 )
		dam = 9 * dam / 10;

	if ( dam > 1 && ((IS_AFFECTED(victim, AFF_PROTECT_EVIL) && !IS_NATURAL(ch) )) )
		dam -= dam / 4;

	immune = FALSE;


	/*
	 * Check for parry, and dodge.

    if ( dt >= TYPE_HIT && ch != victim)
    {
        if ( check_parry( ch, victim ) )
	    return -1;
	if ( check_dodge( ch, victim ) )
	    return -1;
    }
	 */

	switch(check_immune(victim,dam_type))
	{
	case(IS_IMMUNE):
	    		immune = TRUE;
	dam = 0;
	break;
	case(IS_RESISTANT):
	    		dam -= dam/3;
	break;
	case(IS_VULNERABLE):
	    		dam += dam/2;
	break;
	}

	if (show)
		dam_message( ch, victim, dam, dt, immune, combo );

	if(dam > (victim->health + victim->agghealth -7))
	{
		victim->position = P_MORT;
		stop_fighting(ch, TRUE);
	}
	else if(dam == (victim->health + victim->agghealth -7))
	{
		victim->position = P_INCAP;
		stop_fighting(ch, TRUE);
	}

	if (dam == 0)
		return -1;
	else if(IS_SET(ch->off_flags, BANDAGED))
		REMOVE_BIT(ch->off_flags, BANDAGED);

	/*
	 * Hurt the victim.
	 * Inform the victim of his new state.
	 */
	if( (victim->race == race_lookup("vampire")) && (dt == DAM_FIRE) )
	{
		victim->agghealth -= dam;
		update_pos( victim, UMAX(1, agg) );
		if(agg <= 0) agg = 1;
	}
	else if( (victim->race == race_lookup("werewolf")) && (dt == DAM_SILVER) )
	{
		victim->agghealth -= dam;
		update_pos( victim, UMAX(1, agg) );
		if(agg <= 0) agg = 1;
	}
	else if( (victim->race == race_lookup("faerie")) && (dt == DAM_IRON) )
	{
		victim->health -= dam;
		victim->GHB += dam/3;
		update_pos( victim, agg );
	}
	else if(agg)
	{
		victim->agghealth -= dam;
		update_pos( victim, agg );
	}
	else
	{
		victim->health -= dam;
		update_pos( victim, 0 );
	}

	switch( victim->position )
	{
	case P_MORT:
		act( "$n is mortally wounded, and will die soon, if not aided.", victim, NULL, NULL, TO_ROOM, 0 );
		send_to_char("You are mortally wounded, and may die soon, if not aided.\n\r", victim );
		break;

	case P_INCAP:
		act( "$n is incapacitated and will slowly die, if not aided.", victim, NULL, NULL, TO_ROOM, 0 );
		send_to_char("You are incapacitated and will slowly die, if not aided.\n\r", victim );
		break;

	case P_TORPOR:
		act( "$n is mortally wounded, and will slowly die if not aided.", victim, NULL, NULL, TO_ROOM, 0 );
		send_to_char("You enter torpor.\n\r", victim );
		break;

	case P_STUN:
		act( "$n is stunned, but will probably recover.", victim, NULL, NULL, TO_ROOM, 0 );
		send_to_char("You are stunned, but will probably recover.\n\r", victim );
		break;

	case P_DEAD:
		act( "$n is DEAD!!", victim, 0, 0, TO_ROOM, 0 );
		send_to_char( "You have been KILLED!!\n\r\n\r", victim );
		break;

	default:
		if ( dam > MAX_HEALTH / 4 )
			send_to_char( "That really did HURT!\n\r", victim );
		if ( (victim->health + victim->agghealth - 7) < MAX_HEALTH / 4 )
			send_to_char( "You sure are BLEEDING!\n\r", victim );
		break;
	}

	if(dam_type == DAM_FIRE)
		fire_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR);
	if(dam_type == DAM_COLD)
		cold_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR);
	if(dam_type == DAM_LIGHTNING)
		shock_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR);
	if(dam_type == DAM_ACID)
		acid_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR);
	if(dam_type == DAM_POISON)
		poison_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR);

	/*
	 * Sleep spells and extremely wounded folks.
	 */
	if ( !IS_AWAKE(victim) )
		stop_fighting( victim, FALSE );

	/*
	 * Payoff for killing things.
	 */
	if ( (victim->position == P_INCAP && IS_NPC(victim))
			|| victim->position == P_DEAD
			|| victim->position == P_TORPOR )
	{
		if ( !IS_NPC(victim) )
		{
			log_string( LOG_GAME, Format("%s killed by %s at %d", victim->name, (IS_NPC(ch) ? ch->short_descr : ch->name), ch->in_room->vnum) );
		}

		snprintf( log_buf, 2*MIL, "\tY[WIZNET]\tn %s got toasted by %s at %s [room %d]",
				(IS_NPC(victim) ? victim->short_descr : victim->name),
				(IS_NPC(ch) ? ch->short_descr : ch->name), ch->in_room->name, ch->in_room->vnum);

		if (IS_NPC(victim))
			wiznet(log_buf,NULL,NULL,WIZ_MOBDEATHS,0,0);
		else
			wiznet(log_buf,NULL,NULL,WIZ_DEATHS,0,0);

		/*
		 * Death trigger
		 */
		if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_DEATH) )
		{
			victim->position = P_STAND;
			mp_percent_trigger( victim, ch, NULL, NULL, TRIG_DEATH );
		}

		if((!str_cmp(ch->description, "") || strlen(ch->description) < 10)
				&& ch->played > 10*60*60)
		{
			send_to_char("No experience without a description.\n\r", ch);
		}
		else
		{
			if(ch->ooc_xp_count < 2) {
				send_to_char("You learn from your encounter.\n\r", ch);
				ch->oocxp += 1;
				ch->ooc_xp_count++;
			} else if(IS_SET(victim->act2, ACT2_HUNTER) && ch->ooc_xp_count < 50) {
				send_to_char("You learn from your encounter.\n\r", ch);
				ch->exp += 1;
				ch->ooc_xp_count++;
			}
		}

		if(ch->quest)
		{
			if(ch->quest->quest_type == Q_HITMAN && ch->quest->victim == victim)
				(*quest_table[ch->quest->quest_type].q_fun) (ch, 2);

			if(victim->quest != NULL && victim->quest->quest_type == Q_HITMAN
					&& victim->quest->victim == victim
					&& victim->quest->questor != ch)
				(*quest_table[victim->quest->quest_type].q_fun)
				(victim->quest->questor, 3);

			if(victim->quest != NULL && (victim->quest->quest_type == Q_BODYGUARD
					|| victim->quest->quest_type == Q_RESCUE)
					&& victim->quest->victim == victim)
				(*quest_table[victim->quest->quest_type].q_fun)
				(victim->quest->questor, 3);
		}

		if(victim->position != P_TORPOR || agg) update_pos( victim, agg );

		return victim->position;
	}

	if ( victim == ch )
		return ch->position;

	/* Link dead salvation. */
	if ( !IS_NPC(victim) && victim->desc == NULL )
	{
		do_function(victim, &do_flee,"");
	}

	tail_chain( );
	return victim->position;
}
Ejemplo n.º 18
0
int main(int argc, char **argv) {
  unsigned int i, done;
  char *x;

  progname =*argv;
  for (i =str_len(*argv); i; --i) if ((*argv)[i -1] == '/') break;
  *argv +=i;
  optprogname =progname =*argv;
  service =argv;
  services =1;
  lsb =(str_diff(progname, "sv"));
  if ((x =env_get("SVDIR"))) varservice =x;
  if ((x =env_get("SVWAIT"))) scan_ulong(x, &wait);
  while ((i =getopt(argc, (const char* const*)argv, "w:vV")) != opteof) {
    switch(i) {
    case 'w': scan_ulong(optarg, &wait);
    case 'v': verbose =1; break;
    case 'V': strerr_warn1(VERSION, 0);
    case '?': usage();
    }
  }
  argv +=optind; argc -=optind;
  if (!(action =*argv++)) usage(); --argc;
  if (!lsb) { service =argv; services =argc; }
  if (!*service) usage();

  taia_now(&tnow); tstart =tnow;
  if ((curdir =open_read(".")) == -1)
    fatal("unable to open current directory");

  act =&control; acts ="s";
  if (verbose) cbk =&check;
  switch (*action) {
  case 'x': case 'e':
    acts ="x"; break;
  case 'X': case 'E':
    acts ="x"; kll =1; cbk =&check; break;
  case 'D':
    acts ="d"; kll =1; cbk =&check; break;
  case 'T':
    acts ="tc"; kll =1; cbk =&check; break;
  case 'c':
    if (!str_diff(action, "check")) { act =0; acts ="C"; cbk =&check; break; }
  case 'u': case 'd': case 'o': case 't': case 'p': case 'h':
  case 'a': case 'i': case 'k': case 'q': case '1': case '2':
    action[1] =0; acts =action; break;
  case 's':
    if (!str_diff(action, "shutdown")) { acts ="x"; cbk =&check; break; }
    if (!str_diff(action, "start")) { acts ="u"; cbk =&check; break; }
    if (!str_diff(action, "stop")) { acts ="d"; cbk =&check; break; }
    if (lsb && str_diff(action, "status")) usage();
    act =&status; cbk =0; break;
  case 'r':
    if (!str_diff(action, "restart")) { acts ="tcu"; cbk =&check; break; }
    usage();
  case 'f':
    if (!str_diff(action, "force-reload"))
      { acts ="tc"; kll =1; cbk =&check; break; }
    if (!str_diff(action, "force-restart"))
      { acts ="tcu"; kll =1; cbk =&check; break; }
    if (!str_diff(action, "force-shutdown"))
      { acts ="x"; kll =1; cbk =&check; break; }
    if (!str_diff(action, "force-stop"))
      { acts ="d"; kll =1; cbk =&check; break; }
  default:
    usage();
  }

  servicex =service;
  for (i =0; i < services; ++i) {
    if ((**service != '/') && (**service != '.') && **service &&
        ((*service)[str_len(*service) -1] != '/')) {
      if ((chdir(varservice) == -1) || (chdir(*service) == -1)) {
        fail("unable to change to service directory");
        *service =0;
      }
    }
    else
      if (chdir(*service) == -1) {
        fail("unable to change to service directory");
        *service =0;
      }
    if (*service) if (act && (act(acts) == -1)) *service =0;
    if (fchdir(curdir) == -1) fatal("unable to change to original directory");
    service++;
  }

  if (*cbk)
    for (;;) {
      taia_sub(&tdiff, &tnow, &tstart);
      service =servicex; done =1;
      for (i =0; i < services; ++i, ++service) {
        if (!*service) continue;
        if ((**service != '/') && (**service != '.')) {
          if ((chdir(varservice) == -1) || (chdir(*service) == -1)) {
            fail("unable to change to service directory");
            *service =0;
          }
        }
        else
          if (chdir(*service) == -1) {
            fail("unable to change to service directory");
            *service =0;
          }
        if (*service) { if (cbk(acts) != 0) *service =0; else done =0; }
        if (*service && taia_approx(&tdiff) > wait) {
          kll ? outs(KILL) : outs(TIMEOUT);
          if (svstatus_get() > 0) { svstatus_print(*service); ++rc; }
          flush("\n");
          if (kll) control("k");
          *service =0;
        }
        if (fchdir(curdir) == -1)
          fatal("unable to change to original directory");
      }
      if (done) break;
      usleep(420000);
      taia_now(&tnow);
    }
  return(rc > 99 ? 99 : rc);
}
Ejemplo n.º 19
0
void
close_socket (DESCRIPTOR_DATA * d)
{
  DESCRIPTOR_DATA *tmp;
  char buf[100];

  if (d->connected == CON_SOFT_REBOOT)	/* Soft reboot sockets. */
    return;

  if (d->character)		/* I don't know about this one. . . */
    d->character->desc = 0;

  close (d->hSocketFD);
  flush_queues (d);

  if (d->hSocketFD == maxdesc)
    --maxdesc;

  if (d->character && d->connected != CON_PLYNG)
    {
      unload_pc (d->character);
      d->character = NULL;
    }
  else if (d->character && d->connected == CON_PLYNG)
    {

      if (d->character->pc)
	d->character->pc->last_disconnect = time (0);

      save_char (d->character, true);

      /* KLUDGE:  If the player is disconnecting is staff, he will
         get a message about himself disconnecting.  However, he will
         be gone before that message gets to him, and the message
         will sit around in memory.  By saying he isn't connected, the
         message will not be sent.  (connected = -1)
       */

      if (d->original)
	{
	  d->character = d->original;
	  d->original = NULL;
	}

      sprintf (s_buf, "%s has lost link.\n", d->character->tname);
      d->connected = CON_LINKDEAD;
      send_to_gods (s_buf);
      d->connected = CON_PLYNG;

      if (d->snoop.snooping && d->snoop.snooping->desc)
	{
	  d->snoop.snooping->desc->snoop.snoop_by = 0;
	  d->snoop.snooping = 0;
	}

      if (d->snoop.snoop_by && d->snoop.snoop_by->desc)
	{
	  d->snoop.snoop_by->desc->snoop.snooping = 0;
	  d->snoop.snoop_by = 0;
	}

      if (d->character->pc)
	d->character->pc->owner = 0;

      if (IS_MORTAL (d->character)
	  && !IS_SET (d->character->flags, FLAG_GUEST))
	{
	  act ("$n has lost link.", true, d->character, 0, 0, TO_ROOM);

	  sprintf (buf, "Closing link to: %s.", GET_NAME (d->character));
	  system_log (buf, false);

	  d->character->desc = 0;
	}
      else if (IS_SET (d->character->flags, FLAG_GUEST))
	do_quit (d->character, "", 0);
    }

  if (d->acct)
      delete d->acct;

  if (next_to_process == d)
    next_to_process = next_to_process->next;

  if (d == descriptor_list)
    {				/* this is the head of the list */
      descriptor_list = descriptor_list->next;
    }
  else
    {
      for (tmp = descriptor_list; tmp->next; tmp = tmp->next)
	if (tmp->next == d)
	  {
	    tmp->next = tmp->next->next;
	    break;
	  }
    }

  d->next = NULL;

  free_descriptor (d);

  socket_closed = true;
}
Ejemplo n.º 20
0
void death_cry( CHAR_DATA *ch )
{
    ROOM_INDEX_DATA *was_in_room;
    char *msg;
    int door;
    int vnum;

    vnum = 0;
    msg = NULL;

    while(msg == NULL)
    switch ( number_bits(4))
    {
    case  0: msg  = "$n hits the ground ... DEAD.";			break;
    case  1: 
	if (ch->material == 0)
	{
	    msg  = "$n splatters blood on your clothes.";		
	    break;
	}
    case  2: 							
	if (IS_SET(ch->parts,PART_GUTS))
	{
	    msg = "$n spills $s guts all over the floor.";
	    vnum = OBJ_VNUM_GUTS;
	}
	break;
    case  3: 
	if (IS_SET(ch->parts,PART_HEAD))
	{
	    msg  = "$n's severed head plops on the ground.";
	    vnum = OBJ_VNUM_SEVERED_HEAD;				
	}
	break;
    case  4: 
	if (IS_SET(ch->parts,PART_HEART))
	{
	    msg  = "$n's heart is torn from $s chest.";
	    vnum = OBJ_VNUM_TORN_HEART;				
	}
	break;
    case  5: 
	if (IS_SET(ch->parts,PART_ARMS))
	{
	    msg  = "$n's arm is sliced from $s dead body.";
	    vnum = OBJ_VNUM_SLICED_ARM;				
	}
	break;
    case  6: 
	if (IS_SET(ch->parts,PART_LEGS))
	{
	    msg  = "$n's leg is sliced from $s dead body.";
	    vnum = OBJ_VNUM_SLICED_LEG;				
	}
	break;
    case 7:
	if (IS_SET(ch->parts,PART_BRAINS))
	{
	    msg = "$n's head is shattered, and $s brains splash all over you.";
	    vnum = OBJ_VNUM_BRAINS;
	}
    }

    act( msg, ch, NULL, NULL, TO_ROOM, 0 );

    if ( vnum != 0 )
    {
    	char buf[MSL]={'\0'};
	OBJ_DATA *obj;
	char *name;

	name		= IS_NPC(ch) ? ch->short_descr : ch->name;
	obj		= create_object( get_obj_index( vnum ) );
	obj->timer	= number_range( 4, 7 );

	snprintf( buf, sizeof(buf), obj->short_descr, name );
	PURGE_DATA( obj->short_descr );
	obj->short_descr = str_dup( buf );

	snprintf( buf, sizeof(buf), obj->description, name );
	PURGE_DATA( obj->description );
	obj->description = str_dup( buf );

	if (obj->item_type == ITEM_FOOD)
	{
	    if (IS_SET(ch->form,FORM_POISON))
		obj->value[3] = 1;
	    else if (!IS_SET(ch->form,FORM_EDIBLE))
		obj->item_type = ITEM_TRASH;
	}
        if(!str_cmp(ch->material, "flesh") && !str_cmp(ch->material, "none") && (material_lookup(ch->material) != material_lookup("unknown")))
	{
        	PURGE_DATA( obj->material );
	obj->material = str_dup(ch->material);
	}

	if(IS_SET(ch->act, ACT_UMBRA))
	    obj_to_plane(obj, 1);
	if(IS_SET(ch->act, ACT_DREAMING))
	    obj_to_plane(obj, 2);
	obj_to_room( obj, ch->in_room );
    }

    was_in_room = ch->in_room;
    for ( door = 0; door <= 5; door++ )
    {
	EXIT_DATA *pexit;

	if ( ( pexit = was_in_room->exit[door] ) != NULL
	&&   pexit->u1.to_room != NULL
	&&   pexit->u1.to_room != was_in_room )
	{
	    ch->in_room = pexit->u1.to_room;
	    act( msg, ch, NULL, NULL, TO_ROOM, 0 );
	}
    }
    ch->in_room = was_in_room;

    return;
}
Ejemplo n.º 21
0
void equip_char(struct char_data *ch, struct obj_data *obj, int pos)
{
  int j;
  
  assert(pos>=0 && pos<MAX_WEAR);
  assert(!(ch->equipment[pos]));
  
  if (obj->carried_by) {
    logE("EQUIP: Obj is carried_by when equip.");
    assert(0);
  }
  
  if (obj->in_room!=NOWHERE) {
    logE("EQUIP: Obj is in_room when equip.");
    assert(0);
    return;
  }

  /*
    if the item is limited, check its ego.
    use some funky function to determine if pc's ego is higher than objs'
    ego.. if it is, proceed.. otherwise, deny.
    */
  j = ItemEgoClash(ch, obj, 0);
  if (j < -5) {
    act("$p almost seems to say 'You're much too puny to use me, twerp!'",0,
	ch, obj, 0, TO_CHAR); 
    act("$p falls to the floor",0,ch, obj, 0, TO_CHAR); 
    act("$p removes itself, and falls to the floor",0,ch, obj, 0, TO_ROOM); 
    obj_to_room(obj, ch->in_room);
    do_save(ch,"",0);
    return;
  } else if (j < 0) {
    act("$p almost seems to say 'You're pretty puny.  I don't want to be seen with you!\n", 0, ch, obj, 0, TO_CHAR);
    act("$p falls to the floor",0,ch, obj, 0, TO_CHAR); 
    act("$p removes itself, and falls to the floor",0,ch, obj, 0, TO_ROOM); 
    obj_to_room(obj, ch->in_room);
    do_save(ch,"",0);
    return;
  }

  if (ItemAlignClash(ch, obj)) {
    if (ch->in_room != NOWHERE) {
      
      act("You are zapped by $p and instantly drop it.", 
	  FALSE, ch, obj, 0, TO_CHAR);
      act("$n is zapped by $p and instantly drop it.", 
	  FALSE, ch, obj, 0, TO_ROOM);
      obj_to_room(obj, ch->in_room);
      do_save(ch,"",0);
      return;
    } else {
      logE("ch->in_room = NOWHERE when equipping char.");
      assert(0);
    }
  }
  
  if (IS_AFFECTED(ch, AFF_SNEAK) &&
      IsRestricted(GetItemClassRestrictions(obj), CLASS_THIEF))
    affect_from_char(ch, SKILL_SNEAK);
  
  ch->equipment[pos] = obj;
  obj->equipped_by = ch;
  obj->eq_pos = pos;
  
  if (GET_ITEM_TYPE(obj) == ITEM_ARMOR)
    GET_AC(ch) -= apply_ac(ch, pos);
  
  for(j=0; j<MAX_OBJ_AFFECT; j++)
    affect_modify(ch, obj->affected[j].location,
		  (int)obj->affected[j].modifier,
		  obj->obj_flags.bitvector, TRUE);

  if (GET_ITEM_TYPE(obj) == ITEM_WEAPON) {
    /* some nifty manuevering for strength */
    if (IS_NPC(ch) && !IS_SET(ch->specials.act, ACT_POLYSELF))
       GiveMinStrToWield(obj, ch);
  }
  
  affect_total(ch);
}
Ejemplo n.º 22
0
void dam_message( CHAR_DATA *ch, CHAR_DATA *victim,int dam,int dt,bool immune, int combo )
{
    char buf1[256]={'\0'};
    char buf2[256]={'\0'};
    char buf3[256]={'\0'};
    const char *vs;
    const char *vp;
    const char *attack;
    char punct;

    if (ch == NULL || victim == NULL)
	return;

	 if ( dam <=   0 ) { vs = "do nothing to";
			     vp = "does nothing to";		}
    else if ( dam ==   1 ) { vs = "scratch";	vp = "scratches";	}
    else if ( dam ==   2 ) { vs = "hit";	vp = "hits";		}
    else if ( dam ==   3 ) { vs = "injure";	vp = "injures";		}
    else if ( dam ==   4 ) { vs = "wound";	vp = "wounds";		}
    else if ( dam ==   5 ) { vs = "maim";	vp = "maims";		}
    else if ( dam ==   6 ) { vs = "MANGLE";	vp = "MANGLES";		}
    else                   { vs = "do UNSPEAKABLE things to";
			     vp = "does UNSPEAKABLE things to";		}

    punct   = (dam <= 24) ? '.' : '!';

    if ( dt == TYPE_HIT )
    {
    	if (ch  == victim)
    	{
    		snprintf( buf1, sizeof(buf1), "$n %s%s $melf%c",
    				combo==9999?"'s shot ":"",vp,punct);
    		snprintf(buf2, sizeof(buf2), "You%s%s yourself%c",
    				combo==9999?"r shot ":" ",combo==9999?vp:vs,punct);
    	}
    	else
    	{
    		snprintf( buf1, sizeof(buf1), "$n%s%s $N%c",
    				combo==9999?"'s shot ":" ",vp, punct );
    		snprintf( buf2, sizeof(buf2), "You%s%s $N%c",
    				combo==9999?"r shot ":" ",combo==9999?vp:vs, punct );
    		snprintf( buf3, sizeof(buf3), "$n%s%s you%c",
    				combo==9999?"'s shot ":" ",vp, punct );
    	}
    }
    else
    {
    	if ( dt >= 0 && dt < MAX_SKILL )
    		attack	= skill_table[dt].noun_damage;
    	else if ( dt >= TYPE_HIT
    			&& dt < TYPE_HIT + MAX_DAMAGE_MESSAGE)
    		attack	= attack_table[dt - TYPE_HIT - 1].noun;
    	else
    	{
    		log_string(LOG_BUG, Format("Dam_message: bad dt %d.", dt ));
    		dt  = TYPE_HIT;
    		attack  = attack_table[0].noun;
    	}

    	if (immune)
    	{
    		if (ch == victim)
    		{
    			snprintf(buf1, sizeof(buf1), "$n is unaffected by $s own %s.",attack);
    			snprintf(buf2, sizeof(buf2), "Luckily, you are immune to that.");
    		}
    		else
    		{
    			snprintf(buf1, sizeof(buf1), "$N is unaffected by $n's %s!",attack);
    			snprintf(buf2, sizeof(buf2), "$N is unaffected by your %s!",attack);
    			snprintf(buf3, sizeof(buf3), "$n's %s is powerless against you.",attack);
    		}
    	}
    	else
    	{
    		if (ch == victim)
    		{
    			snprintf( buf1, sizeof(buf1), "$n's %s%s %s $m%c",
    					combo==9999?"shot ":"",attack,vp,punct);
    			snprintf( buf2, sizeof(buf2), "Your %s%s %s you%c",
    					combo==9999?"shot ":"",attack,vp,punct);
    		}
    		else
    		{
    			snprintf( buf1, sizeof(buf1), "$n's %s%s %s $N%c",
    					combo==9999?"shot ":"",attack,vp,punct);
    			snprintf( buf2, sizeof(buf2), "Your %s%s %s $N%c",
    					combo==9999?"shot ":"",attack,vp,punct);
    			snprintf( buf3, sizeof(buf3), "$n's %s%s %s you%c",
    					combo==9999?"shot ":"",attack,vp,punct);
    		}
    	}
    }

    if (ch == victim)
    {
    	act(buf1,ch,NULL,NULL,TO_ROOM, 0);
    	act(buf2,ch,NULL,NULL,TO_CHAR, 1);
    }
    else
    {
    	if(combo > 0 && combo != 9999)
    	{
    		act( combo_table[combo].to_room, ch, NULL, victim, TO_NOTVICT, 0 );
    		act( combo_table[combo].to_char, ch, NULL, victim, TO_CHAR, 1 );
    		act( combo_table[combo].to_vict, ch, NULL, victim, TO_VICT, 1 );
    	}

    	act( buf1, ch, NULL, victim, TO_NOTVICT, 0 );
    	act( buf2, ch, NULL, victim, TO_CHAR, 1 );
    	act( buf3, ch, NULL, victim, TO_VICT, 1 );
    }

    return;
}
Ejemplo n.º 23
0
/*
 * Remove an affected_type structure from a char (called when duration
 * reaches zero). Pointer *af must never be NIL!  Frees mem and calls
 * affect_location_apply
 */
void affect_remove(struct char_data * ch, struct affected_type * af, int output)
{
  struct affected_type *temp;
  struct affected_type aff;
  bool accum_affect = FALSE;
  int k;

  if (ch->affected == NULL) {
    core_dump();
    return;
  }

  switch (af->type)
  {

    case SPELL_CHARM:
    { 
      struct char_data* victim = ch->master;
      if (output == 0) break;

      affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE);
      REMOVE_FROM_LIST(af, ch->affected, next);
      free(af);
      affect_total(ch);

      if (ch->master)
      {
        stop_follower(ch);
      }

      if (victim)
      {
        if(IS_NPC(ch))
        {
          SET_BIT(MOB_FLAGS(ch), MOB_AGGRESSIVE | MOB_MEMORY);
        }
        if (mag_savingthrow(victim, SAVING_SPELL))
        {
          hit(victim, ch, TYPE_UNDEFINED);
        }
      }
      return;
    }

    case SPELL_LIGHT:
      if (output == 0) break;
      if (!af->next || (af->next->type != af->type) ||
         (af->next->duration > 0)) 
      {
        if (world[ch->in_room].name != (char*) NULL)
        {
          world[ch->in_room].light -= 10;
        }
      }
      break;
    case SPELL_DARKNESS:
      if (output == 0) break;
      if (!af->next || (af->next->type != af->type) ||
         (af->next->duration > 0)) 
      {
        if (world[ch->in_room].name != (char*) NULL)
        {
          world[ch->in_room].light += 10;
        }
      }
      break;
    case SPELL_BLACK_PLAGUE:
      mag_affects(30, ch, ch, SPELL_BREATH_OF_LIFE, SAVING_SPELL);
      break;
    case SPELL_CALL_ANIMAL_SPIRIT:
    case SPELL_ANIMAL_SUMMONING:
    case SPELL_ANIMAL_SUMMONING_II:
    case SPELL_ANIMAL_SUMMONING_III:
    case SPELL_CONJURE_ELEMENTAL:
    case SPELL_GREATER_ELEMENTAL:
    case SPELL_DUST_DEVIL:
    case SPELL_STICKS_TO_SNAKES:
    case SPELL_SUMMON_INSECTS:
    case SPELL_AERIAL_SERVANT:
    case SPELL_SUMMON_GUARD:
      if (IS_NPC(ch))
      {
        if (GET_POS(ch) > POS_DEAD)
        {
          if (output == 1)
          {
            affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE);
            REMOVE_FROM_LIST(af, ch->affected, next);
            free(af);
            affect_total(ch);

            GET_NAME(ch, chname);
	    stop_fighting(ch); /*Fighting Bug Fix Jasrags*/
            sprintf(buf, "%s disappears into thin air as the summoning ends.", 
              chname);
            act(buf, FALSE, world[ch->in_room].people, 0, 0, TO_ROOM);
            FREE_NAME(chname);
            extract_char(ch);
            ch = NULL;
            return;
          }
        }
      }
      break;
   case SPELL_POLYMORPH:
   if (!PRF_FLAGGED(ch, PRF_NOTSELF)) {
          affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE);
          REMOVE_FROM_LIST(af, ch->affected, next);
          free(af);
          affect_total(ch);
          return;
   }
   break;
   case SPELL_DONTUSEME:
   if(AFF_FLAGGED(ch, AFF_STANCE) && !AFF_FLAGGED(ch, AFF_TIRED)) {
      aff.type = SKILL_STANCE;
      aff.duration = 2;
      aff.location = APPLY_STR;
      aff.modifier = -2;
      aff.bitvector = AFF_TIRED;
      accum_affect = FALSE;

      affect_to_char(ch, &aff);
    }
   break;
    default:
      break;
  }

  if (output && (af->type > 0) && (af->type <= MAX_SPELLS) && af->type != SPELL_POLYMORPH && af->type != SPELL_DONTUSEME) {
    if (!af->next || (af->next->type != af->type) ||
        (af->next->duration > 0)) {
      if (*spell_wear_off_msg[af->type]) {
        send_to_char(spell_wear_off_msg[af->type], ch);
        send_to_char("\r\n", ch);
      }
  }
}

if (output && (af->type > 0) && (af->type <= MAX_SPELLS) && af->type == SPELL_POLYMORPH)  {

  if (!af->next || (af->next->type != af->type) ||
        (af->next->duration > 0)) {
   if (PLR_FLAGGED(ch, PLR_RABBIT)){
REMOVE_BIT(PLR_FLAGS(ch), PLR_RABBIT);
REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);
send_to_char("You feel yourself growing, and your ears shrinking. You no longer feel like a rabbit.\r\n", ch);
act("$n's body grows, $s ears shrinking. $n no longer looks like a rabbit.\r\n", 0, ch, 0, 0, TO_ROOM);

}
if (PLR_FLAGGED(ch, PLR_BIRD)) {
REMOVE_BIT(PLR_FLAGS(ch), PLR_BIRD);
REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);
send_to_char("You feel yourself growing and your feathers falling away. You no longer feel like a bird.\r\n", ch);
act("$n's body grows, $s feathers falling away as it expands. $n no longer looks like a bird.\r\n", 0, ch, 0, 0, TO_ROOM);

}
if (PLR_FLAGGED(ch, PLR_WOLF)) {
REMOVE_BIT(PLR_FLAGS(ch), PLR_WOLF);
REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);
send_to_char("You feel your your fur shed and your teeth shrink. You no longer feel like a wolf.\r\n", ch);
act("$n's teeth shrink, $s fur shedding. $n no longer looks like a wolf.\r\n", 0, ch, 0, 0, TO_ROOM);
}
if (PLR_FLAGGED(ch, PLR_BEAR)) {
REMOVE_BIT(PLR_FLAGS(ch), PLR_BEAR);
REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);
send_to_char("Your claws shrink as does the rest of your body. You no longer feel like a bear.\r\n", ch);
act("$n's claws shrink as does the rest of $s body. $n no longer looks like a bear.\r\n", 0, ch, 0, 0, TO_ROOM);
}
if (PLR_FLAGGED(ch, PLR_CAT)){
REMOVE_BIT(PLR_FLAGS(ch), PLR_CAT);
REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);
send_to_char("You feel your body growing, and your fur shedding. You no longer feel like a cat.\r\n", ch);
act("$n's body slowly grows, $s fur shedding. $n no longer looks like a cat.\r\n", 0, ch, 0, 0, TO_ROOM);
}

for (k = 0; k < NUM_WEARS; k++)
  if (GET_EQ(ch, k)){
    GET_OBJ_DISGUISE(GET_EQ(ch, k)) = 0;
  }

}
} 

  affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE);
  REMOVE_FROM_LIST(af, ch->affected, next);
  free(af);
  affect_total(ch);
}
Ejemplo n.º 24
0
void do_bash( CHAR_DATA *ch, char *argument )
{
    char arg[MIL]={'\0'};
    CHAR_DATA *victim;
    int chance = 0;

    one_argument(argument,arg);
 
    if (IS_NULLSTR(arg))
    {
	victim = ch->fighting;
	if (victim == NULL)
	{
	    send_to_char("But you aren't fighting anyone!\n\r",ch);
	    return;
	}
    }

    else if ((victim = get_char_room(ch,arg)) == NULL)
    {
	send_to_char("They aren't here.\n\r",ch);
	return;
    }

    if (victim->position < P_FIGHT)
    {
	act("You'll have to let $M get back up first.",
	    ch,NULL,victim,TO_CHAR,1);
	return;
    }

    if (victim == ch)
    {
	send_to_char("You try to bash your brains out, but fail.\n\r",ch);
	return;
    }

    if (IS_AFFECTED(ch,AFF_CHARM) && ch->master == victim)
    {
	act("But $N is your friend!",ch,NULL,victim,TO_CHAR,1);
	return;
    }

    /* size */
    if (ch->size < victim->size)
	chance += (ch->size - victim->size) * 15;
    else
	chance += (ch->size - victim->size) * 10; 

    /* stats */
    chance += get_curr_stat(ch,STAT_STR);
    chance -= get_curr_stat(victim,STAT_DEX);

    if (!IS_NPC(victim) 
	&& chance < get_skill(victim,gsn_dodge) )
    {	
	chance -= 3 * (get_skill(victim,gsn_dodge) - chance);
    }

    /* now the attack */
    if (number_percent() < chance )
    {
    
	act("$n sends you sprawling with a powerful bash!",
		ch,NULL,victim,TO_VICT,1);
	act("You slam into $N, and send $M flying!",ch,NULL,victim,TO_CHAR,0);
	act("$n sends $N sprawling with a powerful bash.",
		ch,NULL,victim,TO_NOTVICT,0);

	DAZE_STATE(victim, 3 * PULSE_VIOLENCE);
	WAIT_STATE(ch,skill_table[gsn_bash].beats);
	victim->position = P_REST;
	damage(ch,victim,number_range(2,2 + 2 * ch->size + chance/20),gsn_bash,
	    DAM_BASH,FALSE, 0, -1);
	
    }
    else
    {
	damage(ch,victim,0,gsn_bash,DAM_BASH,FALSE, 0, -1);
	act("You fall flat on your face!",
	    ch,NULL,victim,TO_CHAR,1);
	act("$n falls flat on $s face.",
	    ch,NULL,victim,TO_NOTVICT,0);
	act("You evade $n's bash, causing $m to fall flat on $s face.",
	    ch,NULL,victim,TO_VICT,1);
	ch->position = P_REST;
	damage(ch,ch,number_range(2,2 + 2 * ch->size + chance/20),gsn_bash,
	    DAM_BASH,FALSE, 0, -1);
	WAIT_STATE(ch,skill_table[gsn_bash].beats * 3/2); 
    }
}
Ejemplo n.º 25
0
void equip_char(struct char_data * ch, struct obj_data * obj, int pos)
{
  int j;
  int invalid_class(struct char_data *ch, struct obj_data *obj);
  int invalid_race(struct char_data *ch, struct obj_data *obj);

  assert(pos >= 0 && pos < NUM_WEARS);

  if (GET_EQ(ch, pos)) {
    GET_NAME(ch, chname);
    sprintf(buf, "SYSERR: Char is already equipped: %s, %s", chname,
	    obj->short_description);
    FREE_NAME(chname);
    log(buf);
    return;
  }

if (obj->carried_by) {
  log("SYSERR: EQUIP: Obj is carried_by when equip.");
    return;
  }

  if (obj->in_room != NOWHERE) {
    log("SYSERR: EQUIP: Obj is in_room when equip.");
    return;
  }

  /*  Let's change the messages here.  Soli, 8/12/99  */
  if ((IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && IS_EVIL(ch)) ||
      (IS_OBJ_STAT(obj, ITEM_ANTI_GOOD) && IS_GOOD(ch)) ||
      (IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && IS_NEUTRAL(ch)))
  {
      act("You are zapped by $p and instantly let go of it.", FALSE, ch, obj, 0, TO_CHAR);
      act("$n is zapped by $p and instantly lets go of it.", FALSE, ch, obj, 0, TO_ROOM);
      obj_to_char(obj, ch);	/* changed to drop in inventory instead of
				 * ground */
      return;
  }

  /*  I'm moving the other two to a seperate function, checked before we
      actually wear the eq.  Soli, 8/12/99  */

  GET_EQ(ch, pos) = obj;
  obj->worn_by = ch;
  obj->worn_on = pos;

  if (GET_OBJ_TYPE(obj) == ITEM_ARMOR)
    GET_AC(ch) -= apply_ac(ch, pos);

  if (ch->in_room != NOWHERE) {
    if (pos == WEAR_LIGHT && GET_OBJ_TYPE(obj) == ITEM_LIGHT)
      if (GET_OBJ_VAL(obj, 2))	/* if light is ON */
	world[ch->in_room].light++;
  } else {
    log("SYSERR: ch->in_room = NOWHERE when equipping char.");
  }

  for (j = 0; j < MAX_OBJ_AFFECT; j++)
    affect_modify(ch, obj->affected[j].location,
		  obj->affected[j].modifier,
		  obj->obj_flags.bitvector, TRUE);
  affect_total(ch);
}
Ejemplo n.º 26
0
void do_dirt( CHAR_DATA *ch, char *argument )
{
    char arg[MIL]={'\0'};
    CHAR_DATA *victim;
    int chance;

    one_argument(argument,arg);

    if ( (chance = get_skill(ch,gsn_dirt)) == 0
    ||   (IS_NPC(ch) && !IS_SET(ch->off_flags,OFF_KICK_DIRT))
    ||   (!IS_NPC(ch)
    &&    !(ch->ability[BRAWL].value > 0)))
    {
	send_to_char("You get your feet dirty.\n\r",ch);
	return;
    }

    if (IS_NULLSTR(arg))
    {
	victim = ch->fighting;
	if (victim == NULL)
	{
	    send_to_char("But you aren't in combat!\n\r",ch);
	    return;
	}
    }

    else if ((victim = get_char_room(ch,arg)) == NULL)
    {
	send_to_char("They aren't here.\n\r",ch);
	return;
    }

    if (IS_AFFECTED(victim,AFF_BLIND))
    {
	act("$E's already been blinded.",ch,NULL,victim,TO_CHAR,1);
	return;
    }

    if (victim == ch)
    {
	send_to_char("Very funny.\n\r",ch);
	return;
    }

    if (IS_AFFECTED(ch,AFF_CHARM) && ch->master == victim)
    {
	act("But $N is such a good friend!",ch,NULL,victim,TO_CHAR,1);
	return;
    }

    /* dexterity */
    chance += get_curr_stat(ch,STAT_DEX);
    chance -= 2 * get_curr_stat(victim,STAT_DEX);

    /* sloppy hack to prevent false zeroes */
    if (chance % 5 == 0)
	chance += 1;

    /* terrain */

    switch(ch->in_room->sector_type)
    {
	case(SECT_INSIDE):		chance -= 20;	break;
	case(SECT_CITY):		chance -= 10;	break;
	case(SECT_STREET):		chance -= 10;	break;
	case(SECT_FIELD):		chance +=  5;	break;
	case(SECT_FOREST):				break;
	case(SECT_HILLS):				break;
	case(SECT_MOUNTAIN):		chance -= 10;	break;
	case(SECT_WATER_SWIM):		chance  =  0;	break;
	case(SECT_WATER_NOSWIM):	chance  =  0;	break;
	case(SECT_AIR):			chance  =  0;  	break;
	case(SECT_DESERT):		chance += 10;   break;
    }

    if (chance == 0)
    {
	send_to_char("There isn't any dirt to kick.\n\r",ch);
	return;
    }

    /* now the attack */
    if (number_percent() < chance)
    {
	AFFECT_DATA af;
	act("$n is blinded by the dirt in $s eyes!",victim,NULL,NULL,TO_ROOM,0);
	act("$n kicks dirt in your eyes!",ch,NULL,victim,TO_VICT,1);
        damage(ch,victim,number_range(2,5),gsn_dirt,DAM_NONE,FALSE,0,-1);
	send_to_char("You can't see a thing!\n\r",victim);
	WAIT_STATE(ch,skill_table[gsn_dirt].beats);

	af.where	= TO_AFFECTS;
	af.type 	= gsn_dirt;
	af.duration	= 15;
	af.location	= APPLY_PER;
	af.modifier	= -4;
	af.bitvector 	= AFF_BLIND;

	affect_to_char(victim,&af);
    }
    else
    {
	damage(ch,victim,0,gsn_dirt,DAM_NONE,TRUE,0,-1);
	WAIT_STATE(ch,skill_table[gsn_dirt].beats);
    }
}
Ejemplo n.º 27
0
int board_remove_msg(struct char_data *ch, char *arg, int bnum) {

  /* This should now be fixed so that low level chars can remove armor and such. */

  int ind, tmessage;
  char buf[256], number[MAX_INPUT_LENGTH];
  
  one_argument(arg, number);
  
  if (!*number || !isdigit(*number))
    return(0);
  
  if (!(tmessage = atoi(number))) return(0);
  
  if ( bnum == -1 ) {
    logE("Board special procedure called for non-board object.\r\n");
    send_to_char("This board is not in operation at this time.\n\r", ch);
    return 1;
  }

  curr_board = &boards[bnum];

  if (GetMaxLevel(ch) < min_remove_level[bnum]) {
    send_to_char("You try and grab one of the notes of the board but get a nasty\n\r",ch);
    send_to_char("shock.  Maybe you'd better leave it alone.\n\r",ch);
    return 1;
  }

  if (curr_board->number < 1) {
    send_to_char("The board is empty!\n\r", ch);
    return(1);
  }

  if (tmessage < 0 || tmessage > curr_board->number) {
    send_to_char("That message exists only in your imagination..\n\r",
		 ch);
    return(1);
  }

  /* Check for board locks, return if lock is found */
  
  if (board_check_locks(bnum, ch))
    return(1);

  ind = tmessage;

  free(curr_board->msg[ind].text);
  free(curr_board->msg[ind].date);
  free(curr_board->msg[ind].author);
  free(curr_board->msg[ind].title);

  for ( ; ind < (curr_board->number) ; ind++ )
    curr_board->msg[ind] = curr_board->msg[ind+1];

/* You MUST do this, or the next message written after a remove will */
/* end up doing a free(curr_board->msg[ind].text) because it's not!! */
/* Causing strange shit to happen, because now the message has a     */
/* To a memory location that doesn't exist, and if THAT message gets */
/* Removed, it will destroy what it's pointing to. THIS is the board */
/* Bug we've been looking for!        -=>White Gold<=-               */

  curr_board->msg[curr_board->number].text = NULL;
  curr_board->msg[curr_board->number].date = NULL;
  curr_board->msg[curr_board->number].author = NULL;
  curr_board->msg[curr_board->number].title = NULL;

  curr_board->number--;

  send_to_char("Message removed.\n\r", ch);
  sprintf(buf, "%s just removed message %d.", ch->player.name, tmessage);

  /* Removal message also repaired */

  act(buf, FALSE, ch, 0, 0, TO_ROOM);
  sprintf((buf+strlen(buf)-1)," from board %d.",bnum);
  logE(buf);  /* Message removals now logged. */

  board_save_board(bnum);
  return(1);
}
Ejemplo n.º 28
0
void do_trip( CHAR_DATA *ch, char *argument )
{
    char arg[MIL]={'\0'};
    CHAR_DATA *victim;
    int chance;

    one_argument(argument,arg);

    if ( (chance = get_skill(ch,gsn_trip)) == 0
    ||   (IS_NPC(ch) && !IS_SET(ch->off_flags,OFF_TRIP))
    ||   (!IS_NPC(ch) 
	  && !(ch->ability[BRAWL].value > 0)))
    {
	send_to_char("Tripping?  What's that?\n\r",ch);
	return;
    }


    if (IS_NULLSTR(arg))
    {
	victim = ch->fighting;
	if (victim == NULL)
	{
	    send_to_char("But you aren't fighting anyone!\n\r",ch);
	    return;
 	}
    }

    else if ((victim = get_char_room(ch,arg)) == NULL)
    {
	send_to_char("They aren't here.\n\r",ch);
	return;
    }
    
    if (IS_AFFECTED(victim,AFF_FLYING))
    {
	act("$S feet aren't on the ground.",ch,NULL,victim,TO_CHAR,1);
	return;
    }

    if (victim->position < P_FIGHT)
    {
	act("$N is already down.",ch,NULL,victim,TO_CHAR,1);
	return;
    }

    if (victim == ch)
    {
	send_to_char("You fall flat on your face!\n\r",ch);
	WAIT_STATE(ch,2 * skill_table[gsn_trip].beats);
	act("$n trips over $s own feet!",ch,NULL,NULL,TO_ROOM,0);
	return;
    }

    if (IS_AFFECTED(ch,AFF_CHARM) && ch->master == victim)
    {
	act("$N is so great though!",ch,NULL,victim,TO_CHAR,1);
	return;
    }

    /* size */
    if (ch->size < victim->size)
        chance += (ch->size - victim->size) * 10;  /* bigger = harder to trip */

    /* dex */
    chance += get_curr_stat(ch,STAT_DEX);
    chance -= get_curr_stat(victim,STAT_DEX) * 3 / 2;

    /* now the attack */
    if (number_percent() < chance)
    {
	act("$n trips you and you go down!",ch,NULL,victim,TO_VICT,1);
	act("You trip $N and $N goes down!",ch,NULL,victim,TO_CHAR,1);
	act("$n trips $N, sending $M to the ground.",
	    ch,NULL,victim,TO_NOTVICT,0);

	DAZE_STATE(victim,2 * PULSE_VIOLENCE);
        WAIT_STATE(ch,skill_table[gsn_trip].beats);
	victim->position = P_REST;
	damage(ch,victim,number_range(2, 2 +  2 * victim->size),gsn_trip,
	    DAM_BASH,TRUE,0,-1);
    }
    else
    {
	damage(ch,victim,0,gsn_trip,DAM_BASH,TRUE,0,1);
	WAIT_STATE(ch,skill_table[gsn_trip].beats*2/3);
    } 
}
Ejemplo n.º 29
0
static irqreturn_t swim3_interrupt(int irq, void *dev_id)
{
	struct floppy_state *fs = (struct floppy_state *) dev_id;
	struct swim3 __iomem *sw = fs->swim3;
	int intr, err, n;
	int stat, resid;
	struct dbdma_regs __iomem *dr;
	struct dbdma_cmd *cp;
	unsigned long flags;
	struct request *req = fs->cur_req;

	swim3_dbg("* interrupt, state=%d\n", fs->state);

	spin_lock_irqsave(&swim3_lock, flags);
	intr = in_8(&sw->intr);
	err = (intr & ERROR_INTR)? in_8(&sw->error): 0;
	if ((intr & ERROR_INTR) && fs->state != do_transfer)
		swim3_err("Non-transfer error interrupt: state=%d, dir=%x, intr=%x, err=%x\n",
			  fs->state, rq_data_dir(req), intr, err);
	switch (fs->state) {
	case locating:
		if (intr & SEEN_SECTOR) {
			out_8(&sw->control_bic, DO_ACTION | WRITE_SECTORS);
			out_8(&sw->select, RELAX);
			out_8(&sw->intr_enable, 0);
			del_timer(&fs->timeout);
			fs->timeout_pending = 0;
			if (sw->ctrack == 0xff) {
				swim3_err("%s", "Seen sector but cyl=ff?\n");
				fs->cur_cyl = -1;
				if (fs->retries > 5) {
					swim3_end_request(fs, BLK_STS_IOERR, 0);
					fs->state = idle;
					start_request(fs);
				} else {
					fs->state = jogging;
					act(fs);
				}
				break;
			}
			fs->cur_cyl = sw->ctrack;
			fs->cur_sector = sw->csect;
			if (fs->expect_cyl != -1 && fs->expect_cyl != fs->cur_cyl)
				swim3_err("Expected cyl %d, got %d\n",
					  fs->expect_cyl, fs->cur_cyl);
			fs->state = do_transfer;
			act(fs);
		}
		break;
	case seeking:
	case jogging:
		if (sw->nseek == 0) {
			out_8(&sw->control_bic, DO_SEEK);
			out_8(&sw->select, RELAX);
			out_8(&sw->intr_enable, 0);
			del_timer(&fs->timeout);
			fs->timeout_pending = 0;
			if (fs->state == seeking)
				++fs->retries;
			fs->state = settling;
			act(fs);
		}
		break;
	case settling:
		out_8(&sw->intr_enable, 0);
		del_timer(&fs->timeout);
		fs->timeout_pending = 0;
		act(fs);
		break;
	case do_transfer:
		if ((intr & (ERROR_INTR | TRANSFER_DONE)) == 0)
			break;
		out_8(&sw->intr_enable, 0);
		out_8(&sw->control_bic, WRITE_SECTORS | DO_ACTION);
		out_8(&sw->select, RELAX);
		del_timer(&fs->timeout);
		fs->timeout_pending = 0;
		dr = fs->dma;
		cp = fs->dma_cmd;
		if (rq_data_dir(req) == WRITE)
			++cp;
		/*
		 * Check that the main data transfer has finished.
		 * On writing, the swim3 sometimes doesn't use
		 * up all the bytes of the postamble, so we can still
		 * see DMA active here.  That doesn't matter as long
		 * as all the sector data has been transferred.
		 */
		if ((intr & ERROR_INTR) == 0 && cp->xfer_status == 0) {
			/* wait a little while for DMA to complete */
			for (n = 0; n < 100; ++n) {
				if (cp->xfer_status != 0)
					break;
				udelay(1);
				barrier();
			}
		}
		/* turn off DMA */
		out_le32(&dr->control, (RUN | PAUSE) << 16);
		stat = le16_to_cpu(cp->xfer_status);
		resid = le16_to_cpu(cp->res_count);
		if (intr & ERROR_INTR) {
			n = fs->scount - 1 - resid / 512;
			if (n > 0) {
				blk_update_request(req, 0, n << 9);
				fs->req_sector += n;
			}
			if (fs->retries < 5) {
				++fs->retries;
				act(fs);
			} else {
				swim3_err("Error %sing block %ld (err=%x)\n",
				       rq_data_dir(req) == WRITE? "writ": "read",
				       (long)blk_rq_pos(req), err);
				swim3_end_request(fs, BLK_STS_IOERR, 0);
				fs->state = idle;
			}
		} else {
			if ((stat & ACTIVE) == 0 || resid != 0) {
				/* musta been an error */
				swim3_err("fd dma error: stat=%x resid=%d\n", stat, resid);
				swim3_err("  state=%d, dir=%x, intr=%x, err=%x\n",
					  fs->state, rq_data_dir(req), intr, err);
				swim3_end_request(fs, BLK_STS_IOERR, 0);
				fs->state = idle;
				start_request(fs);
				break;
			}
			fs->retries = 0;
			if (swim3_end_request(fs, 0, fs->scount << 9)) {
				fs->req_sector += fs->scount;
				if (fs->req_sector > fs->secpertrack) {
					fs->req_sector -= fs->secpertrack;
					if (++fs->head > 1) {
						fs->head = 0;
						++fs->req_cyl;
					}
				}
				act(fs);
			} else
				fs->state = idle;
		}
		if (fs->state == idle)
			start_request(fs);
		break;
	default:
		swim3_err("Don't know what to do in state %d\n", fs->state);
	}
	spin_unlock_irqrestore(&swim3_lock, flags);
	return IRQ_HANDLED;
}
 void print()
 {
     print_action act;
     act(base_type::get_gid());
 }