Roi / Reine
|
Yop,
Bon, plusieurs jours que je me débats avec un script que je n'arrive pas à faire fonctionner. Il utilise 2 includes : Code:
/* "location_valid" PLZ Read Genjis txt header just below!!! You still need null_human. I needed a location checker to random place a lift from a airship, most of the script i found didn't work as desired, placing the lift in holes/cliffs/... and on some tilesets it didn't work at all, sometimes it the placeable was placed on the edge of a tile (to water), and the placeables angle was facing the water preventing the PC from using it anyway... I modified Genji's GetIsLocationValid() script so that it returns FALSE if nwn moves the "null_humal", checking X/Z coordinates, ignoring Z. Lastly, moving a PC to a location below/above floorlevel of a tileset, would result in nwn fixing its height... this is not so for placeables (planted in ground/hanging in air). Now, when this script returns a TRUE, a locallocation is saved on the object running this script, which should logically be the one who called the function from "opendoor", this locallocation is the ValidLocation with a fixed Z to be used to create placeables at that location. "open door" can access it via GetLocalLocation(OBJECT_SELF,"Landing_Height"); the localvar can then be deleted to keep ur module clean. If you are only moveing a PC/NPC around then edit out all locallocation parts in this script, its only there for random placeables to spawn at floor level. DONT use this in a (posible) infinite while loop!: "while(GetIsLocationValid()){}" i got it to work fine by looping it 5-10 times. See how i did it in 'dooropen' script. ma'drynn 27/1/2005 ck_madrynn Code:
location GetRandomLocation(int iMinDistance, int iMaxDistance) //CREATED BY: CCC_MADNESS //DATE: 1/23/2003 //FUNCTION INFO: THIS FUNCTION RETURNS A RANDOM LOCATION SOMEWHERE BETWEEN THE MAX AND MIN // DISTANCES SPECIFIED. //USE: location lRandomLoc = GetRandomLocation(iMin, iMax); { //Set Variables int iMeters = iMaxDistance; object oArea = GetArea(OBJECT_SELF); vector vMyPosition = GetPosition(OBJECT_SELF); //Generate X Coordinate iMeters = Random(iMeters*2) - iMeters; //Ensure that the X Coordinate is the correct distance away from the object if ((iMeters > (iMinDistance * -1)) && (iMeters < 0)) { iMeters = iMeters - iMinDistance; } if ((iMeters < (iMinDistance)) && (iMeters > 0)) { iMeters = iMeters + iMinDistance; } float fX = IntToFloat(iMeters) + vMyPosition.x; //Generate Y Coordinate iMeters = iMaxDistance; iMeters = Random(iMeters*2) - iMeters; //Ensure that the Y Coordinate is the correct distance away from the object if ((iMeters > (iMinDistance * -1)) && (iMeters < 0)) { iMeters = iMeters - iMinDistance; } if ((iMeters < (iMinDistance)) && (iMeters > 0)) { iMeters = iMeters + iMinDistance; } float fY = IntToFloat(iMeters) + vMyPosition.y; //Copy Z Coordinate float fZ =vMyPosition.z; //Generate New Vector and Facing vector vPosition = Vector(fX, fY, fZ); float fFacing =GetFacingFromLocation(GetLocation(OBJECT_SELF)); //Generate New Location location lRandomLocation = Location(oArea, vPosition, fFacing); return lRandomLocation; } Voici mon script, que je place dans le OnEnter d'une zone : Code:
#include "locationvalid" #include "aaa_test" void main() { int nVL = FALSE; int nTh = 0; location lExit; while((nVL == FALSE) && (nTh < 30)) { lExit = GetRandomLocation(1,4); //our random location nVL = GetIsLocationValid(lExit); //test it nTh++; //add to counter } //Is the location valid? if(nVL == TRUE) { //Get the height-corrected location lExit = GetLocalLocation(OBJECT_SELF,"Landing_Height"); object oExit = CreateObject(OBJECT_TYPE_PLACEABLE,"sentierdubois",lExit,FALSE); DeleteLocalLocation(OBJECT_SELF,"Landing_Height"); } } Pliz èlp. |
![]() |
|
Problème avec mon script de création d'un objet sur un point aléatoire
Suivre |
|
Partager | Rechercher |
Suivre |
Connectés sur ce fil1 connecté (0 membre et 1 invité)
Afficher la liste détaillée des connectés
|