Aller au contenu

Photo

Getting a Walkable location?


  • Veuillez vous connecter pour répondre
17 réponses à ce sujet

#1
Baaleos

Baaleos
  • Members
  • 1 330 messages
Is it possible to, via nwn scripting - Get a Location in an area, which conforms to

1. It must be on the ground or against a solid surface, and
2. It must not be inside a wall etc.



But the catch is, that it must return a semi-random location.



The plan I have, is to make a plane travelling system.



Similar to the Spectral Realm I have here....


But instead of being a Plane of Spirits, tinted blue, with music to suit, I was planning on having a player ability, that allows the player to travel to different planes depending on their elemental affinity.


eg - If you are aligned with Fire, you travel to the Fire Plane.
The result being you travel to a plane which is tinted in red, has firey ambient music etc, but the problem comes with placeable objects.


I want to be able to place certain placeable objects programatically in the area to suit the plane. eg - Random Distribution of Fire, and maybe Lava etc
(The lava comment just gave me an idea, isnt there tilemagix or something, that lets you turn water in an area to Lava, Ice and Grass - Bingo)


Anyhow..
Fire Plane = Fire all over the area
Earth Plane = Tree's and Grass
Air Plane = Er.... I dunno... Clouds?
Water Plane = Underwater sort of effect.


I can do most of this, I just need to work out a random distribution system, and be able to determine if the location generated conforms to a valid location, and wont materialize inside a wall.

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
The only way i know how to do this would be to create a creature into the area. This will make sure that the location the creature is in the walk mesh. Place a script in the onspawn of the creature to destroy the creature and create the placeable in the same location.

#3
Baaleos

Baaleos
  • Members
  • 1 330 messages
Hmm, suppose that would do it.

There are some functions in the #include "x0_i0_position" which can also be used to get Random Locations - Although I cant see it on the Lexicon - I remember seeing it in the Function List in Toolset.

I could use that function to spawn say.... 20 basic creatures at random locations in the area, and in the onSpawn event, have them destroy themselves, and spawn the placeables.

I just wonder if this will create too much overhead.

#4
Baaleos

Baaleos
  • Members
  • 1 330 messages
Has anyone used
x0_i0_infinite


string INF_BASE;
void INF_CreateRandomEncounter(object oArea, object oPC);
void INF_CreateRandomPlaceable(object oArea, object oPC);
string INF_GetEntryMessage();
string INF_GetReentryMessage();
string INF_GetReachStartMessage();
string INF_GetReturnToStartMessage();
string INF_GetReachRewardMessage();
string INF_GetReturnToRewardMessage();
string INF_GetPoolEmptyMessage();


This function looks interesting.
INF_CreateRandomPlaceable(object oArea, object oPC);


I havent had a chance to look at it.

#5
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

Baaleos wrote...

Has anyone used
x0_i0_infinite


string INF_BASE;
void INF_CreateRandomEncounter(object oArea, object oPC);
void INF_CreateRandomPlaceable(object oArea, object oPC);
string INF_GetEntryMessage();
string INF_GetReentryMessage();
string INF_GetReachStartMessage();
string INF_GetReturnToStartMessage();
string INF_GetReachRewardMessage();
string INF_GetReturnToRewardMessage();
string INF_GetPoolEmptyMessage();


This function looks interesting.
INF_CreateRandomPlaceable(object oArea, object oPC);


I havent had a chance to look at it.


Nope I hvae never seen that one before, 

If it does not work you can use Function - GetAreaSize to find your area size for your random locations.

#6
Xardex

Xardex
  • Members
  • 217 messages
The tile thingy allows you to place any tile anywhere as an effect. It wont be solid though, so generally its only used for stuff like grass, water and lava.

#7
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages

Baaleos wrote...

Hmm, suppose that would do it.

There are some functions in the #include "x0_i0_position" which can also be used to get Random Locations - Although I cant see it on the Lexicon - I remember seeing it in the Function List in Toolset.

I could use that function to spawn say.... 20 basic creatures at random locations in the area, and in the onSpawn event, have them destroy themselves, and spawn the placeables.

I just wonder if this will create too much overhead.

Lightfoot's way is the only way I know of to do it. I seem to recall someone - virusman, maybe? - looking at this issue and finding it too problematic to make a GetIsLocationWalkable because of z values or somesuch.

As for lag, so long as you only spawn the first, and Copy the rest of the creatures, it should be fine. I would probably stagger placeable creation slightly, once you have the locations, depending on how beefy your server is.

Funky

#8
Melkior_King

Melkior_King
  • Members
  • 135 messages
I had a similar problem and solved it.

I wanted a mini-boss in an area to "feed" off of a placeable object's "life" during battle until the placeable ran out of life.

Once the placeable ran out of life, I wanted it to explode and scatter gems around the room, near to where the placeable used to be.

In order to make the gems look realistic, I used the gemstone placeables as containers and created an appropriate gem inside each container.

The important point is that the floor was uneven (the skull-shaped floor) so I needed to find exactly where "floor height" was. The only realistic way to find the correct floor height was to create a NPC in a random location, find out where it was standing then destroy it.

Since the area was a single, self-contained mission, I set up the onenter for the area to check if the boss had been defeated or not, and to set up the area for the entering player if it hadn't already been set up before and the boss left unkilled.

As part of the onenter script, I made a loop which created NPCs randomly around the correct location and then stored the locations of those NPCs in variables on the area before destroying the NPCs.

