Regarding PlaceItemCellPositionCell and Persistence

Post » Thu Jul 07, 2016 5:43 pm

I had a thought to optimize my mod by getting rid of instances where I add only one object each to a ton of different cells, and instead use PlaceItem to drop objects in the cells. I know PlaceItemCell is almost useless for this purpose, because if the player reloads the game before the cell is ever loaded, the item will not show up. It would be nice to have to run the script only once, rather than having it constantly running to place items as the player explores.



So I thought what about using PositionCell on objects kept in a single storage cell? Are those items just as likely to vanish if the cells they're sent to aren't loaded before the player reloads the game? From prior experience I know those items have to be loaded before being sent somewhere else, so the player would have to enter the same cell where the objects are stored at some point, and then I could use a local script to scatter the objects across the game world.



Would the latter actually work? I've had some objects in my mods reset back to their starting positions if positioned in the same cell, so I've had to write scripts to position them correctly every time the cell loads. I've never had positive proof of this happening when an object is positioned to a new cell, but I've had instances where this is suspect. Does anyone know for sure?

User avatar
Niisha
 
Posts: 3393
Joined: Fri Sep 15, 2006 2:54 am

Post » Thu Jul 07, 2016 10:43 am

No idea.


But if these tons of objects are not meant to be temporary, placing them by script is not optimization, it is needless complication IMO

User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Thu Jul 07, 2016 10:10 am

I think that quite safe and working solution for few items is to add invisible activator into the cell with script that looks like this:



if (GetDisabled)
setdetele 1
endif

if (-condition for placing item-)
PlaceAtMe "-desired item-" 1,0,0
disable
endif

This way you do not have to deal with PositionCell problems, since the item will be added only when player enters the cell and activator will delete itself after that, so no script will run there. The item is also script-free.

User avatar
chirsty aggas
 
Posts: 3396
Joined: Wed Oct 04, 2006 9:23 am

Post » Thu Jul 07, 2016 4:36 pm

I had a half-baked idea to randomize the placement of those Books of Daedric Summoning when I posted yesterday. The problem with the hidden activator solution is every activator would need some way to track which pages had already been placed in prior cells, and at that point you might as well constantly run a global script instead. I wanted to be able to do the shuffle all at once, scattering the pages the first time the player loads the mod. I just don't trust it to work. I think abot's right. It's a needless complication when what I've already got works fine, having placed the pages by hand.


I have a far more pressing problem related to this one, with two non-unique refs that need to somehow reference one another. I made some crystal balls the player can place anywhere, which they can use to bind a "permanent summon" to guard that area. The problem is, these crystal balls are non-unique, because I wanted to let the player decide how many they wanted, where to put them, and which daedra to bind it to, as determined by which daedric summoning book page they use, which is then used up (so the player can only place one of that type).


This means the daedra itself needs to be persistent, but then I have to keep them in a storage cell so they can be referenced at all. However, they can't be teleported to an interior cell without MWSE, so I thought I could place a new ref, and the crystal ball would prefer that reference because it's the only one that's loaded. But instead the crystal ball insists on targeting the original reference, or at least I think it does because all my targeted commands and distance checks have no effect on the daedra that's present in the same cell.


I wanted the crystal ball to act like a control device, but it seems I'm stuck placing a daedra with the crystal ball, and the crystal ball being useless ever after (because in-game, that daedra is supposed to be forever bound to it and the crystal can only bind one). I can give the daedra itself commands through dialogue, but it can't be dismissed because there's no way to re-enable it after disabling it.


This would have all worked fine if the script didn't commit suicide at the first targeted disable it hits to a daedra not already placed in the CS, because then I could have those daedra actually be unique (as was originally intended) after the crystal ball placed one, it being the only one of that type in the game.
User avatar
Cassie Boyle
 
Posts: 3468
Joined: Sun Nov 05, 2006 9:33 am

Post » Thu Jul 07, 2016 8:32 pm


Technically, I think it is doable with only one global var.



-global long tracker-

begin local_activator_scpt_for_five_books

short helper
short flag
short rand
short rand2
short finishCalc

if (GetDisabled)
setdelete 1
endif

;calculation is finished, so add finishCalc value to tracker
if (finishCalc > 0)
set helper to tracker
set helper to helper + finishCalc
set tracker to helper
disable
return
endif

;check which book was randomly generated
set rand to Random 5
;get value from global var
set helper to tracker


set helper to (helper / 16) ;2^5 = 16
if(helper == 0);16 is not part of tracker, so page no5 was not yet placed
set rand2 to Random 10 ;one to ten chance this page will be there
if (rand2 == 0)
set finishCalc to 16
PlaceAtMe "book_no5" 1,0,0
return
endif
set helper to tracker
elseif
set helper to (tracker - 16)
endif

set helper to (helper / 8) ;2^4 = 8
if(helper == 0);8 is not part of tracker, so page no5 was not yet placed
set rand2 to Random 10 ;one to ten chance this page will be there
if (rand2 == 0)
set finishCalc to 8
PlaceAtMe "book_no4" 1,0,0
return
endif
set helper to tracker
elseif
set helper to (tracker - 8)
endif

;etc...

end local_activator_scpt

It is hardly an effective approach, though. Basically, the idea is to encode into global variable which pages are already placed. Provided you have five different pages you want to place around, you can encode them into one number in following way:


1 means page no 1


2 means page no 2


4 means page no 3


8 means page no 4


16 means page no 5



then you can decode which pages are already placed in world.



Let's say global variable is set to 21.


21 / 16 = 1 -> page 5 (with encoding 16) is already placed. Set global to 21-16 = 5


5 / 8 = 0 -> page 4 (with encoding 8) is not placed.


5 / 4 = 1 -> page 3 is already placed. Set global to 5-4 = 1


1 / 2 = 0 -> page 2 is not placed.


1 / 1 = 1 -> page 1 is already placed.



If you use long variable, you can encode up to 30 different pages.

User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am

Post » Thu Jul 07, 2016 10:01 am

That is brilliant! I don't think I'm going to bother with my random pages idea, but I have other scripts that this would simplify immensely. Thanks!
User avatar
Matt Bee
 
Posts: 3441
Joined: Tue Jul 10, 2007 5:32 am

Post » Thu Jul 07, 2016 7:14 pm

No problem! I hoped it might be of some use for you :)

User avatar
Prohibited
 
Posts: 3293
Joined: Tue Jun 12, 2007 6:13 am

Post » Thu Jul 07, 2016 6:29 am

You can encode up to 24 values in a globa long I think as globals are saved as float internally



[EDIT]another possible method that could make sense if each item to randomize is going to have a dedicated local script: spawn the item from a dedicated myItems leveled list, remove Item X from myItems leveled list on Activate in ItemXLocalScript

User avatar
W E I R D
 
Posts: 3496
Joined: Tue Mar 20, 2007 10:08 am

Post » Thu Jul 07, 2016 7:29 pm


That's a brilliant idea. I may use something like that for my dungeonspawn activators.





It has! I completely optimized my shipment scripts to use only 2 globals instead of 8. Now one of them tracks which shipments, and the other one cost, which needs to remain separate because I add and subtract different costs based on other factors beside which shipments are ordered. Here's the two relevant scripts, tested and working. The first is for ordering shipments, attached to a ledger the player activates:




Spoiler
Begin Uvi_Shipment_Orders

; single shipping ledger now takes all the player's orders


Short controlvar

Short button

Short doOnce

Short Tier1

Short Tier2

Short Tier3

Short Tier4

Short Tier5

Short Tier6

Short Tier7

Short tracker

Short tmpS


If ( CellChanged )

Return

Endif


If ( doOnce == 0 )

StartScript Uvi_Shipment_Enabler

Set doOnce to 1

Endif


If ( GetJournalIndex HT_StrongholdMaintenance < 20 )

If ( GetDisabled == 0 )

Disable

Endif

Return

Elseif ( GetJournalIndex HT_StrongholdMaintenance == 25 ) ;Almossaren not hired

If ( GetDisabled == 0 )

