Exemple #1
0
void
spell_level (int spell, int chclass, int level)
{
	int bad = 0;

	if (spell < 0 || spell > TOP_SPELL_DEFINE)
	{
		log ("SYSERR: attempting assign to illegal spellnum %d/%d", spell,
			 TOP_SPELL_DEFINE);
		return;
	}

	if (chclass < 0 || chclass >= NUM_CLASSES)
	{
		log ("SYSERR: assigning '%s' to illegal class %d/%d.",
			 skill_name (spell), chclass, NUM_CLASSES - 1);
		bad = 1;
	}

	if (level < 1 || level > LVL_IMPL)
	{
		log ("SYSERR: assigning '%s' to illegal level %d/%d.",
			 skill_name (spell), level, LVL_IMPL);
		bad = 1;
	}

	if (!bad)
		spell_info[spell].min_level[chclass] = level;
}
Exemple #2
0
static void say_spell(struct char_data *ch, int spellnum, struct char_data *tch,
	            struct obj_data *tobj)
{
  char lbuf[256], buf[256], buf1[256], buf2[256];	/* FIXME */
  const char *format;

  struct char_data *i;
  int j, ofs = 0;

  *buf = '\0';
  strlcpy(lbuf, skill_name(spellnum), sizeof(lbuf));

  while (lbuf[ofs]) {
    for (j = 0; *(syls[j].org); j++) {
      if (!strncmp(syls[j].org, lbuf + ofs, strlen(syls[j].org))) {
	strcat(buf, syls[j].news);	/* strcat: BAD */
	ofs += strlen(syls[j].org);
        break;
      }
    }
    /* i.e., we didn't find a match in syls[] */
    if (!*syls[j].org) {
      log("No entry in syllable table for substring of '%s'", lbuf);
      ofs++;
    }
  }

  if (tch != NULL && IN_ROOM(tch) == IN_ROOM(ch)) {
    if (tch == ch)
      format = "$n closes $s eyes and utters the words, '%s'.";
    else
      format = "$n stares at $N and utters the words, '%s'.";
  } else if (tobj != NULL &&
	     ((IN_ROOM(tobj) == IN_ROOM(ch)) || (tobj->carried_by == ch)))
    format = "$n stares at $p and utters the words, '%s'.";
  else
    format = "$n utters the words, '%s'.";

  snprintf(buf1, sizeof(buf1), format, skill_name(spellnum));
  snprintf(buf2, sizeof(buf2), format, buf);

  for (i = world[IN_ROOM(ch)].people; i; i = i->next_in_room) {
    if (i == ch || i == tch || !i->desc || !AWAKE(i))
      continue;
    if (GET_CLASS(ch) == GET_CLASS(i))
      perform_act(buf1, ch, tobj, tch, i);
    else
      perform_act(buf2, ch, tobj, tch, i);
  }

