Please, could you help me ? :)

:grinning: hi, friends, could you help me obout scripting?

1) ON DEATH: I would like the creaure killed create ONE RANDOLY OF A SPECEFIC ITEM (funcion “&&” to create)

void main()
{

object oPC = GetLastKiller();

object oTarget;
object oSpawn;
location lTarget;
oTarget = OBJECT_SELF;

lTarget = GetLocation(oTarget);

(oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, “goldpile”, lTarget))&&
(oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, “scroll”, lTarget)&&
(oSpawn = CreateObject(OBJECT_TYPE_ITEM, “pocion”, lTarget));

}

2) I have many scipts like this, with a floating text

     void main()

{

object oPC = GetLastKiller();

while (GetIsObjectValid(GetMaster(oPC)))
{
oPC=GetMaster(oPC);
}

if (!GetIsPC(oPC)) return;

FloatingTextStringOnCreature(“Ya quedan menos”, oPC);

}

Could i have this scipts on one? I dont care if its talken randomly or continued

Thaaaanks :slight_smile:

Potentially, there are solutions which work for both problems.

You need a list, from which you choose sequentially or randomly, as you prefer.

Perhaps the simplest way to make a list is SetLocalArrayString. Whether it’s a list of treasure item resrefs or floating text strings, assign the values to elements 1, 2, 3… of a string array.

Store the number of elements somewhere - SetLocalInt on the module, for example.

To retrieve values sequentially, store the value of the next available element (initially 1) in another local int. Update by 1 every time you use a string.

To pick a random element, choose string array number (Random(n)+1) where n is the number of elements. (The +1 is because Random returns a value between 0 and n-1).

Refinements are possible if you don’t want random elements to repeat, or if you want to start again once all the elements have been exhausted.

Another way to make a list is a custom 2da file, which you can make in a text editor, then read with Get2daString.

1 Like

Thanks, guy…but
lool?
No idea you are talking about, i just use cuy&copy Aurora toolset, :sweat_smile: :sweat_smile:
It is a standar script to be used on thousands of creaures…

There is no way that script number one would compile let alone run. The following is what I think you were trying for. It combines both script one and two into a single script to go into the creatures OnDeath event.

void main()
{
    object oSpawn;
    object oPC = GetLastKiller();
    int iRandomLoot = d3();
    
    while(GetIsObjectValid(GetMaster(oPC)))
    {
        oPC = GetMaster(oPC);
    }

    if(GetIsPC(oPC))
    {
        switch(iRandomLoot) // give random loot
        {
            case 1:
                oSpawn = CreateItemOnObject("goldpile", OBJECT_SELF, 1);
                break;
            case 2:
                oSpawn = CreateItemOnObject("scroll", OBJECT_SELF, 1);
                break;
            case 3:
                oSpawn = CreateItemOnObject("potion", OBJECT_SELF, 1);
                break;
        }
        
        FloatingTextStringOnCreature("Ya quedan menos", oPC);
    }
}

Note there is no error checking whatsoever. Also, in future you need to put any code you post on here between [code] and [/code] otherwise people trying to help will get errors from it when they copy it.

TR

1 Like

Thanks you very,very much, it is just i was looking for. :slight_smile: :smiley:

In the fact, it was two independents questions, - one for treasure* other for floating text - lool…y expreded bad, but it s better i wanted…lool! :sweat_smile: :sweat_smile: