Scripts

TR_m1_q50_GO5_Husband_scpt

TR_Mainland.esm
Variables 14
Local Variables
state
control
TR_Map
nolore
sPCLookAtMe
T_Local_NPC
T_Local_NoLore
fPCX
fPCY
fPCAngle
fdx
fdy
fRatio
timer
Source
1Begin TR_m1_q50_GO5_Husband_scpt 2 3short state 4short control 5short TR_Map 6short nolore 7float fPCX 8float fPCY 9float fPCAngle 10float fdx 11float fdy 12float fRatio 13short sPCLookAtMe 14float timer 15short T_Local_NPC 16short T_Local_NoLore 17 18if ( MenuMode ) 19 Return 20endif 21 22if ( state == -10 ) 23 if ( timer > 3 ) 24 SetDelete 1 25 Return 26 endif 27 set timer to ( timer + GetSecondsPassed ) 28 Return 29endif 30 31if ( state == 0 ) 32 Disable 33 set TR_Map to 1 34 set state to 1 35 return 36elseif ( state == 1 ) 37 if ( GetJournalIndex TR_m1_GO_5 >= 10 ) 38 Enable 39 set state to 2 40 endif 41 return 42elseif ( state == 2 ) 43 if ( GetDeadCount TR_m1_Q50_GO5_Cultist > 0 ) 44 if ( control != 2 ) 45 set control to 2 46 endif 47 ForceGreeting 48 set state to 3 49 endif 50 if ( OnDeath ) 51 if ( GetDeadCount TR_m1_Q50_GO5_Cultist < 1 ) 52 if ( GetJournalIndex TR_m1_GO_5 < 100 ) 53 set TR_m1_Q50_GO5_Cultist.control to 2 54 TR_m1_Q50_GO5_Cultist->RemoveSpell "TR_m1_Q50_G05Paral_Curse" 55 TR_m1_Q50_GO5_Cultist->ForceGreeting 56 set state to -1 57 return 58 endif 59 endif 60 endif 61 return 62elseif ( state == 3 ) 63 if ( GetHealth <= 0 ) 64 Journal TR_m1_GO_5 103 65 set state to -1 66 return 67 endif 68 if ( timer < 3 ) 69 set timer to ( timer + GetSecondsPassed ) 70 return 71 endif 72 set timer to 0 73 set sPCLookAtMe to 1 74 75 ;All credit to MSFD from which this was untimely ripped 76 77 if ( GetDistance, Player > 8000 ) 78 set sPCLookAtMe to 0 79 else 80 ;yay trigonometry 81 ;this basically does a rough calculation of the PCs direction relative 82 ;to the Actor, it only uses 45 degree chunks, though 83 set fPCX to ( player->GetPos, X ) 84 set fPCY to ( player->GetPos, Y ) 85 set fPCAngle to ( player->GetAngle, Z ) 86 set fdx to GetPos, X 87 set fdy to GetPos, Y 88 set fdx to ( fdx - fPCX ) 89 set fdy to ( fdy - fPCY ) 90 if ( fdy > 0.05 ) 91 set fRatio to ( fdx / fdy ) 92 elseif ( fdy < -0.05 ) 93 set fRatio to ( fdx / fdy ) 94 else 95 return 96 endif 97 98 if ( fdx > 0 ) 99 if ( fdy > 0 ) 100 if ( fRatio > 1 ) 101 if ( fPCAngle < -45 ) 102 set sPCLookAtMe to 0 103 endif 104 else 105 if ( fPCAngle < -90 ) 106 set sPCLookAtMe to 0 107 endif 108 109 if ( fPCAngle > 135 ) 110 set sPCLookAtMe to 0 111 endif 112 endif 113 else 114 if ( fRatio < -1 ) 115 if ( fPCAngle < 0 ) 116 if ( fPCAngle > -135 ) 117 set sPCLookAtMe to 0 118 endif 119 endif 120 else 121 if ( fPCAngle < 45 ) 122 if ( fPCAngle > -90 ) 123 set sPCLookAtMe to 0 124 endif 125 endif 126 endif 127 endif 128 else 129 if ( fdy > 0 ) 130 if ( fRatio < -1 ) 131 if ( fPCAngle > 45 ) 132 set sPCLookAtMe to 0 133 endif 134 else 135 if ( fPCAngle > 90 ) 136 set sPCLookAtMe to 0 137 endif 138 139 if ( fPCAngle < -135 ) 140 set sPCLookAtMe to 0 141 endif 142 endif 143 else 144 if ( fRatio > 1 ) 145 if ( fPCAngle > 0 ) 146 if ( fPCAngle < 135 ) 147 set sPCLookAtMe to 0 148 endif 149 endif 150 else 151 152 if ( fPCAngle > -35 ) 153 if ( fPCAngle < 90 ) 154 set sPCLookAtMe to 0 155 endif 156 endif 157 endif 158 endif 159 endif 160 endif 161 162 if ( sPCLookAtMe == 0 ) 163 disable 164 set timer to 0 165 set state to -10 166 PlaceAtPC "TR_m1_Q50_GO5_TrHusband" 1 256 1 167 endif 168endif 169 170End