  if (tch != NULL && tch != ch && IN_ROOM(tch) == IN_ROOM(ch)) {
    snprintf(buf1, sizeof(buf1), "$n stares at you and utters the words, '%s'.",
	    GET_CLASS(ch) == GET_CLASS(tch) ? skill_name(spellnum) : buf);
    act(buf1, FALSE, ch, NULL, tch, TO_VICT);
  }
}
Exemple #3
0
void list_wands_staves (struct char_data *ch, char *input)
{
	int type=0;
	int i=0;
	int j=0;
	int k=0;
	char *wsbuf = get_buffer(MAX_STRING_LENGTH);

	skip_spaces(&input);
	switch (input[0]) {
	case 'T':
	case 't':
		type = ITEM_STAFF; 
		break;
	case 'W':
	case 'w':
		type = ITEM_WAND; 
		break;
	default:
		extended_mudlog(NRM, SYSL_BUGS, TRUE, "Default reached in list_scrolls_potions (arg = %s)", input);
		release_buffer(wsbuf);
		return; 
	}	/*switch...*/

	wsbuf[0]='\0';
	for (i=0;i<top_of_objt;i++) {
		j=obj_proto[i].obj_flags.type_flag; /*look for specific sort of item*/
		if (j == type) { /*found one*/
			sprintf(wsbuf+strlen(wsbuf),"[%5d] %-30s", /*print vnum, short description*/
			GET_OBJ_VNUM(&obj_proto[i]),
			obj_proto[i].short_description);

			/*
			 * values 0-3:
			 * Potion, Scroll - up to three spells [values 1-3]
			 */

			sprintf(wsbuf+strlen(wsbuf), " Spells: ");
			if (type==ITEM_STAFF) { /*staves have only one spell*/
				if ((GET_OBJ_VAL(&obj_proto[i], 3)) != (-1))
					sprintf(wsbuf+strlen(wsbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], 3)));
			} else {
				for (k=1; k < 4; k++) {
					if ((GET_OBJ_VAL(&obj_proto[i], k)) != (-1))
						sprintf(wsbuf+strlen(wsbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], k)));
				}
				sprintf(wsbuf+strlen(wsbuf), "\r\n");
			}
		}	/*if j == type*/
	}	/*for i...*/
	page_string (ch->desc, wsbuf, 1);
	release_buffer(wsbuf);
}
int cast_wtrigger(char_data *actor, char_data *vict, obj_data *obj, int spellnum) {
  room_data *room;
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_CAST))
    return 1;

  room = &world[IN_ROOM(actor)];
  for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
    if (TRIGGER_CHECK(t, WTRIG_CAST) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {

      ADD_UID_VAR(buf, t, actor, "actor", 0);
      if (vict)
        ADD_UID_VAR(buf, t, vict, "victim", 0);
      if (obj)
        ADD_UID_VAR(buf, t, obj, "object", 0);
      sprintf(buf, "%d", spellnum);
      add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
      add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
      return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
    }
  }

  return 1;
}
Exemple #5
0
/* Called to add a skill to the skills list */
void SkillList::addSkill (int skillId, int value)
{
  if (skillId >= MAX_KNOWN_SKILLS)
  {
    printf("Warning: skillId (%d) is more than max skillId (%d)\n", 
	   skillId, MAX_KNOWN_SKILLS - 1);

    return;
  }

  /* Check if this is a valid skill */
  if (value == 255)
    return;

  QString str;

  /* Check if this is a skill not learned yet */
  if (value == 254)
    str = " NA";
  else
    str.sprintf ("%3d", value);

  /* If the skill is not added yet, look up the correct skill namd and add it
   * to the list
   */
  if (!m_skillList[skillId])
    m_skillList[skillId] =
      new QListViewItem (this, skill_name (skillId), str);
  else
    m_skillList[skillId]->setText (1, str);
}
Exemple #6
0
void MessageShell::increaseSkill(const uint8_t* data)
{
  const skillIncStruct* skilli = (const skillIncStruct*)data;
  QString tempStr;
  tempStr.sprintf("Skill: %s has increased (%d)",
		  (const char*)skill_name(skilli->skillId),
		  skilli->value);
  m_messages->addMessage(MT_Player, tempStr);
}
Exemple #7
0
void list_scrolls_potions (struct char_data *ch, char *input)
{
	int type=0;
	int i=0;
	int j=0;
	int k=0;
	char *spbuf = get_buffer(MAX_STRING_LENGTH);

	skip_spaces(&input);
	switch (input[0]) {
	case 'S':
	case 's':
		type = ITEM_SCROLL; 
		break;
	case 'P':
	case 'p':
		type = ITEM_POTION; 
		break;
	default :
		mlog("SYSERR:  Default reached in list_scrolls_potions (arg = %s)", input);
		release_buffer(spbuf);
		return;
	}/*switch...*/

	spbuf[0]='\0';
	for (i=0;i<top_of_objt;i++) {
		j=obj_proto[i].obj_flags.type_flag; /*look for specific sort of item*/
		if (j == type) { /*found one*/
			sprintf(spbuf+strlen(spbuf),"[%5d] %-20s", /*print vnum, short description*/
			GET_OBJ_VNUM(&obj_proto[i]),
			obj_proto[i].short_description);

			/*
			 * values 0-3:
			 * Potion, Scroll - up to three spells [values 1-3]
			 */

			sprintf(spbuf+strlen(spbuf), " Spells: ");
			for (k=1;k<4;k++) {
				if ((GET_OBJ_VAL(&obj_proto[i], k)) != (-1))
					sprintf(spbuf+strlen(spbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], k)));
			}


			sprintf(spbuf+strlen(spbuf), "\r\n");

		}/*if j == type*/
	}/*for i...*/
	page_string (ch->desc, spbuf, 1);
	release_buffer(spbuf);
}
Exemple #8
0
void EQPlayer::increaseSkill(const skillIncreaseStruct* skilli)
{
  // save the new skill value
  m_playerSkills[skilli->skillId] = skilli->value;
  m_thePlayer.skills[skilli->skillId] = skilli->value;

  // notify others of the new value
  emit changeSkill (skilli->skillId, skilli->value);

  QString tempStr;
  tempStr.sprintf("Skill: %s has increased (%d)",
		  (const char*)skill_name(skilli->skillId),
		  skilli->value);

  emit msgReceived(tempStr);
  emit stsMessage(tempStr);
}
Exemple #9
0
/* Called to add a skill to the skills list */
void SkillList::addSkill (int skillId, int value)
{
  if (skillId >= MAX_KNOWN_SKILLS)
  {
    seqWarn("skillId (%d) is more than max skillId (%d)\n", 
	   skillId, MAX_KNOWN_SKILLS - 1);

    return;
  }

  // Purple: Skills are uint32_now, but these special values don't seem to have
  //         been moved up to the top bits. Somehow, the client still knows
  //         the difference between a skill you don't get get and a skill that
  //         you do get and can train and should be shown in the list. For us,
  //         for now all skills show up and are skill 0 whether you can learn
  //         them or now.
#if 0
  if (value == 255)
    return;

  QString str;

  /* Check if this is a skill not learned yet */
  if (value == 254)
    str = " NA";
  else
    str.sprintf ("%3d", value);
#endif
  QString str;

  str.sprintf("%3d", value);

  /* If the skill is not added yet, look up the correct skill namd and add it
   * to the list
   */
  if (!m_skillList[skillId])
    m_skillList[skillId] =
      new QListViewItem (this, skill_name (skillId), str);
  else
    m_skillList[skillId]->setText (1, str);
}
Exemple #10
0
/* Skill update */
void SkillList::changeSkill (int skillId, int value)
{
  if (skillId >= MAX_KNOWN_SKILLS)
  {
    seqWarn("skillId (%d) is more than max skillId (%d)\n", 
	   skillId, MAX_KNOWN_SKILLS - 1);

    return;
  }
                                
  QString str;
  /* Update skill value with new value */
  str.sprintf ("%3d", value);

  // create skill entry if needed or set the value of the existing item
  if (!m_skillList[skillId])
    m_skillList[skillId] =
      new QListViewItem (this, skill_name (skillId), str);
  else
    m_skillList[skillId]->setText (1, str);
}
Exemple #11
0
int cast_mtrigger(char_data *actor, char_data *ch, int spellnum) {
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  if (ch == NULL)
    return 1;

  if (!SCRIPT_CHECK(ch, MTRIG_CAST) || AFF_FLAGGED(ch, AFF_CHARM))
    return 1;

  for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
    if (TRIGGER_CHECK(t, MTRIG_CAST) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
      ADD_UID_VAR(buf, t, actor, "actor", 0);
      sprintf(buf, "%d", spellnum);
      add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
      add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
      return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
    }
  }

  return 1;
}
Exemple #12
0
int cast_otrigger(char_data *actor, obj_data *obj, int spellnum) {
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  if (obj == NULL)
    return 1;

  if (!SCRIPT_CHECK(obj, OTRIG_CAST))
    return 1;

  for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
    if (TRIGGER_CHECK(t, OTRIG_CAST) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
      ADD_UID_VAR(buf, t, actor, "actor", 0);
      sprintf(buf, "%d", spellnum);
      add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
      add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
      return script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
    }
  }

  return 1;
}
Exemple #13
0
void game::craft()
{
 if (u.morale_level() < MIN_MORALE_CRAFT) {	// See morale.h
  add_msg("Your morale is too low to craft...");
  return;
 }
 WINDOW *w_head = newwin( 3, 80, 0, 0);
 WINDOW *w_data = newwin(22, 80, 3, 0);
 craft_cat tab = CC_WEAPON;
 std::vector<recipe*> current;
 std::vector<bool> available;
 item tmp;
 int line = 0, xpos, ypos;
 bool redraw = true;
 bool done = false;
 char ch;

 do {
  if (redraw) { // When we switch tabs, redraw the header
   redraw = false;
   line = 0;
   draw_recipe_tabs(w_head, tab);
   current.clear();
   available.clear();
// Set current to all recipes in the current tab; available are possible to make
   pick_recipes(current, available, tab);
  }

// Clear the screen of recipe data, and draw it anew
  werase(w_data);
   mvwprintz(w_data, 20, 0, c_white, "\
Press ? to describe object.  Press <ENTER> to attempt to craft object.");
  wrefresh(w_data);
  for (int i = 0; i < current.size() && i < 23; i++) {
   if (i == line)
    mvwprintz(w_data, i, 0, (available[i] ? h_white : h_dkgray),
              itypes[current[i]->result]->name.c_str());
   else
    mvwprintz(w_data, i, 0, (available[i] ? c_white : c_dkgray),
              itypes[current[i]->result]->name.c_str());
  }
  if (current.size() > 0) {
   nc_color col = (available[line] ? c_white : c_dkgray);
   mvwprintz(w_data, 0, 30, col, "Primary skill: %s",
             (current[line]->sk_primary == sk_null ? "N/A" :
              skill_name(current[line]->sk_primary).c_str()));
   mvwprintz(w_data, 1, 30, col, "Secondary skill: %s",
             (current[line]->sk_secondary == sk_null ? "N/A" :
              skill_name(current[line]->sk_secondary).c_str()));
   mvwprintz(w_data, 2, 30, col, "Difficulty: %d", current[line]->difficulty);
   if (current[line]->sk_primary == sk_null)
    mvwprintz(w_data, 3, 30, col, "Your skill level: N/A");
   else
    mvwprintz(w_data, 3, 30, col, "Your skill level: %d",
              u.sklevel[current[line]->sk_primary]);
   if (current[line]->time >= 1000)
    mvwprintz(w_data, 4, 30, col, "Time to complete: %d minutes",
              int(current[line]->time / 1000));
   else
    mvwprintz(w_data, 4, 30, col, "Time to complete: %d turns",
              int(current[line]->time / 100));
   mvwprintz(w_data, 5, 30, col, "Tools required:");
   if (current[line]->tools[0].size() == 0) {
    mvwputch(w_data, 6, 30, col, '>');
    mvwprintz(w_data, 6, 32, c_green, "NONE");
    ypos = 6;
   } else {
    ypos = 5;
 // Loop to print the required tools
    for (int i = 0; i < 5; i++) {
     if (current[line]->tools[i].size() > 0) {
      ypos++;
      mvwputch(w_data, ypos, 30, col, '>');
     }
     xpos = 32;
     for (int j = 0; j < current[line]->tools[i].size(); j++) {
      itype_id type = current[line]->tools[i][j].type;
      int charges = current[line]->tools[i][j].count;
      nc_color toolcol = c_red;
      if (charges < 0 && u.has_amount(type, 1))
       toolcol = c_green;
      else if (charges > 0 && u.has_charges(type, charges))
       toolcol = c_green;
      if (u.has_bionic(bio_tools))
       toolcol = c_green;
      std::stringstream toolinfo;
      toolinfo << itypes[type]->name + " ";
      if (charges > 0)
       toolinfo << "(" << charges << " charges) ";
      std::string toolname = toolinfo.str();
      if (xpos + toolname.length() >= 80) {
       xpos = 32;
       ypos++;
      }
      mvwprintz(w_data, ypos, xpos, toolcol, toolname.c_str());
      xpos += toolname.length();
      if (j < current[line]->tools[i].size() - 1) {
       if (xpos >= 77) {
        xpos = 32;
        ypos++;
       }
       mvwprintz(w_data, ypos, xpos, c_white, "OR ");
       xpos += 3;
      }
     }
    }
   }
 // Loop to print the required components
   ypos++;
   mvwprintz(w_data, ypos, 30, col, "Components required:");
   for (int i = 0; i < 5; i++) {
    if (current[line]->components[i].size() > 0) {
     ypos++;
     mvwputch(w_data, ypos, 30, col, '>');
    }
    xpos = 32;
    for (int j = 0; j < current[line]->components[i].size(); j++) {
     int count = current[line]->components[i][j].count;
     itype_id type = current[line]->components[i][j].type;
     nc_color compcol = (u.has_amount(type, count) ? c_green : c_red);
     std::stringstream dump;
     dump << count << "x " << itypes[type]->name << " ";
     std::string compname = dump.str();
     if (xpos + compname.length() >= 80) {
      ypos++;
      xpos = 32;
     }
     mvwprintz(w_data, ypos, xpos, compcol, compname.c_str());
     xpos += compname.length();
     if (j < current[line]->components[i].size() - 1) {
      if (xpos >= 77) {
       ypos++;
       xpos = 32;
      }
      mvwprintz(w_data, ypos, xpos, c_white, "OR ");
      xpos += 3;
     }
    }
   }
  }
  
  wrefresh(w_data);
  ch = input();
  switch (ch) {
  case '<':
   if (tab == CC_WEAPON)
    tab = CC_MISC;
   else
    tab = craft_cat(int(tab) - 1);
   redraw = true;
   break;
  case '>':
   if (tab == CC_MISC)
    tab = CC_WEAPON;
   else
    tab = craft_cat(int(tab) + 1);
   redraw = true;
   break;
  case 'j':
   line++;
   break;
  case 'k':
   line--;
   break;
  case '\n':
   if (!available[line])
    popup("You can't do that!");
   else {
    make_craft(current[line]);
    done = true;
   }
   break;
  case '?':
   tmp = item(itypes[current[line]->result], 0);
   full_screen_popup(tmp.info(true).c_str());
   redraw = true;
   break;
  }
  if (line < 0)
   line = current.size() - 1;
  else if (line >= current.size())
   line = 0;
 } while (ch != KEY_ESCAPE && ch != 'q' && ch != 'Q' && !done);

 werase(w_head);
 werase(w_data);
 delwin(w_head);
 delwin(w_data);
 refresh_all();
}
Exemple #14
0
int main(int argc, char *argv[])
{
	// open the output data stream
	Q3TextStream out(stdout, QIODevice::WriteOnly);

	const char* header =
		"Content-type: text/html; charset=iso-8859-1\n\n"
		"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n"
		"<HTML>\n"
		"  <HEAD>\n"
		"    <TITLE>ShowEQ Item Display</TITLE>\n"
		"    <style type=\"text/css\">\n"
		"      <!--\n"
		"          table { border: black 2px solid }\n"
		"          td { border: black 1px solid }\n"
		"          th { border: black 1px solid }\n"
		"          span.head { color: black }\n"
		"          span.known1 { color: green }\n"
		"          span.known2 { color: blue }\n"
		"          span.varies { color: purple }\n"
		"          span.unknown { color: red }\n"
		"          b.warning { color: red }\n"
		"      -->\n"
		"    </style>\n"
		"  </HEAD>\n"
		"  <BODY>\n";

	/* Print HTML header */
	out << header;

	const char* footer =
		"  </BODY>\n"
		"</HTML>\n";

	// number of item to display
	QString itemNumber;

	// should binary data be displayed (default = false)
	bool displayBinaryData = false;

	// should the icon be displayed
	bool displayIcon = DISPLAY_ICONS;

	// CGI Convenience class
	CGI cgiconv;

	// process any CGI data
	cgiconv.processCGIData();

	// If there are form parameters use them
	if (cgiconv.getParamCount() != 0)
	{
		itemNumber = cgiconv.getParamValue("item");

		if (cgiconv.getParamValue("displayBinary") == "y")
			displayBinaryData = true;
		else if (cgiconv.getParamValue("displayBinary") == "n")
			displayBinaryData = false;

		if (cgiconv.getParamValue("showIcon") == "y")
			displayIcon = true;
		else if (cgiconv.getParamValue("hideIcon") == "y")
			displayIcon = false;
	}
	else if (argc == 2)
	{
		// use argument for item number
		itemNumber = argv[1];

	}
	else if (argc > 2)
	{
		out << "<H1>Error: " << argv[0] << " called with " << argc
			<< " arguments!</H1>\n";
		out << "Format: " << argv[0] << "?<ItemID>\n";
		out << footer;
		exit(-1);
	}

	if (itemNumber.isNull())
		itemNumber = "";

	// check for browser type
	QString userAgent = cgiconv.getHTTPUserAgent();
	out << "    <!-- Output for UserAgent: " << userAgent << "-->\n";

	// beware Netscape4 style sheet brain death
	bool isNetscape4 = false;
	if ((userAgent.contains("Mozilla/4.") == 1) &&
		(userAgent.contains("MSIE") == 0))
		isNetscape4 = true;

	// display form to allow user to select an item or display the binary data
	out << "    <FORM method=\"POST\" action=\"" << cgiconv.getScriptName()
		<< "\">\n";

	if (isNetscape4)
		out << "      <TABLE border cellspacing=0 cellpadding=2>\n";
	else
		out << "      <TABLE cellspacing=0 cellpadding=2>\n";

	out <<
		"        <TR><TH>Item ID:</TH><TH>Binary Data</TH><TH>Icon</TH>"
		"<TD><INPUT type=\"reset\" value=\"Reset\"/></TD></TR>\n"
		"        <TR>\n";

	out << "          <TD><INPUT type=\"text\" name=\"item\" value=\""
		<< itemNumber
		<< "\" size=\"5\"/></TD>\n";

	out <<
		"          <TD>"
		"<INPUT type=\"checkbox\" name=\"displayBinary\" value=\"y\"";

	if (displayBinaryData)
		out << " checked";
	out << "/>Display</TD>\n";

	out <<
		"          <TD>";

	if (displayIcon)
		out << "<INPUT type=\"checkbox\" name=\"hideIcon\" value=\"y\" unchecked>"
		<< "Hide</TD>\n";
	else
		out << "<INPUT type=\"hidden\" name=\"hideIcon\" value=\"y\">"
		<< "<INPUT type=\"checkbox\" name=\"showIcon\" value=\"y\" unchecked>"
		<< "Show</TD>\n";


	// Submission button
	out <<
		"          <TD>"
		"<INPUT type=\"submit\" value=\"Search\"/></TD>\n";

	out << "        </TR>\n";
	out << "      </TABLE>\n";
	out << "    </FORM>\n";


	// if no item number was passed in, then just return
	if (itemNumber.isEmpty())
	{
		// ask the user to enter an ItemID
		out << "<H1>Please Enter an ItemID!</H1>\n";

		// close the document
		out << footer;

		return 0;
	}

	// convert the passed in item number to a short
	uint16_t currentItemNr = itemNumber.toShort();

	EQItemDB* itemDB = new EQItemDB;
	QString nameString;
	QString loreString;
	bool hasEntry = false;
	EQItemDBEntry* entry = NULL;

	hasEntry = itemDB->GetItemData(currentItemNr, &entry);

	out << "<H1>Information on ItemID: " << currentItemNr << "</H1>\n";

	if (hasEntry)
	{
		loreString = entry->GetLoreName();
		nameString = entry->GetName();

		if (displayIcon)
			out << "<P><IMG src=\"" << ICON_DIR << entry->GetIconNr()
			<< ".png\" alt=\"Icon: " << entry->GetIconNr() << "\"/></P>";

		if (!nameString.isEmpty())
		{
			out << "<H2>" << nameString << "</H2>\n";
			out << "<P><B>Lore:</B> " << loreString << "<BR></P>\n";
		}
		else
		{
			out << "<H2>Lore: " << loreString << "</H2>\n";
		}

		out << "<P>\n";
		time_t updated = entry->GetUpdated();
		out << "<B>Last Updated:</B> " << ctime(&updated) << "<BR>\n";
		out << "<B>Icon Number:</B> " << entry->GetIconNr() << "<BR>\n";
		out << "<B>Model:</B> " << entry->GetIdFile() << "<BR>\n";
		out << "<B>ItemType:</B> " << QString::number(entry->GetItemType())
			<< "<BR>\n";
		out << "<B>Weight:</B> " << (int)entry->GetWeight() << "<BR>\n";
		out << "<B>Flags:</B> ";
		if (entry->IsBook())
			out << " BOOK";
		if (entry->IsContainer())
			out << " CONTAINER";
		if (entry->GetNoDrop() == 0)
			out << " NO-DROP";
		if (entry->GetNoRent() == 0)
			out << " NO-RENT";
		if (entry->GetMagic() == 1)
			out << " MAGIC";
		if (entry->GetLoreFlag())
			out << " LORE";
		else if (entry->GetSummonedFlag())
			out << " SUMMONED";
		else if (entry->GetArtifactFlag())
			out << " ARTIFACT";
		else if (entry->GetPendingLoreFlag())
			out << " PENDING-LORE";

		out << "<BR>\n";
		out << "<B>Size:</B> " << size_name(entry->GetSize()) << "<BR>\n";
		out << "<B>Slots:</B> " << print_slot(entry->GetSlots()) << "<BR>\n";
		out << "<B>Base Price:</B> " << reformatMoney(entry->GetCost())
			<< "<BR>\n";
		if (entry->GetSTR())
			out << "<B>Str:</B> " << (int)entry->GetSTR() << "<BR>\n";
		if (entry->GetSTA())
			out << "<B>Sta:</B> " << (int)entry->GetSTA() << "<BR>\n";
		if (entry->GetCHA())
			out << "<B>Cha:</B> " << (int)entry->GetCHA() << "<BR>\n";
		if (entry->GetDEX())
			out << "<B>Dex:</B> " << (int)entry->GetDEX() << "<BR>\n";
		if (entry->GetINT())
			out << "<B>Int:</B> " << (int)entry->GetINT() << "<BR>\n";
		if (entry->GetAGI())
			out << "<B>Agi:</B> " << (int)entry->GetAGI() << "<BR>\n";
		if (entry->GetWIS())
			out << "<B>Wis:</B> " << (int)entry->GetWIS() << "<BR>\n";
		if (entry->GetMR())
			out << "<B>Magic:</B> " << (int)entry->GetMR() << "<BR>\n";
		if (entry->GetFR())
			out << "<B>Fire:</B> " << (int)entry->GetFR() << "<BR>\n";
		if (entry->GetCR())
			out << "<B>Cold:</B> " << (int)entry->GetCR() << "<BR>\n";
		if (entry->GetDR())
			out << "<B>Disease:</B> " << (int)entry->GetDR() << "<BR>\n";
		if (entry->GetPR())
			out << "<B>Poison:</B> " << (int)entry->GetPR() << "<BR>\n";
		if (entry->GetHP())
			out << "<B>HP:</B> " << (int)entry->GetHP() << "<BR>\n";
		if (entry->GetMana())
			out << "<B>Mana:</B> " << (int)entry->GetMana() << "<BR>\n";
		if (entry->GetAC())
			out << "<B>AC:</B> " << (int)entry->GetAC() << "<BR>\n";
		if (entry->GetLight())
			out << "<B>Light:</B> " << (int)entry->GetLight() << "<BR>\n";
		if (entry->GetDelay())
			out << "<B>Delay:</B> " << (int)entry->GetDelay() << "<BR>\n";

		if (entry->GetDamage())
		{
			out << "<B>Damage:</B> " << (int)entry->GetDamage() << "<BR>\n";
			QString qsTemp = print_skill (entry->GetSkill());
			out << "<B>Skill:</B> ";

			if (qsTemp.find("U0x") == -1)
				out << qsTemp << "<BR>\n";
			else
				out << "Unknown (ID: " << qsTemp << ")<BR>\n";
		}

		if (entry->GetRange())
			out << "<B>Range:</B> " << (int)entry->GetRange() << "<BR>\n";

		if (entry->GetMaterial())
		{
			out << "<B>Material:</B> " << QString::number(entry->GetMaterial(), 16)
				<< " (" << print_material (entry->GetMaterial()) << ")<BR>\n";

			out << "<B>Color:</B> " << QString::number(entry->GetColor(), 16) << "<BR>\n";

			out << ((entry->GetColor())  ?
				(QString("<TABLE><TR><TD bgcolor=\"#%1\">").arg(entry->GetColor(), 6, 16)) :
			("<TABLE><TR><TD bgcolor=\"#ffffff\">"))
				<< "&nbsp;&nbsp;###&nbsp;SAMPLE&nbsp;###&nbsp;&nbsp</TD></TR></TABLE>\n";
		}
		else
			out << "<B>Material:</B> 0 (None)<BR>\n";

		if (entry->GetStackable() != -1)
			out << "<B>Stackable:</B> "
			<< ((entry->GetStackable() == 1) ? "yes" : "no?") << "<BR>\n";

		if (entry->GetEffectType() != -1)
			out << "<B>Effect Type:</B> "
			<< entry->GetEffectTypeString() << "<BR>\n";
		if (entry->GetSpellId() != ITEM_SPELLID_NOSPELL)
		{
			out << "<B>Spell Effect:</B> " << spell_name (entry->GetSpellId())
				<< "<BR>\n";
			if (entry->GetLevel())
				out << "<B>Casting Level:</B> " << (int)entry->GetLevel() << "<BR>\n";
			if (entry->GetCharges())
			{
				out << "<B>Charges:</B> ";

				if (entry->GetCharges() == -1)
					out << "Unlimited<BR>\n";
				else
					out << (int)entry->GetCharges() << "<BR>\n";
			}
			if (entry->GetCastTime())
				out << "<B>Casting Time:</B> " << (int)entry->GetCastTime()
				<< "<BR>\n";
		}
		out << "<B>Class:</B> " << print_classes (entry->GetClasses()) << "<BR>\n";
		out << "<B>Race:</B> " << print_races (entry->GetRaces()) << "<BR>\n";
		if (entry->GetSkillModId())
			out << "<B>Skill Modifier:</B> " << skill_name(entry->GetSkillModId())
			<< " " << (int)entry->GetSkillModPercent() << "% <BR>\n";
		if (entry->IsContainer())
		{
			if (entry->GetNumSlots())
				out << "<B>Container Slots:</B> " << (int)entry->GetNumSlots()
				<< "<BR>\n";
			if (entry->GetSizeCapacity())
				out << "<B>Size Capacity:</B> " << size_name(entry->GetSizeCapacity())
				<< "<BR>\n";
			if (entry->GetWeightReduction())
				out << "<B>% Weight Reduction:</B> " << (int)entry->GetWeightReduction()
				<< "<BR>\n";
		}
		out << "</P>\n";
	}

	int size = 0;

	if (displayBinaryData)
	{
		time_t updated;
		char* rawData = NULL;
		size = itemDB->GetItemRawData(currentItemNr, updated, &rawData);

		if ((size > 0) && (rawData != NULL))
		{
			out << "<P><B>Raw data: (" << size << " octets) last updated: "
				<< ctime(&updated) << "</B></P>\n";
			out << "</P>";
			out << "<PRE>\n";
			printdata (out, size, rawData);
			out << "</PRE>\n";
			delete [] rawData;
		}
	}

	if (!hasEntry && nameString.isEmpty() && loreString.isEmpty() &&
		(size == 0))
		out << "<P>Item " << currentItemNr << " not found</P>\n";

	// close the document with the footer
	out << footer;

	// delete DB entry
	delete entry;

	// shutdown the ItemDB instance
	itemDB->Shutdown();

	// delete the ItemDB instance
	delete itemDB;

	return 0;
}
Exemple #15
0
void perform_obj_type_list(struct char_data * ch, char *arg)
{
  int num, itemtype, v1, v2, found = 0, len = 0, tmp_len = 0;
  obj_vnum ov;
  obj_rnum r_num;
  char buf[MAX_STRING_LENGTH];

  itemtype = atoi(arg);

  len = snprintf(buf, sizeof(buf), "Listing all objects of type %s[%s]%s\r\n",
       QYEL, item_types[itemtype], QNRM);

  for(num=0;num<=top_of_objt;num++) {
    if(obj_proto[num].obj_flags.type_flag == itemtype) {
      if ((r_num = real_object(obj_index[num].vnum)) != NOTHING) { /* Seems silly? */
        /* Set default vals, which may be changed below */
        ov = obj_index[num].vnum;
        v1 = (obj_proto[num].obj_flags.value[0]);

        switch (itemtype) {
          case ITEM_LIGHT:
            v1 = (obj_proto[num].obj_flags.value[2]);
            if (v1 == -1)
              tmp_len = snprintf(buf+len, sizeof(buf)-len, "%s%3d%s) %s[%s%5d%s]%s INFINITE%s %s%s\r\n",
                   QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QBRED, QCYN, obj_proto[r_num].short_description, QNRM);
            else
              tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%5d%s]%s (%-3dhrs) %s%s%s\r\n",
                   QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
            break;

          case ITEM_SCROLL:
          case ITEM_POTION:
            tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %s%s\r\n",
                 QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, obj_proto[r_num].short_description, QNRM);
            break;

          case ITEM_WAND:
          case ITEM_STAFF:
            v1 = (obj_proto[num].obj_flags.value[1]);
            v2 = (obj_proto[num].obj_flags.value[3]);
            tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dx%s) %s%s%s\r\n",
                 QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, skill_name(v2), QCYN, obj_proto[r_num].short_description, QNRM);
            break;

          case ITEM_WEAPON:
            v1 = ((obj_proto[num].obj_flags.value[2]+1)*(obj_proto[r_num].obj_flags.value[1])) / 2;
            tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%d Avg Dam) %s%s%s\r\n",
                 QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
            break;

          case ITEM_ARMOR:
            tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dAC) %s%s%s\r\n",
                 QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
            break;

          case ITEM_CONTAINER:
            tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (Max: %d) %s%s%s\r\n",
                 QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
            break;

          case ITEM_DRINKCON:
          case ITEM_FOUNTAIN:
            if (v1 != -1)
              tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (Max: %d) %s%s%s\r\n",
                   QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
            else
              tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %sINFINITE%s %s%s\r\n",
                   QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QBRED, QCYN, obj_proto[r_num].short_description, QNRM);
            break;

          case ITEM_FOOD:
            v2 = (obj_proto[num].obj_flags.value[3]);
            if (v2 != 0)
              tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dhrs) %s%s %sPoisoned!%s\r\n",
                   QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QBGRN, QNRM);
            else
              tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dhrs) %s%s%s\r\n",
                   QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
            break;

          case ITEM_MONEY:
            tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %s%s (%s%d coins%s)\r\n",
                 QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, obj_proto[r_num].short_description, QNRM, QYEL, v1, QNRM);
            break;

          /* The 'normal' items - don't provide extra info */
          case ITEM_TREASURE:
          case ITEM_TRASH:
          case ITEM_OTHER:
          case ITEM_WORN:
          case ITEM_NOTE:
          case ITEM_PEN:
          case ITEM_BOAT:
          case ITEM_KEY:
            tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %s%s\r\n",
                 QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, obj_proto[r_num].short_description, QNRM);
            break;

          default:
            send_to_char(ch, "Not a valid item type");
            return;
        }
        if (len + tmp_len < sizeof(buf) - 1)
          len += tmp_len;
        else {
		  buf[sizeof(buf) -1] = '\0';
		  break;	
		}
      }
    }
  }
  page_string(ch->desc, buf, TRUE);
}
Exemple #16
0
void do_obj_report (struct char_data *ch)
{
	struct obj_data *obj, *key;
	int i=0, j=0, found=0;

	FILE *reportfile; 

	if (!(reportfile = fopen("report.obj", "w"))) {
		mlog("SYSERR:  Object report file unavailable.");
		send_to_char ("Report.obj could not be generated.\r\n",ch);
		return;
	}
	sprintf(buf, "OBJECTS\n-------\n");
	for (i=0; i<top_of_objt;i++) {
		obj=read_object(i, REAL);
		sprintf(buf+strlen(buf), "[%5d] %s\nSpec Proc: ",
		GET_OBJ_VNUM(obj), obj->short_description);

		if (obj_index[GET_OBJ_RNUM(obj)].func!=NULL)
			get_spec_name(GET_OBJ_RNUM(obj), buf2,'o');
		else sprintf(buf2, "none");

		sprintf(buf+strlen(buf), "%s  Aliases:  %s\n", buf2, GET_OBJ_NAME(obj));

		sprinttype(GET_OBJ_TYPE(obj), item_types, buf2, sizeof(buf2));
		sprintf (buf+strlen(buf),"Type:  %s    Worn on: ",buf2); 
		sprintbit(obj->obj_flags.wear_flags, wear_bits, buf2, sizeof(buf2));
		sprintf(buf+strlen(buf), "%s\n", buf2); 

		sprintf(buf+strlen(buf), "Weight: %d, Value: %d, Cost/day: %d, Timer: %d\n",
		GET_OBJ_WEIGHT(obj), GET_OBJ_COST(obj), GET_OBJ_RENT(obj), GET_OBJ_TIMER(obj));

		sprintbit(obj->obj_flags.bitvector, affected_bits, buf2, sizeof(buf2));
		sprintf(buf+strlen(buf), "Affects player: %s\n",buf2);

		sprintbit(obj->obj_flags.bitvector, affected_bits, buf2, sizeof(buf2));
		sprintf(buf+strlen(buf), "Extra bits:  %s\n",buf2); 


		switch (GET_OBJ_TYPE(obj)) {
		case ITEM_LIGHT:
			if (GET_OBJ_VAL(obj, 2) == -1) strcpy(buf, "Hours left: Infinite\n");
			else sprintf(buf+strlen(buf), "Hours left: [%d]\n", GET_OBJ_VAL(obj, 2));
			break;
		case ITEM_SCROLL:
		case ITEM_POTION:
			sprintf(buf+strlen(buf), "Spells: (Level %d) %s, %s, %s\n", GET_OBJ_VAL(obj, 0),
			skill_name(GET_OBJ_VAL(obj, 1)), skill_name(GET_OBJ_VAL(obj, 2)),
			skill_name(GET_OBJ_VAL(obj, 3)));
			break;
		case ITEM_WAND:
		case ITEM_STAFF:
			sprintf(buf+strlen(buf), "Spell: %s at level %d, %d (of %d) charges remaining\n",
			skill_name(GET_OBJ_VAL(obj, 3)), GET_OBJ_VAL(obj, 0),
			GET_OBJ_VAL(obj, 2), GET_OBJ_VAL(obj, 1));
			break;
		case ITEM_WEAPON:
			sprintf(buf+strlen(buf), "Ave. Dam: %d, Message type: %d\n",
			get_weapon_dam(obj), GET_OBJ_VAL(obj, 3));
			break;
		case ITEM_ARMOR:
			sprintf(buf+strlen(buf), "Passive Defense: [%d]\n", GET_OBJ_VAL(obj, 0));
			sprintf(buf+strlen(buf), "Damage Reduction: [%d]\n", GET_OBJ_VAL(obj, 1));
			break;
		case ITEM_TRAP:
			sprintf(buf+strlen(buf), "Spell: %d, - Hitpoints: %d\n",
			GET_OBJ_VAL(obj, 0), GET_OBJ_VAL(obj, 1));
			break;
		case ITEM_CONTAINER:
			sprintbit(GET_OBJ_VAL(obj, 1), container_bits, buf2, sizeof(buf2));
			sprintf(buf+strlen(buf), "Weight capacity: %d, Lock Type: %s, Key Num: %d ",
			GET_OBJ_VAL(obj, 0), buf2, GET_OBJ_VAL(obj, 2)); 
			if (GET_OBJ_VAL(obj, 2) > 0) {
				key=read_object(GET_OBJ_VAL(obj,2), VIRTUAL);
				if (key) {
					sprintf(buf+strlen(buf), "(%s)", GET_OBJ_NAME(key));
					extract_obj(key); 
				}
				else
					sprintf(buf+strlen(buf), "(Error: Key does not exist!)");
			}
			sprintf(buf+strlen(buf), "\n");
			break;
		case ITEM_DRINKCON:
		case ITEM_FOUNTAIN:
			sprinttype(GET_OBJ_VAL(obj, 2), drinks, buf2, sizeof(buf2));
			sprintf(buf+strlen(buf), "Capacity: %d, Contains: %d, Poisoned: %s, Liquid: %s\n",
			GET_OBJ_VAL(obj, 0), GET_OBJ_VAL(obj, 1), YESNO(GET_OBJ_VAL(obj, 3)),buf2);
			break; 
		case ITEM_FOOD:
			sprintf(buf+strlen(buf), "Makes full: %d, Poisoned: %s\n", 
			GET_OBJ_VAL(obj, 0),YESNO(GET_OBJ_VAL(obj, 3)));
			break;
		case ITEM_MONEY:
			sprintf(buf, "Coins: %d\n", GET_OBJ_VAL(obj, 0));
			break;
		case ITEM_PORTAL:
			sprintf(buf, "To room: %d\n", GET_OBJ_VAL(obj, 0));
			break;
		default:
			sprintf(buf+strlen(buf), "Values 0-3: [%d] [%d] [%d] [%d]\n",
			GET_OBJ_VAL(obj, 0), GET_OBJ_VAL(obj, 1),
			GET_OBJ_VAL(obj, 2), GET_OBJ_VAL(obj, 3));
			break;
		}

		found = 0;
		sprintf(buf+strlen(buf), "Affects on player stats:\n");
		for (j = 0; j < MAX_OBJ_AFFECT; j++)
			if (obj->affected[j].modifier) {
				sprinttype(obj->affected[j].location, apply_types, buf2, sizeof(buf2));
				sprintf(buf+strlen(buf), "    %+d to %s\n",obj->affected[j].modifier, buf2); 
				found=1;
			}
		if (!found)
			sprintf(buf+strlen(buf),"    None\n"); 
		sprintf(buf+strlen(buf), "\n--------\n");
		extract_obj(obj);
		fprintf(reportfile, buf);
		buf[0]='\0';
	}/*for i=0...*/
	fclose (reportfile);
	send_to_char ("report.obj printed\r\n",ch);
}
Exemple #17
0
void CombatWindow::updateOffense()
{
#ifdef DEBUGCOMBAT
	seqDebug("CombatWindow::updateOffense starting...");
#endif

	QString s_totaldamage;
	QString s_percentspecial;
	QString s_percentnonmelee;
	QString s_avgmelee;
	QString s_avgspecial;
	QString s_avgnonmelee;

	int iTotalDamage = 0;
	int iTotalHits = 0;
	double dPercentSpecial = 0.0;
	double dPercentNonmelee = 0.0;
	double dAvgMelee = 0.0;
	double dAvgSpecial = 0.0;
	double dAvgNonmelee = 0.0;

	int iMeleeDamage = 0;
	int iMeleeHits = 0;
	int iSpecialDamage = 0;
	int iSpecialHits = 0;
	int iNonmeleeDamage = 0;
	int iNonmeleeHits = 0;

	//	empty the list so we can repopulate
	m_offenseListView->clear();

	CombatOffenseRecord *pRecord;

	for (pRecord = m_combat_offense_list.first(); pRecord != 0; pRecord = m_combat_offense_list.next())
	{
		int iType = pRecord->getType();
		int iSpell = pRecord->getSpell();
		int iHits = pRecord->getHits();
		int iMisses = pRecord->getMisses();
		int iMinDamage = pRecord->getMinDamage();
		int iMaxDamage = pRecord->getMaxDamage();
		int iDamage = pRecord->getTotalDamage();

		double dAvgDamage, dRatio;

		if (iHits != 0)
			dAvgDamage = (double)iDamage / (double)iHits;
		else
			dAvgDamage = 0.0;

		if (iMisses != 0)
			dRatio = (double)iHits / (double)iMisses;
		else
			dRatio = 0.0;

		QString s_type;
		// Belith -- Damage shields are strange!
		switch (iType)
		{
			case 0:		// 1H Blunt
			case 1:		// 1H Slashing
			case 2:		// 2H Blunt
			case 3:		// 2H Slashing
			case 28:	// Hand To Hand
			case 36:	// Piercing
			case 7:		// Archery
			case 8:		// Backstab
			case 10:	// Bash
			case 21:	// Dragon Punch
			case 23:	// Eagle Strike
			case 26:	// Flying Kick
			case 30:	// Kick
			case 38:	// Round Kick
			case 51:	// Throwing
			case 52:	// Tiger Claw
				// this is a normal skill
				s_type.sprintf("%s(%d)", (const char*)skill_name(iType), iType);
				break;

			case 231:       // Non Melee Damage
				s_type.sprintf("Spell: %s(%d)", (const char*)spell_name(iSpell), iSpell);
				break;

			default:    // Damage Shield?
				// 245 Mark of Retribution
				// 248 Flameshield of Ro? (45pt) (mage)
				// -11 Killing Blow with MoR
				// -8  Killing Blow with Ro? (45pt) (mage)
				s_type.sprintf("Damage Shield: (%d)", iType);
				break;
		}

		QString s_hits;
		s_hits.setNum(iHits);
		QString s_misses;
		s_misses.setNum(iMisses);
		QString s_ratio;
		s_ratio = QString("%1 to 1").arg(dRatio);
		QString s_avgdamage;
		s_avgdamage.setNum(dAvgDamage);
		QString s_mindamage;
		s_mindamage.setNum(iMinDamage);
		QString s_maxdamage;
		s_maxdamage.setNum(iMaxDamage);
		QString s_damage;
		s_damage.setNum(iDamage);

		Q3ListViewItem *pItem = new Q3ListViewItem(m_offenseListView,
				s_type, s_hits, s_misses, s_ratio, s_avgdamage, s_mindamage,
				s_maxdamage, s_damage);
		m_offenseListView->insertItem(pItem);

		switch (iType)
		{
			case 0:		// 1H Blunt
			case 1:		// 1H Slashing
			case 2:		// 2H Blunt
			case 3:		// 2H Slashing
			case 28:	// Hand To Hand
			case 36:	// Piercing
				iMeleeDamage += iDamage;
				iMeleeHits += iHits;
				break;

			case 7:		// Archery
			case 8:		// Backstab
			case 10:	// Bash
			case 21:	// Dragon Punch
			case 23:	// Eagle Strike
			case 26:	// Flying Kick
			case 30:	// Kick
			case 38:	// Round Kick
			case 51:	// Throwing
			case 52:	// Tiger Claw
				iSpecialDamage += iDamage;
				iSpecialHits += iHits;
				break;

			default:
				iNonmeleeDamage += iDamage;
				iNonmeleeHits += iHits;
				break;
		}
	}

	iTotalDamage = iMeleeDamage + iSpecialDamage + iNonmeleeDamage;
	iTotalHits = iMeleeHits + iSpecialHits + iNonmeleeHits;

	if (iTotalDamage != 0)
	{
		dPercentSpecial = ((double)iSpecialDamage / (double)iTotalDamage) * 100.0;
		dPercentNonmelee = ((double)iNonmeleeDamage / (double)iTotalDamage) * 100.0;
	}
	else
	{
		dPercentSpecial = 0.0;
		dPercentNonmelee = 0.0;
	}

	if (iMeleeHits != 0)
		dAvgMelee = (double)iMeleeDamage / (double)iMeleeHits;
	else
		dAvgMelee = 0.0;

	if (iSpecialHits != 0)
		dAvgSpecial = (double)iSpecialDamage / (double)iSpecialHits;
	else
		dAvgSpecial = 0.0;

	if (iNonmeleeHits != 0)
		dAvgNonmelee = (double)iNonmeleeDamage / (double)iNonmeleeHits;
	else
		dAvgNonmelee = 0.0;

	s_totaldamage.setNum(iTotalDamage);
	s_percentspecial.setNum(dPercentSpecial);
	s_percentnonmelee.setNum(dPercentNonmelee);
	s_avgmelee.setNum(dAvgMelee);
	s_avgspecial.setNum(dAvgSpecial);
	s_avgnonmelee.setNum(dAvgNonmelee);

	m_offenseTotalDamage->setText(s_totaldamage);
	m_offensePercentSpecial->setText(s_percentspecial);
	m_offensePercentNonMelee->setText(s_percentnonmelee);
	m_offenseAvgMelee->setText(s_avgmelee);
	m_offenseAvgSpecial->setText(s_avgspecial);
	m_offenseAvgNonMelee->setText(s_avgnonmelee);


#ifdef DEBUGCOMBAT
	seqDebug("CombatWindow::updateOffense finished...");
#endif

}
Exemple #18
0
/* say_spell erodes buf, buf1, buf2 */
void
say_spell (struct char_data *ch, int spellnum, struct char_data *tch,
		   struct obj_data *tobj)
{
	char lbuf[256];
	const char *format;

