Aller au contenu

Photo

gp_treasure_op_de


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

#1
Youkai

Youkai
  • Members
  • 44 messages
 I am currently trying to get this script to work as a basic treasure-generation script for my PW that is nearing release. I have applied it to the "onopen" and "ondeath" scripts for many containers. It does generate random treasure as advertised, but it does not seem to vary based on the variables I input onto those containers. For example, one container has a variable of "TreasureType" being set to 16. It should drop only magic items based on that, or be more likely to do so. I have yet to have it yield anything more than disposables, gold, or gems.
I was wondering if I was using the variables field correctly. On all of my containers I have one variable named "Treasureclass" and one named "TreasureType." Treasureclass has a number of -1 to 2 listed on its string and TreasureType has one of several numbers listed in the script entered into its string field.
I hope what I explained makes sense enough for anyone to tell if I am using this script properly. Any advice will be appreciated!


Here is a link with information on the script: Link

Modifié par Youkai, 27 décembre 2011 - 02:47 .


#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
The variables are ints, not strings. Make sure the integer field is filled out to what you want, not the string field, and that the variables are listed as ints.

#3
Morbane

Morbane
  • Members
  • 1 883 messages
If you read the comments of the script - it says that the higher level items have been disabled. You will have to edit the script to accept higher level items and treasure. (iirc)

I made one if you are interested - it will take some doing to find it but it definitely works correctly.

#4
Morbane

Morbane
  • Members
  • 1 883 messages
// 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, 4d20 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, 28 décembre 2011 - 01:15 .


#5
Morbane

Morbane
  • Members
  • 1 883 messages
Be aware that Treasureclass 2 can generate some overpowered items - it is just the way the constants go into the DTSGenerateTreasureOnContainer (OBJECT_SELF, oOpener, iTreasureclass, iTreasureType); But it does add to the same ol same ol +1 whatever

Modifié par Morbane, 28 décembre 2011 - 09:02 .


#6
Youkai

Youkai
  • Members
  • 44 messages
Thank you for your replies guys, I appreciate it!
Yes, I noticed that about the script Morbane. I figure with additional tweaking one could "balance" it out even more. Thanks for the modified script too. I noticed that about Treasureclass 2 after applying it to some "rare" spawning containers. Sometimes it creates over 4000 in gold too! I will reserve that class for near-epic level and higher dungeons. Right now I have it set to 0s for most containers, 1s are used for "boss" containers.
I have even found this script to be useful for generating random treasure on creatures as well.

#7
Morbane

Morbane
  • Members
  • 1 883 messages

Youkai wrote...
I have even found this script to be useful for generating random treasure on creatures as well.


That is a good idea - did you have to tweak the script for it to work on creatures or did it work out of the box?

#8
Youkai

Youkai
  • Members
  • 44 messages
Hey Morbane, it worked right out of the box. Pretty cool, eh?

#9
Morbane

Morbane
  • Members
  • 1 883 messages
Just curious - are you using my modified script or the generic script?

#10
Youkai

Youkai
  • Members
  • 44 messages
The generic script for now. I have not applied your script yet, though I do like the idea of being able to have those "unique" items drop rather than just having generic +1 blades and such drop.