当前位置: 首页>>代码示例>>C++>>正文


C++ damage函数代码示例

本文整理汇总了C++中damage函数的典型用法代码示例。如果您正苦于以下问题:C++ damage函数的具体用法?C++ damage怎么用?C++ damage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了damage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: do_earthshatter

void do_earthshatter( CHAR_DATA *ch, char *argument)
{
    CHAR_DATA *vch;
    CHAR_DATA *vch_next;
    int dam;
    int level;
    

	if (IS_NPC(ch)) return;

	if (!IS_CLASS(ch, CLASS_DROW) || !IS_SET(ch->pcdata->powers[1], DPOWER_EARTHSHATTER)) {
	send_to_char("Huh?\n\r", ch );
	return;}

	if (ch->mana < 150) {
	send_to_char("You need more mana.\n\r", ch );
	return;}

	level = ch->spl[PURPLE_MAGIC];
	ch->mana -= 150;

	send_to_char("You summon the power of the underworld, shattering the earth.\n\r", ch );
	act("$n causes the earth to shatter",ch,NULL,NULL,TO_ROOM);

    for ( vch = ch->in_room->people; vch != NULL; vch = vch_next )
    {
        vch_next = vch->next_in_room;

	if (vch == ch) continue;
        if (vch->trust>6) continue;
            dam  = dice(level, 7 );
            if ( saves_spell( level, vch ) )
                dam /= 2;
            damage( ch, vch, dam, skill_lookup("earthquake"));
    }
	WAIT_STATE(ch, 12);
    return;
}
开发者ID:smthbh,项目名称:dystopia-mud,代码行数:38,代码来源:drow.c

示例2: getSize

