コード例 #1
0
ファイル: multitrack.c プロジェクト: flv0/veejay
static	void	update_widgets(int *status, sequence_view_t *p, int pm)
{
	multitracker_t *mt = (multitracker_t*) p->backlink;
	int *h = p->history[pm];
	if( h[PLAY_MODE] != pm )
		playmode_sensitivity( p, pm );

	if( pm == MODE_STREAM )
	{
		update_pos( p, status[TOTAL_FRAMES], 0 );
		update_speed( p, 1 );
	}
	else
	if( pm == MODE_SAMPLE || pm == MODE_PLAIN )
	{
		if( h[FRAME_NUM] != status[FRAME_NUM] )
			update_pos( p, status[TOTAL_FRAMES],status[FRAME_NUM] );
		if( h[SAMPLE_SPEED] != status[SAMPLE_SPEED] )
			update_speed( p, status[SAMPLE_SPEED] );
	}

	if( h[TOTAL_SLOTS] != status[TOTAL_SLOTS])
	{
		gvr_need_track_list( mt->preview, p->num );
		update_track_view( MAX_TRACKS, get_track_tree( p->tracks ), (void*)p );
	}
}
コード例 #2
0
ファイル: SampleSVGPong.cpp プロジェクト: google/skia
        void updateDom() {
            const SkPoint corner = pos - SkPoint::Make(size.width() / 2, size.height() / 2);
            update_pos(objectNode, corner);

            // Simulate parallax shadow for a centered light source.
            SkPoint shadowOffset = pos - SkPoint::Make(kBounds.centerX(), kBounds.centerY());
            shadowOffset.scale(kShadowParallax);
            const SkPoint shadowCorner = corner + shadowOffset;

            update_pos(shadowNode, shadowCorner);
        }
コード例 #3
0
ファイル: test.cpp プロジェクト: lafeingcrokodil/multirogue
int main() {

  int max_row, max_col; // size of standard screen
  int row, col;         // current row and column of rogue
  int key;              // key pressed by user

  initialize_gui();

  /* Place rogue in his initial position. */
  row = 0;
  col = 0;
  mvaddch(row, col, '@');

  /* Move rogue based on user input. */
  while ((key = getch()) != 'q') {
    mvaddch(row, col, ' ');
    update_pos(key, row, col);
    mvaddch(row, col, '@');
    refresh();
  }

  endwin();

  return 0;
}
コード例 #4
0
ファイル: fight.c プロジェクト: MUDOmnibus/DikuMUD-Alfa
/* remove a char from the list of fighting chars */
void stop_fighting(struct char_data *ch)
{
	struct char_data *tmp;

	assert(ch->specials.fighting);

	if (ch == combat_next_dude)
		combat_next_dude = ch->next_fighting;

	if (combat_list == ch)
	   combat_list = ch->next_fighting;
	else
	{
		for (tmp = combat_list; tmp && (tmp->next_fighting != ch); 
			tmp = tmp->next_fighting);
		if (!tmp) {
			log("Char fighting not found Error (fight.c, stop_fighting)");
			abort();
		}
		tmp->next_fighting = ch->next_fighting;
	}

	ch->next_fighting = 0;
	ch->specials.fighting = 0;
	GET_POS(ch) = POSITION_STANDING;
	update_pos(ch);
}
コード例 #5
0
ファイル: Example.cpp プロジェクト: CScarame/gemini_engine
void update()
{
  kbPtr->update();

  dy = 0;
  if(kbPtr->check_key(k_up) && !kbPtr->check_key(k_down)){
    dy = -1 * SPEED;
  }if(kbPtr->check_key(k_down) && !kbPtr->check_key(k_up)){
    dy = 1 * SPEED;
  }
  dx = 0;
  if(kbPtr->check_key(k_left) && !kbPtr->check_key(k_right)){
    dx = -1 * SPEED;
  }if(kbPtr->check_key(k_right) && !kbPtr->check_key(k_left)){
    dx = 1 * SPEED;
  }
  dy2 = 0;
  if(kbPtr->check_key(k_up) && !kbPtr->check_key(k_down)){
    dy2 = -1 * SPEED2;
  }if(kbPtr->check_key(k_down) && !kbPtr->check_key(k_up)){
    dy2 = 1 * SPEED2;
  }
  dx2 = 0;
  if(kbPtr->check_key(k_left) && !kbPtr->check_key(k_right)){
    dx2 = -1 * SPEED2;
  }if(kbPtr->check_key(k_right) && !kbPtr->check_key(k_left)){
    dx2 = 1 * SPEED2;
  }

  update_pos();

  if(kbPtr->check_key(k_esc)){
    tmPtr->quit(1);
  }
}
コード例 #6
0
ファイル: serial.c プロジェクト: sumartoyo/BH86
void step() {
    int i, epoch = 0;
    float fx, fy;
    clock_t timer_start, timer_end;
    double time_elapsed = 0;
    float time_per_frame;

    while (steps > 0 && epoch < steps) {
        printf("[STEP %d]\n", epoch+1);

        timer_start = clock();

        make_tree();
        for (i = 0; i < n_bodies; i++) {
            compute_force(i, 0, &fx, &fy);
            update_pos(i, fx, fy);
        }

        timer_end = clock();
        time_elapsed += timer_end-timer_start;

        if (is_print_tree) print_tree(0, 0, "root");
        if (is_print_bodies) print_bodies("[UPDATED POSITION]");

        free_nodes();
        epoch += 1;
    }

    time_per_frame = (time_elapsed/(double)CLOCKS_PER_SEC)/epoch;

    printf("\n[TIME]\n");
    printf("Time per iteration: %f s\n", time_per_frame);
    printf("Iteration per second: %f\n", 1/time_per_frame);
}
コード例 #7
0
ファイル: magic.c プロジェクト: Yuffster/CircleMUD
void mag_points(int level, struct char_data *ch, struct char_data *victim,
		     int spellnum, int savetype)
{
  int healing = 0, move = 0;

  if (victim == NULL)
    return;

  switch (spellnum) {
  case SPELL_CURE_LIGHT:
    healing = dice(1, 8) + 1 + (level / 4);
    send_to_char(victim, "You feel better.\r\n");
    break;
  case SPELL_CURE_CRITIC:
    healing = dice(3, 8) + 3 + (level / 4);
    send_to_char(victim, "You feel a lot better!\r\n");
    break;
  case SPELL_HEAL:
    healing = 100 + dice(3, 8);
    send_to_char(victim, "A warm feeling floods your body.\r\n");
    break;
  }
  GET_HIT(victim) = MIN(GET_MAX_HIT(victim), GET_HIT(victim) + healing);
  GET_MOVE(victim) = MIN(GET_MAX_MOVE(victim), GET_MOVE(victim) + move);
  update_pos(victim);
}
コード例 #8
0
ファイル: regen.c プロジェクト: DalilaMud/Dalila-Mud
/*
 * subtracts amount of hitpoints from ch's current and starts points event
 */
