Two questions...

Post » Tue Sep 15, 2009 12:59 am

1: How can I detect which direction the player is moving? In other words--forward, backwards, side-to-side?

2: Is there a way I can simulate a general "weakness" to everything? Basically what I want to do is:
When an NPC falls from 0 fatigue, I want to make them weak to anything (IE: any attack can probably do them in). The catch is that this isn't NPC specific, so I can't just specify someone's health. I know there's Weakness to Normal Weapons from Bloodmoon, but is there a Weakness to Enchanted Weapons too? It doesn't make sense to me that under these conditions, a normal weapon would do more damage than an enchanted one. It goes without saying that underneath the enchantment, there should be just a steel weapon. How do I simulate this logic?
User avatar
MISS KEEP UR
 
Posts: 3384
Joined: Sat Aug 26, 2006 6:26 am

Post » Mon Sep 14, 2009 9:14 pm

For player movement, that might be difficult to get right... I know that you can use particular GetSoundPlaying calls to look for (like "FootHeavyRight", "FootHeavyLeft," "FootBareRight," "FootBareLeft", etc) but I haven't tested to see how reliable they are, I only use them in one of my scripts to detect that the player is walking.


For knocked out actors, it looks like the fCombatKODDamageMult GMST entry might be what you want to adjust, but I haven't touched it personally, I'm only guessing from the name.
User avatar
(G-yen)
 
Posts: 3385
Joined: Thu Oct 11, 2007 11:10 pm

Post » Tue Sep 15, 2009 2:10 am

1.
float thisPosXfloat thisPosYfloat lastPosXfloat lastPoxYfloat dXfloat dYSet thisPosX To "player"->GetPos XSet dX To ( lastPosX - thisPosX )Set lastPosX To thisPosX...etc...


2. Watch for a health change and multiply it.
User avatar
Gisela Amaya
 
Posts: 3424
Joined: Tue Oct 23, 2007 4:29 pm

Post » Mon Sep 14, 2009 8:31 pm

For player movement, that might be difficult to get right... I know that you can use particular GetSoundPlaying calls to look for (like "FootHeavyRight", "FootHeavyLeft," "FootBareRight," "FootBareLeft", etc) but I haven't tested to see how reliable they are, I only use them in one of my scripts to detect that the player is walking.


For knocked out actors, it looks like the fCombatKODDamageMult GMST entry might be what you want to adjust, but I haven't touched it personally, I'm only guessing from the name.


Thanks for this pointer. :) While there are perks to scripting this myself, the GMST will be much easier.

1.
float thisPosXfloat thisPosYfloat lastPosXfloat lastPoxYfloat dXfloat dYSet thisPosX To "player"->GetPos XSet dX To ( lastPosX - thisPosX )Set lastPosX To thisPosX...etc...


2. Watch for a health change and multiply it.


As for 1: I have tried this approach before, and it works to detect player movement. However, I think the GetPos axis are based on the cell, not the player. Therefore, depending on the player's facing, a decrease in your X axis could mean you're going in any direction. I might need some sort of mathematical formula that can extract your movement direction based on your GetPos and GetAngle... :bonk:
User avatar
Jonathan Montero
 
Posts: 3487
Joined: Tue Aug 14, 2007 3:22 am

Post » Mon Sep 14, 2009 10:02 am

I just realized 2 wouldn't be general-use unless you use MWSE, so forget that.

But as for 1: It should be based on the cell/world coordinates, so you can take that info (the dX and dY variables) and just use "player"->GetAngle Z to figure out what's "forward". Way, way back when I had a working demo of the Oblivion hit-the-bucket scene using some simple trig and the player's angle to figure out if they faced the bucket while swinging. MWSfD has an example trig script you can grab.
User avatar
CRuzIta LUVz grlz
 
Posts: 3388
Joined: Fri Aug 24, 2007 11:44 am

Post » Tue Sep 15, 2009 1:25 am

I just realized 2 wouldn't be general-use unless you use MWSE, so forget that.