Disable

Endif

Return

Elseif ( GetJournalIndex HT_StrongholdMaintenance == 100 ) ;Almossaren fired

If ( GetDisabled == 0 )

Disable

Endif

Return

Elseif ( GetDisabled )

Enable

Endif


If ( GetJournalIndex HT_StrongholdMaintenance >= 30 )

If ( ScriptRunning Uvi_Shipment_Respawn == 0 )

StartScript Uvi_Shipment_Respawn

Endif

Endif


If ( OnActivate )

If ( MenuMode )

Messagebox "These records are needed here to maintain the tower."

Elseif ( GetJournalIndex HT_StrongholdMaintenance < 40 )

Activate

Else

Set Tier1 to 0

Set Tier2 to 0

Set Tier3 to 0

Set Tier4 to 0

Set Tier5 to 0

Set Tier6 to 0

Set Tier7 to 0

Set tracker to Uvi_Shipment_Tracker

Set controlvar to 1

Endif

Endif


If ( MenuMode )

Return

Elseif ( controlvar == 0 )

Return

Elseif ( controlvar == 1 )

If ( Uvi_Shipment_Cost < 0 ) ; defaulted on payment

If ( uvi_schedulesOff < 2 )

Messagebox "You must pay ^Uvi_Shipment_Cost before you can order new shipments."

Set controlvar to 0

Return

Endif

Endif

If ( tracker >= 64 )

Set Tier7 to 1

Set tracker to ( tracker - 64 )

Return

Elseif ( tracker >= 32 )

Set Tier6 to 1

Set tracker to ( tracker - 32 )

Return

Elseif ( tracker >= 16 )

Set Tier5 to 1

Set tracker to ( tracker - 16 )

Return

Elseif ( tracker >= 8 )

Set Tier4 to 1

Set tracker to ( tracker - 8 )

Return

Elseif ( tracker >= 4 )

Set Tier3 to 1

Set tracker to ( tracker - 4 )

Return

Elseif ( tracker >= 2 )

Set Tier2 to 1

Set tracker to ( tracker - 2 )

Return

Elseif ( tracker )

Set Tier1 to 1

Set tracker to 0

Endif

Set controlvar to 2

Endif


If ( controlvar == 2 )

If ( GetJournalIndex HT_StrongholdMaintenance < 45 ) ;Standard

Messagebox "Your current shipment cost is ^Uvi_Shipment_Cost." "Done" "Base Cost" "Standard Shipment"

Elseif ( GetJournalIndex HT_StrongholdMaintenance < 60 ) ;Ashlander

Messagebox "Your current shipment cost is ^Uvi_Shipment_Cost." "Done" "Base Cost" "Standard Shipment" "Ashlander Goods"

Elseif ( GetJournalIndex HT_StrongholdMaintenance < 70 ) ;Gems

Messagebox "Your current shipment cost is ^Uvi_Shipment_Cost." "Done" "Base Cost" "Standard Shipment" "Ashlander Goods" "Gem Shipment"

Elseif ( GetJournalIndex HT_StrongholdMaintenance < 75 ) ;Mournhold

Messagebox "Your current shipment cost is ^Uvi_Shipment_Cost." "Done" "Base Cost" "Standard Shipment" "Ashlander Goods" "Gem Shipment" "Mournhold Shipment"

Elseif ( GetJournalIndex HT_StrongholdMaintenance < 85 ) ;Solstheim

Messagebox "Your current shipment cost is ^Uvi_Shipment_Cost." "Done" "Base Cost" "Standard Shipment" "Ashlander Goods" "Gem Shipment" "Mournhold Shipment" "Solstheim Shipment"

Elseif ( GetJournalIndex HT_StrongholdMaintenance < 90 ) ;Mainland

Messagebox "Your current shipment cost is ^Uvi_Shipment_Cost." "Done" "Base Cost" "Standard Shipment" "Ashlander Goods" "Gem Shipment" "Mournhold Shipment" "Solstheim Shipment" "Mainland Shipment"

