07-16-2013, 05:36 PM
Is it possible to make a custom usable item ? By usable item I mean something like "Sanity Potion" or "Oil". I want to make a potion that increases the players speed for a short duration of time.
void OnStart()
{
SetEntityCallbackFunc("name", "BoostPlayer");
}
void BoostPlayer(string &in ent, string &in type)
{
if(type == "OnPickup")
{
SetPlayerMoveSpeedMul(2.2f);
AddTimer("", 5.5f, "StopPlayer");
}
}
void StopPlayer(string &in timer)
{
SetPlayerMoveSpeedMul(1.0f);
}
(07-17-2013, 06:17 PM)ClayPigeon Wrote: [ -> ]Model creation:You'll have to create a model first (if you want a custom model) in any 3d editing program that supports OpenCOLLADA (.dae exporter). After exporting it you'll need to open it in the model editor and add some physical properties to it by attatching a body to it, and then you'll need to set the item's settings so it will be a coin (Settings -> User Defined Variables -> Type - Item -> Subtype - Coins).
Script-wise:
Afterwards, you'll need to place it in the Level Editor somewhere in your map, and give it a name, and script it so when the player will pick up "name" it will boost him. You'll need to use:
Code:void OnStart()
{
SetEntityCallbackFunc("name", "BoostPlayer");
}
void BoostPlayer(string &in ent, string &in type)
{
if(type == "OnPickup")
{
SetPlayerMoveSpeedMul(2.2f);
AddTimer("", 5.5f, "StopPlayer");
}
}
void StopPlayer(string &in timer)
{
SetPlayerMoveSpeedMul(1.0f);
}
This code will boost the player's speed by 2.2 times for 5.5 seconds, after he picks up "name".
(07-19-2013, 05:35 PM)hunchbackproduction Wrote: [ -> ]However, although that works I wanted something you activate inside your inventory. Anyway to do that ?
(07-19-2013, 09:16 PM)Your Computer Wrote: [ -> ](07-19-2013, 05:35 PM)hunchbackproduction Wrote: [ -> ]However, although that works I wanted something you activate inside your inventory. Anyway to do that ?
Perhaps mess around with item combinations.