Since all of the hard work is done during the onenter script, any lag caused is combined with the normal delay on loading a new area and therefore is less noticable.

When I need to create the placeables which contain the loot gems, I just access the variables I stored previously on the area.

Maybe you can do something similar?

Modifié par Melkior_King, 01 juin 2011 - 10:24 .


#9
Baaleos

Baaleos
  • Members
  • 1 330 messages
Yeah, suppose that idea is feasible.

In order to make sure that the system doesnt lag everytime it does it, I can have it so that the Locations of where the placeables are spawned, are stored persistently per area.


Meaning that next time the server resets, and runs the same function, it doesnt need to spawn NPC's to get the data, because the server will have the position date already on hand.


If I wanted to be really fanci, I could have the onModLoad event, load the Persistent Locations into Memory or something as Locals.

#10
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Is it at all possible to somehow import/use NWN2 functions into NWN1 here? Just curious, as we have the functions GetIsLocationValid() and CalcSafeLocation() that sound like they are the exact functions you are in need of. The first obviously tells you if a location is a valid (walkable) spot, the other allows you to do a random search within a given space/range, centered on a given starting point, to find/pick a valid (walkable) location. Just wondering.

Modifié par _Knightmare_, 01 juin 2011 - 12:56 .


#11
virusman

virusman
  • Members
  • 282 messages
There are a few functions for this: GetGroundHeight & GetIsWalkable in nwnx_funcs and GetSurface in nwnx_funcsext.
CalculateSafeLocation is possible, but hasn't been requested; besides, it can be done with existing functions.

Modifié par virusman, 01 juin 2011 - 02:42 .


#12
DM_Vecna

DM_Vecna
  • Members
  • 280 messages
Just curious, have you thought of using a number of waypoints and then grabbing a random waypoint in order to give the illusion of randomness?

#13
DM_Vecna

DM_Vecna
  • Members
  • 280 messages
Blarg! Post did not show up for a minute.

Modifié par DM_Vecna, 05 juin 2011 - 07:50 .


#14
Greyfort

Greyfort
  • Members
  • 234 messages
I agree with lightfoot, and funky...
A:) Generating random loc is very easy with Function - GetAreaSize, then create a creature at loc to check validity. annd follow funky way of copying and placeing objects.

the mention of nwnx_funct extender I had know Idea it GetGroundHeight & GetIsWalkable, the CalculateSafeLocation would be a nice function and make the above A:) even easyer I would enjoy a function like that. Rather then go through all the create a creature and check. I VOTE if you can do it V-Man Go For it, I will use it rather then the A:) meathod

#15
CID-78

CID-78
  • Members
  • 1 124 messages
just keep in mind that walkable surface isn't allways reachable surface. ie in exterior you might have thing poping onto "wall terrain" ie terrain that is there to prevent the player from going in one direction. You can usually not be here so if you pop down something at this location the player will never reach it. Depending on what you do with random location, you might get logic bugs aswell such as thing poping up on heigh ledges. NWN isn't really suitable for physics properties.

#16
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
If it's only in one or two areas where you need this, you could paint down a bunch of triggers that delimit the 'bad' areas and test your generated loc to see if it falls within one of them...or vice-versa.

Modifié par Axe_Murderer, 06 juin 2011 - 08:52 .


#17
Baaleos

Baaleos
  • Members
  • 1 330 messages

Greyfort wrote...

I agree with lightfoot, and funky...
A:) Generating random loc is very easy with Function - GetAreaSize, then create a creature at loc to check validity. annd follow funky way of copying and placeing objects.

the mention of nwnx_funct extender I had know Idea it GetGroundHeight & GetIsWalkable, the CalculateSafeLocation would be a nice function and make the above A:) even easyer I would enjoy a function like that. Rather then go through all the create a creature and check. I VOTE if you can do it V-Man Go For it, I will use it rather then the A:) meathod



I agree,
I do plan on using this method to generate the random locations in the area, but to further optimize it, I plan on storing the Locations Persistently, so that they do not need to be re-acquired via the spawning in of npc's.

It makes sense, if I am going to spawn in npc's which is a somewhat cpu intensive process, especially if done multiple times, that I should save the valid locations for re-use.

#18
Baaleos

Baaleos
  • Members
  • 1 330 messages

Axe_Murderer wrote...

If it's only in one or two areas where you need this, you could paint down a bunch of triggers that delimit the 'bad' areas and test your generated loc to see if it falls within one of them...or vice-versa.



The Idea I have, is to simulate a multi-planar invasion, basically a rip off of 'Rift - Planes of Telaria'

Where there can be world events, where Planar Tears open, and out pours enemies of the specific rift element.

eg- Rift of Fire = Plane of Fire is invading.


I want to make the system capable of randomly choosing an area, save for the few designated city areas, and then starting the planar tear in the area, and then the Planar Tear will grow in size, and then become a fully fledged Rift.
(Server wide announcements would be generated, which would allow players to travel to the area, and participate in the event etc)

With the nwnx_areas plugin, I can then instance that area, to make an elemental copy of the area.

eg- Rift of Fire appears,  players could then cross over the rift, and enter a flaming version of the area they just left.

Some aspects of this would be similar to Oblivion, where you have to cross into the other plane, to destroy the gateway.

Modifié par Baaleos, 06 juin 2011 - 08:57 .