Page 1 of 1

Script to emplace a random placeable from a list?

PostPosted: Wed Aug 31, 2005 7:41 pm
Author: Starslayer_D
I am looking to create a script to emplace a random placeable from a predetermined list on a waypoint upon first entry of a character into an area. This is to provide modifications in the areas from server reset to serverreset.

Lists may be for outdoors/indoors eg, and place small things like vases or decorative plants upon several WP in the area.

That way, even a few areas will allways look different upon a visit after server reset.

Can someone give me ahand in develloping this?

PostPosted: Wed Aug 31, 2005 7:51 pm
Author: Final Shinryuu
Wow, this is a great idea. If someone can help you work this out, could I borrow it for buildings on Hades?

PostPosted: Thu Sep 01, 2005 12:22 am
Author: Jonezie
You'll need to know the resrefs of the placeables you want. Then it'd go something like...

Code: Select all
void main()
{
    int iRand = Random(3);
   
    string sResRef;

    object oWP = GetNearestObjectByTag("WP_RandPlc");
    location lWP = GetLocation(oWP);

    switch(iRand)
    {
         case 0:    sResRef = "placeable_1";    break;
         case 1:    sResRef = "placeable_2";    break;
         case 2:    sResRef = "placeable_3";    break;
    }

    CreateObject(OBJECT_TYPE_PLACEABLE, sResRef, lWP);

    DestroyObject(OBJECT_SELF);
}

Basically, that'll create a random placeable from a list of three at the nearest waypoint with tag "WP_RandPlc". You can add as many options as you like, you just have to add an additional case for each inside the switch, and increase the number in the random() function. Also the strings "placeable_1", etc should be replaced with the resrefs of the placeables you want to use.

This should be placed on the OnEnter event of a trigger, which is in the area where you want to be creating things. The last line means that the trigger will be destroyed after this script fires, so it'll only ever fire once - for the first person who enters.

One thing to keep in mind is that some placables are oriented 'backwards' from where you'd expect. So if you don't want to have couches and stuff spawn in facing the wall, you probably need to test it with each placeable you plan on using.

Enjoy,
J

PostPosted: Thu Sep 01, 2005 1:11 am
Author: Starslayer_D
*cheers* wonderfull, Jonezie.

I was more thinking about flovers, wases, bottles and other stuff without front. Or trees, stones etc. in the landscape.


And yes, Penguin, go ahead and borrow. If I wouldn't like others to see and use, would I have asked here? *grin*