	struct char_data *i;
	int j, ofs = 0;

	*buf = '\0';
	strcpy (lbuf, skill_name (spellnum));

	while (lbuf[ofs])
	{
		for (j = 0; *(syls[j].org); j++)
		{
			if (!strncmp (syls[j].org, lbuf + ofs, strlen (syls[j].org)))
			{
				strcat (buf, syls[j].news);
				ofs += strlen (syls[j].org);
				break;
			}
		}
		/* i.e., we didn't find a match in syls[] */
		if (!*syls[j].org)
		{
			log ("No entry in syllable table for substring of '%s'", lbuf);
			ofs++;
		}
	}

	if (tch != NULL && IN_ROOM (tch) == IN_ROOM (ch))
	{
		if (tch == ch)
		{
			if (IS_PSIONIC (ch) && (GET_LEVEL (ch) != LVL_IMPL))
			{
				format =
					"$n congiunge le mani sulla testa e chiude i suoi occhi.";
			}
			else
			{
				format =
					"$n chiude i suoi occhi e lancia sul suo tricorder il processo, '%s'.";
			}
		}
		else
		{
			if (IS_PSIONIC (ch) && (GET_LEVEL (ch) != LVL_IMPL))
			{
				format =
					"$n posa una mano sulla testa e punta l'altra su $N e chiude gli occhi.";
			}
			else
			{
				format =
					"$n punta il suo tricorder a $N e lancia  il processo, '%s'.";
			}
		}
	}
	else if (tobj != NULL &&
			 ((IN_ROOM (tobj) == IN_ROOM (ch)) || (tobj->carried_by == ch)))
	{
		if (IS_PSIONIC (ch) && (GET_LEVEL (ch) != LVL_IMPL))
		{
			format = "$n congiunge le mani su $p e chiude i suoi occhi.";
		}
		else
		{
			format =
				"$n punta il suo tricorder a $p e lancia il processo, '%s'.";
		}
	}
	else
	{
		if (IS_PSIONIC (ch) && (GET_LEVEL (ch) != LVL_IMPL))
		{
			format =
				"$n congiunge le mani sulla testa e chiude i suoi occhi.";
		}
		else
		{
			format = "$n lancia sul suo tricorder il processo, '%s'.";
		}
	}

