Jump to content
The Dark Mod Forums

Turning off particles when not needed


Springheel

Recommended Posts

I have a machine that emits steam whenever it is triggered. However, the steam particle goes through the ceiling and is visible on the floor above, if an AI triggers the machine while the player is up there. The player only needs to see the particle if they are in the same room as the machine.

 

Is there a way to handle this with a script?

 

I have a script that turns particles on/off when the player enters a location (example below)...would that work for triggered particles too? Or would it just trigger the steam when the player enters/leaves the location?

 

void turn_on_dust(entity old_zone)
{

sys.trigger( $dust_10 );
sys.trigger( $dust_9 );
}

 

 

  • Like 1
Link to comment
Share on other sites

Sounds like your machine trigger should call a script rather than activate the particle directly.

 

The script should include the canSeeEntity script event to check whether the location entity for the room with the machine

can see the player. Best I can fathom without a bunch of trial and error:

 

void particle_if_player_sees

{

sys.waitFrame();
while ($name_of_location.canSeeEntity($player1, 0))

{

if (self)

sys.trigger($dust_10);

sys.trigger($dust_9);

sys.wait(0.03);
}

}

  • Like 2

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Sounds like your machine trigger should call a script rather than activate the particle directly.

 

 

I should have been more specific. The particle effect is actually controlled by a func_emitter targetted from an elevator. As long as the elevator is moving, the func_emitter keeps firing.

Link to comment
Share on other sites

If it's derived from:

 

// infinite loop that passes the elevators z coordinate to the material every frame
vector origin;
while(1)
{
    if (isMoving() && canSeeEntity($player1,0)) 
    // only change the shaders appearence if the elevator is actually moving 
    // and if the player is visible from the elevators origin (instead of this player stim could be used for this, too)
    {
        origin=getOrigin(); //pass the origin of the elevator
        setShaderParm(5,origin_z); /pass the z value (height) to the shaderparm to alter texture shift
    }
    waitFrame();
}

then the you could add another canSeeEntity check from the location to the player:

 

// infinite loop that passes the elevators z coordinate to the material every frame
vector origin;
while(1)
{
if (isMoving() && canSeeEntity($player1,0) && $location_entity_example.canSeeEntity($player1,0))
// only change the shaders appearence if the elevator is actually moving
// and if the player is visible from the elevators origin (instead of this player stim could be used for this, too)
{
origin=getOrigin(); //pass the origin of the elevator
setShaderParm(5,origin_z); /pass the z value (height) to the shaderparm to alter texture shift
}
waitFrame();
}

  • Like 1

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Instead of an visibility check you can also check whether the player is in the same location:

 

if (isMoving() && getLocation()==$player1.getLocation())
  • Like 1

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

This is one of those situations where I find it difficult to offer a suggestion because there isn't enough information about the layout:

 

- where is the emitter in relation to the elevator?

- is the elevator the only means of access to the area containing the emitter?

- can you see the emitter from the top and/or bottom of the elevator?

- is the emitter bound to the elevator (perhaps it's a small engine that powers the elevator)?

- if an AI uses the elevator and takes it to a room the player is in, can the player see the emitter?

- if the player is up on the second floor and the emitter is on the first floor, and the player calls the elevator, can the player look down the elevator shaft and see the emitter?

 

A picture or diagram might help.

  • Like 1
Link to comment
Share on other sites

Note that canSeeEntity($player1,0) draws a line from the origin of the sighting entity to the origin of the targeted entity. This can give you false negatives depending on the architecture between the ends of the line.

 

For example, think of the player standing at the top of an elevator shaft and looking down at the emitter below. The emitter can't see the player's feet, so the emitter stays off, even though the player can see it.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 3 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
×
×
  • Create New...