Elseif ( GetJournalIndex HT_StrongholdMaintenance < 100 ) ;Telvannis

Messagebox "Your current shipment cost is ^Uvi_Shipment_Cost." "Done" "Base Cost" "Standard Shipment" "Ashlander Goods" "Gem Shipment" "Mournhold Shipment" "Solstheim Shipment" "Mainland Shipment" "Telvannis Shipment"

Endif

Set controlvar to 3

Endif


If ( controlvar == 3 )

Set button to GetButtonPressed

If ( button == -1 )

Return

Elseif ( button == 0 ) ; Done

Set Uvi_Shipment_Tracker to ( Tier1 + Tier2 + Tier3 + Tier4 + Tier5 + Tier6 + Tier7 )

Set controlvar to 0

Return

Elseif ( button == 1 ) ; Base Cost

If ( uvi_schedulesOff < 2 )

Set Uvi_Shipment_Cost to 500

Else

Set Uvi_Shipment_Cost to 0

Endif

Set Tier1 to 0

Set Tier2 to 0

Set Tier3 to 0

Set Tier4 to 0

Set Tier5 to 0

Set Tier6 to 0

Set Tier7 to 0

Elseif ( button == 2 ) ; Standard Shipment

If ( Tier1 )

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 1150 )

Set Tier1 to 0

Else

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost + 1150 )

Set Tier1 to 1

Endif

Elseif ( button == 3 ) ; Ashland Shipment

If ( Tier2 )

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 350 )

Set Tier2 to 0

Else

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost + 350 )

Set Tier2 to 2

Endif

Elseif ( button == 4 ) ; Gem Shipment

If ( Tier3 )

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 4150 )

Set Tier3 to 0

Else

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost + 4150 )

Set Tier3 to 4

Endif

Elseif ( button == 5 ) ; Mournhold Shipment

If ( Tier4 )

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 250 )

Set Tier4 to 0

Else

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost + 250 )

Set Tier4 to 8

Endif

Elseif ( button == 6 ) ; Solstheim Shipment

If ( Tier5 )

If ( GetJournalIndex CO_Choice >= 70 )

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 850 )

Else

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 1000 )

Endif

Set Tier5 to 0

Else

If ( GetJournalIndex CO_Choice >= 70 )

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost + 850 )

Else

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost + 1000 )

Endif

Set Tier5 to 16

Endif

Elseif ( button == 7 ) ; Mainland Shipment

If ( Tier6 )

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 1750 )

Set Tier6 to 0

Else

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost + 1750 )

Set Tier6 to 32

Endif

Elseif ( button == 8 ) ; Telvannis Shipment

If ( Tier7 )

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 5150 )

Set Tier7 to 0

Else

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost + 5150 )

Set Tier7 to 64

Endif

Endif

If ( Uvi_Shipment_Cost <= 500 ) ;base cost

Elseif ( GetPCRank "East Empire Company" == 9 )

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 250 )

Endif

Set controlvar to 2

Return

Endif


End



The second is the combination timer/respawn script:




Spoiler
Begin Uvi_Shipment_Respawn

; Timer used to calculate when you have to pay your weekly maintenance fees.

; Started in Uvi_Shipment_Orders script


Short currentDay

Short dayCount

Short tracker

Short tier

Short tmpS


If ( CellChanged )

Return

Elseif ( MenuMode )

Return

Endif


If ( tier != 0 ) ;don't reset variables during respawn

Elseif ( ScriptRunning Uvi_Shipment_Payment ) ;wait for payment before resetting anything

Return

Elseif ( Uvi_Shipment_Cost < 0 )

If ( uvi_schedulesOff > 1 ) ;schedules/payments off

Set Uvi_Shipment_Cost to 0

Endif

Elseif ( Uvi_Shipment_Cost == 0 )

If ( uvi_schedulesOff < 2 ) ;schedules/payments on

Set Uvi_Shipment_Cost to 500

Endif

Elseif ( Uvi_Shipment_Cost == 500 )

If ( uvi_schedulesOff > 1 ) ;schedules/payments off

Set Uvi_Shipment_Cost to 0

Endif

Endif


If ( currentDay != Day )

Set currentDay to Day

If ( Uvi_Shipment_Cost != 0 )

Set dayCount to ( dayCount + 1 )

Endif

Endif


If ( GetJournalIndex HT_StrongholdMaintenance == 35 )

If ( dayCount < 2 ) ;RESET TO 4 AFTER TESTING

Return

Endif

Set dayCount to 7

Set Uvi_Shipment_Tracker to 1

Set Uvi_Shipment_Cost to 1150

Journal HT_StrongholdMaintenance 40

Elseif ( dayCount < 2 ) ;RESET TO 7 AFTER TESTING

Return

Endif


If ( tier == -2 )

If ( Uvi_Shipment_Cost < 1 ) ;defaulted on payment

Set Uvi_Shipment_Tracker to 0

Endif

Set dayCount to 0

Set tier to 0

Return

Elseif ( tier == 0 ) ; items from Uvi_Shipments

If ( Uvi_Shipment_Cost > 0 )

uvi_shipment_eggs01->Additem food_kwama_egg_01 20

uvi_shipment_eggs02->Additem food_kwama_egg_02 10

uvi_shipment_scribjelly->Additem ingred_scrib_jelly_01 10

If ( GetJournalIndex HT_Zhariphel >= 40 ) ; items from uvi_shipment_bloat

uvi_shipment_bloat->Enable

uvi_shipment_bloat->Additem ingred_bloat_01 10

uvi_shipment_ore->Additem uvi_insc_oil 6

Endif

If ( GetJournalIndex HT_Zhariphel >= 100 ) ; items from uvi_shipment_crystal

uvi_shipment_crystal->Enable

uvi_shipment_bloat->Additem uvi_crystal_shard 6

Endif

Else ;skip respawn

Set tier to -2

Return

Endif

Set tracker to Uvi_Shipment_Tracker

Set tier to 7

Endif

If ( tier == 7 ) ; RESPAWN SHIPMENTS

Set tmpS to ( tracker / 64 )

If ( tmpS) ; items from Uvi_ShipmentMainland

StartScript Uvi_Shipment_TR

Set tracker to ( tracker - 64 )

Endif

Set tier to 6

Elseif ( tier == 6 )

Set tmpS to ( tracker / 32 )

If ( tmpS ) ; items from Uvi_ShipmentMainland

uvi_shipment_TM_honey->AddItem TM_honeycomb 20

uvi_shipment_flour1->Additem TM_flour_course 20

uvi_shipment_flour2->Additem TM_flour_fine 20

uvi_shipment_NoM->Additem NOM_food_a_apple 20

uvi_shipment_NoM->Additem NOM_food_a_lemon 10

uvi_shipment_NoM->Additem NOM_food_egg2 12

uvi_shipment_NoM->Additem NOM_sltw_food_a_onion 20

uvi_shipment_NoM_lard->Additem NOM_food_lard 15

uvi_shipment_NoM_salt->Additem NOM_salt 20

uvi_shipment_NoM_sugar->Additem NOM_sugar 20

uvi_shipment_NoM_yeast->Additem NOM_yeast 20

uvi_shipment_soap->Additem "_EG_soapinv_01" 1

uvi_shipment_soap->Additem "_EG_soapinv_02" 2

uvi_shipment_soap->Additem "_EG_soapinv_03" 1

uvi_shipment_soap->Additem "_EG_soapinv_04" 2

uvi_shipment_soap->Additem "_EG_soapinv_05" 2

uvi_shipment_soap->Additem "_EG_soapinv_06" 2

uvi_shipment_soap->Additem "_EG_soapinv_07" 1

uvi_shipment_soap->Additem "_EG_soapinv_08" 2

uvi_shipment_soap->AddItem ingred_sload_soap_01 5

uvi_shipment_ore->Additem ingred_adamantium_ore_01 1

StartScript Uvi_Shipment_TM

Set tracker to ( tracker - 32 )

EndIf

Set tier to 5

Elseif ( tier == 5 )