	sprintf (buf1, format, skill_name (spellnum));
	sprintf (buf2, format, buf);

	for (i = world[IN_ROOM (ch)].people; i; i = i->next_in_room)
	{
		if (i == ch || i == tch || !i->desc || !AWAKE (i))
			continue;
		if (GET_CLASS (ch) == GET_CLASS (i))
			perform_act (buf1, ch, tobj, tch, i);
		else
			perform_act (buf2, ch, tobj, tch, i);
	}

	if (tch != NULL && tch != ch && IN_ROOM (tch) == IN_ROOM (ch))
	{
		if (IS_PSIONIC (ch) && (GET_LEVEL (ch) != LVL_IMPL))
		{
			sprintf (buf1,
					 "$n posa una mano sulla testa e punta l'altra su di te.");
		}
		else
		{
			sprintf (buf1,
					 "$n ti punta il suo tricorder e lancia il processo, '%s'.",
					 GET_CLASS (ch) ==
					 GET_CLASS (tch) ? skill_name (spellnum) : buf);
		}
		act (buf1, FALSE, ch, NULL, tch, TO_VICT);
	}
}
Exemple #19
0
/*
 * Write the char to the file.
 *
 * @param ch the character to be written
 * @param fp the file to write to
 */
void fwrite_char( struct char_data *ch, FILE *fp )
{
  extern struct race_data * races;
  
  struct affected_type *paf;
  int          sn, i;
  
  fprintf( fp, "#%s\n", IS_NPC( ch ) ? "MOB" : "PLAYER"		);
  
  fprintf( fp, "Name        %s~\n",	GET_NAME(ch)			);
  fprintf( fp, "ShtDsc      %s~\n",	GET_SHORT_DESC(ch) ?
	   GET_SHORT_DESC(ch) : "" );
  fprintf( fp, "LngDsc      %s~\n",	GET_LONG_DESC(ch) ?
	   GET_LONG_DESC(ch) : "" );
  fprintf( fp, "Dscr        %s~\n",	GET_DESCRIPTION(ch) ?
	   GET_DESCRIPTION(ch) : "" );
  // fprintf( fp, "Prmpt       %s~\n",	ch->pcdata->prompt	);
  fprintf( fp, "Sx          %d\n",	GET_SEX(ch)			);
  fprintf( fp, "Race        %s~\n",	races[ (int)GET_RACE(ch) ].name );
  fprintf( fp, "Lvl         %d\n",	GET_LEVEL(ch)			);
  fprintf( fp, "Trst        %d\n",	GET_TRUST(ch)			);
  /*
    fprintf( fp, "Playd       %ld\n",
    GET_PLAYED(ch) + (int)( time( 0 ) - GET_LOGON(ch) )		);
  */
  // fprintf( fp, "Note        %ld\n",   (unsigned long)ch->last_note );
  fprintf( fp, "Room        %ld\n",
	   (  ch->in_room == NOWHERE && ch->was_in_room )
	   ? ch->was_in_room : ch->in_room );
  
  fprintf( fp, "HpMnMv      %d %d %d %d %d %d\n",
	   GET_HIT(ch), GET_MAX_HIT(ch),
	   GET_MANA(ch), GET_MAX_MANA(ch),
	   GET_MOVE(ch), GET_MAX_MOVE(ch) );
  fprintf( fp, "Gold        %ld\n",	GET_GOLD(ch)		);
  fprintf( fp, "Exp         %ld\n",	GET_EXP(ch)		);
  fprintf( fp, "Act         %lld\n",  PLR_FLAGS(ch)           );
  fprintf( fp, "Act2        %lld\n",  PLR2_FLAGS(ch)          );
  fprintf( fp, "Pref        %lld\n",  PRF_FLAGS(ch)		);
  fprintf( fp, "Pref2       %lld\n",  PRF2_FLAGS(ch)		);
  fprintf( fp, "AffdBy      %lld\n",	AFF_FLAGS(ch)		);
  fprintf( fp, "AffdBy2     %lld\n",	AFF2_FLAGS(ch)		);
  /* Bug fix from Alander */
  fprintf( fp, "Pos         %d\n",
	   GET_POS(ch) == POS_FIGHTING ? POS_STANDING : GET_POS(ch) );
  fprintf( fp, "Prac        %d\n",    GET_PRACTICES(ch)       );
  fprintf( fp, "PAlign      %d\n",	GET_PERMALIGN(ch)	);
  fprintf( fp, "CAlign      %d\n",	GET_ALIGNMENT(ch)	);
  fprintf( fp, "SavThr      " );
  for ( i = 0; i < NUM_SAVES; i++ )
    fprintf( fp, "%d%s",    GET_SAVE(ch, i), (i != NUM_SAVES-1 ? ", " : "\n")	);
  fprintf( fp, "Hitroll     %d\n",	GET_HITROLL(ch)		);
  fprintf( fp, "Damroll     %d\n",	GET_DAMROLL(ch)		);
  fprintf( fp, "Armr        " );
  for ( i = 0; i < ARMOR_LIMIT; i++ )
    fprintf( fp, "%d%s",   GET_AC(ch, i), (i != ARMOR_LIMIT-1 ? ", " : "\n") );
  fprintf( fp, "Wimp        %d\n",	GET_WIMP_LEV(ch)	);
  
  if ( IS_NPC( ch ) ) {
    fprintf( fp, "Vnum        %ld\n",	GET_MOB_VNUM(ch)	);
  } else {
    fprintf( fp, "Paswd       %s~\n",	GET_PASSWD(ch)		);
    fprintf( fp, "Poofin      %s~\n",	POOFIN(ch) ?
	     POOFIN(ch) : "" );
    fprintf( fp, "Poofout     %s~\n",	POOFOUT(ch) ?
	     POOFOUT(ch) : "" );
    fprintf( fp, "Ttle        %s~\n",	GET_TITLE(ch) ?
	     GET_TITLE(ch) : "" );
    fprintf( fp, "AtrPrm      %d/%d %d %d %d %d %d %d\n",
	     ch->real_abils.str,
	     ch->real_abils.str_add,
	     ch->real_abils.intel,
	     ch->real_abils.wis,
	     ch->real_abils.dex,
	     ch->real_abils.con,
	     ch->real_abils.cha,
	     ch->real_abils.will );
    
    fprintf( fp, "AtrMd       %d/%d %d %d %d %d %d %d\n",
	     ch->aff_abils.str, 
	     ch->aff_abils.str_add, 
	     ch->aff_abils.intel, 
	     ch->aff_abils.wis, 
	     ch->aff_abils.dex, 
	     ch->aff_abils.con, 
	     ch->aff_abils.cha, 
	     ch->aff_abils.will );
    
    fprintf( fp, "Conditions  " );
    for ( i = 0; i < MAX_COND; i++ )
      fprintf( fp, "%d%s", GET_COND(ch, i), (i != MAX_COND-1 ? ", " : "\n") );
    
    fprintf( fp, "Addictions  " );
    for ( i = 0; i < MAX_COND; i++ )
      fprintf( fp, "%d%s", GET_ADDICT(ch, i), (i != MAX_COND-1 ? ", " : "\n") );
    
    for ( sn = 0; sn < MAX_SKILLS; sn++ ) {
      if ( skill_name( sn ) &&
           strcmp( skill_name( sn ), "!UNUSED!" ) &&
           GET_SKILL(ch, sn) > 0 ) {
	fprintf( fp, "Skill       %d '%s'\n",
		 GET_SKILL(ch, sn),
		 skill_name( sn ) );
      }
    }
  }
  
  for ( paf = ch->affected; paf; paf = paf->next )  {
    fprintf( fp, "Afft       %18s~ %3d %3d %3d %lld\n",
	     skill_name( paf->type ),
	     paf->duration,
	     paf->modifier,
	     paf->location,
	     paf->bitvector );
  }
  
  for ( paf = ch->affected2; paf; paf = paf->next )  {
    fprintf( fp, "Afft2       %18s~ %3d %3d %3d %lld\n",
	     skill_name( paf->type ),
	     paf->duration,
	     paf->modifier,
	     paf->location,
	     paf->bitvector );
  }
  
  fprintf( fp, "End\n\n" );
  return;
}
Exemple #20
0
/*
 * Write an object and its contents.
 */
