Aller au contenu

Photo

Loot Script


  • Veuillez vous connecter pour répondre
12 réponses à ce sujet

#1
andysks

andysks
  • Members
  • 1 652 messages
Hi I have a script here provided from ColorsFade which is a simple random loot script, which creates some basic loot like arrows and stuff based on some variables. It is a remake of the script for containers, problems is it gives broken items to creatures too when they die. I guess it treats them like containers because they have inventory and get hit. Does anyone know how to remove this... like a line which needs commenting or something?

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


const string GOLD_ITEM_RES_REF = "nw_it_gold001";
// gold!
// local ints stored on the chestconst string VAR_TREASURE_CLASS = "TreasureClass";
const string VAR_TREASURE_TYPE = "TreasureType";
const string VAR_TREASURE_CLASS = "TreasureClass";

void main()
{
// craft_drop_placeable();
if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0)
{
return;
}
object oOpener = GetLastOpener();
int iTreasureClass = GetLocalInt(OBJECT_SELF, VAR_TREASURE_CLASS);
int iTreasureType = GetLocalInt(OBJECT_SELF, VAR_TREASURE_TYPE);

if (iTreasureClass != X2_DTS_CLASS_NONE)
{
if (iTreasureType == 0) iTreasureType = X2_DTS_TYPE_DISP | X2_DTS_TYPE_GOLD;
// if bashed, replace disposable w/ broken item

// remove Tresure Type "Item" - these don't scale and are to
dangerous for balance reasons // to have in the standard treasure
generation if (iTreasureType & X2_DTS_TYPE_ITEM)
{
iTreasureType = iTreasureType & (~X2_DTS_TYPE_ITEM);
}
int iNumGenerated = DTSGenerateTreasureOnContainer (OBJECT_SELF, oOpener, iTreasureClass, iTreasureType);

// everything must have something... // if we didn't generate
anything then add a smidgen of gold if (iNumGenerated == 0)
{
CreateItemOnObject(GOLD_ITEM_RES_REF, OBJECT_SELF, d20(1));
}
}
SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
ShoutDisturbed();
}

#2
Morbane

Morbane
  • Members
  • 1 883 messages
sometimes the "random" produces the "broken item" item - especially when the script focuses on "low magic" - or the lower end in general

this is my "medium treasure" script - I chopped up a stock script - it might provide some insight...

// gp_treasure_op_de
/*
Spawns in general purpose treasure and gold based on variables:

TreasureClass - one of three values. Default is low
const int X2_DTS_CLASS_NONE = -1; //Treasure Class None (generate nothing)
const int X2_DTS_CLASS_LOW = 0; //Treasure Class Low
const int X2_DTS_CLASS_MEDIUM = 1; //Treasure Clas Medium
const int X2_DTS_CLASS_HIGH = 2; //Treasure Class High

TreasureType - add desired types together. For example, gold + disposable = 5
Defualt is 5 (gold + disp)
Note that you cannot add the same type more than once (i.e. no gold+gold).
const int X2_DTS_TYPE_DISP = 1;
const int X2_DTS_TYPE_AMMO = 2;
const int X2_DTS_TYPE_GOLD = 4; // actually gold and gems
const int X2_DTS_TYPE_ITEM = 8; // char specific Item (ignores treasure class)
const int X2_DTS_TYPE_MAGIC = 16; // random magic items
const int X2_DTS_TYPE_MUNDANE = 32; // random mundane items

This script should be placed in the container's OnOpen and OnDeath events.
If bashed, disposeable will be dropped and broken item generated.
If no treasures are generated, 1d20 gold will be created.
*/
// ChazM 5/26/06
// ChazM 7/31/06 Added broken items when bashing
// ChazM 8/7/06 Generate smidgen of gold if nothing else was generated. Set broken item to proper resref.
// ChazM 8/30/06 Fixed broken item res ref.
// ChazM 9/5/06 Disallowed treasure type X2_DTS_TYPE_ITEM
// ChazM 5/31/07 - added support for X2_DTS_CLASS_NONE

// Morbane 2/25/10 - Made TreasureClassItem available = 8

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

const string BROKEN_ITEM_RES_REF = "n2_it_brokenitem"; // the catch-all broken item
const string GOLD_ITEM_RES_REF = "nw_it_gold001"; // gold!

// local ints stored on the chest
const string VAR_TREASURE_CLASS = "TreasureClass";
const string VAR_TREASURE_TYPE = "TreasureType";


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

object oOpener = GetLastOpener();

int iTreasureClass = GetLocalInt(OBJECT_SELF, VAR_TREASURE_CLASS);
int iTreasureType = GetLocalInt(OBJECT_SELF, VAR_TREASURE_TYPE);

if (iTreasureClass != X2_DTS_CLASS_NONE)
{
if (iTreasureType == 0)
iTreasureType = X2_DTS_TYPE_DISP | X2_DTS_TYPE_GOLD;

else if (iTreasureType == 2)
iTreasureType = X2_DTS_TYPE_AMMO | X2_DTS_TYPE_GOLD;

else if (iTreasureType == 4)
iTreasureType = X2_DTS_TYPE_GOLD | X2_DTS_TYPE_GOLD;

else if (iTreasureType == 8)
iTreasureType = X2_DTS_TYPE_ITEM | X2_DTS_TYPE_GOLD;

else if (iTreasureType == 16)
iTreasureType = X2_DTS_TYPE_MAGIC | X2_DTS_TYPE_GOLD;

else if (iTreasureType == 32)
iTreasureType = X2_DTS_TYPE_MUNDANE | X2_DTS_TYPE_GOLD;


int iNumGenerated = DTSGenerateTreasureOnContainer (OBJECT_SELF, oOpener, iTreasureClass, iTreasureType);
// everything must have something...
// if we didn't generate anything then add a smidgen of gold
if (iNumGenerated == 0)
{
CreateItemOnObject(GOLD_ITEM_RES_REF, OBJECT_SELF, d20(4));
}
}
SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
ShoutDisturbed();
}


