Aller au contenu

Photo

Exploration and Discovery system


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

#1
indio

indio
  • Members
  • 204 messages
Can I please get some input on how to develop a system that allows for the following:

- PC explores area, discovering placeables as they go
- They might discover a small rock under which a gem lies, for example
- The 'spot' requirement would be very low, essentially automatic, although it would be great if it could be varied to become more difficult

Is such a system possible? Can the trap system be modified to spawn useable placeables containing items? If it cannot, could an invisible usable placeable be clicked to execute a script that determined your success in finding an onject, with failure resulting in a message "Your eyes have played tricks on you after all", or somesuch.

The purpose of the system is to avoid the use of the tab key to auto-identify all usable items, and promote exploration of the nooks and crannies of an area. I cannot remember exploriong one little, hidden-away place behind a boulder in DA:O.

Any input would be most appreciated.

#2
Magic

Magic
  • Members
  • 187 messages
There are several ways to achieve this. For example,
- make the placeable inactive at first with SetObjectActive()
- use a "heartbeat" event (for simplicity) or a trigger around the placeable (for precise control and performance) to check for the hidden object
- activate the placeable on success

If you hook into the core scripts, you can apply this even to the official campaign. A problem would be that many players already know where to look. :blush: For replayability in a discovery system, random spawnpoints would be nice. For example, create several waypoints and spawn your placeable at one of them randomly.

#3
indio

indio
  • Members
  • 204 messages
Most excellent.



Thanks for the advice.

#4
indio

indio
  • Members
  • 204 messages
There are so few templates from which to work. I'm used to having the vault there to provide me with a framework which can be modified.



Can someone please code for me a script that uses a trigger which, when entered, performs a modifiable spot test to determine if a defined placeable becomes active?



It's a big ask, and I'd rather be able to simply modify an existing script, but it is what it is.

#5
Bibdy

Bibdy
  • Members
  • 1 455 messages
There should be a Trigger template you can use, so you don't have to create the main bulk of the code, and the switches for the various events. In the right-hand panel in the Script editor, there are 4 buttons at the top. The right-most one (the little white sheet of paper thing) lists a bunch of templates. Double-click "Custom trigger events.txt" and it'll fill your script with the template code, from which you add your personal scripting.



The basic Trigger code has sections for when the trigger is spawned, entered or exited.



Simplest method would be to



1) Create your placeable

2) Set it to Inactive

3) Create a Trigger

4) Create a script, and assign it to your Trigger

5) In the script, under the "ENTER" event, create code that gets the nearest placeable and sets it active.

6) Place your trigger on the ground near your placeable, where you want the player to walk to, to spawn it.



Obviously you'd have to make sure that there are no other placeables near the trigger, but you'll be able to use it multiple times around your Area for different inactive placeables without having to parameterise anything, store variables or define a different script per location.



If you want to get more complex and do some randomisation, then it will probably require a lot more work to store and read variables, do some random number-crunching and testing to make sure you don't spawn more than one, and so on.

#6
Bibdy

Bibdy
  • Members
  • 1 455 messages
The commands you want for finding and setting your inactive placeable to active should be:



object oPC = GetHero();

object oDiscovery = GetNearestObject(oPC,OBJECT_TYPE_PLACEABLE);

WR_SetObjectActive(oDiscovery, TRUE);



You'll need to "#include wrappers_h", but that should be in the default Trigger template. Put that under the code where the Script grabs the "ENTER" event with the switch and you should be good to go.



You may want to destroy the trigger afterwards, to make sure nothing weird happens with running in and out of it all the time by using:



DestroyObject(OBJECT_SELF, 0);



If you want to get more technical, you might want to check whether or not it was the PLAYER who walked into the trigger, before you do anything else, just in case an enemy wanders into that trigger during combat and spawns the thing accidentally.

#7
indio

indio
  • Members
  • 204 messages
You've bought a smile to my face, Bidby. Many thanks for this assistance.

#8
indio

indio
  • Members
  • 204 messages
I'm getting a compile error from this portion of the script:



object oCreature = GetEventCreator(ev);

object oPC = GetHero();

object oDiscovery = GetNearestObjectByTag(oPC, "_invis_cont", OBJECT_TYPE_PLACEABLE);



WR_SetObjectActive(oDiscovery, TRUE);



break;



The error is: E: 16:44:18 - _invis_cont.nss - _invis_cont.nss(46): Mismatched types (while compiling var_constants_h.nss)



The error is from the oDiscovery line.

#9
Phaenan

Phaenan
  • Members
  • 315 messages
Hmm.

I don't have the toolset at hand to check right now, but I'd say GetNearestObjectByTag() probably returns an array of object (object[]) rather than one single object.

#10
Nattfodd

Nattfodd
  • Members
  • 321 messages
Yes it returns an array so you have to write

object [] oDiscovery = GetNearestObjectByTag(oPC, "_invis_cont", OBJECT_TYPE_PLACEABLE);



If you want to extract more than one object it should work correctly, but if you want only a specific object, why not using a direct GetObjectByTag()?.

#11
Bibdy

Bibdy
  • Members
  • 1 455 messages
Oh, yeah, those commands will return an array of objects, so you'll need to do
object [] oDiscovery = GetNearestObjectByTag(oPC, "_invis_cont", OBJECT_TYPE_PLACEABLE);

WR_SetObjectActive(oDiscovery[0], TRUE);

Bolded the changed parts. The 0th element should be the closest object to the player with that tag.

#12
indio

indio
  • Members
  • 204 messages
Sweet success. Thanks ever so kindly.