Friday, March 9, 2007

Custom Treasure Systems

One thing that I found increasingly annoying as I was playing the original campaign and experimenting with some of my first areas in the Toolset was the fact that I could search a weapon rack and wind up picking up a healer's kit...or a ring. Why would anyone store a healer's kit on a weapon rack!? So I decided to take the treasure table that I'd created for an adventure awhile back and create a custom script that could be used in the game to hand out what seemed appropriate.

The script itself is pretty straightforward, so I'll just let the code speak for itself. This weekend I plan on finishing up my first exterior area and completing the town of Marketh, so I'm sure I'll have some new tidbits to share come Monday...


// First attempt at making a script to assign weapon treasure to an object (weapon rack).
// Cliff G~~~~~~ (~~~~~~@gmail.com) - February 11, 2007

#include "x2_inc_treasure"
#include "nw_o2_coninclude"
#include "x2_inc_compon"
#include "ginc_debug"

void main()
{

if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0)
{
return;
}

object oOpener = GetLastOpener();

int iCount = d100(1);
int x = 0;

// Calculate the number of items that will be found on the weapon rack:
// 01 - 40 = 1 item
// 41 - 80 = 2 items
// 81 - 95 = 3 items
// 95 - 99 = 4 items
// 00 = 0 items (critical failure)

if (iCount < 51) {
iCount = 1;
}
else if (iCount > 51 && iCount < 76) {
iCount = 2;
}
else if (iCount > 75 && iCount < 96) {
iCount = 3;
}
else if (iCount < 100){
iCount = 4;
}
else {
FloatingTextStringOnCreature("You find nothing but dust and metal shavings.",OBJECT_SELF,FALSE,5.0);
return;
}

for (x = 0;x < iCount;x++)
{

string strObjectTag = GetTag(OBJECT_SELF);
int iDiceRoll = 0;
int iDiceRollSub = 0;

if (strObjectTag == "MOD_PLC_MC_WEAPRCK03")
{
//Weapon Rack 1 is the most primitive-looking, so it has the least valuable items:
// 01 - 50 = Simple Weapon
// 51 - 80 = Martial Weapon
// 81 - 00 = Light Armor

iDiceRoll = d100(1);
if (iDiceRoll < 51) {
CreateGenericSimple(OBJECT_SELF,oOpener,0);
}
else if (iDiceRoll > 50 && iDiceRoll < 81) {
CreateGenericMartial(OBJECT_SELF,oOpener,0);
}
else {
CreateGenericLightArmor(OBJECT_SELF,oOpener,0);
}
}

else if (strObjectTag == "MOD_PLC_MC_WEAPRCK02")
{
// Weapon Rack 2 looks less primitive, so it should have some better stuff:
// 01 - 25 = Simple Weapon
// 26 - 50 = Martial Weapon
// 51 - 75 = Class Weapon
// 01 - 33 = Wizard Weapon
// 34 - 66 = Monk Weapon
// 67 - 00 = Druid Weapon
// 75 - 00 = Armor
// 01 - 75 = Light
// 76 - 00 = Medium

iDiceRoll = d100(1);
if (iDiceRoll < 26) {
CreateGenericSimple(OBJECT_SELF,oOpener,0);
}
else if (iDiceRoll > 25 && iDiceRoll < 51) {
CreateGenericMartial(OBJECT_SELF,oOpener,0);
}
else if (iDiceRoll > 50 && iDiceRoll < 76) {
iDiceRollSub = d100(1);
if (iDiceRollSub < 34) {
CreateGenericWizardWeapon(OBJECT_SELF,oOpener,0);
}
else if (iDiceRollSub > 33 && iDiceRollSub < 67) {
CreateGenericMonkWeapon(OBJECT_SELF,oOpener,0);
}
else {
CreateGenericDruidWeapon(OBJECT_SELF,oOpener,0);
}
}
else {
iDiceRollSub = d100(1);
if (iDiceRollSub < 76) {
CreateGenericLightArmor(OBJECT_SELF,oOpener,0);
}
else {
CreateGenericMediumArmor(OBJECT_SELF,oOpener,0);
}
}
}

else if (strObjectTag == "MOD_PLC_MC_WEAPRCK01")
{
// Weapon Rack 1 looks the most advanced; thus, it has the best loot table:
// 01 - 50 = Weapon
// 01 - 33 = Martial
// 34 - 66 = Class Specific
// 01 - 33 = Wizard
// 34 - 66 = Monk
// 67 - 00 = Druid
// 67 - 00 = Exotic
// 51 - 90 = Armor
// 01 - 50 = Light
// 51 - 75 = Medium
// 76 - 00 = Heavy
// 91 - 00 = Wand/Staff/Wand

iDiceRoll = d100(1);
if (iDiceRoll < 51) {
iDiceRollSub = d100(1);
if (iDiceRollSub < 34) {
CreateGenericMartial(OBJECT_SELF,oOpener,0);
}
else if (iDiceRollSub > 33 && iDiceRollSub < 67) {
int iPercClass = d100(1);
if (iPercClass < 34) {
CreateGenericWizardWeapon(OBJECT_SELF,oOpener,0);
}
else if (iPercClass > 33 && iPercClass < 67) {
CreateGenericMonkWeapon(OBJECT_SELF,oOpener,0);
}
else {
CreateGenericDruidWeapon(OBJECT_SELF,oOpener,0);
}
}
else {
CreateGenericExotic(OBJECT_SELF,oOpener,0);
}
}
else if (iDiceRoll > 50 && iDiceRoll < 91) {
iDiceRollSub = d100(1);
if (iDiceRollSub < 51) {
CreateGenericLightArmor(OBJECT_SELF,oOpener,0);
}
else if (iDiceRollSub > 50 && iDiceRoll < 76) {
CreateGenericMediumArmor(OBJECT_SELF,oOpener,0);
}
else {
CreateGenericHeavyArmor(OBJECT_SELF,oOpener,0);
}
}
else {
CreateGenericRodStaffWand(OBJECT_SELF,oOpener,0);
}
}
else {
// If this is not one of the identified Weapon Rack types, put some gold on the item.
CreateGold(OBJECT_SELF,oOpener,4,0);
}
}

SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
ShoutDisturbed();

}

No comments: