Aller au contenu

Photo

Generating Items, Scripting Challenge


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

#1
UltimaPhoenix

UltimaPhoenix
  • Members
  • 24 messages
The campaign I envsion will involve the collection of resources by the player to craft items as part of a survival-type of experience, and they either destroy an object or by access its inventory to get a specific resource. I want to randomly generate the amount of a specific item that the player will recieve. For example, if the player cuts down a tree, they get x + nd6 pieces of wood. Similarily, if they access a pile of rocks, they find x + nd6 stones.

Another point that I could use some help with would be changing the kind of loot a creature drops.

Third, I have special creatures that will constantly be a threat to the PC throughout the campaign that not only appear randomly, but also being to respond to the threat the PC becomes to them. Essentially, I want these creatures to attack at random, subsequently get their butt's kick, and then respond by increasing the severity of the encounters while the PC is killing them off all during one encounter. How do I implement this?

Thanks alot, guys!

Modifié par UltimaPhoenix, 17 juin 2012 - 02:05 .


#2
rjshae

rjshae
  • Members
  • 4 509 messages
For the middle one, I believe the dropped loot is determined by the nw_c2_default9 spawn-in script, which calls routines in the treasure generation system in x0_i0_treasure. The generate treasure calls are in nw_o2_coninclude. I guess you could either override those or perhaps use a custom death script.

#3
Morbane

Morbane
  • Members
  • 1 883 messages
#1... dont know much about crafting but useable placeables can achieve the examples you gave with some basic scripting

#2 again...

op_treasure**

can be modified to be onDeath

#3... is something that will take a lot of work - not impossible but definitely will require triggers and advanced scripting - time to search for scripting tutorials - a good place to start is a topic in this (Scripting) forum -> Scripting Resources....

#4
Morbane

Morbane
  • Members
  • 1 883 messages
also look on the Vault for "Lilac Soul's" "Scripting Generator" - everyone starts there - mostly anyways

#5
UltimaPhoenix

UltimaPhoenix
  • Members
  • 24 messages
Thanks a lot, guys.

Quick follow-up. As for the randomly generating the inventory contents, in cases where it would make sense, I would like to prevent the PC from accessing the inventory of an object before they destroy it. Even if I can't prevent that, upon the destruction of the object, I want the resource to appear. How would I implement that?

#6
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 603 messages
You can use my choppable tree script in this thread.

Regards

#7
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
I like to use the fewest amount of scripts possible. So another option would be to not give any of your placeables an inventory and just create the objects and do it all from one script in all your placeables OnDeath events. Something kinda like so for example:

//Placeable resources OnDeath script.
void main()
{
    string sTag = GetTag(OBJECT_SELF);
    location lLoc = GetLocation(OBJECT_SELF);
    int iObjectType;
    int iX;
    int iN;
    //You could also just add the X and N values as integer variables directly
    //to the placeable objects, then get rid of the iX and iN in each "if" below:
    //int iX = GetLocalInt(OBJECT_SELF, "MY_X_VALUE");
    //int iN = GetLocalInt(OBJECT_SELF, "MY_N_VALUE");
    string sResRef;

    if (sTag == "BIG_TREE")
    {
        iX = 4;
        iN = 2;
        iObjectType = OBJECT_TYPE_PLACEABLE;
        sResRef = "plc_woodpile";
    }
    if (sTag == "SMALL_TREE")
    {
        iX = 1;
        iN = 1;
        iObjectType = OBJECT_TYPE_ITEM;
        sResRef = "x2_it_cmat_elmw";
    }
    if (sTag == "IRON_ORE")
    {
        iX = 1;
        iN = 2;
        iObjectType = OBJECT_TYPE_ITEM;
        sResRef = "iron_ore";
    }
    //if (sTag == etc.....

    int iAmount = iX + d6(iN);

    //For items to appear on the ground at the location of the destroyed
    //placeable use this:
    int Y;
    for (Y = 0; Y <= iAmount; Y++)
    {
        CreateObject(iObjectType, sResRef, lLoc);
    }

    //For stack items to appear in the inventory of the destroyer use this:
    /*
    object oKiller = GetLastDamager(OBJECT_SELF);
    if (GetIsObjectValid(GetMaster(oKiller)))
    oKiller = GetMaster(oKiller);
    CreateItemOnObject(sResRef, oKiller, iAmount);
    */
}

Hope it helps.

P.S. I used the Aurora  toolset to whip this up. Hopefully functions used are the same.

Modifié par GhostOfGod, 18 juin 2012 - 04:02 .


#8
The Fred

The Fred
  • Members
  • 2 516 messages
Do you not get wonky behaviour (i.e. "opening" the tree) if you give it an inventory? You can set the default action to attack, but I think people can still use it normally.

What I would do is just set the resref of the item as a variable on the placeable, then look it up in the script. You could have variables for the amount, too.

A slightly nicer version (though a little more work) would be to create a "chopped wood" placeable after killing the tree. When you click on the chopped wood, then you get it in your inventory. Also I would try to check that the tree was "killed" with e.g. an axe, or at least that it wasn't burnt down, and only give them the wood then - though that would be somewhat more awkward.