Set tmpS to ( tracker / 16 )

If ( tmpS ) ; items from Uvi_ShipmentBloodmoon

uvi_shipment_solstheim1->AddItem ingred_bear_fat_SA 10

uvi_shipment_solstheim1->AddItem ingred_bear_meat_SA 10

uvi_shipment_solstheim1->Additem ingred_bear_pelt 5

uvi_shipment_solstheim1->Additem ingred_boar_leather 5

uvi_shipment_solstheim1->Additem ingred_wolf_meat_SA 10

uvi_shipment_solstheim1->Additem ingred_wolf_pelt 5

uvi_shipment_solstheim1->Additem ingred_wolf_ribs_SA 10

uvi_shipment_solstheim2->Additem ingred_belladonna_01 20

uvi_shipment_solstheim2->Additem ingred_belladonna_02 20

uvi_shipment_solstheim2->Additem ingred_heartwood_01 1

uvi_shipment_solstheim2->Additem ingred_holly_01 20

uvi_shipment_solstheim2->Additem ingred_horker_tusk_01 2

uvi_shipment_solstheim2->Additem ingred_wolfsbane_01 5

Set tracker to ( tracker - 16 )

Endif

Set tier to 4

Elseif ( tier == 4 )

Set tmpS to ( tracker / 8 )

If ( tmpS ) ; items from Uvi_ShipmentTribunal

uvi_shipment_mournhold->Additem ingred_durzog_meat_01 5

uvi_shipment_mournhold->Additem Ingred_golden_sedge_01 10

uvi_shipment_mournhold->Additem Ingred_horn_lily_bulb_01 10

uvi_shipment_mournhold->Additem Ingred_lloramor_spines_01 15

uvi_shipment_mournhold->Additem Ingred_meadow_rye_01 10

uvi_shipment_mournhold->Additem Ingred_nirthfly_stalks_01 10

uvi_shipment_mournhold->Additem Ingred_noble_sedge_01 10

uvi_shipment_mournhold->Additem Ingred_sweetpulp_01 20

uvi_shipment_mournhold->Additem "Ingred_timsa-come-by_01" 10

uvi_shipment_mournhold->Additem Ingred_scrib_cabbage_01 20

Set tracker to ( tracker - 8 )

Endif

Set tier to 3

Elseif ( tier == 3 )

Set tmpS to ( tracker / 4 )

If ( tmpS ) ; items from Uvi_ShipmentGems

uvi_shipment_diamond->Additem ingred_diamond_01 3

uvi_shipment_ore->Additem ingred_raw_ebony_01 1

uvi_shipment_ore->Additem ingred_raw_glass_01 1

uvi_shipment_amethyst->Additem ingred_amethyst_SA 1

uvi_shipment_ore->Additem ingred_goldnugget_SA 1

uvi_shipment_ore->Additem ingred_silvernugget_ST 1

uvi_shipment_opal->Additem ingred_opal_SA 1

uvi_shipment_sapphire->Additem ingred_sapphire_SA 1

uvi_shipment_emerald->Additem ingred_emerald_01 5

uvi_shipment_pearl->Additem ingred_pearl_01 5

uvi_shipment_ruby->Additem ingred_ruby_01 4

Set tracker to ( tracker - 4 )

Endif

Set tier to 2

Elseif ( tier == 2 )

Set tmpS to ( tracker / 2 )

If ( tmpS ) ; items from Uvi_ShipmentAshland

uvi_shipment_hides->Additem ingred_alit_hide_01 10

uvi_shipment_hides->Additem ingred_guar_hide_01 10

uvi_shipment_hides->Additem ingred_kagouti_hide_01 15

uvi_shipment_hides->Additem ingred_netch_leather_01 20

uvi_shipment_trama01->Additem ingred_trama_root_01 10

uvi_shipment_trama02->Additem ingred_trama_root_01 10

Set tracker to ( tracker - 2 )

Endif

Set tier to 1

Elseif ( tier == 1 )

If ( tracker ) ; items from Uvi_ShipmentStandard

uvi_shipment_ashyam01->Additem ingred_ash_yam_01 10