//--------------------------------------------------------------
// mouse pressed
void mgSimpleDesktop::mouseDown(
  void* source,
  int x,
  int y,
  int modifiers,
  int button)
{
#ifdef WORKED
//  takeKeyFocus();

  mgDimension size;
  getSize(size);

  mgRectangle inside(0, 0, size.m_width, size.m_height);
  if (m_upFrame != NULL)
    m_upFrame->getInsideRect(inside);

  // =-= select entry under point
  y = y - inside.m_y;

  int index = (y/m_lineHeight) + m_scrollPosn;
  if (index < m_entries.length())
  {
    if (m_multiSelect)
    {
      // =-= shift select, cntl select, start of drag select
      // =-= reset all other selections if just click
      mgListEntry* entry = (mgListEntry*) m_entries.getAt(index);
      entry->m_selected = true;
    }
    else
    {
      m_selected = index;
    }
    damage();
  }
#endif
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:40,代码来源:mgSimpleDesktop.cpp

示例3: send_to_char

void Character::spell_earthquake (int sn, int lvl, void *vo)
{
  send_to_char ("The earth trembles beneath your feet!\r\n");
  act ("$n makes the earth tremble and shiver.", NULL, NULL, TO_ROOM);

  CharIter c, next;
  for (c = char_list.begin(); c != char_list.end(); c = next) {
    Character* vch = *c;
    next = ++c;
    if (vch->in_room == NULL)
      continue;
    if (vch->in_room == in_room) {
      if (vch != this && (is_npc () ? !vch->is_npc () : vch->is_npc ()))
        damage (this, vch, lvl + dice (2, 8), sn);
      continue;
    }

    if (vch->in_room->area == in_room->area)
      vch->send_to_char ("The earth trembles and shivers.\r\n");
  }

  return;
}
开发者ID:MUDOmnibus,项目名称:Merc22-for-Cpp,代码行数:23,代码来源:spells.cpp

示例4: notify_all

void Text::eraseLine() 
{
	if (insertion_.line_ < text_->Height()) 
	{
		int oldWidth = text_->Width();
		int index0 = text_->LineIndex(insertion_.line_);
		int index1 = text_->BeginningOfNextLine(index0);

		// ---- delete the text ----
		text_->Delete(index0, index1 - index0);

		// --- check for width change ----
		if (text_->Width() != oldWidth)
		{
			needWidth_ = true;
			notify_all();
		}
	}
	insertion_.column_ = 0;
	repair();
	damage(insertion_);
	repair();
}
开发者ID:PNCG,项目名称:neuron,代码行数:23,代码来源:iv3text.cpp

示例5: number_range

/*
 * Drain XP, MANA, HP.
 * Caster gains HP.
 */
void Character::spell_energy_drain (int sn, int lvl, void *vo)
{
  Character *victim = (Character *) vo;
  int dam;

  if (victim->saves_spell (lvl))
    return;

  alignment = std::max (-1000, alignment - 200);
  if (victim->level <= 2) {
    dam = hit + 1;
  } else {
    victim->gain_exp(0 - number_range (lvl / 2, 3 * lvl / 2));
    victim->mana /= 2;
    victim->move /= 2;
    dam = dice (1, lvl);
    hit += dam;
  }

  damage (this, victim, dam, sn);

  return;
}
开发者ID:MUDOmnibus,项目名称:Merc22-for-Cpp,代码行数:27,代码来源:spells.cpp

示例6: act

void Character::spell_dispel_evil (int sn, int lvl, void *vo)
{
  Character *victim = (Character *) vo;

  if (!is_npc () && is_evil ())
    victim = this;

  if (victim->is_good ()) {
    act ("God protects $N.", NULL, victim, TO_ROOM);
    return;
  }

  if (victim->is_neutral ()) {
    act ("$N does not seem to be affected.", NULL, victim, TO_CHAR);
    return;
  }

  int dam = dice (lvl, 4);
  if (victim->saves_spell (lvl))
    dam /= 2;
  damage (this, victim, dam, sn);
  return;
}
开发者ID:MUDOmnibus,项目名称:Merc22-for-Cpp,代码行数:23,代码来源:spells.cpp

示例7: w

void Fl_Sparkline::draw(void)
{
    int i;
    int index;

    width = w() - padding * 2;
    height = h() - padding * 2;

    if (num_values == 0) {
        draw_box();
        return;
    }

    if (damage() == FL_DAMAGE_USER1) {
        index = num_values * (Fl::event_x() - x() - padding) / width;
        index = snap(index);
        tip->position(Fl::event_x_root() + 10, Fl::event_y_root() + 10);
        tip->value(values[index]);
        tip->show();

        drawCursor();
        return;
    }

    draw_box();

    fl_color(FL_BLACK);

    drawPeaks();
    fl_color(FL_BLACK);

    for (i = 0; i < width; i++) {
        drawPoint(i);
    }

    draw_label();
}
开发者ID:qartis,项目名称:dori,代码行数:37,代码来源:sparkline.cpp

示例8: switch

void Character::spell_frost_breath (int sn, int lvl, void *vo)
{
  Character *victim = (Character *) vo;

  if (number_percent () < 2 * lvl && !victim->saves_spell (lvl)) {
    Object *obj_lose;
    ObjIter o, onext;
    for (o = victim->carrying.begin(); o != victim->carrying.end(); o = onext) {
      obj_lose = *o;
      onext = ++o;
      const char *msg;

      if (number_percent() <= 75)
        continue;

      switch (obj_lose->item_type) {
      default:
        continue;
      case ITEM_CONTAINER:
      case ITEM_DRINK_CON:
      case ITEM_POTION:
        msg = "$p freezes and shatters!";
        break;
      }

      victim->act (msg, obj_lose, NULL, TO_CHAR);
      obj_lose->extract_obj ();
    }
  }

  int hpch = std::max (10, hit);
  int dam = number_range (hpch / 16 + 1, hpch / 8);
  if (victim->saves_spell (lvl))
    dam /= 2;
  damage (this, victim, dam, sn);
  return;
}
开发者ID:MUDOmnibus,项目名称:Merc22-for-Cpp,代码行数:37,代码来源:spells.cpp

示例9: letter

//--------------------------------------------------------------
// character typed
void mgSimpleField::keyChar(
  void* source,
  int keyCode,
  int modifiers)
{
  if (!iswprint(keyCode) && keyCode != ' ')
    return;  // non-letter key

  WCHAR keyChar[2];
  keyChar[0] = (WCHAR) keyCode;
  keyChar[1] = '\0';
  mgString letter(keyChar);

  if (m_insertMode)
  {
    // extend string up to cursor position
    while (m_text.length() < m_cursorPosn)
      m_text += " ";

    // insert character at cursor
    m_text.insertAt(m_cursorPosn, letter);
  }
  else
  {
    // extend string, including cursor position
    while (m_text.length() <= m_cursorPosn)
      m_text += " ";

    // replace current character
    m_text.setLetter(m_cursorPosn, letter);
  }
  m_cursorPosn = m_text.nextLetter(m_cursorPosn);
  updateScrollPosn();
  m_changed = true;

  damage();
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:39,代码来源:mgSimpleField.cpp

示例10: getSize

//--------------------------------------------------------------
// mouse moved
void mgUglyList::mouseMove(
  void* source,
  int x,
  int y,
  int modifiers)
{
  mgDimension size;
  getSize(size);

  mgRectangle inside(0, 0, size.m_width, size.m_height);
  if (m_upFrame != NULL)
    m_upFrame->getInsideRect(inside);

  // find entry under point
  y = y - inside.m_y;

  int index = (y/m_lineHeight) + m_scrollPosn;
  if (index < m_entries.length())
  {
    m_hover = index;
    damage();
  }
  else m_hover = -1;
}
开发者ID:duaneking,项目名称:SeaOfMemes,代码行数:26,代码来源:mgUglyList.cpp

示例11: warp

void
warp(int fl, int c, double d)
{
	int		course;
	double		power;
	double		dist;
	double		p_time;
	double		speed;
	double		frac;
	int		percent;
	int		i;
	char		*s;

	if (Ship.cond == DOCKED) {
		printf("%s is docked\n", Ship.shipname);
		return;
	}
	if (damaged(WARP)) {
		out(WARP);
		return;
	}
	course = c;
	dist = d;

	/* check to see that we are not using an absurd amount of power */
	power = (dist + 0.05) * Ship.warp3;
	percent = 100 * power / Ship.energy + 0.5;
	if (percent >= 85) {
		printf("Scotty: That would consume %d%% of our remaining energy.\n",
			percent);
		if (!getynpar("Are you sure that is wise"))
			return;
	}

	/* compute the speed we will move at, and the time it will take */
	speed = Ship.warp2 / Param.warptime;
	p_time = dist / speed;

	/* check to see that that value is not ridiculous */
	percent = 100 * p_time / Now.time + 0.5;
	if (percent >= 85) {
		printf("Spock: That would take %d%% of our remaining time.\n",
			percent);
		if (!getynpar("Are you sure that is wise"))
			return;
	}

	/* compute how far we will go if we get damages */
	if (Ship.warp > 6.0 && ranf(100) < 20 + 15 * (Ship.warp - 6.0)) {
		frac = franf();
		dist *= frac;
		p_time *= frac;
		damage(WARP, (frac + 1.0) * Ship.warp * (franf() + 0.25) * 0.20);
	}

	/* do the move */
	Move.time = move(fl, course, p_time, speed);

	/* see how far we actually went, and decrement energy appropriately */
	dist = Move.time * speed;
	Ship.energy -= dist * Ship.warp3 * (Ship.shldup + 1);

	/* test for bizarre events */
	if (Ship.warp <= 9.0)
		return;
	printf("\n\n  ___ Speed exceeding warp nine ___\n\n");
	sleep(2);
	printf("Ship's safety systems malfunction\n");
	sleep(2);
	printf("Crew experiencing extreme sensory distortion\n");
	sleep(4);
	if (ranf(100) >= 100 * dist) {
		printf("Equilibrium restored -- all systems normal\n");
		return;
	}

	/* select a bizzare thing to happen to us */
	percent = ranf(100);
	if (percent < 70) {
		/* time warp */
		if (percent < 35 || !Game.snap) {
			/* positive time warp */
			p_time = (Ship.warp - 8.0) * dist * (franf() + 1.0);
			Now.date += p_time;
			printf("Positive time portal entered -- it is now Stardate %.2f\n",
				Now.date);
			for (i = 0; i < MAXEVENTS; i++) {
				percent = Event[i].evcode;
				if (percent == E_FIXDV || percent == E_LRTB)
					Event[i].date += p_time;
			}
			return;
		}

		/* s/he got lucky: a negative time portal */
		p_time = Now.date;
		s = Etc.snapshot;
		bmove(s, Quad, sizeof Quad);
		bmove(s += sizeof Quad, Event, sizeof Event);
		bmove(s += sizeof Event, &Now, sizeof Now);
//.........这里部分代码省略.........
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:101,代码来源:warp.c

示例12: damage

void Character::spell_cause_serious (int sn, int lvl, void *vo)
{
  damage (this, (Character *) vo, dice (2, 8) + lvl / 2, sn);
  return;
}
开发者ID:MUDOmnibus,项目名称:Merc22-for-Cpp,代码行数:5,代码来源:spells.cpp

示例13: switch


//.........这里部分代码省略.........
			}
			break;
		}
		case EVENT_ENEMY_DESTROYED: {
			struct SEnemyDestroyedEvent* evt = (struct SEnemyDestroyedEvent*) data;
			if(evt->enemy < 0){
				game->SendToConsole("shard-runtime warning: enemydestroyed evt->unit < 0");
				break;
			}
			CSpringUnit* u = game->GetUnitById(evt->enemy);
			if (!u) {
				u = game->CreateUnit(evt->enemy);
			}
			/*if(u){
				// @TODO: Add enemy dead event
				game->Me()->UnitDead(u);
			}*/
			game->DestroyUnit(evt->enemy);
			break;
		}
		case EVENT_ENEMY_CREATED: {
			struct SEnemyCreatedEvent* evt = (struct SEnemyCreatedEvent*) data;
			game->CreateUnit(evt->enemy);
			break;
		}
		case EVENT_ENEMY_FINISHED: {
			struct SEnemyFinishedEvent* evt = (struct SEnemyFinishedEvent*) data;
			game->CreateUnit(evt->enemy);
			break;
		}
		case EVENT_UNIT_DAMAGED: {
			struct SUnitDamagedEvent* evt = (struct SUnitDamagedEvent*) data;
			if(evt->unit < 0){
				game->SendToConsole("shard-runtime warning: unitdamaged evt->unit < 0");
				break;
			}
			CSpringDamage::Ptr damage(new CSpringDamage(game, callback, evt));

			CSpringUnit* u = game->GetUnitById(evt->unit);
			if (!u) {
				u = game->CreateUnit(evt->unit);
			}

			//attacker is allowed to be -1 if attacker cannot be seen or determined.
			CSpringUnit* a = NULL;
			if (evt->attacker >= 0) {
				a = game->GetUnitById(evt->attacker);
				if (!a) {
					game->CreateUnit(evt->attacker);
				}
			}
			if(u) {
				game->Me()->UnitDamaged(u,a,damage);
			} else {
				if (!u)
					game->SendToConsole("shard-runtime warning: attacked unit not found.");
			}
			break;
		}
		case EVENT_UNIT_IDLE: {
			struct SUnitIdleEvent* evt = (struct SUnitIdleEvent*) data;
			if(evt->unit < 0){
				game->SendToConsole("shard-runtime warning: unitidle evt->unit < 0");
				break;
			}
			CSpringUnit* u = game->GetUnitById(evt->unit);
开发者ID:pandaro,项目名称:Shard,代码行数:67,代码来源:CppTestAI.cpp

示例14: damage

//--------------------------------------------------------------------
// damage entire bitmap
void mgGenSurface::damageAll()
{
  damage(0, 0, m_surfaceWidth, m_surfaceHeight);
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:6,代码来源:mgGenSurface.cpp

示例15: mag_damage

/*
 * Every spell that does damage comes through here.  This calculates the
 * amount of damage, adds in any modifiers, determines what the saves are,
 * tests for save and calls damage().
 *
 * -1 = dead, otherwise the amount of damage done.
 */
int mag_damage(int level, struct char_data *ch, struct char_data *victim,
		     int spellnum, int savetype)
{
  int dam = 0;

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

  switch (spellnum) {
    /* Mostly mages */
  case SPELL_MAGIC_MISSILE:
  case SPELL_CHILL_TOUCH:	/* chill touch also has an affect */
    if (IS_MAGIC_USER(ch))
      dam = dice(1, 8) + 1;
    else
      dam = dice(1, 6) + 1;
    break;
  case SPELL_BURNING_HANDS:
    if (IS_MAGIC_USER(ch))
      dam = dice(3, 8) + 3;
    else
      dam = dice(3, 6) + 3;
    break;
  case SPELL_SHOCKING_GRASP:
    if (IS_MAGIC_USER(ch))
      dam = dice(5, 8) + 5;
    else
      dam = dice(5, 6) + 5;
    break;
  case SPELL_LIGHTNING_BOLT:
    if (IS_MAGIC_USER(ch))
      dam = dice(7, 8) + 7;
    else
      dam = dice(7, 6) + 7;
    break;
  case SPELL_COLOR_SPRAY:
    if (IS_MAGIC_USER(ch))
      dam = dice(9, 8) + 9;
    else
      dam = dice(9, 6) + 9;
    break;
  case SPELL_FIREBALL:
    if (IS_MAGIC_USER(ch))
      dam = dice(11, 8) + 11;
    else
      dam = dice(11, 6) + 11;
    break;

    /* Mostly clerics */
  case SPELL_DISPEL_EVIL:
    dam = dice(6, 8) + 6;
    if (IS_EVIL(ch)) {
      victim = ch;
      dam = GET_HIT(ch) - 1;
    } else if (IS_GOOD(victim)) {
      act("The gods protect $N.", FALSE, ch, 0, victim, TO_CHAR);
      return (0);
    }
    break;
  case SPELL_DISPEL_GOOD:
    dam = dice(6, 8) + 6;
    if (IS_GOOD(ch)) {
      victim = ch;
      dam = GET_HIT(ch) - 1;
    } else if (IS_EVIL(victim)) {
      act("The gods protect $N.", FALSE, ch, 0, victim, TO_CHAR);
      return (0);
    }
    break;


  case SPELL_CALL_LIGHTNING:
    dam = dice(7, 8) + 7;
    break;

  case SPELL_HARM:
    dam = dice(8, 8) + 8;
    break;

  case SPELL_ENERGY_DRAIN:
    if (GET_LEVEL(victim) <= 2)
      dam = 100;
    else
      dam = dice(1, 10);
    break;

    /* Area spells */
  case SPELL_EARTHQUAKE:
    dam = dice(2, 8) + level;
    break;

  } /* switch(spellnum) */

//.........这里部分代码省略.........
开发者ID:Yuffster,项目名称:CircleMUD,代码行数:101,代码来源:magic.c


注:本文中的damage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。