void fwrite_obj( struct obj_data *obj, FILE *fp, int iNest )
{
  // struct affected_type    * paf = NULL;
  struct extra_descr_data  * ed  = NULL;
  int i;

  /*
   * Slick recursion to write lists backwards,
   *   so loading them will load in forwards order.
   */
  if ( obj->next_content )
    fwrite_obj( obj->next_content, fp, iNest );
  
  /*
   * Castrate storage characters.
   */
  if ( obj->obj_flags.type_flag == ITEM_KEY )
    return;
  
  fprintf( fp, "#OBJECT\n" );
  fprintf( fp, "Nest         %d\n",	iNest			     );
  fprintf( fp, "Name         %s~\n",	obj->name		     );
  fprintf( fp, "ShortDescr   %s~\n",	obj->short_description	     );
  fprintf( fp, "Description  %s~\n",	obj->description	     );
  fprintf( fp, "ActionDescr  %s~\n",
	   obj->action_description ? obj->action_description : ""  );
  fprintf( fp, "Vnum         %ld\n",	obj->item_number	     );
  fprintf( fp, "ExtraFlags   %ld\n",	obj->obj_flags.extra_flags   );
  fprintf( fp, "WearFlags    %d\n",	obj->obj_flags.wear_flags    );
  fprintf( fp, "ItemType     %d\n",	obj->obj_flags.type_flag     );
  fprintf( fp, "Weight       %d\n",	obj->obj_flags.weight	     );
  fprintf( fp, "Timer        %d\n",	obj->obj_flags.timer	     );
  fprintf( fp, "Cost         %d\n",	obj->obj_flags.cost	     );
  fprintf( fp, "Values       %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n",
	   obj->obj_flags.value[0], obj->obj_flags.value[1],
	   obj->obj_flags.value[2], obj->obj_flags.value[3],
	   obj->obj_flags.value[4], obj->obj_flags.value[5],
	   obj->obj_flags.value[6], obj->obj_flags.value[7],
	   obj->obj_flags.value[8], obj->obj_flags.value[9] );
  
  switch ( obj->obj_flags.type_flag ) {
  case ITEM_POTION:
  case ITEM_SCROLL:
    if ( obj->obj_flags.value[1] > 0 ) {
      fprintf( fp, "Spell 1      '%s'\n", 
	       skill_name( obj->obj_flags.value[1] ) );
    }
    
    if ( obj->obj_flags.value[2] > 0 ) {
      fprintf( fp, "Spell 2      '%s'\n", 
	       skill_name( obj->obj_flags.value[2] ) );
    }
    
    if ( obj->obj_flags.value[3] > 0 ) {
      fprintf( fp, "Spell 3      '%s'\n", 
	       skill_name( obj->obj_flags.value[3] ) );
    }
    break;
    
  case ITEM_STAFF:
  case ITEM_WAND:
    if ( obj->obj_flags.value[3] > 0 ) {
      fprintf( fp, "Spell 3      '%s'\n", 
	       skill_name( obj->obj_flags.value[3] ) );
    }
    break;
    
  default:
    /* ERROR */
    break;
  }

  for ( i = 0; i < MAX_OBJ_AFFECT; i++ )
    fprintf( fp, "Affect       %d %d\n",
	     obj->affected[ i ].location,
	     obj->affected[ i ].modifier );
  /*
  paf = obj->affected;
  for ( paf = obj->affected; paf; paf = paf->next ) {
    fprintf( fp, "Affect       %d %d %d %d %ld\n",
	     paf->type, paf->duration,
	     paf->modifier, paf->location,
	     paf->bitvector );
  }
  */
  
  for ( ed = obj->ex_description; ed; ed = ed->next ) {
    fprintf( fp, "ExtraDescr   %s~ %s~\n",
	     ed->keyword, ed->description );
  }
  
  fprintf( fp, "End\n\n" );

  if ( obj->contains )
    fwrite_obj( obj->contains, fp, iNest + 1 );
  
  tail_chain( );
  return;
}
Exemple #21
0
std::string item::info(bool showtext)
{
 std::stringstream dump;
 if( !is_null() )
 {
  dump << " Volume: " << volume() << "    Weight: " << weight() << "\n" <<
          " Bash: " << int(type->melee_dam) <<
          (has_flag(IF_SPEAR) ? "  Pierce: " : "  Cut: ") <<
          int(type->melee_cut) << "  To-hit bonus: " <<
          (type->m_to_hit > 0 ? "+" : "" ) << int(type->m_to_hit) << "\n" <<
          " Moves per attack: " << attack_time() << "\n";
 }

 if (is_food()) {

  it_comest* food = dynamic_cast<it_comest*>(type);
  dump << " Nutrition: " << int(food->nutr) << "\n Quench: " <<
          int(food->quench) << "\n Enjoyability: " << int(food->fun);

 } else if (is_food_container()) {

 // added charge display for debugging
 
  it_comest* food = dynamic_cast<it_comest*>(contents[0].type);
  dump << " Nutrition: " << int(food->nutr) << "\n Quench: " <<
          int(food->quench) << "\n Enjoyability: " << int(food->fun)
          << "\n Charges: " << int(contents[0].charges);

 } else if (is_ammo()) {
 
  // added charge display for debugging

  it_ammo* ammo = dynamic_cast<it_ammo*>(type);
  dump << " Type: " << ammo_name(ammo->type) << "\n Damage: " <<
           int(ammo->damage) << "\n Armor-pierce: " << int(ammo->pierce) <<
           "\n Range: " << int(ammo->range) << "\n Accuracy: " <<
           int(100 - ammo->accuracy) << "\n Recoil: " << int(ammo->recoil)
           << "\n Count: " << int(ammo->count);

 } else if (is_ammo_container()) {

  it_ammo* ammo = dynamic_cast<it_ammo*>(contents[0].type);
  dump << " Type: " << ammo_name(ammo->type) << "\n Damage: " <<
           int(ammo->damage) << "\n Armor-pierce: " << int(ammo->pierce) <<
           "\n Range: " << int(ammo->range) << "\n Accuracy: " <<
           int(100 - ammo->accuracy) << "\n Recoil: " << int(ammo->recoil)
           << "\n Count: " << int(contents[0].charges); 
           
 } else if (is_gun()) {

  it_gun* gun = dynamic_cast<it_gun*>(type);
  int ammo_dam = 0, ammo_recoil = 0;
  bool has_ammo = (curammo != NULL && charges > 0);
  if (has_ammo) {
   ammo_dam = curammo->damage;
   ammo_recoil = curammo->recoil;
  }
   
  dump << " Skill used: " << skill_name(gun->skill_used) << "\n Ammunition: " <<
          clip_size() << " rounds of " << ammo_name(ammo_type());

  dump << "\n Damage: ";
  if (has_ammo)
   dump << ammo_dam;
  dump << (gun_damage(false) >= 0 ? "+" : "" ) << gun_damage(false);
  if (has_ammo)
   dump << " = " << gun_damage();

  dump << "\n Accuracy: " << int(100 - accuracy());

  dump << "\n Recoil: ";
  if (has_ammo)
   dump << ammo_recoil;
  dump << (recoil(false) >= 0 ? "+" : "" ) << recoil(false);
  if (has_ammo)
   dump << " = " << recoil();

  dump << "\n Reload time: " << int(gun->reload_time);
  if (has_flag(IF_RELOAD_ONE))
   dump << " per round";

  if (burst_size() == 0) {
   if (gun->skill_used == sk_pistol && has_flag(IF_RELOAD_ONE))
    dump << "\n Revolver.";
   else
    dump << "\n Semi-automatic.";
  } else
   dump << "\n Burst size: " << burst_size();
  if (contents.size() > 0)
   dump << "\n";
  for (int i = 0; i < contents.size(); i++)
   dump << "\n+" << contents[i].tname();

 } else if (is_gunmod()) {

  it_gunmod* mod = dynamic_cast<it_gunmod*>(type);
  if (mod->accuracy != 0)
   dump << " Accuracy: " << (mod->accuracy > 0 ? "+" : "") <<
           int(mod->accuracy);
  if (mod->damage != 0)
   dump << "\n Damage: " << (mod->damage > 0 ? "+" : "") << int(mod->damage);
  if (mod->clip != 0)
   dump << "\n Magazine: " << (mod->clip > 0 ? "+" : "") << int(mod->damage) << "%";
  if (mod->recoil != 0)
   dump << "\n Recoil: " << int(mod->recoil);
  if (mod->burst != 0)
   dump << "\n Burst: " << (mod->clip > 0 ? "+" : "") << int(mod->clip);
  if (mod->newtype != AT_NULL)
   dump << "\n " << ammo_name(mod->newtype);
  dump << "\n Used on: ";
  if (mod->used_on_pistol)
   dump << "Pistols.  ";
  if (mod->used_on_shotgun)
   dump << "Shotguns.  ";
  if (mod->used_on_smg)
   dump << "SMGs.  ";
  if (mod->used_on_rifle)
   dump << "Rifles.";

 } else if (is_armor()) {

  it_armor* armor = dynamic_cast<it_armor*>(type);
  dump << " Covers: ";
  if (armor->covers & mfb(bp_head))
   dump << "The head. ";
  if (armor->covers & mfb(bp_eyes))
   dump << "The eyes. ";
  if (armor->covers & mfb(bp_mouth))
   dump << "The mouth. ";
  if (armor->covers & mfb(bp_torso))
   dump << "The torso. ";
  if (armor->covers & mfb(bp_arms))
   dump << "The arms. ";   
  if (armor->covers & mfb(bp_hands))
   dump << "The hands. ";
  if (armor->covers & mfb(bp_legs))
   dump << "The legs. ";
  if (armor->covers & mfb(bp_feet))
   dump << "The feet. ";
  dump << "\n Encumberment: "			<< int(armor->encumber) <<
          "\n Bashing protection: "		<< int(armor->dmg_resist) <<
          "\n Cut protection: "			<< int(armor->cut_resist) <<
          "\n Environmental protection: "	<< int(armor->env_resist) <<
          "\n Warmth: "				<< int(armor->warmth) <<
          "\n Storage: "			<< int(armor->storage);

} else if (is_book()) {

  it_book* book = dynamic_cast<it_book*>(type);
  if (book->type == sk_null)
   dump << " Just for fun.\n";
  else {
   dump << " Can bring your " << skill_name(book->type) << " skill to " <<
           int(book->level) << std::endl;
   if (book->req == 0)
    dump << " It can be understood by beginners.\n";
   else
    dump << " Requires " << skill_name(book->type) << " level " <<
            int(book->req) << " to understand.\n";
  }
  dump << " Requires intelligence of " << int(book->intel) << " to easily read." << std::endl;
  if (book->fun != 0)
   dump << " Reading this book affects your morale by " <<
           (book->fun > 0 ? "+" : "") << int(book->fun) << std::endl;
  dump << " This book takes " << int(book->time) << " minutes to read.";

 } else if (is_tool()) {

  it_tool* tool = dynamic_cast<it_tool*>(type);
  dump << " Maximum " << tool->max_charges << " charges";
  if (tool->ammo == AT_NULL)
   dump << ".";
  else
   dump << " of " << ammo_name(tool->ammo) << ".";

 } else if (is_style()) {

  dump << "\n";
  it_style* style = dynamic_cast<it_style*>(type);
  for (int i = 0; i < style->moves.size(); i++) {
   dump << default_technique_name(style->moves[i].tech) <<
           ". Requires Unarmed Skill of " << style->moves[i].level << "\n";
  }

 } else if (!is_null() && type->techniques != 0) {

  dump << "\n";
  for (int i = 1; i < NUM_TECHNIQUES; i++) {
   if (type->techniques & mfb(i))
    dump << default_technique_name( technique_id(i) ) << "; ";
  }

 }

 if ( showtext && !is_null() ) {
  dump << "\n\n" << type->description << "\n";
  if (contents.size() > 0) {
   if (is_gun()) {
    for (int i = 0; i < contents.size(); i++)
     dump << "\n " << contents[i].type->description;
   } else
    dump << "\n " << contents[0].type->description;
   dump << "\n";
  }
 }
 return dump.str();
}
Exemple #22
0
void CombatWindow::updateOffense()
{
#ifdef DEBUGCOMBAT
	printf("CombatWindow::updateOffense starting...\n");
#endif


	QString s_totaldamage;
	QString s_percentspecial;
	QString s_percentnonmelee;
	QString s_avgmelee;
	QString s_avgspecial;
	QString s_avgnonmelee;

	int iTotalDamage = 0;
	int iTotalHits = 0;
	double dPercentSpecial = 0.0;
	double dPercentNonmelee = 0.0;
	double dAvgMelee = 0.0;
	double dAvgSpecial = 0.0;
	double dAvgNonmelee = 0.0;

	int iMeleeDamage = 0;
	int iMeleeHits = 0;
	int iSpecialDamage = 0;
	int iSpecialHits = 0;
	int iNonmeleeDamage = 0;
	int iNonmeleeHits = 0;


	//	empty the list so we can repopulate
	m_listview_offense->clear();

	CombatOffenseRecord *pRecord;

	for(pRecord = m_combat_offense_list.first(); pRecord != 0; pRecord = m_combat_offense_list.next())
	{
		int iType = pRecord->getType();
		int iHits = pRecord->getHits();
		int iMisses = pRecord->getMisses();
		int iMinDamage = pRecord->getMinDamage();
		int iMaxDamage = pRecord->getMaxDamage();
		int iDamage = pRecord->getTotalDamage();

		double dAvgDamage = (double)iDamage / (double)iHits;
		double dRatio = (double)iHits / (double)iMisses;

		QString s_type;
		s_type.sprintf("%s(%d)", (const char*)skill_name(iType), iType);
		QString s_hits;
		s_hits.setNum(iHits);
		QString s_misses;
		s_misses.setNum(iMisses);
		QString s_ratio;
		s_ratio = QString("%1 to 1").arg(dRatio);
		QString s_avgdamage;
		s_avgdamage.setNum(dAvgDamage);
		QString s_mindamage;
		s_mindamage.setNum(iMinDamage);
		QString s_maxdamage;
		s_maxdamage.setNum(iMaxDamage);
		QString s_damage;
		s_damage.setNum(iDamage);

		QListViewItem *pItem = new QListViewItem(m_listview_offense,
			s_type, s_hits, s_misses, s_ratio,
			s_avgdamage, s_mindamage, s_maxdamage, s_damage);

		m_listview_offense->insertItem(pItem);

		switch(iType)
		{
			case 0:		// 1H Blunt
			case 1:		// 1H Slashing
			case 2:		// 2H Blunt
			case 3:		// 2H Slashing
			case 28:	// Hand To Hand
			case 36:	// Piercing
			{
				iMeleeDamage += iDamage;
				iMeleeHits += iHits;
				break;
			}
			case 7:		// Archery
			case 8:		// Backstab
			case 10:	// Bash
			case 21:	// Dragon Punch
			case 23:	// Eagle Strike
			case 26:	// Flying Kick
			case 30:	// Kick
			case 38:	// Round Kick
			case 51:	// Throwing
			case 52:	// Tiger Claw
			{
				iSpecialDamage += iDamage;
				iSpecialHits += iHits;
				break;
			}
			default:
			{
				iNonmeleeDamage += iDamage;
				iNonmeleeHits += iHits;
				break;
			}
		}
	}

	iTotalDamage = iMeleeDamage + iSpecialDamage + iNonmeleeDamage;
	iTotalHits = iMeleeHits + iSpecialHits + iNonmeleeHits;

	dPercentSpecial = ((double)iSpecialDamage / (double)iTotalDamage) * 100.0;
	dPercentNonmelee = ((double)iNonmeleeDamage / (double)iTotalDamage) * 100.0;

	dAvgMelee = (double)iMeleeDamage / (double)iMeleeHits;
	dAvgSpecial = (double)iSpecialDamage / (double)iSpecialHits;
	dAvgNonmelee = (double)iNonmeleeDamage / (double)iNonmeleeHits;

	s_totaldamage.setNum(iTotalDamage);
	s_percentspecial.setNum(dPercentSpecial);
	s_percentnonmelee.setNum(dPercentNonmelee);
	s_avgmelee.setNum(dAvgMelee);
	s_avgspecial.setNum(dAvgSpecial);
	s_avgnonmelee.setNum(dAvgNonmelee);

	m_label_offense_totaldamage->setText(s_totaldamage);
	m_label_offense_percentspecial->setText(s_percentspecial);
	m_label_offense_percentnonmelee->setText(s_percentnonmelee);
	m_label_offense_avgmelee->setText(s_avgmelee);
	m_label_offense_avgspecial->setText(s_avgspecial);
	m_label_offense_avgnonmelee->setText(s_avgnonmelee);


#ifdef DEBUGCOMBAT
	printf("CombatWindow::updateOffense finished...\n");
#endif

}