Author Topic: Items_Potion  (Read 881 times)

I'm working on a medieval fort and it would be nice to have some more potions other than the red one.
They would be:
Green- Heals 50 health and adds a 25% speed boost for a couple of seconds.
Blue- Heals 25 health.
Orange- Heals 45 health.
Purple- Poison, takes away 10 health.
Pink- Causes a heart emote to appear above the player
« Last Edit: July 18, 2012, 06:13:39 PM by Cool Boi »


Easy to make.
Think you could do it? If possible in the model of your milk/ red potion addon?

Ive looked into this.
Couldn't figure out how to incorporate temporary item effects like upping player speed.

If someone can provide the code for that, I have a pack ready to go already.

Ive looked into this.
Couldn't figure out how to incorporate temporary item effects like upping player speed.

If someone can provide the code for that, I have a pack ready to go already.
Code: [Select]
datablock PlayerData(PlayerPotionFasterArmor : PlayerStandardArmor)
{
maxBackwardSpeed = "5";
maxForwardSpeed = "8";
maxSideSpeed = "7";

maxBackwardCrouchSpeed = "3";
maxForwardCrouchSpeed = "4";
maxSideCrouchSpeed = "3";

maxUnderwaterBackwardSpeed = "8.8";
maxUnderwaterForwardSpeed = "9.4";
maxUnderwaterSideSpeed = "8.8";

maxJumpSpeed = "35";

uiName = "";
};

//When they drink it
%oldDatablock = %player.datablock.getName();
%player.setDatablock("PlayerPotionFasterArmor");
%player.schedule(5000, 0, setDatablock, %oldDatablock);

Code: [Select]
datablock PlayerData(PlayerPotionFasterArmor : PlayerStandardArmor)
{
maxBackwardSpeed = "5";
maxForwardSpeed = "8";
maxSideSpeed = "7";

maxBackwardCrouchSpeed = "3";
maxForwardCrouchSpeed = "4";
maxSideCrouchSpeed = "3";

maxUnderwaterBackwardSpeed = "8.8";
maxUnderwaterForwardSpeed = "9.4";
maxUnderwaterSideSpeed = "8.8";

maxJumpSpeed = "35";

uiName = "";
};

//When they drink it
%oldDatablock = %player.datablock.getName();
%player.setDatablock("PlayerPotionFasterArmor");
%player.schedule(5000, 0, setDatablock, %oldDatablock);

Oh god, thank you.
Ive been wanting to do this for years.

Oh god, thank you.
Ive been wanting to do this for years.
If you are making this, can I request that you use this model if it isn't any trouble?
http://forum.blockland.us/index.php?topic=155962.0

Oh god, thank you.
Ive been wanting to do this for years.
Umm why didn't you just ask how to do it in Coding Help?

Umm why didn't you just ask how to do it in Coding Help?

I did.  I made a topic and nobody gave me any help.

Code: [Select]
Loading Add-On: Item_Potion_Green (CRC:-894162420)
Add-Ons/Item_Potion_Green/Item_Green_Potion.cs Line: 76 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^maxForwardCrouchSpeed = "4";

^maxSideCrouchSpeed = "3";



^maxUnderwaterBackwardSpeed = "8.8";

^maxUnderwaterForwardSpeed = "9.4";

^maxUnderwaterSideSpeed = "8.8";



^maxJumpSpeed = "35";



^uiName = "";

};



//When they drink it

%oldDatablock = %player.datablock.##g##etName();

%player.setDatablock("PlayerPotionFasterArmor");

%player.schedule(5000, 0, setDatablock, %oldDatablock);

};



activatePackage(Green_PotionPackage);

>>> Error report complete.

ADD-ON "Item_Potion_Green" CONTAINS SYNTAX ERRORS

I'm having this problem.  I don't know much about scripting, so how would I use this code?
« Last Edit: July 19, 2012, 11:36:51 PM by Mr.Noßody »

You're having that problem because you're defining a local variable outside the scope of a function. In layman's terms, you're trying to create something that shouldn't exist at a time where it shouldn't exist in a place where it can't exist.

You have to include the last three lines of jes' code in the function where the drink is drunk

You're having that problem because you're defining a local variable outside the scope of a function. In layman's terms, you're trying to create something that shouldn't exist at a time where it shouldn't exist in a place where it can't exist.

You have to include the last three lines of jes' code in the function where the drink is drunk
That's not the problem. When executing a script, all local variables will exist until the end of the script.

The actual problem is that when you do obj.dataBlock instead of obj.getDataBlock(), you NEED to make the B capital in dataBlock

New problem (Thanks Chrono for fixing the previous problem):

Code: [Select]
Loading Add-On: Item_Potion_Green (CRC:-219870240)
Executing Add-Ons/Item_Potion_Green/server.cs.
Executing Add-Ons/Item_Potion_Green/Item_Green_Potion.cs.

Add-Ons/Item_Potion_Green/Item_Green_Potion.cs (0): Unable to find object: '' attempting to call function 'getName'
BackTrace: ->SM_StartMission->createServer->onServerCreated->loadAddOns


Add-Ons/Item_Potion_Green/Item_Green_Potion.cs (0): Unable to find object: '' attempting to call function 'setDataBlock'
BackTrace: ->SM_StartMission->createServer->onServerCreated->loadAddOns


Add-Ons/Item_Potion_Green/Item_Green_Potion.cs (0): Unable to find object: '' attempting to call function 'schedule'
BackTrace: ->SM_StartMission->createServer->onServerCreated->loadAddOns

3 datablocks added.

Code: [Select]
Set::add: Object "0" doesn't exist
base/server/scripts/allGameScripts.cs (9243): Unable to instantiate non-conobject class .

base/server/scripts/allGameScripts.cs (9244): Unable to find object: '0' attempting to call function 'setScale'
BackTrace: ->WeaponImage::onFire

Top is on loading the add-on, second is on use.

I'll attach the script I have here:

Code: [Select]
datablock ItemData(Green_PotionItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

// Basic Item Properties
shapeFile = "./Green_Potion.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "Potion Green (Small)";
iconName = "./GPIcon";
doColorShift = false;

// Dynamic properties defined by the scripts
image = Green_PotionImage;
canDrop = true;
};

datablock ShapeBaseImageData(Green_PotionImage)
{
   // Basic Item properties
   shapeFile = "./Green_Potion.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "0 0 0" );

   className = "WeaponImage";
   item = Green_PotionItem;

   //raise your arm up or not
   armReady = true;

   // Initial start up state
stateName[0]                     = "Ready";
stateTransitionOnTriggerDown[0]  = "Fire";
stateAllowImageChange[0]         = true;

stateName[1]                     = "Fire";
stateTransitionOnTimeout[1]      = "Ready";
stateAllowImageChange[1]         = true;
      stateScript[1]                   = "onFire";
stateTimeoutValue[1]    = 1;
};

datablock PlayerData(PlayerPotionFasterArmor : PlayerStandardArmor)
{
maxBackwardSpeed = "5";
maxForwardSpeed = "8";
maxSideSpeed = "7";

maxBackwardCrouchSpeed = "3";
maxForwardCrouchSpeed = "4";
maxSideCrouchSpeed = "3";

maxUnderwaterBackwardSpeed = "8.8";
maxUnderwaterForwardSpeed = "9.4";
maxUnderwaterSideSpeed = "8.8";

maxJumpSpeed = "35";

uiName = "";
};

//When they drink it
%oldDataBlock = %player.DataBlock.getName();
%player.setDataBlock("PlayerPotionFasterArmor");
%player.schedule(5000, 0, setDataBlock, %oldDataBlock);