Author Topic: Making Pickupable Gold  (Read 1015 times)

How would I make pickupable gold and how would I set the text above it and set what happens when you pick it up?

Code: [Select]
datablock ItemData(GoldItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system
shapeFile = "base/data/shapes/brickweapon.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
rotate = true;
uiName = "Gold";
doColorShift = false;
colorShiftColor = "0.823 0.627 0.117 1.000";
canDrop = true;
};
function GoldItem::onAdd(%this, %obj)
{
%obj.setShapeName("TEXT HERE");
Parent::onAdd(%this, %obj);
}

package GoldPackage
{
function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
if(%col.dataBlock $= "GoldItem" && %obj.getDamagePercent() < 100 && %col.canPickup)
{
Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
//stuff
                }
}
};
activatePackage(GoldPackage);
« Last Edit: January 17, 2012, 11:52:26 AM by swollow »

Code: [Select]
datablock ItemData(GoldItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system
shapeFile = "base/data/shapes/brickweapon.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
rotate = true;
uiName = "Gold";
doColorShift = false;
colorShiftColor = "0.823 0.627 0.117 1.000";
canDrop = true;
};
function GoldItem::onAdd(%this, %obj)
{
%obj.setShapeName("TEXT HERE");
Parent::onAdd(%this, %obj);
}

package GoldPackage
{
function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
if(%col.dataBlock $= "GoldItem" && %obj.getDamagePercent() < 100 && %col.canPickup)
{
Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
//stuff
                }
}
};
activatePackage(GoldPackage);
???
Code: [Select]
function serverCmdDropGold(%client, %num)
{
if(%client.Gold >= %num && (%num >= 1))
{
%client.Gold -= %num;
messageClient(%client,'',"\c6You dropped \c3" @ %num @ "\c6 gold.");

%GoldBar = new Item()
{
datablock = GoldBarItem;
canPickup = false;
};

%GoldBar.setVelocity(VectorScale(%client.player.getEyeVector(), 10));

MissionCleanup.add(%GoldBar);
%GoldBar.setShapeName(%amount);
}

else
{
messageClient(%client,'',"\c6Please enter a valid amount of gold to drop.");
}
}

package GoldBar
{
//=========================================================================
// On Gold Bar Pickup
//=========================================================================
function Armor::onCollision(%this, %obj, %col, %thing, %other)
{
if(%col.getDatablock().getName() $= "GoldBarItem")
{
if(isObject(%obj.client))
{
if(isObject(%col))
{
if(%obj.client.minigame)
%col.minigame = %obj.client.minigame;


%this.Gold += %col.value;

messageClient(%obj.client, '', "\c6You picked up\c3" SPC %col.value SPC "\c6gold.");

%col.canPickup = false;
%col.delete();
}
else
{
%col.delete();
MissionCleanup.remove(%col);
}
}
}

parent::onCollision(%this, %obj, %col, %thing, %other);
}
};
activatePackage(GoldBar);
//=========================================================================
// Gold Bar Datablock
//=========================================================================
datablock ItemData(GoldBarItem)
{
category = "Weapon";
className = "Weapon";

shapeFile = "./Gold_Bar.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

uiName = "";

doColorShift = false;
colorShiftColor = "252 241 0 1";
image = GoldBarImage;
candrop = true;
canPickup = true;
};

For serverCmdDropGold, You need to also have the position of the gold bar
Something like "position = %client.player.getPosition();" in the new item declaration.
Also I would round up the amount of gold dropped.

For serverCmdDropGold, You need to also have the position of the gold bar
Something like "position = %client.player.getPosition();" in the new item declaration.
Also I would round up the amount of gold dropped.
Why?

Why?
Because unless you want fractions of a gold coin in the currency you would want to round it up or down with mCeil or mFloor

Because unless you want fractions of a gold coin in the currency you would want to round it up or down with mCeil or mFloor
How? I've never used mCeil or mFloor.

Also I was talking about the other thing he said.

How? I've never used mCeil or mFloor.

Also I was talking about the other thing he said.
because then the gold bar will appear at like position 0 0 0

because then the gold bar will appear at like position 0 0 0
But where would I do position = %client.player.getPosition();?

Code: [Select]
%pos = %client.player.getPosition();
%GoldBar = new Item()
{
position = %pos;
datablock = GoldBarItem;
canPickup = false;
};

So how do you use mCeil and mFloor? I've never used mCeil or mFloor.

mCeil(number) - returns the number rounded up
mFloor(number) - returns the number rounded down

That's how you use them. In case you need this too:
mFloatLength(number, 0) - returns the number rounded up or down dependent on what's closest

I tried making a VCE rpg once with pickup-able gold. I kept getting fractions of gold after killing monsters so thats how I found out about Ceil/Floor. Round your gold up so you can get a whole number.