uvi_shipment_ashyam02->Additem ingred_ash_yam_01 10

uvi_shipment_ashyam03->Additem ingred_ash_yam_01 10

uvi_shipment_bittergrn->Additem ingred_bittergreen_petals_01 10

uvi_shipment_comberry01->Additem ingred_comberry_01 10

uvi_shipment_comberry02->Additem ingred_comberry_01 10

uvi_shipment_corkbulb01->Additem ingred_corkbulb_root_01 10

uvi_shipment_corkbulb02->Additem ingred_corkbulb_root_01 10

uvi_shipment_cuttle->Additem ingred_kwama_cuttle_01 10

uvi_shipment_hackle_01->Additem "ingred_hackle-lo_leaf_01" 10

uvi_shipment_jerky01->Additem ingred_scrib_jerky_01 10

uvi_shipment_jerky02->Additem ingred_scrib_jerky_01 10

uvi_shipment_jerky03->Additem ingred_scrib_jerky_01 10

uvi_shipment_merrow01->Additem ingred_marshmerrow_01 10

uvi_shipment_merrow02->Additem ingred_marshmerrow_01 10

uvi_shipment_merrow03->Additem ingred_marshmerrow_01 10

uvi_shipment_meat->Additem ingred_crab_meat_01 20

uvi_shipment_meat->Additem ingred_hound_meat_01 20

uvi_shipment_meat->Additem ingred_kollop_meat_ST 10

uvi_shipment_meat->Additem ingred_rat_meat_01 20

uvi_shipment_meat->Additem ingred_salt_fish_SA 10

uvi_shipment_meat->Additem ingred_fishegg_ST 5

uvi_shipment_saltrice01->Additem ingred_saltrice_01 10

uvi_shipment_saltrice02->Additem ingred_saltrice_01 10

uvi_shipment_saltrice03->Additem ingred_saltrice_01 10

uvi_shipment_scuttle->Additem ingred_scuttle_01 20

uvi_shipment_wheat01->Additem ingred_wickwheat_01 10

uvi_shipment_wheat02->Additem ingred_wickwheat_01 10

uvi_shipment_wheat03->Additem ingred_wickwheat_01 10

uvi_shipment_random01->StartScript Uvi_Shipment_Rand

Set tracker to 0

Set tmpS to -2

Endif

If ( tmpS == -2 )

If ( uvi_shipment_random01->ScriptRunning Uvi_Shipment_Rand )

Return

Else

uvi_shipment_random02->StartScript Uvi_Shipment_Rand

Set tmpS to -1

Endif

Elseif ( tmpS == -1 )

If ( uvi_shipment_random02->ScriptRunning Uvi_Shipment_Rand )

Return

Else

uvi_shipment_random03->StartScript Uvi_Shipment_Rand

Set tmpS to 0

Endif

Else

StartScript Uvi_Shipment_Enabler

Set tier to -1

Endif

Endif

If ( tier == -1 )

If ( Uvi_Shipment_Cost > 0 )

; leave as is

Elseif ( uvi_schedulesOff > 1 ) ;staff payments disabled

; else player is already in debt

Elseif ( uvi_schedulesOff != 0 ) ;staff bonus flagged

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 1000 )

Else

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 500 )

Endif

Uvi_Strongbox->StartScript Uvi_Shipment_Payment

Set tier to -2

Endif


End



And just to complete the picture, the payment script:




Spoiler
Begin Uvi_Shipment_Payment

; Global started in Uvi_Shipment_Respawn and Uvi_Tower_Strongbox scripts


Short doOnce ;first week reprieve on staff payments once shipments are ordered

Short CostSet

Long Cost


If ( MenuMode )

Return

Endif


If ( doOnce == 0 )

If ( Uvi_Shipment_Cost == 1150 ) ;first week reprieve on staff payments

Set doOnce to 1

Endif

Endif


If ( CostSet == 0 )

If ( doOnce == 1 ) ;first week reprieve on staff payments

Elseif ( uvi_schedulesOff > 1 ) ;staff payments disabled

