Aller au contenu

Photo

Scripted Trigger Spawns


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

#1
niapet

niapet
  • Members
  • 41 messages
Hello everyone,

Is there any function that allows you to spawn a trigger?   If so how would you go about telling it what size to make the trigger? 

Any help with this issue would be very much appreciated.

Modifié par niapet, 22 avril 2011 - 07:55 .


#2
Morbane

Morbane
  • Members
  • 1 883 messages
you could try to make a blueprint and spawn it like a placeable - the problem would be that a trigger isnt really a placeable so it might not spawn right without the correct OBJECT_TYPE_** constant.

#3
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Can you describe exactly what you need to spawn a trigger for? Maybe we can come up with some kind of work-around.

#4
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Morbane wrote...

you could try to make a blueprint and spawn it like a placeable - the problem would be that a trigger isnt really a placeable so it might not spawn right without the correct OBJECT_TYPE_** constant.


Traps are essentially triggers and you can spawn them via script, so the concept is valid. You can even dictate its size (though I think it needs to be square shaped).

@OP - I'll look into it and see if I can find anything. A little info on what you are trying to accomplish and why you need to spawn the trigger would help. It might be possible to just place down the trigger in the toolset and have conditions on it's OnEnter script that tells it when to do whatever the trigger is meant to do.

#5
Shallina

Shallina
  • Members
  • 1 011 messages
The easiest way isn't to spawn or destroy trigger, but to activate.desactivate them in the script that run them.

#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
+1 on what Shallina and KM said. Just put the trigger there and activate it when you want it or do what KM said and set the OnEnter script to fire at the right time.

#7
niapet

niapet
  • Members
  • 41 messages
Activating and deactivating will not work. What I am trying to do is spawn a trigger around a camp fire when a PC creates the campfire. The trigger will set a local variable on any PC that gets close enough to the fire and will allow them to rest.

At the moment the workaround I am using is to set the local variable directly when a PC spawns a campfire. The problem with this is a group of PCs need to all spawn their own fires to rest.. Also they may eventually figure out that they could spawn a fire and clean it up and not rest. They could, theoretically, then go about with the variable set and could rest anywhere they like.

So what I would like to do is have the campfire spawn and a small square trigger spawn on top of it so that the PC, and any other PC with them, could just get close to it and rest. Any other Ideas that would accomplish this same end would work too of course.

P.S. The way PCs rest in our PW is by spawning the campfire from the Heed PC tools. I just modified the part of the code that spawns the fire to also set the local variable, in case that matters at all (though it shouldn't).

#8
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
You could spawn the fireplace, make it useable and name the fireplace "Rest for the night" so that when you float the cursor over it, that's the text that pops up. You could also make a conversation that fires when you select the placeable (give the placeable the convo you want, then put "nw_g0_convplac" in the on use event).

This works well for me. I use the conversation so I can put different conversations in, some allow only one or two rest breaks at the area and other may allow more. It makes it easily interchangeable.

#9
MasterChanger

MasterChanger
  • Members
  • 686 messages
 I haven't tested applying an AoE to a placeable object, but you could theoretically try that. That's the best way to dynamically create a specific area that has an OnEnter, OnHB, and OnExit.

I know that if you were using a creature object, this would be very straightforward. You just pick an AoE (from vfx_persistent.2da) that has the shape and size you want and no fill SEF. Since you can supply parameters to EffectAreaofEffect to dynamically specify your OnEnter, OnHB, and OnExit, you don't have to care about those columns in the 2da.
I can't think of any reason you couldn't apply an EffectAreaOfEffect to a placeable, but the community has found that certain functions don't seem to work for placeables. Try it and see. 

#10
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Here is a simple script that accomplishes what you are looking to do. This does not spawn in a trigger, nor does it set/check variables on the PC. All it does is check for the existance of a Rest Fire nearby and that the PC is close enough to the Fire. If neither of those is true, it cancels the rest. You will need to edit the Tag of the rest fire and the distance (in meters) from the fire that you allow. Multiple PCs can use the same fire here and it essentially sets up a circle (with 10.0 meter radius as now written) that is the "allowed rest area." I did a simple test in game and it worked. The only drawback is that it gives the string messages twice because an OnPlayerRest script fires twice with each rest attempt (once when they try to enter rest and again when they exit rest).

// Module OnPlayerRest script
// By Knightmare, 4/23/11

void main()
{
object oPC = GetLastPCRested();
object oFire = GetNearestObjectByTag("rest_campfire", oPC); // Change Tag as needed here

// If Rest Fire does not exist, cancel rest and alert player
if(!GetIsObjectValid(oFire))
      {
      FloatingTextStringOnCreature("You need to build a fire before you can rest!", oPC);
      AssignCommand(oPC, ClearAllActions());
      return;
      }
 
// If player is too far from Rest Fire, cancel rest and alert player
else if(GetDistanceBetween(oPC, oFire) > 10.0) // Change distance as needed here
      {
      FloatingTextStringOnCreature("You need to get closer to the fire before you can rest!", oPC);
      AssignCommand(oPC, ClearAllActions());
      return; 
      }
}

Modifié par _Knightmare_, 23 avril 2011 - 01:21 .


#11
MasterChanger

MasterChanger
  • Members
  • 686 messages
 That's true--since the action you're talking about (resting) already has an event handler associated with it, you don't need to create either triggers or AoEs. Triggers or AoEs are really there for the purpose of giving you event handlers to attach scripts to.

Go with KM's method of using an OnPlayerRest and checking the distance. 

#12
niapet

niapet
  • Members
  • 41 messages
Sorry I took so long to reply, I was waiting for some as5 to reseat my heat-sinks for a week..

Anyway Thanks for the script Knightmare, though I also want to allow players to rest in rooms. There Are to ways I can handle this. I could simply replace the triggers I am using in inn rooms with an invisible place-able tagged the same as the fire near the bed, or I could add a check for the local variable in the script as an alternative to the fire.

Anyway Thanks for the help!

#13
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
You could also add to Knightmare's script to check to see if this will be interior or exterior or a particular list of areas, etc..so that you wouldn't necessarily have to change anything about the other places that players rest.

Modifié par GhostOfGod, 01 mai 2011 - 03:49 .


#14
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

niapet wrote...

Sorry I took so long to reply, I was waiting for some as5 to reseat my heat-sinks for a week..

Anyway Thanks for the script Knightmare, though I also want to allow players to rest in rooms. There Are to ways I can handle this. I could simply replace the triggers I am using in inn rooms with an invisible place-able tagged the same as the fire near the bed, or I could add a check for the local variable in the script as an alternative to the fire.

Anyway Thanks for the help!



No problem, happy to help. That's what we're here for. As GoG said you can just edit my script a bit there. I suggest just adding in another "else if" section (or more). You can do the same idea and check for the existance of a placeable tagged "Rest_bed" or whatever and then make sure the player is close to that (like 1.0 or 2.0 meters or whatever you find appropriate). If you need any help with it, feel free to let us know.

#15
niapet

niapet
  • Members
  • 41 messages
Well the script does not seem to work with the item spawned from the heed PC tools. It is a long bit of code but I will have to look through it and see if something in there changes the tag of each fire spawned so the system can keep track of it?

I may just have to make an item for PCs to use to spawn a fire instead. I wanted to avoid this since the PC tools can make a fire already.. However I could do it with Flint and steel and make them one time use items, thereby requiring PCs to carry some with them and have a permanent item for rangers and druids or something like that.