PDA

View Full Version : Mudlib


xAndrewx
05-24-2007, 01:05 AM
The item information, obviously edit certain things. Make sure that the NPC server has rights to the folder.

Here's the item information, I decided to make this a database. It's vital that "temp.itemStuff.coreData" contains information. Scroll down to find out more!


function onCreated()
{
//name
temp.itemStuff.itemName = "sworda";

//item stuff
temp.itemStuff.coreData = {
{"description", "Here's my item information, it's a sword!"},
//description of the item

{"damages", {2, 5, 8}},
//min, avg and max

{"effects", {{"fire", 5}, {"ice", 2}, {"poison", 15}}},
//effect name, percentage hit/100

{"improvements", {{"dex", 2}, {"con", 5}, {"str", -5}}, {"speed", 0.3}},
//stat name, in/decrease amount

{"equip", true, {{"idle", "newIdle"}, {"walk", "newWalk"}}}
//auto equip, ganiData
};

temp.itemStuff.saveVars("docs/item_"@ temp.itemStuff.itemName @".arc", 0);
}


As you can see, without the coreData, it wouldn't store any important information. The coreData works as functions. Here's an example


{"improvements", {{"dex", 2}, {"con", 5}, {"str", -5}, {"speed", 0.3}}},


As you can see, it'll improve the dex, con and speed while reducing the str of the player. Here's how it works


{"FUNCTION NAME", {{"STRNAME", VALUE}, {"STRNAME", VALUE}}}


Now, for it to work you need the FUNCTIONNAME to exist! Without the function existing shall alert your RC that the function doesn't exist.
Changing the STRNAME to a stat that the player shall have.
They're saved in this format


clientr.("playerstat_"@ NAME OF THE STAT HERE)


Here's an example of how the str string shall look


clientr.playerstat_str=5


Obviously, editing the VALUE [negative or posative] shall assign the vector to the string!

Here's the functions to it.


//You'd need to replace this part. Use function onActionServerside(itemName)
function onCreated()
{
//Add your item checking here, if the player has the item, perform this function!
this.equipItem("sworda");
}
function equipItem(itemName)
{
//Now, we load the information of the item name being equip
temp.itemData.loadvars("docs/item_"@ temp.itemName @".arc");

//Now it reads the coreData, and then tells it to perform ech function
for (temp.currentFunction: temp.itemData.coreData)
{
//Found a function, now perform it!
this.("do"@ temp.currentFunction[0])(temp.currentFunction[1], temp.currentFunction[2]);
}

//inform the weapon that it's been equip on the serverside
//could also add your message system on the clientside, just add the item name as a param
player.triggerclient("weapon", this.name, "itemEquip");
}

//Assign the itemDescription to the player
function doDescription(itemDescription)
{

//Just a description of the current item equip
player.clientr.itemDescription = temp.itemDescription;
}

//Produce the damage the player currently has
function doDamages(damageData)
{

//The string names
temp.damageTypes = {"min", "avg", "max"};

//For each damage
for (temp.currentDamage: temp.damageData)
{

//Assign it to the player
player.clientr.("damage_"@ temp.damageTypes[temp.damageData.index(temp.currentDamage)]) += temp.currentDamage;
}
}
//Produces clientr.damage_min=5, clientr.damage_avg=5 and clientr.damage_max=7

//The effects that the player currently has
function doEffects(effectNames)
{

//Clear the current weapon effects
player.clientr.weaponeffects.clear();

//Assign some new weapon effects
player.clientr.weaponeffects.addArray(temp.effectN ames);
}
//You'd use this for a damage system, for (temp.currentEffect: player.clientr.weaponEffects) etc

//Here's the player stats being assigned
function doImprovements(improvementData)
{

//For each stat
for (temp.currentStat: temp.improvementData)
{

//Assign it to the player
player.clientr.("playerstat_"@ temp.currentStat[0]) += temp.currentStat[1];
}
}
//Produces player.clientr.playerstat_dex=5, player.clientr.playerstat_str=7 etc

//Assigns the gani's to the player as a string, has the choice of auto equiping the item once called
function doEquip(autoEquip, ganiData)
{

//Let's clear the current gani data
player.clientr.ganiData.clear();

//Now we'll add the new one
player.clientr.ganiData.addArray(temp.ganiData);

//Should it auto equip the item?
if (temp.autoEquip)
{
//Trigger action here, here's the clientside part
for (temp.currentGani: temp.ganiData)
{
player.replaceani(temp.currentGani[0], temp.currentGani[1]);
}
}
}


Now, you'll see that it stores all the information in seperate strings.
Why did I do this you ask? Simple, I made one array which contained the items that the player has.

player.clientr.currentItems = {{"sworda", x}, {"swordb", 5}};

Adding / removing items from this array and obviously check if the player still has the items before the above functions are performed!

Skyld
05-24-2007, 01:45 AM
Please provide a decent amount of information as to the setting up, use and functionality of this code. Your description is inexistent, directions for use are scarce and some people are likely not to understand what this is for, or what you are supposed to do with it.

xAndrewx
05-24-2007, 08:50 AM
Okay, :)

[Re-read top post]

Deadly_Killer
05-25-2007, 05:43 AM
Hi!