Scripts

TR_m1_q_57_SuperCrabScript

TR_Mainland.esm
Variables 10
Local Variables
crabmove
crabcount
timer
xcoord
ycoord
pxcoord
pycoord
xdiff
ydiff
xyratio
Source
1Begin TR_m1_q_57_SuperCrabScript 2 3;This script handles the behavior of supercrab (the crab you are repeatedly collecting) 4;and the feather spear compass 5 6Float timer ;timer 7Float xcoord ;crab x coord 8Float ycoord ;crab y coord 9Float pxcoord ;player x coord 10Float pycoord ;player y coord 11Float xdiff ;crab x coord relative to player 12Float ydiff ;crab y coord relative to player 13Float xyratio ;angle of crab relative to player 14Short crabmove ;toggle to move the crab 15Short crabcount ;counts how many crabs have been collected 16 17 18If ( GetJournalIndex "TR_m1_wil_MudlapMosslog" >= 40 ) 19 SetDelete 1 20 Return 21ElseIf ( GetJournalIndex "TR_m1_wil_MudlapMosslog" >= 30 ) 22 If ( GetDisabled ) 23 Enable 24 Endif 25Else 26 If ( GetDisabled == 0 ) 27 Disable 28 Endif 29 Return 30Endif 31;makes our supercrab turn up when we need him and get deleted after that 32 33 34If ( Gethealth <= 0 ) 35 ModCurrentHealth 100 ;don't let supercrab die 36 Resurrect 37 PlaceAtMe "dead_mudcrab" 1 0 0 ;create a fake dead crab 38 Set crabmove to ( 10 - crabmove ) ;this is the toggle for moving supercrab ( values -2 to -9 ) 39Endif 40;creates a fake dead crab and teleport supercrab if you kill it 41 42 43If ( GetDistance "TR_m1_q_57_Mudlap" < 600 ) ;if you bring supercrab sufficiently close to mudlap 44 Set crabcount to ( crabcount + 1 ) ;note the collection 45 If ( crabcount >= 3 ) ;if enough collected 46 Journal "TR_m1_wil_MudlapMosslog" 40 ;update journal 47 PlaceAtMe "TR_m1_q_57_AttackCrab" 1 0 0 ;replace supercrab with fake passive crab 48 Disable ;get rid of supercrab 49 Return 50 Else ;if not enough collected yet 51 MessageBox "The Feather Spear vibrates in your hands as it locates a new target." 52 PlaceAtMe "TR_m1_q_57_AttackCrab" 1 0 0 ;replace supercrab with fake passive crab 53 Set crabmove to ( 10 - crabmove ) ;this is the toggle for moving supercrab ( values -2 to -9 ) 54 Endif 55Endif 56;checks how many crabs you have collected 57 58 59If ( crabmove < 0 ) ;this is the toggle for moving supercrab ( values -2 to -9 ) 60 RemoveEffects 118 ;gets rid of the command creature effect 61 If ( random100 <= 20 ) ;a position is chosen randomly from 5 options 62 If ( crabmove != -2 ) ;this prevents the same position being chosen twice consecutively 63 Set crabmove to 2 ;this toggles to check if supercrab is visible to the player after moving ( values 2 to 9 ) 64 Positioncell 350581 171522 248 18480 "Telvanni Isles" ;TR_m1_MARK_SuperCrab 65 Else 66 Positioncell 356906 165522 272 5760 "Telvanni Isles" ;TR_m1_MARK_SuperCrab; if the same position is chosen twice, run the script again with our crab out of sight (and more than 600 away) 67 Return 68 Endif 69 Elseif ( random100 <= 40 ) ;the next four sections are identical, just for different 'spawning' positions 70 If ( crabmove != -3 ) 71 Set crabmove to 3 72 Positioncell 351017 166045 177 5760 "Telvanni Isles" ;TR_m1_MARK_SuperCrab 73 Else 74 Positioncell 356906 165522 272 5760 "Telvanni Isles" ;TR_m1_MARK_SuperCrab 75 Return 76 Endif 77 Elseif ( random100 <= 60 ) 78 If ( crabmove != -4 ) 79 Set crabmove to 4 80 Positioncell 346509 162469 115 960 "Telvanni Isles" ;TR_m1_MARK_SuperCrab 81 Else 82 Positioncell 356906 165522 272 5760 "Telvanni Isles" ;TR_m1_MARK_SuperCrab 83 Return 84 Endif 85 Elseif ( random100 <= 80 ) 86 If ( crabmove != -5 ) 87 Set crabmove to 5 88 Positioncell 366417 173772 213 1740 "Telvanni Isles" ;TR_m1_MARK_SuperCrab 89 Else 90 Positioncell 356906 165522 272 5760 "Telvanni Isles" ;TR_m1_MARK_SuperCrab 91 Return 92 Endif 93 Else 94 If ( crabmove != -6 ) 95 Set crabmove to 6 96 Positioncell 361361 173810 244 18840 "Telvanni Isles" ;TR_m1_MARK_SuperCrab 97 Else 98 Positioncell 356906 165522 272 5760 "Telvanni Isles" ;TR_m1_MARK_SuperCrab 99 Return 100 Endif 101 Endif 102ElseIf ( crabmove == 0 ) ;this toggles so nothing is being checked ( values 11 to 19 ) 103 Set crabmove to 11 104ElseIf ( crabmove < 10 ) ;this is the toggle to check if supercrab is visible to the player ( values 2 to 9 ) 105 If ( GetDistance "player" < 3800 ) ;is the player close enough to see? 106 If ( GetLOS "player" == 1 ) ;can the player see? 107 Set crabmove to ( ( -1 ) * ( crabmove ) ) ;toggle movement so supercrab spawns somewhere else ( values -2 to -9 ) 108 Endif 109 Else 110 Set crabmove to ( crabmove + 10 ) ;this toggles so nothing is being checked ( values 11 to 19 ) 111 StopCombat 112 SetFight 83 113 Endif 114Endif 115;handles the teleporting of supercrab 116 117 118If ( player->getItemCount "TR_m1_q_57_FeatherSpear" == 0 ) 119 return 120Endif 121;The remainder of the script describes the compass effect and only runs when the player has the Feather Spear 122 123 124If ( MenuMode == 1 ) 125 Return 126Endif 127;This shouldn't run in menu mode 128 129 130Set timer to ( timer + GetSecondsPassed ) 131;could the time passed 132 133Set xcoord to GetPos, x ;crab x coord 134Set ycoord to GetPos, y ;crab y coord 135Set pxcoord to ( player->GetPos, x ) ;player xcoord 136Set pycoord to ( player->GetPos, y ) ;player y coord 137Set xdiff to ( xcoord - pxcoord ) ;crab x coord relative to player 138Set ydiff to ( ycoord - pycoord ) ;crab y coord relative to player 139 140If ( xdiff >= 0 ) 141 If ( xdiff < 1 ) 142 Return 143 Endif 144Else 145 If ( xdiff > -1 ) 146 Return 147 Endif 148Endif 149;prevents issues with xyratio being too high 150 151Set xyratio to ( ydiff / xdiff ) 152;measures the angle of the crab relative to player 153 154If ( timer > 3.7 ) 155 Set timer to 0 156 If ( ydiff >= 0 ) 157 If ( xyratio < -2.41421 ) 158 MessageBox "The Feather Spear points North." 159 Elseif ( xyratio < -0.41421 ) 160 MessageBox "The Feather Spear points Northwest." 161 Elseif ( xyratio < 0 ) 162 MessageBox "The Feather Spear points West." 163 Elseif ( xyratio < 0.41421 ) 164 MessageBox "The Feather Spear points East." 165 Elseif ( xyratio < 2.41421 ) 166 MessageBox "The Feather Spear points Northeast." 167 Else 168 MessageBox "The Feather Spear points North." 169 Endif 170 Else 171 If ( xyratio < -2.41421 ) 172 MessageBox "The Feather Spear points South." 173 Elseif ( xyratio < -0.41421 ) 174 MessageBox "The Feather Spear points Southeast." 175 Elseif ( xyratio < 0 ) 176 MessageBox "The Feather Spear points East." 177 Elseif ( xyratio < 0.41421 ) 178 MessageBox "The Feather Spear points West." 179 Elseif ( xyratio < 2.41421 ) 180 MessageBox "The Feather Spear points Southwest." 181 Else 182 MessageBox "The Feather Spear points South." 183 Endif 184 Endif 185Endif 186;Gives appropriate direction depending on xyratio value. 187;0.41421 type values are calculated by trig 188 189End