Ejemplo n.º 1
0
TRIGGER( use )(obj user)
{
  obj player = user;
  if(!hasObjVar(this, "bountyPlayer"))
  {
    systemMessage(user, "Select player to bounty:");
    targetObj(user, this);
    return(0x00);
  }
  string Q5IU = "PD BugKiller";
  if(hasObjVar(this, "bountyPlayerName"))
  {
    Q5IU = getObjVar(this, "bountyPlayerName");
  }
  systemMessage(user, "creating bounty for (" + objtoint(player) + ".");
  obj bountyInfo = createNoResObjectAt(0x01, getLocation(user));
  setObjVar(bountyInfo, "subject", player);
  attachScript(bountyInfo, "bountyinfo");
  list args = list( player, 0x029A, 0x00, Q5IU );
  message(bountyInfo, "addBounty", args);
  int Q4Q1 = teleport(bountyInfo, getRelayLoc(player));
  if(isValid(bountyInfo))
  {
    clearList(args);
    message(bountyInfo, "teleported", args);
  }
  args = list( getAdjFame(user) );
  systemMessage(user, "MurderReport: Messaging via probe to " + objtoint(user) + ".");
  Q56V(player, "murderReport", args);
  obj head = createNoResObjectIn(0x1DA0, getBackpack(user));
  setObjVar(head, "nameVar", Q5IU);
  setObjVar(head, "controller", player);
  return(0x00);
}
Ejemplo n.º 2
0
void cPlayer::giveGold( quint32 amount, bool inBank )
{
	P_ITEM pCont = NULL;
	if ( !inBank )
		pCont = getBackpack();
	else
		pCont = getBankbox();

	if ( !pCont )
		return;

	// Begin Spawning
	quint32 total = amount;

	while ( total > 0 )
	{
		P_ITEM pile = cItem::createFromScript( "eed" );
		pile->setAmount( wpMin<quint32>( total, static_cast<quint32>( 65535 ) ) );
		total -= pile->amount();

		pCont->addItem( pile );
		if ( !pile->free )
		{
			pile->update();
		}
	}

	goldSound( amount, false );
}
Ejemplo n.º 3
0
FUNCTION void Q4E8(obj user, obj Q66M, int Q4QY, string name)
{
  if(isAtHome(this))
  {
    systemMessage(user, "You can't use that, it belongs to someone else.");
    return;
  }
  int Q66P = getObjType(Q66M);
  if(Q4Z2(Q66P))
  {
    if(!testSkill(user, 0x0D))
    {
      systemMessage(user, "You burn the food to a crisp! It's ruined.");
      destroyOne(this);
      return;
    }
    if(name != "default")
    {
      if(hasObjVar(this, "NAME"))
      {
        removeObjVar(this, "NAME");
        setObjVar(this, "NAME", name);
      }
    }
    if(random(0x00, 0x01))
    {
      barkTo(user, user, "Looks delicious.");
    }
    else
    {
      barkTo(user, user, "Mmmm, smells good.");
    }
    obj Q47F = getBackpack(user);
    int Q4TM;
    obj Q5CN = createGlobalObjectOn(this, Q4QY);
    if(!isInContainer(this))
    {
      if(canHold(Q47F, Q5CN))
      {
        Q4TM = putObjContainer(Q5CN, Q47F);
        systemMessage(user, "You put the cooked food into your backpack.");
      }
      else
      {
        Q4TM = teleport(Q5CN, getLocation(user));
        systemMessage(user, "You put the cooked food on the ground.");
      }
    }
    destroyOne(this);
  }
  else
  {
    systemMessage(user, "You can't cook on that.");
  }
  return;
}
Ejemplo n.º 4
0
UINT32 cNPC::takeGold( UINT32 amount, bool useBank )
{
	P_ITEM pPack = getBackpack();

	UINT32 dAmount = 0;

	if( pPack )
		dAmount = pPack->DeleteAmount( amount, 0xEED, 0 );

	return dAmount;
}
Ejemplo n.º 5
0
void cNPC::giveGold( Q_UINT32 amount, bool inBank )
{
	P_ITEM pCont = getBackpack();

	if( !pCont )
		return;

	// Begin Spawning
	Q_UINT32 total = amount;

	while( total > 0 )
	{
		P_ITEM pile = cItem::createFromScript( "eed" );
		pile->setAmount( QMIN( total, static_cast<Q_UINT32>(65535) ) );
		pCont->addItem( pile );
		total -= pile->amount();
	}
}
Ejemplo n.º 6
0
FUNCTION obj Q4SE(obj Q68D)
{
  obj Q491 = getBackpack(Q68D);
  if(Q491 == NULL())
  {
    Q491 = createGlobalObjectIn(0x0E75, Q68D);
    if(!isValid(Q491))
    {
      return(NULL());
    }
    if(!equipObj(Q491, Q68D, 0x15))
    {
      deleteObject(Q491);
      return(NULL());
    }
  }
  return(Q491);
}
Ejemplo n.º 7
0
/*!
	Reduces the specified \a amount of gold from the user
	and returns the amount reduced. If it was successfull, it will return
	the same value passed on \a amount parameter.
*/
Q_UINT32 cPlayer::takeGold( Q_UINT32 amount, bool useBank )
{
	P_ITEM pPack = getBackpack();

	Q_UINT32 dAmount = 0;

	if ( pPack )
		dAmount = pPack->deleteAmount( amount, 0xEED, 0 );

	if ( ( dAmount > 0 ) && useBank )
	{
		P_ITEM pBank = getBankbox();

		if ( pBank )
			dAmount += pBank->deleteAmount( ( amount - dAmount ), 0xEED, 0 );
	}

	goldSound( amount, false );

	return amount - dAmount;
}
Ejemplo n.º 8
0
TRIGGER( targetobj )(obj user, obj usedon)
{
  removeObjVar(this, "inUse");
  if(usedon == NULL())
  {
    return(0x00);
  }
  if(getDistanceInTiles(getLocation(user), getLocation(usedon)) > 0x03)
  {
    systemMessage(user, "That is too far away.");
    return(0x00);
  }
  if(getDistanceInTiles(getLocation(this), getLocation(usedon)) > 0x03)
  {
    systemMessage(user, "The ore is too far away.");
    return(0x00);
  }
  if(!canSeeObj(user, usedon))
  {
    systemMessage(user, "You can't see that.");
    return(0x00);
  }
  int Q4Q1;
  int Q4YO;
  Q4Q1 = getResource(Q4YO, this, "metal", 0x03, 0x02);
  int Q4Z5 = 0x00;
  int Q4ZU = 0x00;
  obj ore = this;
  int Q62A = getObjType(this);
  int Q66P = getObjType(usedon);
  if(Q66P == 0x0FB1)
  {
    Q4Z5 = 0x01;
  }
  if(Q66P >= 0x197A)
  {
    if(Q66P <= 0x19A9)
    {
      Q4Z5 = 0x01;
    }
  }
  if(Q66P > 0x19B6)
  {
    if(Q66P < 0x19BB)
    {
      Q4ZU = 0x01;
      if(isInContainer(this))
      {
        obj Q61O = getTopmostContainer(this);
        int Q62E = getWeight(Q61O) + getWeight(usedon);
      }
      if(isInContainer(usedon))
      {
        obj Q66Q = getTopmostContainer(usedon);
        int Q66T = getWeight(Q66Q) + getWeight(this);
      }
      if((Q62E > 0x03E8) || (Q66T > 0x03E8))
      {
        ebarkTo(user, user, "The weight is too great to combine in a container.");
        return(0x00);
      }
    }
  }
  if(Q4ZU)
  {
    ore = this;
    if(Q62A == 0x19B9)
    {
      Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
      transferResources(usedon, ore, Q4YO, "metal");
    }
    if(Q62A == 0x19B8)
    {
      switch(Q66P)
      {
      case 0x19B9:
      case 0x19B8:
        Q4Q1 = getResource(Q4YO, usedon, "metal", 0x03, 0x02);
        transferResources(ore, usedon, Q4YO, "metal");
        break;
      case 0x19B7:
      case 0x19BA:
        Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
        transferResources(usedon, ore, Q4YO, "metal");
        break;
      default:
        return(0x00);
        break;
      }
    }
    if(Q62A == 0x19BA)
    {
      switch(Q66P)
      {
      case 0x19B9:
      case 0x19B8:
        Q4Q1 = getResource(Q4YO, usedon, "metal", 0x03, 0x02);
        transferResources(ore, usedon, Q4YO, "metal");
        break;
      case 0x19B7:
      case 0x19BA:
        Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
        transferResources(usedon, ore, Q4YO, "metal");
        break;
      default:
        return(0x00);
        break;
      }
    }
    if(Q62A == 0x19B7)
    {
      switch(Q66P)
      {
      case 0x19B9:
      case 0x19B8:
      case 0x19BA:
        Q4Q1 = getResource(Q4YO, usedon, "metal", 0x03, 0x02);
        transferResources(ore, usedon, Q4YO, "metal");
        break;
      case 0x19B7:
        Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
        transferResources(usedon, ore, Q4YO, "metal");
        break;
      default:
        return(0x00);
        break;
      }
    }
    Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
    if(Q4YO < 0x01)
    {
      deleteObject(ore);
    }
    Q4Q1 = getResource(Q4YO, usedon, "metal", 0x03, 0x02);
    if(Q4YO < 0x01)
    {
      deleteObject(usedon);
    }
    if(hasObjVar(this, "inUse"))
    {
      removeObjVar(this, "inUse");
    }
    return(0x00);
  }
  if(Q4Z5)
  {
    obj Q47G = getBackpack(user);
    ore = this;
    int Q5GQ = getObjType(ore);
    int Q4Y6 = 0x1BF2;
    Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
    int count = Q4YO / 0x02;
    if(count < 0x01)
    {
      systemMessage(user, "There is not enough metal-bearing ore in this pile to make an ingot.");
      if(hasObjVar(this, "inUse"))
      {
        removeObjVar(this, "inUse");
      }
      return(0x00);
    }
    if(testSkill(user, 0x2D))
    {
      obj Q5BW = createNoResObjectIn(Q4Y6, Q47G);
      transferResources(Q5BW, ore, count, "metal");
      returnResourcesToBank(ore, count, "metal");
      Q4Q1 = putObjContainer(Q5BW, Q47G);
      Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
      if(Q4YO < 0x01)
      {
        deleteObject(ore);
      }
      systemMessage(user, "You smelt the ore removing the impurities and put the metal in your backpack.");
    }
    else
    {
      if(count == 0x01)
      {
        systemMessage(user, "You burn away the impurities but are left with no useable metal.");
        deleteObject(ore);
        return(0x01);
      }
      returnResourcesToBank(ore, count, "metal");
      systemMessage(user, "You burn away the impurities but are left with less useable metal.");
      Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
      if(Q4YO < 0x01)
      {
        deleteObject(ore);
      }
    }
  }
  return(0x01);
}
Ejemplo n.º 9
0
void cPlayer::applyStartItemDefinition( const cElement* element )
{
	for ( unsigned int i = 0; i < element->childCount(); ++i )
	{
		const cElement* node = element->getChild( i );

		// Apply another startitem definition
		if ( node->name() == "inherit" )
		{
			const cElement* inheritNode = Definitions::instance()->getDefinition( WPDT_STARTITEMS, node->getAttribute( "id" ) );

			if ( inheritNode )
			{
				applyStartItemDefinition( inheritNode );
			}
		}

		// Item related nodes
		else
		{
			P_ITEM pItem = 0;

			if ( node->hasAttribute( "id" ) && node->getAttribute( "id" ) != QString::null )
			{
				pItem = cItem::createFromScript( node->getAttribute( "id" ) );
			}
			else if ( node->hasAttribute( "list" ) && node->getAttribute( "list" ) != QString::null )
			{
				pItem = cItem::createFromList( node->getAttribute( "list" ) );
			}
			else if ( node->hasAttribute( "randomlist" ) && node->getAttribute( "randomlist" ) != QString::null )
			{
				QStringList RandValues = node->getAttribute( "randomlist" ).split( "," );
				pItem = cItem::createFromList( RandValues[RandomNum( 0, RandValues.size() - 1 )] );
			}

			if ( !pItem )
			{
				Console::instance()->log( LOG_ERROR, tr( "Invalid item tag without id or list in startitem definition '%1'" ).arg( element->getAttribute( "id" ) ) );
			}
			else
			{
				pItem->applyDefinition( node );

				if ( node->name() == "item" )
				{
					pItem->toBackpack( this );
				}
				else if ( node->name() == "bankitem" )
				{
					getBackpack()->addItem( pItem );
				}
				else if ( node->name() == "equipment" )
				{
					unsigned char layer = pItem->layer();
					pItem->setLayer( 0 );

					if ( !layer )
					{
						tile_st tile = TileCache::instance()->getTile( pItem->id() );
						layer = tile.layer;
					}

					if ( layer )
					{
						// Check if there is sth there already.
						// Could happen due to inherit.
						P_ITEM existing = atLayer( static_cast<cBaseChar::enLayer>( layer ) );
						if ( existing )
							existing->remove();
						addItem( static_cast<cBaseChar::enLayer>( layer ), pItem );
					}
					else
					{
						Console::instance()->log( LOG_ERROR, tr( "Trying to equip invalid item (%1) in startitem definition '%2'" ).arg( pItem->id(), 0, 16 ).arg( element->getAttribute( "id" ) ) );
					}
				}
				else
				{
					pItem->remove();
					Console::instance()->log( LOG_ERROR, tr( "Unrecognized startitem tag '%1' in definition '%2'." ).arg( QString(node->name()) ).arg( element->getAttribute( "id" ) ) );
				}
			}
		}
	}
}
Ejemplo n.º 10
0
/*!
	Reduces the specified \a amount of gold from the user
	and returns the amount reduced. If it was successfull, it will return
	the same value passed on \a amount parameter.
*/
quint32 cPlayer::takeGold( quint32 amount, bool useBank )
{
	P_ITEM pPack = getBackpack();
	P_ITEM pBank = getBankbox();

	// Count total gold
	unsigned int totalGold = 0;

	// Change useBank if we have "Pay from pack only" enabled
	if (Config::instance()->payfrompackonly())
		useBank = false;

	// Lets try global IDs
	QString idthird = Config::instance()->defaultThirdCoin();
	QString idfirst = Config::instance()->defaultFirstCoin();

	// Lets try values
	if (Config::instance()->usenewmonetary()) {

		// Lets Assign Region
		cTerritory* Region = this->region();

		if (Config::instance()->usereversedvaluable())
		{
			// Region Assignment
			if ( Region )
			{
				idthird = Region->thirdcoin();
			}

			// Get Amounts
			totalGold = pPack->countBaseItems( idthird );

			if (useBank && totalGold < amount) {
				totalGold += pBank->countBaseItems( idthird );
			}
		}
		else
		{
			// Region Assignment
			if ( Region )
			{
				idfirst = Region->firstcoin();
			}

			// Get Amounts
			totalGold = pPack->countBaseItems( idfirst );

			if (useBank && totalGold < amount) {
				totalGold += pBank->countBaseItems( idfirst );
			}
		}
	}
	else
	{
		totalGold = pPack->countItems(0xEED, 0);

		if (useBank && totalGold < amount) {
			totalGold += pBank->countItems(0xEED, 0);
		}
	}

	if (totalGold < amount) {
		return 0;
	}

	// Amount to Delete
	quint32 dAmount = 0;

	// Lets Delete
	if (Config::instance()->usenewmonetary())
	{
		if (Config::instance()->usereversedvaluable())
		{
			dAmount = pPack->removeItem( idthird, amount );

			if (useBank && dAmount > 0) {
				pBank->removeItem( idthird, dAmount );
			}
		}
		else
		{
			dAmount = pPack->removeItem( idfirst, amount );

			if (useBank && dAmount > 0) {
				pBank->removeItem( idfirst, dAmount );
			}
		}
	}
	else
	{
		dAmount = pPack->deleteAmount( amount, 0xEED, 0 );

		if (useBank && dAmount > 0) {
			pBank->deleteAmount( dAmount, 0xEED, 0 );
		}
	}

	goldSound(amount, false);
	return amount;
}
Ejemplo n.º 11
0
FUNCTION int Q4WT(obj user, obj Q5AO, obj Q5AB, obj Q5AP, int bank)
{
  loc Q575 = loc( getLocation(user) );
  loc Q4VS = loc( getLocation(Q5AB) );
  moveDir(Q4VS, 0x04);
  list Q51X = list( 0x100E, 0x100F, 0x1010, 0x1013 );
  int num = random(0x00, (numInList(Q51X) - 0x01));
  int Q51W = Q51X[num];
  obj key = NULL();
  obj Q47G = NULL();
  if(bank)
  {
    fixBank(user);
    Q47G = getItemAtSlot(user, 0x1D);
    if(Q47G == NULL())
    {
      Q47G = getBackpack(user);
      bank = 0x00;
    }
  }
  else
  {
    Q47G = getBackpack(user);
  }
  if(Q47G == NULL())
  {
    key = createGlobalObjectAt(Q51W, Q575);
    barkTo(user, user, "A house key is now at my feet.");
  }
  else
  {
    key = createGlobalObjectIn(Q51W, Q47G);
    if(bank)
    {
      barkTo(user, user, "A house key is now in my safety deposit box.");
    }
    else
    {
      barkTo(user, user, "A house key is now in my backpack.");
    }
  }
  if(key == NULL())
  {
    bark(user, "Ack, a key could not be created!");
    deleteObject(Q5AO);
    return(0x00);
  }
  attachScript(key, "key");
  list Q5Z5;
  if(hasObjVar(Q5AO, "myhousedoors"))
  {
    getObjListVar(Q5Z5, Q5AO, "myhousedoors");
  }
  int Q55T = numInList(Q5Z5);
  for(int Q4EJ = 0x00; Q4EJ < Q55T; Q4EJ ++)
  {
    Q5AB = Q5Z5[Q4EJ];
    Q45B(Q5AB, key);
  }
  if(Q5AP != NULL())
  {
    Q45B(Q5AP, key);
  }
  attachScript(key, "housekey");
  return(0x01);
}
Ejemplo n.º 12
0
FUNCTION int Q659(obj user)
{
  int Q62A = getObjType(this);
  if(hasObjVar(this, "fuel"))
  {
    int fuel = getObjVar(this, "fuel");
  }
  switch(Q62A)
  {
  case 0x0A26:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x0B1A);
    break;
  case 0x0A27:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x0B1D);
    break;
  case 0x0A29:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x0B26);
    break;
  case 0x1853:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x1854);
    break;
  case 0x1857:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x1858);
    break;
  case 0x1849:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x184A);
    break;
  case 0x184D:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x184E);
    break;
  case 0x0A28:
    int Q527;
    obj Q47F = getBackpack(user);
    obj Q5BO = requestCreateObjectAt(0x0A0F, getLocation(user));
    setObjVar(this, "fuel", 0x64);
    setObjVar(Q5BO, "burning", 0x01);
    attachscript(Q5BO, "torch");
    callback(Q5BO, 0x1E, 0x39);
    if(!isInContainer(this))
    {
      Q527 = teleport(Q5BO, getLocation(this));
      if(getQuantity(this) > 0x01)
      {
        destroyOne(this);
        if(canHold(Q47F, this))
        {
          systemMessage(user, "You put the remaining unlit candles into your backpack.");
          Q527 = putObjContainer(this, Q47F);
        }
        else
        {
          systemMessage(user, "You put the remaining unlit candles at your feet.");
          Q527 = teleport(this, getLocation(user));
        }
      }
    }
    else
    {
      destroyOne(this);
      if(getItemAtSlot(user, 0x02) != NULL())
      {
        systemMessage(user, "You cannot hold the candle, so it has been placed at your feet.");
      }
      else
      {
        Q527 = equipObj(Q5BO, user, 0x02);
        systemMessage(user, "You put the candle in your left hand.");
      }
    }
    if(getQuantity(this) == 0x01)
    {
      destroyOne(this);
    }
    break;
  case 0x0F64:
  case 0x0F6B:
    Q47F = getBackpack(user);
    obj Q5CB = requestCreateObjectAt(0x0A12, getLocation(user));
    setObjVar(this, "fuel", 0x64);
    setObjVar(Q5CB, "burning", 0x01);
    attachscript(Q5CB, "torch");
    callback(Q5CB, 0x1E, 0x39);
    if(!isInContainer(this))
    {
      Q527 = teleport(Q5CB, getLocation(this));
      if(getQuantity(this) > 0x01)
      {
        destroyOne(this);
        if(canHold(Q47F, this))
        {
          systemMessage(user, "You put the remaining unlit torches into your backpack.");
          Q527 = putObjContainer(this, Q47F);
        }
        else
        {
          systemMessage(user, "You put the remaining unlit torches at your feet.");
          Q527 = teleport(this, getLocation(user));
        }
      }
    }
    else
    {
      destroyOne(this);
      if(getItemAtSlot(user, 0x02) != NULL())
      {
        systemMessage(user, "You cannot hold the torch, so it has been placed at your feet.");
      }
      else
      {
        Q527 = equipObj(Q5CB, user, 0x02);
        systemMessage(user, "You put the torch in your left hand.");
      }
    }
    if(getQuantity(this) == 0x01)
    {
      destroyOne(this);
    }
    break;
  case 0x0A18:
  case 0x0A1D:
  case 0x0A25:
    if(fuel > 0x00)
    {
      setObjVar(this, "burning", 0x01);
      callback(this, 0x1E, 0x39);
      setType(this, Q62A - 0x03);
    }
    else
    {
      systemMessage(user, "The lantern is out of fuel.");
    }
    break;
  default:
    return(0x00);
    break;
  }
  sfx(getLocation(this), 0x47, 0x00);
  return(0x01);
}