Пример #1
0
bool Item::isConsumable()
{
    if(!isWeapon() && !isConsumable())
        return true;
    else return false;
}
int32_t LogisticsComponent::init(PSTR dataLine)
{
	PSTR line  = dataLine;
	PSTR pLine = line;
	char pBuffer[1025];
	ID = (extractInt(pLine));
	// the type
	extractString(pLine, pBuffer, 1024);
	int32_t i;
	for (i = 0; i < NUM_COMPONENT_FORMS; ++i)
	{
		if (0 == _stricmp(ComponentFormString[i], pBuffer))
		{
			Type = i;
			break;
		}
	}
	if (i == NUM_COMPONENT_FORMS)
		return -1;
	// name, probably aren't going to use this, they should be in the RC.
	extractString(pLine, pBuffer, 1024);
	// name, probably aren't going to use this, they should be in the RC.
	extractString(pLine, pBuffer, 1024); // ignore critical hits
	recycleTime = extractFloat(pLine);
	heat		= extractFloat(pLine);
	// weight
	weight = extractFloat(pLine);
	damage = extractFloat(pLine);
	// ignore battle rating
	extractString(pLine, pBuffer, 1024);
	// cost
	cost = extractInt(pLine);
	// range
	extractString(pLine, pBuffer, 1024);
	if (!isWeapon())
		rangeType = NO_RANGE;
	else if (!strcmp(pBuffer, "int32_t"))
		rangeType = int32_t;
	else if (!strcmp(pBuffer, "medium"))
		rangeType = MEDIUM;
	else
		rangeType = int16_t;
	// we need to figure out where things can go
	extractString(pLine, pBuffer, 1024);
	bHead = _stricmp(pBuffer, "Yes") ? false : true;
	extractString(pLine, pBuffer, 1024);
	bTorso = _stricmp(pBuffer, "Yes") ? false : true;
	// ignore the next 4 columns
	for (i = 0; i < 4; ++i)
		extractString(pLine, pBuffer, 1024);
	extractString(pLine, pBuffer, 1024);
	bLegs = _stricmp(pBuffer, "Yes") ? false : true;
	// ignore the next 4 columns
	for (i = 0; i < 4; ++i)
		extractString(pLine, pBuffer, 1024);
	Ammo = extractInt(pLine);
	// now read in icon info
	extractString(pLine, pBuffer, 1024);
	if (*pBuffer && (pBuffer[0] != '0'))
	{
		iconFileName = new char[strlen(pBuffer) + 1];
		strcpy(iconFileName, pBuffer);
	}
	else
		return -1; // fail if no picture
	extractString(pLine, pBuffer, 1024);
	if (*pBuffer)
	{
		pictureFileName =
			new char[strlen(pBuffer) + 1]; // Forgot the nullptr all over the place did we?
		strcpy(pictureFileName, pBuffer);
	}
	stringID	 = extractInt(pLine);
	helpStringID = extractInt(pLine);
	iconX		 = extractInt(pLine);
	iconY		 = extractInt(pLine);
	char nameBuffer[256];
	cLoadString(stringID, nameBuffer, 256);
	name = flavorText = new char[strlen(nameBuffer) + 1]; // Lets not forget the nullptr!!!
	strcpy(name, nameBuffer);
	return ID;
}
Пример #3
0
std::string Item::getDescription(int32_t lookDistance) const
{
	std::stringstream s;
	const ItemType& it = items[id];

	if (it.name.length()) {
		if(isStackable() && count > 1){
			s << (int)count << " " << it.name << "s.";

			if(lookDistance <= 1) {
				s << std::endl << "They weight " << std::fixed << std::setprecision(2) << ((double) count * it.weight) << " oz.";
			}
		}		
		else{
			if(items[id].runeMagLevel != -1)
			{
				s << "a spell rune for level " << it.runeMagLevel << "." << std::endl;

				s << "It's an \"" << it.name << "\" spell (";
				if(getItemCharge())
					s << (int)getItemCharge();
				else
					s << "1";

				s << "x).";
			}
			else if(isWeapon() && (getAttack() || getDefense()))
			{
				if(getAttack()){
					s << "a " << it.name << " (Atk:" << (int)getAttack() << " Def:" << (int)getDefense() << ").";
				}
				else{
					s << "a " << it.name << " (Def:" << (int)getDefense() << ").";	
				}
			}
			else if(getArmor()){
				s << "a " << it.name << " (Arm:" << (int)getArmor() << ").";
			}
			else if(isFluidContainer()){
				s << "a " << it.name;
				if(fluid == 0){
					s << ". It is empty.";
				}
				else{
					s << " of " << items[fluid].name << ".";
				}
			}
			else if(isSplash()){
				s << "a " << it.name << " of ";
				if(fluid == 0){
					s << items[1].name << ".";
				}
				else{
					s << items[fluid].name << ".";
				}
			}
			else if(it.isKey()){
				s << "a " << it.name << " (Key:" << actionId << ").";
			}
			else if(it.isGroundTile()){
				s << it.name << ".";
			}
			else if(it.isContainer()){
				s << "a " << it.name << " (Vol:" << getContainer()->capacity() << ").";
			}
			else if(it.allowDistRead){
				s << it.name << "." << std::endl;

				if(lookDistance <= 4){
					if(text && text->length() > 0){
						s << "You read: " << *text;
					}
					else
						s << "Nothing is written on it.";
				}
				else
					s << "You are too far away to read it.";
			}
			else{
				s << "a " << it.name << ".";
			}

			if(lookDistance <= 1){
				double weight = getWeight();
				if(weight > 0)
					s << std::endl << "It weighs " << std::fixed << std::setprecision(2) << weight << " oz.";
			}

			if(specialDescription)
				s << std::endl << specialDescription->c_str();
			else if(lookDistance <= 1 && it.description.length()){
				s << std::endl << it.description;
			}
		}
	}
	else
		s << "an item of type " << id <<".";
	
	return s.str();
}
Пример #4
0
TRIGGER( targetobj )(obj user, obj usedon)
{
  cleanup();
  if(Q4BL(user, "The blacksmith skill", 0x00))
  {
    return(0x00);
  }
  if(!Q4ZM(user))
  {
    return(0x00);
  }
  if(isWeapon(usedon) && hasResource(usedon, resourceTypeToId("metal")))
  {
    if(isInContainer(usedon))
    {
      obj container = getTopmostContainer(usedon);
      if(isMobile(container))
      {
        if(container != user)
        {
          systemMessage(user, "You can't work on that item.");
          return(0x00);
        }
      }
    }
    int Q4G6 = getWeaponCurHP(usedon);
    int Q56H = getWeaponMaxHP(usedon);
    if((Q56H == 0x00) || (Q4G6 >= Q56H))
    {
      systemMessage(user, "That is already in full repair.");
      return(0x00);
    }
    int Q5MK = (Q56H - Q4G6) * 0x04E2 / Q56H - 0xFA;
    int Q4Q1;
    int success = testAndLearnSkill(user, 0x07, Q5MK, 0x32);
    Q56H --;
    Q4G6 --;
    if(Q4G6 < 0x01)
    {
      systemMessage(user, "You destroyed the item.");
      deleteObject(usedon);
    }
    else
    {
      if(success > 0x00)
      {
        Q4G6 = Q56H;
        systemMessage(user, "You repair the item.");
      }
      Q4Q1 = setWeaponMaxHP(usedon, Q56H);
      Q4Q1 = setWeaponCurHP(usedon, Q4G6);
    }
    if(Q46J(user, this))
    {
      deleteObject(this);
    }
    return(0x00);
  }
  systemMessage(user, "You can't repair that.");
  return(0x00);
}
Пример #5
0
bool GameObject::isEquipment(){
	return(
		isWeapon() ||
		isArmor() ||
		isAccessory());
}