How to detect whether a player or any actor is not under a r

Post » Mon Nov 19, 2012 9:51 am

How to detect whether a player or any actor is not under a roof? I tried to place an actor far above the player and check whether the actor has a LOS on the player. It sometimes works but mostly not. Any idea?
User avatar
Joey Avelar
 
Posts: 3370
Joined: Sat Aug 11, 2007 11:11 am

Post » Mon Nov 19, 2012 9:29 am

If I were to attack this one, I'd probably write a spell that fires straight up from an invisible Activator spawned over the player's head. It would have no magnitude and an area of 5000. In that spell's ActiveMagicEffect script, I'd set a Global that can tell other scripts we're under a roof.

If the spell hits a surface on it's way up, the player is under a roof (or something that blocks the sky over their head). The tremendous area of effect means the script will always run at least once, even if it's only because the player is an affected target. If the player is in the open, the projectile never impacts, so the script doesn't get run, so the Global doesn't get set.

The downside of this is that, if the player was under a roof but is now standing in the open, the script doesn't get run at all, so whatever script fires this checking spell will need to reset the global, fire the check-for-roof spell, wait a moment, then check the value of the Global.

A bit cumbersome but it should be fairly reliable.

Incidentally, I'm assuming you want to literally check if the player is under a roof, not just to see if we're in an interior cell. If this is not the case, ignore everything I just typed and http://www.creationkit.com/IsInInterior_-_ObjectReference.
User avatar
Baylea Isaacs
 
Posts: 3436
Joined: Mon Dec 25, 2006 11:58 am

Post » Mon Nov 19, 2012 11:18 pm

A projectile! Ofcourse! Thanks! A question how to fire a projectile upwards? Right now I fire a projectile in the direction Im currently looking.

There is another problem with the method. I dont want just to check a roof above the player but above any actor nearby.

Wait a second! What if I place a marker high above and try to hit actors in some area below. Can I fire the projectile in the direction of picked actor somehow? Perhaps its better to use a cloak spell but with AOF that doesnt ignore LOS? What do you think?
User avatar
CRuzIta LUVz grlz
 
Posts: 3388
Joined: Fri Aug 24, 2007 11:44 am

Post » Mon Nov 19, 2012 2:57 pm

If the spell hits a surface on it's way up, the player is under a roof (or something that blocks the sky over their head). The tremendous area of effect means the script will always run at least once, even if it's only because the player is an affected target. If the player is in the open, the projectile never impacts, so the script doesn't get run, so the Global doesn't get set.

Just to let you know, I've had the same idea before but it doesn't work. An area effect can't target the player if the player casted it.

Your overall idea might work still, but I'll suggest a variation of it:

Make an invisible dummy actor, and move it very high above the player (5000 units sounded good, but I'd use more), and then fire the projectile at that actor and set a global or an actor value (or you can make a faction for this and set the faction rank to 1/0, then you can use it on more than just the player). That way it certainly has a target to hit. You can just move the actor back to their starting location when you're done, and use the same actor every time.

Oh, and if you want to fire a projectile in a specific direction, I think you can just place an object away from the caster in the direction you want it to fire and pass it to the cast function as the target.
User avatar
Verity Hurding
 
Posts: 3455
Joined: Sat Jul 22, 2006 1:29 pm

Post » Mon Nov 19, 2012 12:43 pm

seventyfour, I think you'll find that scripts attached to area-of-effect spells can affect the player when fired from a remote activator, even if the player is set as the "blame" actor. I know I've had to specifically exempt the player from spell scripts before for that very reason.

gulogulo, you can fire a projectile straight up by setting the X angle of the activator to 90 (or possibly -90, can't recall for certain). Or as seventyfour stated you can fire a targeted spell at an activator over your head.

You can also, instead of using the spells AoE to run the script, use the invisible Explosion/place Activator trick, then have the activator check the distance to the player and set the Global in its onload event. Should work just as well my original post and it avoids concerns about whether the player will be within the AoE.

Your idea about placing the activator high and firing down at the player or NPCs is also a good one, but bear in mind the player and npcs are -very- narrow targets from directly overhead and even a very fast projectile will probably miss sometimes.
User avatar
Teghan Harris
 
Posts: 3370
Joined: Mon Mar 05, 2007 1:31 pm

Post » Mon Nov 19, 2012 1:07 pm

Sorry for the double post, for some reason I can't edit my last post. I was going to add that seventyfour's idea of firing at a target placed overhead is probably the best one. You could use the dummy actor's "Onhit" even to set the "open ground" Global, since nothing else SHOULD be hitting it at that altitude.
User avatar
Abi Emily
 
Posts: 3435
Joined: Wed Aug 09, 2006 7:59 am

Post » Mon Nov 19, 2012 5:31 pm

OK. I do the following thing:

1) A dummy invisible actor is periodically firing a cloak spell from above when outside and is raining
2) The cloak spells reaches actors below including the player (unfortunatelly LOS is ignored)
3) I try then to make the dummy actor fire at the actors below including the player (identified by the cloak spell) a projectile that will put a short lived spell (this spell will allow me to identify the actor as not being below the roof).

The problem is the dummy actor will never fire the projectile. But if I make the actors fire the projectile at the dummy actor all is well. Any idea why this is so?

Can I make a cloak spell ar some kind of AoE spell that doesnt ignore LOS?
User avatar
Manuel rivera
 
Posts: 3395
Joined: Mon Sep 10, 2007 4:12 pm

Post » Mon Nov 19, 2012 12:24 pm

seventyfour, I think you'll find that scripts attached to area-of-effect spells can affect the player when fired from a remote activator, even if the player is set as the "blame" actor. I know I've had to specifically exempt the player from spell scripts before for that very reason.

Oh, sorry, I misunderstood your idea then, I thought you meant that the player should fire an aimed spell that was supposed to apply an effect to self.
User avatar
Nathan Barker
 
Posts: 3554
Joined: Sun Jun 10, 2007 5:55 am

Post » Mon Nov 19, 2012 10:48 am

OK. I changed the script to the following:
LOSBolt.Cast(akCaster, akTarget)

Now, it works! Too bad you dont see that missiles and explosions. Ofcourse I will remove them since I dont need them but potentially someone can make a nice armageddon spell mod with this! Needless to say actors beneath roofs are not hit by the projectiles!
User avatar
Brandon Bernardi
 
Posts: 3481
Joined: Tue Sep 25, 2007 9:06 am

Post » Mon Nov 19, 2012 8:16 pm

Well, it works but its not perfect. There are sometimes long breaks between impacts of the projectiles. How can I increase the speed and range of a projectile spell/effect? Can I make a cloak spell or some kind of AoE spell that doesnt ignore LOS?
User avatar
CYCO JO-NATE
 
Posts: 3431
Joined: Fri Sep 21, 2007 12:41 pm

Post » Mon Nov 19, 2012 10:23 pm

You can duplicate the vanilla Projectile "EmptyProjectile" and increase its speed to 999999. You can also check the box labeled "Hitscan". Hitscan means the projectile doesn't actually travel, but instead arrives instantly where the game thinks it should go. Sometimes it's a bit flakey but it should work fine for targeting an actor.

Either way, you then need to set your new projectile as the projectile used by your check-for-open-sky spell, and you should get much faster results.
User avatar
Rowena
 
Posts: 3471
Joined: Sun Nov 05, 2006 11:40 am

Post » Mon Nov 19, 2012 8:30 am

Thank you again Verteiron once again. You helped me with commanding minions and now you helped me with detection of rain. Seems I will credit you once more on the front page of my mod. :)
User avatar
Kit Marsden
 
Posts: 3467
Joined: Thu Jul 19, 2007 2:19 pm


Return to V - Skyrim