Scripts

TR_m4_Pub_Omaynis

TR_Mainland.esm
Variables 15
Local Variables
TR_Map
control
controlQ
rent
rentDay
rentMonth
setup
cleanup
T_Local_NPC
NoLore
T_Local_HHScripExchange
ScripCount
ScripStart
GoldStart
GoldEnd
Source
1begin TR_m4_Pub_Omaynis 2 3;Cell: Omaynis, The Kwama's Scuttle 4;Publican: Either Nalvos Omayn or Olvys Omayn 5;Flag: TR_m4_Rent_Omaynis 6;Room Doors: TR_m4_rd_Omaynis (inside), TR_act_m4_Inn_11_rent (outside) 7 8;all rooms get rented for one day 9;This NPC must be in the map where the room is if you use the locked door cell loading cleanup 10;rename the script for the NPC and make a specific door to unlock or flag to set 11;NO actual key is given to player, a global flag is set that removes the ownership on the beds. 12 13;this script fires off when RENT is set true. Rent is set true through the BEDS topic in dialogue, which all Publicans have. 14;Each publican will also have a separate response to buying the bed, so they can give simple directions. There is also a default one. 15 16short TR_Map 17short control ; is used for Olvys Omayn's dialogue in TR_m4_Om_Statue 18short controlQ ; is used for Olvys Omayn's dialogue at the new inn 19short rent ;if room is rented, set through dialogue on this NPC 20short rentDay ;the day of the rental 21short rentMonth ;the month of the rental 22short setup ;if setup has been done 23short cleanup ;true if you want to cleanup all the flags, rental is over and can be reset 24short T_Local_NPC 25short NoLore 26short T_Local_HHScripExchange 27long ScripCount 28long ScripStart 29long GoldStart 30long GoldEnd 31;this script also uses a global variable (TR_m4_Rent_Omaynis). Make a new one for each rental. You can have as many 32;beds as you want use that variable, it is used through the ownership data on the object reference 33 34 35if ( OnDeath ) 36 set T_Local_HHScripExchange to -1 37elseif ( GetPCCell "Omaynis, The Kwama's Scuttle" ) 38 ; scrip exchange is only enabled at the mine pub 39 if ( T_Local_HHScripExchange >= 0 ) 40 Set T_Local_HHScripExchange to -1 41 endif 42endif 43 44if ( OnActivate ) 45 if ( GetPCSneaking ) ; when PC is pickpocketing, ignore. 46 elseif ( GetFatigue < 10 ) ; when NPC is knocked out, ignore. <10 is for recovery animation. 47 elseif ( T_Local_HHScripExchange == 0 ) ; else initiate scrip exchange if PC has scrip 48 if ( player->GetItemCount T_De_HlaaluCompanyScrip_01 > 0 ) 49 50 set T_Local_HHScripExchange to 1 51 52 ; add the topic so the merchant can be asked about it, in case player is confused 53 AddTopic "Hlaalu Company scrip" 54 55 set ScripStart to ( player->GetItemCount T_De_HlaaluCompanyScrip_01 ) 56 set GoldStart to ( player->GetItemCount gold_001 ) 57 set ScripCount to ScripStart 58 59 while ( ScripCount > 0 ) 60 if ( ScripCount >= 10000 ) 61 set ScripCount to ( ScripCount - 10000 ) 62 player->RemoveItem T_De_HlaaluCompanyScrip_01 10000 63 player->AddItem gold_001 10000 64 elseif ( ScripCount >= 1000 ) 65 set ScripCount to ( ScripCount - 1000 ) 66 player->RemoveItem T_De_HlaaluCompanyScrip_01 1000 67 player->AddItem gold_001 1000 68 elseif ( ScripCount >= 100 ) 69 set ScripCount to ( ScripCount - 100 ) 70 player->RemoveItem T_De_HlaaluCompanyScrip_01 100 71 player->AddItem gold_001 100 72 elseif ( ScripCount >= 10 ) 73 set ScripCount to ( ScripCount - 10 ) 74 player->RemoveItem T_De_HlaaluCompanyScrip_01 10 75 player->AddItem gold_001 10 76 elseif ( ScripCount >= 1 ) 77 set ScripCount to ( ScripCount - 1 ) 78 player->RemoveItem T_De_HlaaluCompanyScrip_01 1 79 player->AddItem gold_001 1 80 endif 81 endwhile 82 Return ; no activate now, delay one frame instead. 83 endif 84 endif 85 Activate 86elseif ( T_Local_HHScripExchange == 1 ) 87 set T_Local_HHScripExchange to 2 88 Activate 89elseif ( T_Local_HHScripExchange == 2 ) 90 set T_Local_HHScripExchange to 3 ; skip one frame 91elseif ( T_local_HHScripExchange == 3 ) 92 if ( MenuMode == 0 ) 93 94 set GoldEnd to ( player->GetItemCount gold_001 ) 95 set GoldEnd to ( GoldEnd - ScripStart ) 96 set ScripCount to ( ScripStart - ( GoldStart - GoldEnd ) ) 97 98 if ( ScripCount > ScripStart ) 99 set ScripCount to ScripStart ; don't give the player more scrip than they had at the start, have profits be gold instead. 100 endif 101 102 while ( ScripCount > 0 ) 103 if ( ScripCount >= 10000 ) 104 set ScripCount to ( ScripCount - 10000 ) 105 player->AddItem T_De_HlaaluCompanyScrip_01 10000 106 player->RemoveItem gold_001 10000 107 elseif ( ScripCount >= 1000 ) 108 set ScripCount to ( ScripCount - 1000 ) 109 player->AddItem T_De_HlaaluCompanyScrip_01 1000 110 player->RemoveItem gold_001 1000 111 elseif ( ScripCount >= 100 ) 112 set ScripCount to ( ScripCount - 100 ) 113 player->AddItem T_De_HlaaluCompanyScrip_01 100 114 player->RemoveItem gold_001 100 115 elseif ( ScripCount >= 10 ) 116 set ScripCount to ( ScripCount - 10 ) 117 player->AddItem T_De_HlaaluCompanyScrip_01 10 118 player->RemoveItem gold_001 10 119 elseif ( ScripCount >= 1 ) 120 set ScripCount to ( ScripCount - 1 ) 121 player->AddItem T_De_HlaaluCompanyScrip_01 1 122 player->RemoveItem gold_001 1 123 endif 124 endwhile 125 set ScripCount to 0 126 set ScripStart to 0 127 set GoldStart to 0 128 set GoldEnd to 0 129 set T_local_HHScripExchange to 0 130 131 endif 132endif 133 134if ( rent == 1 ) 135 136 if ( setup == 0 ) 137 set rentDay to Day 138 set rentMonth to Month 139 set setup to 1 140 set TR_m4_Rent_Omaynis to 1 ;this is the flag for the ownership on the bed 141 TR_m4_rd_Omaynis->unlock ;opens the door 142 TR_act_m4_Inn_11_rent->Unlock 143 TR_m4_rd_Omaynis->PlaySound3D "Open Lock" 144 145 else ;setup is done so check to see if the day is over 146 147 if ( Day != rentDay ) 148 set cleanup to 1 149 150 elseif ( Month != rentMonth ) 151 set cleanup to 1 152 153 endif 154 155 endif 156 157 if ( CellChanged ) ;this is only needed if you've done a locked door. If so, you only want to do this on cell change so you don't lock them in the room 158 if ( cleanup == 1 ) ;this gets called when the rental is over and everything can be cleaned up 159 set rent to 0 160 set TR_m4_Rent_Omaynis to 0 161 TR_m4_rd_Omaynis->lock 30 ;locks the door 162 TR_act_m4_Inn_11_rent->Lock 40 163 TR_m4_rd_Omaynis->PlaySound3D "LockedDoor" 164 set setup to 0 165 set rentDay to 0 166 set rentMonth to 0 167 set cleanup to 0 168 endif 169 endif 170 171endif 172 173; This short script is there to allow dialogue to be filtered on the TR_Map local variable, 174; allowing for regional topics such as "Morrowind Lore" or "Geographic Regions" to be 175; appropriate to the location the NPC is. 176 177if ( TR_Map == 4 ) 178 return 179endif 180 181set TR_Map to 4 182 183End