Server Totals
Ferrell - (7)
M'Chek - (1)
Visimontium - (0)
Wilderness - (0)
Elysia - (0)
Le'Or - (0)
Deglos - (0)
Underdark - (0)
Mikona - (0)
Total players: 8
Gallery
  • Emerald Grove at Night
    Album name: DM Events
    Uploaded by: Ronan
    Uploaded: Wed Aug 20, 2014 3:33 am

Links Menu

Script to emplace a random placeable from a list?

Moderators: Nighthawk4, Dungeon Masters

Script to emplace a random placeable from a list?

PostAuthor: Starslayer_D » Wed Aug 31, 2005 7:41 pm

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?
ashzz: at the very core of the problem is that good characters and organizations can do much more EVIL in the name of good than evil can do evil.
Daerthe: There is only room for so much realism before things start to get silly

Starslayer_D
Master Sage
 
Posts: 5182
Joined: Thu Oct 24, 2002 7:35 pm
Location: Germany (+1 GMT)

PostAuthor: Final Shinryuu » Wed Aug 31, 2005 7:51 pm

Wow, this is a great idea. If someone can help you work this out, could I borrow it for buildings on Hades?
User avatar
Final Shinryuu
Sage
 
Posts: 2060
Joined: Thu Jun 24, 2004 3:20 am
Location: http://hades.mercuric.net/

PostAuthor: Jonezie » Thu Sep 01, 2005 12:22 am

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
User avatar
Jonezie
Team Member; Retired with Honors
 
Posts: 3906
Joined: Wed Jun 09, 2004 7:05 am
Location: Melbourne (GMT +10)

PostAuthor: Starslayer_D » Thu Sep 01, 2005 1:11 am

*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*
ashzz: at the very core of the problem is that good characters and organizations can do much more EVIL in the name of good than evil can do evil.
Daerthe: There is only room for so much realism before things start to get silly

Starslayer_D
Master Sage
 
Posts: 5182
Joined: Thu Oct 24, 2002 7:35 pm
Location: Germany (+1 GMT)


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], galen_macbyrne, Google [Bot], Gorgon, MusicOfLight, Tel