Modifié par christinetooley, 08 mars 2011 - 04:18 .
script gods, once again i implore u!
#1
Posté 08 mars 2011 - 02:18
#2
Posté 08 mars 2011 - 04:57
To have the "random" placement, create 3 times the number of waypoints as you need in the area and tag them with a number (like "random_1", "random_2", ...). Then, one time only, in the on client enter script of the area randomly spawn your placeable in a third of the locations.
The regrowing part is probably trickier. In the on use script you could hide the placeable and set a variable on it indicating the time that it should be regrown. Then in the on heartbeat script of the area you can loop through the used ones and if the current time is equal to or exceeds the regrown time then unhide the placeable.
Regards
#3
Posté 08 mars 2011 - 05:16
/**
* Get the (roughly) center point of an area, can adjust for height.
* @author
* @param
* @see
* @return
*/
location CSLGetCenterPointOfArea(object oArea, float fheightAdjust = 0.0f)
{
// GetIsObjectValid(oArea);
int iHeight = GetAreaSize( AREA_HEIGHT, oArea );
if ( iHeight == 0 )
{
oArea = GetArea(oArea);
iHeight = GetAreaSize( AREA_HEIGHT, oArea );
}
int iWidth = GetAreaSize( AREA_WIDTH, oArea );
float fY = 10.0f;
float fX = 10.0f;
// convert to meters
if ( GetIsAreaInterior( oArea ) )
{
fY = ( ( (iHeight* 9.0f) / 2) + 0.45f);
fX = ( ( (iWidth*9.0f) / 2) + 0.45f);
}
else
{
fY = ( ( (iHeight*10.0f) / 2) + 0.5f);
fX = ( ( (iWidth*10.0f) / 2) + 0.5f);
}
return Location(oArea, Vector(fX, fY, 0.0+fheightAdjust), 0.0f );
}
/**
* Get a random location in a given area based on a given object,
* the specified distance away.
* If no object is given, will use a random object in the area.
* If that is not available, will use the roughly-center point
* of the area.
* If distance is <= to 0.0, a random distance will be used.
* @author
* @param
* @see
* @return
*/
location CSLGetRandomLocation( object oArea, object oSource=OBJECT_INVALID, float fDist=0.0f )
{
location lStart;
if ( GetIsObjectValid( oSource ) == FALSE )
{
lStart = CSLGetCenterPointOfArea( oArea );
}
else
{
lStart = GetLocation( oSource );
}
// BMA-OEI 7/13/06 float precision
if ( fDist <= 0.001f )
{
fDist = IntToFloat( Random( FloatToInt( SC_DISTANCE_HUGE - SC_DISTANCE_TINY ) * 10 ) ) / 10;
}
float fAngle = IntToFloat( Random( 360 ) );
float fOrient = IntToFloat( Random( 360 ) );
location lRandLoc = CSLGenerateNewLocationFromLocation( lStart, fDist, fAngle, fOrient );
return ( lRandLoc );
// if (fDist == 0.0) {
// int iRoll = Random(3);
// switch (iRoll) {
// case 0:
// fDist = SC_DISTANCE_MEDIUM; break;
// case 1:
// fDist = SC_DISTANCE_LARGE; break;
// case 2:
// fDist = SC_DISTANCE_HUGE; break;
// }
// }
//
// fAngle = IntToFloat(Random(140) + 40);
}
#4
Posté 08 mars 2011 - 08:00
#5
Posté 09 mars 2011 - 10:41
What I get from your post is something like... a plant, that when used by a player, gives the player an herb or berry or something an then the plant disappears.
If this is the case it can be done in the OnUsed event with a DelayCommand.
This is an example script(Note: This was done in NWN1 and is working):
const float RESPAWN_TIME = 10.0;//seconds till object respawns in rand location
const int NUM_OF_WPS = 3;//amount of random waypoints
const string WP_TAG = "PLANT_WP_";//this is the tag of your waypoints without the
//number at the end. Example: if you give your
//waypoints the tag "PLANT_WP_1", "PLANT_WP_2",
//etc.., then WP_TAG should be "PLANT_WP_".
const string ITEM_GET = "nw_it_msmlmisc12";//NWN1 default fenberry res ref
void RespawnMe(string sResRef, location lLocation, string sNewTag)
{
CreateObject(OBJECT_TYPE_PLACEABLE, sResRef, lLocation, FALSE, sNewTag);
}
void main()
{
object oPC = GetLastUsedBy();
string sMyResRef = GetResRef(OBJECT_SELF);
object oArea = GetArea(OBJECT_SELF);
int iRandom = Random(NUM_OF_WPS) + 1;
string sWaypoint = WP_TAG + IntToString(iRandom);
location lNewLoc = GetLocation(GetWaypointByTag(sWaypoint));
string sMyTag = GetTag(OBJECT_SELF);
AssignCommand(oArea, DelayCommand(RESPAWN_TIME, RespawnMe(sMyResRef, lNewLoc, sMyTag)));
CreateItemOnObject(ITEM_GET, oPC);
DestroyObject(OBJECT_SELF, 0.1);
}
Hopefully this is what you are looking for or at least gets things moving in the right direction.
Also not: If i remember correctly the function "GetWaypointByTag" wasn't working in NWN2? If it isn't then this function would just have to be replaced with "GetObjectByTag".
Modifié par GhostOfGod, 09 mars 2011 - 10:46 .
#6
Posté 09 mars 2011 - 07:26
#7
Posté 24 mars 2011 - 03:49





Retour en haut