void alter_hit(struct char_data *ch, int amount)
{
  struct regen_event_obj *regen;
  long time;
  int gain;

  GET_HIT(ch) = MIN(GET_HIT(ch) - amount, GET_MAX_HIT(ch));

  if (GET_HIT(ch) <= HIT_INCAP||IS_AFFECTED(ch,AFF_TRAMORTITO))
    return;
  if (PLR_FLAGGED(ch, PLR_FANTASMA) && amount > 0)
    return;

  if (GET_HIT(ch) < GET_MAX_HIT(ch) && !GET_POINTS_EVENT(ch, REGEN_HIT)) {
    CREATE(regen, struct regen_event_obj, 1);	
    regen->ch = ch;
    regen->type = REGEN_HIT;
    gain = hit_gain(ch);
    time = PULSES_PER_MUD_HOUR / (gain ? gain : 1);
    GET_POINTS_EVENT(ch, REGEN_HIT) = event_create(points_event, regen, time);

    if (amount >= 0) {
	
      /*
       * if the character gained hp, update position and
       * restart mana and move regeneration if needed.
       */
      update_pos(ch);
      alter_mana(ch, 0);
      alter_move(ch, 0);
    }
  }
コード例 #9
0
/*
 * Stop fights.
 */
void stop_fighting( CHAR_DATA *ch, bool fBoth )
{
	CHAR_DATA *fch;
	COMBAT_DATA *pcombo;
	COMBAT_DATA *next;

	for ( fch = char_list; fch != NULL; fch = fch->next )
	{
		if ( fch == ch || ( fBoth && fch->fighting == ch ) )
		{
			fch->position	= IS_NPC(fch) ? fch->default_pos : P_STAND;
			update_pos( fch, 0 );
			fch->fighting	= NULL;
			fch->balance = 1;
			for(pcombo = fch->combo; pcombo; pcombo = next)
			{
				next = pcombo->next;
				free_combat_move(pcombo);
			}
			fch->combo = NULL;
		}
	}

	return;
}
コード例 #10
0
ファイル: game.c プロジェクト: tommp/SatacaGameConsole
int main(int argc, char *argv[])
{
	printf("Initializing game\n");
	clock_t start, end;
	int remaining_time;
	
	display_init();
    gamepad_init();
    grid_init(grid);
    players_init(grid, players);
    
    display_fill_screen(0);
    g_running = 1;
    
    while(g_running) {
        start = clock();
        
        update_pos(grid, players);
        
        end = clock();
        
        remaining_time = TIME_PER_LOOP - (((end - start)/CLOCKS_PER_SEC)*1000);
        
        if(remaining_time > 0) {
            usleep(remaining_time*1000);
        }
        
        continue;
    }
	exit(EXIT_SUCCESS);
}
コード例 #11
0
ファイル: mudlimits.c プロジェクト: Lundessa/NewRavenVM
/* nb, also mess up anyone affected by AFF_POISON */
void pulse_heal(void)
{
    CharData *ch;
    int gain = number(18,24);

    for (ch = character_list; ch; ch = ch->next) {
        if(ch->in_room == NOWHERE)
            continue;

        if(!(pvpFactor() > 1)) {
            if( GET_POS(ch) == POS_INCAP )      damage(ch, ch, 1, TYPE_SUFFERING);
            else if( GET_POS(ch) == POS_MORTALLYW )  damage(ch, ch, 2, TYPE_SUFFERING);
            else if( GET_POS(ch) == POS_DEAD) {
                if(IN_ARENA(ch) || IN_QUEST_FIELD(ch) ||
                   ZONE_FLAGGED(world[ch->in_room].zone, ZONE_ARENA) ||
                   ZONE_FLAGGED(world[ch->in_room].zone, ZONE_SLEEPTAG))
                    // If they're dying in the arena, they eventually get better (or killed by someone)
                {
                    GET_HIT(ch) = number(GET_HIT(ch), 1);
                    sendChar(ch, "You slowly recover.\r\n");
                    update_pos(ch);
                }
                else {
                    raw_kill(ch, NULL);
                    continue;
                }
            }
        }

        if (IS_AFFECTED(ch, AFF_PULSE_HIT))
            if (GET_HIT(ch) < GET_MAX_HIT(ch)) GET_HIT(ch) += gain;
        if (IS_AFFECTED(ch, AFF_PULSE_MANA))
            if (GET_MANA(ch) < GET_MAX_MANA(ch)) GET_MANA(ch) += gain;
        if (IS_AFFECTED(ch, AFF_POISON)) doPoison(ch);
        if (IS_AFFECTED(ch, AFF_DISEASE)) doDisease(ch);
	if (affected_by_spell(ch, SKILL_INVIGORATE)) doInvigorate(ch);
        if (IS_BOUNTY_HUNTER(ch) && GET_ADVANCE_LEVEL(ch) >= 1 && IS_AFFECTED(ch, AFF_HIDE)) GET_MOVE(ch) = MIN(GET_MOVE(ch) + 3*gain, GET_MAX_MOVE(ch));
        if (IS_PRESTIDIGITATOR(ch)) GET_MANA(ch) = MIN(GET_MANA(ch) + GET_ADVANCE_LEVEL(ch) * 2, GET_MAX_MANA(ch));
        if (affected_by_spell(ch, SPELL_HIPPOCRATIC_OATH)) GET_MANA(ch) = MIN(GET_MANA(ch) + 25, GET_MAX_MANA(ch));
        if (affected_by_spell(ch, SKILL_PET_MEND)) GET_HIT(ch) = MIN(GET_HIT(ch) * 115 / 100, GET_MAX_HIT(ch));
        if (IS_HOLY_PRIEST(ch)) GET_MANA(ch) = MIN(GET_MANA(ch) + 10 + 2*GET_ADVANCE_LEVEL(ch), GET_MAX_MANA(ch));

        /* The room might be poisoned! (Or later, otherwise dangerous) */
        if (ch->in_room != NOWHERE) {
            if (ROOM_FLAGGED(ch->in_room, ROOM_POISONED)) {
                if (!mag_savingthrow(ch, SAVING_SPELL)) {
                    act("$n chokes and gags!", TRUE, ch, 0, 0, TO_ROOM);
                    act("You choke and gag!", TRUE, ch, 0, 0, TO_CHAR);
                    add_affect( ch, ch, SPELL_POISON, 30, APPLY_NONE, 0, 5 TICKS,
                            AFF_POISON, FALSE, FALSE, FALSE, FALSE);
                }
            }
        }

        if(IS_DEFENDER(ch) && !affected_by_spell(ch, SKILL_DEFENDER_HEALTH))
            add_affect(ch, ch, SKILL_DEFENDER_HEALTH, GET_LEVEL(ch), APPLY_HIT, GET_ADVANCE_LEVEL(ch)*5, -1, FALSE, FALSE, FALSE, FALSE, FALSE);

    }
}
コード例 #12
0
ファイル: si_spells.c プロジェクト: krs256/KillerMUDPL
void stop_fight_after_charm(CHAR_DATA *ch, CHAR_DATA *victim)
{
    if(IS_AFFECTED(victim, AFF_CHARM))
    {
        victim->fighting = NULL;
        victim->position = POS_STANDING;
        update_pos( victim );

        if(ch->fighting == victim)
        {
            ch->fighting = NULL;
            ch->position = POS_STANDING;
            update_pos( ch );
            forget(ch, victim, MEM_HATE, FALSE);
        }
    }
    return;
}
コード例 #13
0
ファイル: vtape.c プロジェクト: AlD/bareos
/*
 * This function try to emulate the append only behavior
 * of a tape. When you wrote something, data after the
 * current position are discarded.
 */
int vtape::truncate_file()
{
   Dmsg2(dbglevel, "truncate %i:%i\n", current_file, current_block);
   ftruncate(fd, lseek(fd, 0, SEEK_CUR));
   last_file = current_file;
   atEOD=true;
   update_pos();
   return 0;
}
コード例 #14
0
ファイル: gui_canvas.c プロジェクト: bert/fped
static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
    gpointer data)
{
	struct coord pos = canvas_to_coord(curr_pos.x, curr_pos.y);

	DPRINTF("--- key press ---");
	switch (event->keyval) {
	case ' ':
		user_origin = pos;
		update_pos(pos);
		break;
	case '+':
	case '=':
		zoom_in(pos);
		break;
	case '-':
		zoom_out(pos);
		break;
	case '*':
		zoom_to_extents();
		break;
	case '#':
		zoom_to_frame();
		break;
	case '.':
		tool_dehover();
		draw_ctx.center = pos;
		redraw();
		tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
		break;
	case GDK_BackSpace:
	case GDK_Delete:
#if 0
	case GDK_KP_Delete:
		if (selected_inst) {
			inst_delete(selected_inst);
			change_world();
		}
		break;
#endif
	case 'u':
		if (undelete())
			change_world();
		break;
	case '/':
{
/* @@@ find a better place for this */
extern int show_vars;
		show_vars = !show_vars;
change_world();
}
	}
	return TRUE;
}
コード例 #15
0
ファイル: ostream_wrapper.cpp プロジェクト: 3rf/mongo
 void ostream_wrapper::write(const std::string& str)
 {
     if(m_pStream) {
         m_pStream->write(str.c_str(), str.size());
     } else {
         m_buffer.resize(std::max(m_buffer.size(), m_pos + str.size() + 1));
         std::copy(str.begin(), str.end(), &m_buffer[m_pos]);
     }
     
     for(std::size_t i=0;i<str.size();i++)
         update_pos(str[i]);
 }