But as for 1: It should be based on the cell/world coordinates, so you can take that info (the dX and dY variables) and just use "player"->GetAngle Z to figure out what's "forward". Way, way back when I had a working demo of the Oblivion hit-the-bucket scene using some simple trig and the player's angle to figure out if they faced the bucket while swinging. MWSfD has an example trig script you can grab.


Well I know how to detect if the player is facing an object... but what I need is the actual direction the player is moving when they step. The only way I can figure it out is this (in theory - I wish I had a better formula, I'm sure there's something out there)...

If player is facing within -45 and 45 degrees (forward), then:
Left= Subtractions in X axis.
Right=Additions in X axis.
Forward=Additions in Y axis
Back=Subtractions in Y axis

If player is facing within -45 and -135 degrees (left), then:
Left= Subtractions in Y axis.
Right=Additions in Y axis.
Forward=Subtractions in X axis
Back=Additions in X axis

If player is facing within 135 and -135 degrees (down), then:
Left= Subtractions in Y axis.
Right=Additions in Y axis.
Forward=Subtractions in X axis
Back=Additions in X axis

If player is facing within 45 and 135 degrees (down), then:
Left= Additions in Y axis.
Right=Subtractions in Y axis.
Forward=Additions in X axis
Back=Subtractions in X axis

If I can avoid actually scripting all that, I will.
User avatar
Andrew
 
Posts: 3521
Joined: Tue May 08, 2007 1:44 am

Post » Mon Sep 14, 2009 10:24 pm

Considering the Move commands don't work on the PC (which would allow you to get the forward and backward deltas and greatly simplify everything else), I'm not sure what choice you have. It's pretty simple code, just a bit of it.

[assume dX is delta X pos, dY is delta Y pos, and rotZ is Z angle, all for player]short threshold ; number of units of fuzziness, before counting it as movedshort movedIn ; 0 is forward, 1 is forward-right, 2 is right, 3 is back-right, 4 is back, 5 is back-left, 6 is left, 7 is forward-leftif ( rotZ < 22.5 )    if ( dX > threshold  )        if ( dY > threshold )            Set movedIn to 1        elseif ( dY < -threshold )            Set movedIn to 7        else            Set movedIn To 0        endif    elseif ( dX < -threshold )        if ( dY > threshold )            Set movedIn to 3        elseif ( dY < -threshold )            Set movedIn to 5        else            Set movedIn To 4        endif   endifelseif ( rotZ < 67.5 )    if ( dX > threshold  )        if ( dY > threshold )            Set movedIn to 0        elseif ( dY < -threshold )            Set movedIn to 2        else            Set movedIn To 1        endif    elseif ( dX < -threshold )        if ( dY > threshold )            Set movedIn to 4        elseif ( dY < -threshold )            Set movedIn to 6        else            Set movedIn To 5        endif   endif...etc...


I think there's actually a pattern there. For each 45-degree segment, you increment all the values by 1. Value A-1 is x, A-2 is x+2, A-3 is x+1, B-1 is the opposite of x (4 for 0, 5 for 1), B-2 is opposite+2, and B-3 is opposite+1. Should just be copy and paste from there for the rest of the arc.
User avatar
Rachell Katherine
 
Posts: 3380
Joined: Wed Oct 11, 2006 5:21 pm

Post » Mon Sep 14, 2009 3:04 pm

Thanks. I got this working. :) I really appreciate your help!
User avatar
Nikki Lawrence
 
Posts: 3317
Joined: Sat Jul 01, 2006 2:27 am

Post » Tue Sep 15, 2009 1:48 am

One thing to ask, I thought that enchanted weapons are not considered a normal weapons? So enchanted steel dagger should damage ghosts just as silver dagger does, no?
User avatar
Philip Rua
 
Posts: 3348
Joined: Sun May 06, 2007 11:53 am

Post » Mon Sep 14, 2009 6:39 pm

One thing to ask, I thought that enchanted weapons are not considered a normal weapons? So enchanted steel dagger should damage ghosts just as silver dagger does, no?

Yep. It just won't do more damage against a werewolf unless it was silver as well.
User avatar
Rude Gurl
 
Posts: 3425
Joined: Wed Aug 08, 2007 9:17 am


Return to III - Morrowind