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?
Script to emplace a random placeable from a list?
Moderator: Event DM
-
- Master Sage
- Posts: 5178
- Joined: Thu Oct 24, 2002 7:35 pm
- Location: Germany (+1 GMT)
- Contact:
Script to emplace a random placeable from a list?
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
Daerthe: There is only room for so much realism before things start to get silly
- Final Shinryuu
- Sage
- Posts: 2060
- Joined: Thu Jun 24, 2004 3:20 am
- Location: http://hades.mercuric.net/
- Jonezie
- Team Member; Retired with Honors
- Posts: 3905
- Joined: Wed Jun 09, 2004 7:05 am
- Location: Melbourne (GMT +10)
You'll need to know the resrefs of the placeables you want. Then it'd go something like...
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
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);
}
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
-
- Master Sage
- Posts: 5178
- Joined: Thu Oct 24, 2002 7:35 pm
- Location: Germany (+1 GMT)
- Contact:
*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*
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
Daerthe: There is only room for so much realism before things start to get silly