Elseif ( uvi_schedulesOff != 0 ) ;staff bonus flagged

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost + 500 )

Endif

If ( Uvi_Strongbox_Goldreserve > Uvi_Shipment_Cost )

Set Cost to Uvi_Shipment_Cost

Elseif ( Uvi_Shipment_Cost > 0 ) ;default on payment

Set Cost to Uvi_Shipment_Cost

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost * -1 )

Endif

Set CostSet to 1

Return

Elseif ( Uvi_Strongbox_Goldreserve < Cost ) ;can't pay

If ( doOnce == 1 )

Set Uvi_Shipment_Cost to 0 ;tiers reset in timer script

Set doOnce to -1

Set CostSet to 0

Elseif ( Uvi_Shipment_Cost < ( Cost * -1 ) ) ;further in debt, set in timer script

Set Cost to ( Uvi_Shipment_Cost * -1 )

Endif

StopScript Uvi_Shipment_Payment

Return

Elseif ( Cost == 0 ) ;paid

If ( GetPCCell "Tel Uvirith, Tower Storage" )

PlaySound "Item Gold Up"

Messagebox "^Uvi_Shipment_Cost paid from Tel Uvirith Strongbox."

Endif

If ( doOnce == 1 )

Set Uvi_Shipment_Cost to 1650

Set doOnce to -1

Endif

If ( uvi_schedulesOff > 1 ) ;staff payments disabled

Elseif ( uvi_schedulesOff != 0 ) ;staff bonus flagged

Set Uvi_Shipment_Cost to ( Uvi_Shipment_Cost - 500 )

Set uvi_schedulesOff to 0

Endif

If ( Uvi_Shipment_Cost > 0 ) ;paid on time

Set Uvi_Strongbox_Goldreserve to ( Uvi_Strongbox_Goldreserve - Uvi_Shipment_Cost )

Set uvi_serv_almossaren.SugarLimit to 0

Else

Set Uvi_Shipment_Cost to 0 ;tiers reset in timer script

Endif

Set CostSet to 0

StopScript Uvi_Shipment_Payment

Return

Endif


If ( Cost >= 1000 )

RemoveItem Gold_001 1000

Set Cost to ( Cost - 1000 )

Elseif ( Cost >= 250 )

RemoveItem Gold_001 250

Set Cost to ( Cost - 250 )

Elseif ( Cost >= 50 )

RemoveItem Gold_001 50

Set Cost to ( Cost - 50 )

Elseif ( Cost >= 5 )

RemoveItem Gold_001 250

Set Cost to ( Cost - 5 )

Elseif ( Cost >= 1 )

RemoveItem Gold_001 1

Set Cost to ( Cost - 1 )

Endif


End



It's too bad the tower's rug changing script has 50 rugs to track. I managed to compress that into 5 globals (5 rugs, 10 choices each), but I don't think I could use your method to compress it down to one. It needed to be global variables (at least that's what's safest) because the rugs are in a different area from where you order rug changes. You pay for new rugs in the same strongbox as the shipments.

User avatar
Amy Gibson
 
Posts: 3540
Joined: Wed Oct 04, 2006 2:11 pm

Post » Thu Jul 07, 2016 10:14 am


Yes, you are correct, sorry for the wrong info. Does the 24 digits include sign bit? If not, you can teoretically encode up to 25 values, since one value can be encoded as either plus or minus.





I haven't thought of that, great idea! :thumbsup:





Great! Yeah, you can only compress up to 24 (possibly 25) values. And compressing it to 2 globals would probably work, but it is probably not worth it. Using 5 variables where one var corresponds to one rug type is easier to undestand and work with IMO.

User avatar
Aliish Sheldonn
 
Posts: 3487
Joined: Fri Feb 16, 2007 3:19 am

Post » Thu Jul 07, 2016 2:44 pm

I think 24, all included, but I'm not sure, it could be 23 or 25, needs testing

User avatar
Mari martnez Martinez
 
Posts: 3500
Joined: Sat Aug 11, 2007 9:39 am


Return to III - Morrowind