コード例 #16
0
ファイル: ostream_wrapper.cpp プロジェクト: 3rf/mongo
 void ostream_wrapper::write(const char *str, std::size_t size)
 {
     if(m_pStream) {
         m_pStream->write(str, size);
     } else {
         m_buffer.resize(std::max(m_buffer.size(), m_pos + size + 1));
         std::copy(str, str + size, &m_buffer[m_pos]);
     }
     
     for(std::size_t i=0;i<size;i++)
         update_pos(str[i]);
 }
コード例 #17
0
ファイル: fight.cpp プロジェクト: stefan-lindstrom/circpp
/* remove a char from the list of fighting chars */
void stop_fighting(struct char_data *ch)
{
  struct char_data *temp;

  if (ch == next_combat_list)
    next_combat_list = ch->next_fighting;

  REMOVE_FROM_LIST(ch, combat_list, next_fighting);
  ch->next_fighting = NULL;
  FIGHTING(ch) = NULL;
  GET_POS(ch) = POS_STANDING;
  update_pos(ch);
}
コード例 #18
0
void SimpleRelationCanvas::update(bool updatepos)
{
    if (data) {
        itstype = data->get_type();

        QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
        SimpleRelationCanvas * pstereotype;

        {
            ArrowCanvas * aplabel;	// cannot exist
            ArrowCanvas * apstereotype;

            search_supports(aplabel, apstereotype);
            pstereotype = (SimpleRelationCanvas *) apstereotype;
        }

        // manages relation's stereotype

        QString s = data->get_short_stereotype();

        if (s.isEmpty()) {
            // relation does not have stereotype
            if (pstereotype != 0) {
                // removes it
                the_canvas()->del(pstereotype->stereotype);
                pstereotype->stereotype = 0;
            }
        }
        else {
            s = toUnicode(s);

            if (s[0] != '{')
                s = QString("<<") + s + ">>";

            if ((pstereotype == 0) && (begin->type() != UmlArrowPoint)) {
                // adds relation's stereotype
                stereotype = new LabelCanvas(s, the_canvas(), 0, 0);
                stereotype_default_position();
            }
            else if ((pstereotype != 0) &&
                     (pstereotype->stereotype->get_name() != s)) {
                // update name
                pstereotype->stereotype->set_name(s);
                pstereotype->stereotype_default_position();
            }
        }
    }

    if (updatepos)
        update_pos();
}
コード例 #19
0
ファイル: main.c プロジェクト: patrick963534/a517
static void create_laser(int x, int y, int type)
{
    laser_t *me;
    int dir;
    int count;
    
    me = malloc(sizeof(*me));
    me->x = x;
    me->y = y;
    me->type = type;

    sl_list_init(&me->e);
    sl_list_init(&me->lights);

    dir = type >> 8;
    count = 0;

    printf("\n**********begin lights**********\n");

    while (1)
    {
        int ground;
        light_t *l;

        if (count++ > 10000)
            assert(!"failure to generate lights for laser.");


        update_pos(&x, &y, dir);
        ground = map[x + y * map_width];
        
        if (x < 0 || y < 0 || x >= map_width || y >= map_height)
            break;

        if ((ground & 0xF000) != G_NORMAL)
            break;

        l = malloc(sizeof(*l));
        l->x = x;
        l->y = y;
        l->dir = dir;
        sl_list_init(&l->e);
        sl_list_add_tail(&me->lights, &l->e);

        printf("(%02d,%02d) ", x, y);

        update_dir(ground, &dir);
    }

    printf("\n");
}
コード例 #20
0
ファイル: SdLifeLineCanvas.cpp プロジェクト: kralf/bouml
SdLifeLineCanvas::SdLifeLineCanvas(UmlCanvas * canvas, SdObjCanvas * o)
    : DiagramCanvas(0, canvas, 0, 0, LIFE_LINE_WIDTH, LIFE_LINE_HEIGHT, -1),
      obj(o), end(LIFE_LINE_HEIGHT) {
  update_pos();
  set_center100();
  setZ(DIAGRAMCANVAS_Z);
  
  if (obj->is_mortal())
    update_instance_dead();	// call show
  else
    show();
  
  if (canvas->paste())
    // must not be selected else the move done after if wrong
    canvas->unselect(this);
}
コード例 #21
0
ファイル: gui_canvas.c プロジェクト: bert/fped
static gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
    gpointer data)
{
	struct coord pos = canvas_to_coord(event->x, event->y);

	DPRINTF("--- motion ---");
	curr_pos.x = event->x;
	curr_pos.y = event->y;
	tool_hover(pos);
	if (event->state & GDK_BUTTON1_MASK)
		drag_left(pos);
	if (event->state & GDK_BUTTON2_MASK)
		drag_middle(pos);
	update_pos(pos);
	return FALSE;
}
コード例 #22
0
ファイル: vtape.c プロジェクト: AlD/bareos
/*
 * Write a variable block of count size.
 * block = vtape_header + data
 * vtape_header = sizeof(data)
 * if vtape_header == 0, this is a EOF
 */