Modifié par Morbane, 21 septembre 2013 - 02:25 .


#3
Morbane

Morbane
  • Members
  • 1 883 messages
to answer you question:

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


const string GOLD_ITEM_RES_REF = "nw_it_gold001";
// gold!
// local ints stored on the chestconst string VAR_TREASURE_CLASS = "TreasureClass";
const string VAR_TREASURE_TYPE = "TreasureType";
const string VAR_TREASURE_CLASS = "TreasureClass";

void main()
{
// craft_drop_placeable();
if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0)
{
return;
}
object oOpener = GetLastOpener();
int iTreasureClass = GetLocalInt(OBJECT_SELF, VAR_TREASURE_CLASS);
int iTreasureType = GetLocalInt(OBJECT_SELF, VAR_TREASURE_TYPE);

if (iTreasureClass != X2_DTS_CLASS_NONE)
{
if (iTreasureType == 0) iTreasureType = X2_DTS_TYPE_DISP | X2_DTS_TYPE_GOLD; 
// if bashed, replace disposable w/ broken item<------------***** LOOK HERE

// remove Tresure Type "Item" - these don't scale and are to
dangerous for balance reasons // to have in the standard treasure
generation if (iTreasureType & X2_DTS_TYPE_ITEM)
{
iTreasureType = iTreasureType & (~X2_DTS_TYPE_ITEM);
}
int iNumGenerated = DTSGenerateTreasureOnContainer (OBJECT_SELF, oOpener, iTreasureClass, iTreasureType);

// everything must have something... // if we didn't generate
anything then add a smidgen of gold if (iNumGenerated == 0)
{
CreateItemOnObject(GOLD_ITEM_RES_REF, OBJECT_SELF, d20(1));
}
}
SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
ShoutDisturbed();
}


Modifié par Morbane, 21 septembre 2013 - 02:31 .


#4
andysks

andysks
  • Members
  • 1 652 messages
That could be yes. Since the first chapter of my campaign gets you to level 5 roughly, loot is pretty much low. Maybe that's why it generates the broken items.

#5
andysks

andysks
  • Members
  • 1 652 messages
But the line for the broken item is commeneted out, isn't it? So do they have broken items because of this or because the loot is low?

#6
Morbane

Morbane
  • Members
  • 1 883 messages
...not sure - i just spotted that comment - it might refer to the code below or above - im not sure now colorsfade does his comments - most of the time it refers to the code below....

#7
Morbane

Morbane
  • Members
  • 1 883 messages
seeing as though both versions of loot scrip are based on the same stock script - reading the comments in the one i posted might reveal your answer as i cannot directly see where the broken item code might fit in -

unless it is pulled out of an include

#8
andysks

andysks
  • Members
  • 1 652 messages
Could it be because of this line?
int iNumGenerated = DTSGenerateTreasureOnContainer (OBJECT_SELF, oOpener, iTreasureClass, iTreasureType);
It says OnContainer... well a creature has an inventory so it might be a container as well.
But the it say oOpener... is that normal?

#9
Morbane

Morbane
  • Members
  • 1 883 messages
nope - thats the one that puts the random loot in the chest - the DTS... function is in an include - find it and edit it (a copy of it) rename it and edit the include line.

#10
Morbane

Morbane
  • Members
  • 1 883 messages
comment out this line:

const string BROKEN_ITEM_RES_REF = "n2_it_brokenitem"; // the catch-all broken item

delete all instances (or comment out) of the BROKEN_ITEM......

Modifié par Morbane, 26 septembre 2013 - 07:45 .


#11
andysks

andysks
  • Members
  • 1 652 messages
This line BROKEN_ITEM_RES_REF = "n2_it_brokenitem"; // the catch-all broken item, appears only in one global script, which is gp_treasure_op_de. This is the default on open for containers I think. The variables I have on creatures, don't call for this one, but for the one I posted. This is the reason I am so confused. On the four includes, there is no line for broken item, neither on the script I posted. Where are there broken items come from? I think I'll just give every creature in my campaign a custom inventory with mundane items and what not. Could be better. Do the arrow, bullet etc blueprints come by default in stacks? Or do I need to create new for that?

#12
andysks

andysks
  • Members
  • 1 652 messages
Solved. Quite an idiot here. One of the creatures on my tests had the gp_treasure_op_de called as its DeathScript. So if one of five is dropping a broken item, i thought there is a general problem. Only when I relaxed and cleared my mind thought of checking the individual and not the script. Sorry if I confused others with me. Morbane you pointed in the right direction, since you said this about the const string. It got me thinking... how it was called. It wasn't. Only from the gp_treasure_op_de...

#13
Morbane

Morbane
  • Members
  • 1 883 messages
glad you sussed it out

ain't life grand?