ssize_t vtape::d_write(int, const void *buffer, size_t count)
{
   ASSERT(online);
   ASSERT(current_file >= 0);
   ASSERT(count > 0);
   ASSERT(buffer);

   ssize_t nb;
   Dmsg3(dbglevel*2, "write len=%i %i:%i\n",
         count, current_file,current_block);

   if (atEOT) {
      Dmsg0(dbglevel, "write nothing, EOT !\n");
      errno = ENOSPC;
      return -1;
   }

   if (!atEOD) {                /* if not at the end of the data */
      truncate_file();
   }

   if (current_block != -1) {
      current_block++;
   }

   atBOT = false;
   atEOF = false;
   atEOD = true;                /* End of data */

   needEOF = true;              /* next operation need EOF mark */

   uint32_t size = count;
   ::write(fd, &size, sizeof(uint32_t));
   nb = ::write(fd, buffer, count);

   if (nb != (ssize_t)count) {
      atEOT = true;
      Dmsg2(dbglevel,
            "Not enough space writing only %i of %i requested\n",
            nb, count);
   }

   update_pos();

   return nb;
}
コード例 #23
0
ファイル: Trap.c プロジェクト: Lundex/wileymud
void TrapDamage(struct char_data *v, int damtype, int amnt, struct obj_data *t)
{
  struct char_data *tmp_ch;
  char buf[132];

  if(DEBUG) dlog("TrapDamage");
  amnt = SkipImmortals(v, amnt);
  if (amnt == -1) 
    return;

  if (IS_AFFECTED(v, AFF_SANCTUARY))
    amnt = MAX((int)(amnt/2), 0);  /* Max 1/2 damage when sanct'd */
        
   amnt = PreProcDam(v, damtype, amnt);

   if (saves_spell(v, SAVING_PETRI))
     amnt = MAX((int)(amnt/2),0);

   DamageStuff(v, damtype, amnt);
   amnt=MAX(amnt,0);
   GET_HIT(v)-=amnt;
   update_pos(v);
   TrapDam(v, damtype, amnt, t);
   InformMess(v);
   if (GET_POS(v) == POSITION_DEAD) 
   {
     if (!IS_NPC(v)) 
     {
       if (real_roomp(v->in_room)->name)
         sprintf(buf, "%s killed by a trap at %s",
	   GET_NAME(v),real_roomp(v->in_room)->name);
       log(buf);
			/* remove the hatreds of this character */
     }

     for (tmp_ch=character_list; tmp_ch; tmp_ch=tmp_ch->next) 
     {
       if (Hates(tmp_ch, v)) 
       {
         RemHated(tmp_ch, v);
       }
     }
     die(v);
  }
} 
コード例 #24
0
ファイル: dev.c プロジェクト: dl5rcw/bareos
/*
 * Position device to end of medium (end of data)
 *
 * Returns: true  on succes
 *          false on error
 */
bool DEVICE::eod(DCR *dcr)
{
   boffset_t pos;

   if (m_fd < 0) {
      dev_errno = EBADF;
      Mmsg1(errmsg, _("Bad call to eod. Device %s not open\n"), print_name());
      return false;
   }

   if (is_vtl()) {
      return true;
   }

   Dmsg0(100, "Enter eod\n");
   if (at_eot()) {
      return true;
   }

   clear_eof();         /* remove EOF flag */

   block_num = file = 0;
   file_size = 0;
   file_addr = 0;

   pos = lseek(dcr, (boffset_t)0, SEEK_END);
   Dmsg1(200, "====== Seek to %lld\n", pos);

   if (pos >= 0) {
      update_pos(dcr);
      set_eot();
      return true;
   }

   dev_errno = errno;
   berrno be;
   Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), print_name(), be.bstrerror());
   Dmsg0(100, errmsg);

   return false;
}
コード例 #25
0
ファイル: fight.c プロジェクト: mysidia/circle31dgpy
void raw_kill(struct char_data * ch, struct char_data * killer)
{
  if (FIGHTING(ch))
    stop_fighting(ch);

  while (ch->affected)
    affect_remove(ch, ch->affected);

  /* To make ordinary commands work in scripts.  welcor*/  
  GET_POS(ch) = POS_STANDING; 
  
  if (killer) {
    if (check_hooks(HOOK_CONT_DIED, ch_script_cont(ch), killer, SNull, SNull ))
      death_cry(ch);
  } else
  death_cry(ch);

  update_pos(ch);

  make_corpse(ch);
  extract_char(ch);
}
コード例 #26
0
ファイル: Trap.c プロジェクト: jonm/SillyMUD
void trap_damage(struct char_data *v, int damtype, int amnt,
                 struct obj_data *t) {
  amnt = skip_immortals(v, amnt);
  if (amnt == -1) {
    return;
  }

  if (IS_AFFECTED(v, AFF_SANCTUARY))
    amnt = MAX((int)(amnt / 2), 0);     /* Max 1/2 damage when sanct'd */

  amnt = pre_proc_dam(v, damtype, amnt);

  if (saves_spell(v, SAVING_PETRI))
    amnt = MAX((int)(amnt / 2), 0);

  damage_stuff(v, damtype, amnt);

  amnt = MAX(amnt, 0);

  GET_HIT(v) -= amnt;

  update_pos(v);

  trap_dam(v, damtype, amnt, t);

  inform_mess(v);
  if (GET_POS(v) == POSITION_DEAD) {
    if (!IS_NPC(v)) {
      if (real_roomp(v->in_room)->name)
        log_msgf("%s killed by a trap at %s",
                 GET_NAME(v), real_roomp(v->in_room)->name);
    }

    die(v);
  }
}
コード例 #27
0
ファイル: limits.c プロジェクト: matthewbode/mg2
/* Update PCs, NPCs, and objects */
void point_update(void)
{
  struct char_data *i, *next_char;
  struct obj_data *j, *next_thing, *jj, *next_thing2;

  /* characters */
  for (i = character_list; i; i = next_char) {
    next_char = i->next;
	
    gain_condition(i, FULL, -1);
    gain_condition(i, DRUNK, -1);
    gain_condition(i, THIRST, -1);
	
    if (GET_POS(i) >= POS_STUNNED) {
      GET_HIT(i) = MIN(GET_HIT(i) + hit_gain(i), GET_MAX_HIT(i));
      GET_MANA(i) = MIN(GET_MANA(i) + mana_gain(i), GET_MAX_MANA(i));
      GET_MOVE(i) = MIN(GET_MOVE(i) + move_gain(i), GET_MAX_MOVE(i));
      if (AFF_FLAGGED(i, AFF_POISON))
	if (damage(i, i, 2, SPELL_POISON) == -1)
	  continue;	/* Oops, they died. -gg 6/24/98 */
      if (GET_POS(i) <= POS_STUNNED)
	update_pos(i);
    } else if (GET_POS(i) == POS_INCAP) {
      if (damage(i, i, 1, TYPE_SUFFERING) == -1)
	continue;
    } else if (GET_POS(i) == POS_MORTALLYW) {
      if (damage(i, i, 2, TYPE_SUFFERING) == -1)
	continue;
    }
    if (!IS_NPC(i)) {
      update_char_objects(i);
      if (GET_LEVEL(i) < idle_max_level)
	check_idling(i);
    }
  }

  /* objects */
  for (j = object_list; j; j = next_thing) {
    next_thing = j->next;	/* Next in object list */

    /* If this is a corpse */
    if (IS_CORPSE(j)) {
      /* timer count down */
      if (GET_OBJ_TIMER(j) > 0)
	GET_OBJ_TIMER(j)--;

      if (!GET_OBJ_TIMER(j)) {

	if (j->carried_by)
	  act("$p decays in your hands.", FALSE, j->carried_by, j, 0, TO_CHAR);
	else if ((IN_ROOM(j) != NOWHERE) && (world[IN_ROOM(j)].people)) {
	  act("A quivering horde of maggots consumes $p.",
	      TRUE, world[IN_ROOM(j)].people, j, 0, TO_ROOM);
	  act("A quivering horde of maggots consumes $p.",
	      TRUE, world[IN_ROOM(j)].people, j, 0, TO_CHAR);
	}
	for (jj = j->contains; jj; jj = next_thing2) {
	  next_thing2 = jj->next_content;	/* Next in inventory */
	  obj_from_obj(jj);

	  if (j->in_obj)
	    obj_to_obj(jj, j->in_obj);
	  else if (j->carried_by)
	    obj_to_room(jj, IN_ROOM(j->carried_by));
	  else if (IN_ROOM(j) != NOWHERE)
	    obj_to_room(jj, IN_ROOM(j));
	  else
	    core_dump();
	}
	extract_obj(j);
      }
    }
    /* If the timer is set, count it down and at 0, try the trigger */
    /* note to .rej hand-patchers: make this last in your point-update() */
    else if (GET_OBJ_TIMER(j)>0) {
      GET_OBJ_TIMER(j)--; 
      if (!GET_OBJ_TIMER(j))
        timer_otrigger(j);
    }
  }
}
コード例 #28
0
void Character::update() {
    AFFECT_DATA *paf;
    AFFECT_DATA *paf_next;

    if ( this->desc && this->desc->connected == CON_PLAYING )
        send_to_char("\n\r",this);

    if ( this->position >= POS_STUNNED )
    {
        if ( this->hit  < this->max_hit )
            this->hit  += this->hit_gain();
        else
            this->hit = this->max_hit;

        if ( this->mana < this->max_mana )
            this->mana += this->mana_gain();
        else
            this->mana = this->max_mana;

        if ( this->move < this->max_move )
            this->move += this->move_gain();
        else
            this->move = this->max_move;
    }

    if ( this->position == POS_STUNNED )
        update_pos( this );

    for ( paf = this->affected; paf != NULL; paf = paf_next )
    {
        paf_next	= paf->next;
        if ( paf->duration > 0 )
        {
            paf->duration--;
            if (number_range(0,4) == 0 && paf->level > 0)
                paf->level--;  /* spell strength fades with time */
        }
        else if ( paf->duration < 0 )
            ;
        else
        {
            if ( paf_next == NULL
                    ||   paf_next->type != paf->type
                    ||   paf_next->duration > 0 )
            {
                if ( paf->type > 0 && skill_table[paf->type].msg_off )
                {
                    send_to_char( skill_table[paf->type].msg_off, this );
                    send_to_char( "\n\r", this );
                }
            }

            affect_remove( this, paf );
        }
    }

    /*
     * Careful with the damages here,
     *   MUST NOT refer to ch after damage taken,
     *   as it may be lethal damage (on NPC).
     */

    if (is_affected(this, gsn_plague) && this != NULL)
    {
        if (this->in_room == NULL)
            return;

        ::act("$n writhes in agony as plague sores erupt from $s skin.",
                this,NULL,NULL,TO_ROOM);
        send_to_char("You writhe in agony from the plague.\n\r",this);

        AFFECT_DATA *af;
        for ( af = this->affected; af != NULL; af = af->next )
        {
            if (af->type == gsn_plague)
                break;
        }

        if (af == NULL)
        {
            REMOVE_BIT(this->affected_by,AFF_PLAGUE);
            return;
        }

        if (af->level == 1)
            return;

        AFFECT_DATA plague;
        plague.where		= TO_AFFECTS;
        plague.type 		= gsn_plague;
        plague.level 		= af->level - 1;
        plague.duration 	= number_range(1,2 * plague.level);
        plague.location		= APPLY_STR;
        plague.modifier 	= -5;
        plague.bitvector 	= AFF_PLAGUE;

        for ( Character* vch = this->in_room->people; vch != NULL; vch = vch->next_in_room)
        {
            if (!saves_spell(plague.level - 2,vch,DAM_DISEASE)
                    &&  !IS_IMMORTAL(vch)
                    &&  !IS_AFFECTED(vch,AFF_PLAGUE) && number_bits(4) == 0)
            {
                send_to_char("You feel hot and feverish.\n\r",vch);
                ::act("$n shivers and looks very ill.",vch,NULL,NULL,TO_ROOM);
                affect_join(vch,&plague);
            }
        }

        int dam = UMIN(this->level,af->level/5+1);
        this->mana -= dam;
        this->move -= dam;
        damage_old( this, this, dam, gsn_plague,DAM_DISEASE,FALSE);
    }
    else if ( IS_AFFECTED(this, AFF_POISON) && this != NULL
            &&   !IS_AFFECTED(this,AFF_SLOW))

    {
        AFFECT_DATA *poison;

        poison = affect_find(this->affected,gsn_poison);

        if (poison != NULL)
        {
            ::act( "$n shivers and suffers.", this, NULL, NULL, TO_ROOM );
            send_to_char( "You shiver and suffer.\n\r", this );
            damage_old(this,this,poison->level/10 + 1,gsn_poison,
                    DAM_POISON,FALSE);
        }
    }

    else if ( this->position == POS_INCAP && number_range(0,1) == 0)
    {
        ::damage( this, this, 1, TYPE_UNDEFINED, DAM_NONE,FALSE);
    }
    else if ( this->position == POS_MORTAL )
    {
        ::damage( this, this, 1, TYPE_UNDEFINED, DAM_NONE,FALSE);
    }
}
コード例 #29
0
ファイル: mudlimits.c プロジェクト: Lundessa/NewRavenVM
void regen_update( void ) {
    CharData *i, *next_char;
    int hit, mana, move;
    int vivify_level;

    for( i = character_list; i; i = next_char )
    {
        next_char = i->next;

        if(affected_by_spell(i, SKILL_EMACIATED) && (GET_COND(i, HUNGER) != 0 || IS_VAMPIRE(i)) && GET_COND(i, THIRST) != 0) {
            if(!affected_by_spell(i, SKILL_EMACIATED_MANA) && !affected_by_spell(i, SKILL_EMACIATED_HIT))
                affect_from_char(i, SKILL_EMACIATED);
            else if(percentSuccess(4)) {
                affect_from_char(i, SKILL_EMACIATED_MANA);
                affect_from_char(i, SKILL_EMACIATED_HIT);
            }
        }

        // Dwarves sober up 3x faster than most races (unless they drink more...)
        if(IS_DWARF(i) && !number(0, 35))
            gain_condition(i, DRUNK, -1);

        vivify_level = spell_level(i, SPELL_VIVIFY);
        affect_from_char(i, SPELL_VIVIFY);
        if(GET_POS(i) <= POS_MEDITATING) {
            add_affect(i, i, SPELL_VIVIFY, MIN(vivify_level + 1, 100), APPLY_NONE, 0, -1,
                    0, FALSE, FALSE, FALSE, FALSE);
        }

        if(GET_POS(i) >= POS_MORTALLYW)
        {
            hit = hit_gain(i);
            mana = mana_gain(i);
            move = move_gain(i);

            if(affected_by_spell(i, SPELL_VIVIFY)) {
                if(hit > 0)
                    hit += spell_level(i, SPELL_VIVIFY) * GET_MAX_HIT(i)/600;
                if(mana > 0)
                    mana += spell_level(i, SPELL_VIVIFY) * GET_MAX_MANA(i)/600;
                if(move > 0)
                    move += spell_level(i, SPELL_VIVIFY) * GET_MAX_MOVE(i)/600;
            }

            // Regeneration is increased on pvp holidays.  If you're incapactitated, you will
            // eventually recover.
            if(pvpHoliday(i)) {
                if (GET_POS(i) < POS_SLEEPING)
                    hit = 20;
                else {
                    hit  = (hit  > 0) ? hit *3 : 20;
                    mana = (mana > 0) ? mana*2 : 40;
                    move = (move > 0) ? move*2 : 40;
                }
            }
                

            // 72 seconds per tick...
            if(hit < 0 || GET_HIT(i) < GET_MAX_HIT(i)) {
                if(hit>0)
                    GET_HIT(i) += hit/72 + (hit % 72 > number(0, 71)? 1:0);
                else
                    GET_HIT(i)  = MAX(GET_HIT(i) + hit/72 + (-hit % 72 > number(0, 71)?-1:0), -9);
            }
            else {
                int surplus = (GET_HIT(i) - GET_MAX_HIT(i));
                GET_HIT(i) -= surplus / 72 + (surplus % 72 > number(0, 71)? 1:0);
            }


            if(mana>0)
                GET_MANA(i) = MAX(MIN(GET_MANA(i) + mana/72 + (mana % 72 > number(0, 71)?1:0), GET_MAX_MANA(i)), 0);
            else
                GET_MANA(i) = MIN(GET_MANA(i) + mana/72 + (-mana % 72 > number(0, 71)?-1:0), GET_MAX_MANA(i));

            if(move>0)
                GET_MOVE(i) = MIN(GET_MOVE(i) + move/72 + (move % 72 > number(0, 71)?1:0), GET_MAX_MOVE(i));
            else
                GET_MOVE(i) = MAX(MIN(GET_MOVE(i) + move/72 + (-move % 72 > number(0, 71)?-1:0), GET_MAX_MOVE(i)), 0);

            update_pos(i);
        }
    }
}
コード例 #30
0
ファイル: ninja.c プロジェクト: pfchrono/Anotherland_Mud
/* New strangle code -Beorn */
void do_strangle(CHAR_DATA *ch, char *argument)
{
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;
    char buf [MAX_STRING_LENGTH];
    int         dam;
    AFFECT_DATA af;

    argument = one_argument(argument, arg);

    if (IS_NPC(ch))

        if (!IS_CLASS(ch, CLASS_NINJA))
    {
        send_to_char("Huh?",ch);
        return;
    }

    if (ch->pcdata->powers[NPOWER_NINGENNO] < 2)
    {
        send_to_char("You do not have that ability yet.\n\r",ch);
        return;
    }
    if (arg[0] == '\0')
    {
        send_to_char("Hakunetsu who?\n\r",ch);
        return;
    }

    if ((victim = get_char_room( ch, arg )) == NULL)
    {
        send_to_char("They are not here.\n\r",ch);
        return;
    }
    if (!IS_SET(ch->act, PLR_SUPERINVIS))
    {
        send_to_char("You must using Kakusu to Hakunetsu!\n\r",ch);
        return;
    }
    if ( victim->fighting != NULL )
    {
        send_to_char( "You can't Hakunetsu a fighting person.\n\r", ch);
        return;
    }

    if (victim->hit <= (victim->max_hit *0.9))
    {
        send_to_char("They are already wounded.\n\r",ch);
        return;
    }

    if (is_safe(ch,victim))
        return;

    act("You step out from behind $N and cruelly stab them in the back.\n\r",ch,NULL,victim, TO_CHAR);
    act("$n steps out from behind you and plants a dagger between your shoulders.\n\r",ch,NULL,victim, TO_VICT);
    act("$n suddenly steps out from behind $N and stabs them in the back.\n\r",ch,NULL,victim, TO_NOTVICT);

    if (IS_SET(victim->act,PLR_HOLYLIGHT)) REMOVE_BIT(victim->act,PLR_HOLYLIGHT);
    if (IS_SET(victim->affected_by, AFF_DETECT_HIDDEN))
        REMOVE_BIT(victim->affected_by, AFF_DETECT_HIDDEN);
    if (IS_SET(victim->affected_by, AFF_DETECT_INVIS))
        REMOVE_BIT(victim->affected_by, AFF_DETECT_INVIS);
    af.type      = skill_lookup("blindness");
    af.location  = APPLY_HITROLL;
    af.modifier  = -50*(ch->pcdata->upgrade_level + 1);
    af.duration  = 60;
    af.bitvector = AFF_BLIND;
    affect_to_char( victim, &af );

    do_web(victim, "");
    do_web(victim, "");
    do_web(victim, "");
    do_web(victim, "");

    /*    spelltype = skill_table[sn].target;
        level = ch->spl[spelltype] * 1.5;
        (*skill_table[sn].spell_fun) ( sn, level, ch, victim );
    */
    dam = ((victim->hit) * .10);

    if (ch->generation == 5) dam *= 1.05;
    if (ch->generation == 4) dam *= 1.10;
    if (ch->generation == 3) dam *= 1.15;
    if (ch->generation == 2) dam *= 1.20;
    if (ch->generation == 1) dam *= 1.25;
    if (ch->generation == 0) dam *= 1.30;
    if (victim->position == POS_SLEEPING) dam *= 1.25;

    sprintf( buf, "You twist your blade cruelly in $N's back. #r[#l**#R%d#l**#r]#n",dam );
    act( buf, ch, NULL, victim, TO_CHAR );
    sprintf( buf, "$n's steps out from behind you and plants a dagger between your shoulders. #r[#l**#R%d#l**#r]#n",dam );
    act( buf, ch, NULL, victim, TO_VICT );
    act( "$n's steps out from behind $N and stabs them in the back.", ch, NULL, victim, TO_NOTVICT );
    hurt_person(ch, victim, dam);
    ch->fighting = victim;
    victim->fighting = ch;
    autodrop(ch);
    autodrop(victim);
    ch->position = POS_FIGHTING;
    victim->position = POS_FIGHTING;
    update_pos(ch);
    update_pos(victim);
    WAIT_STATE(ch,12);
    return;
}