I've made some decent progress on this room now. The room now knows whether or not the troll is dead, the troll will fight you if he's not dead and you get too close to his pile of stuff, after the fight it returns you to the room and the troll falls over dead, and you can search his pile of stuff and only get treasure once. I am, however, seeing a problem with that last one.
If i hack a game save first thing so i can beat the troll right away, the first place i go it to the troll cave. I can get in and fight the troll in the first part of the cave, the part that existed in the release, and i can go to the new part of the cave and get the loot from the pile. No troll in that part, i can only get the loot once, works perfect. However, if i play longer before visiting the cave, it thinks the loot is already taken even when it's not. the rest of the room works as expected. It's as though the flag is being set at some other point in the game but that shouldn't be possible. It uses a global variable that I added myself that shouldn't be referenced anywhere else in the game.
I'll drop some code below. If anyone has any thoughts i'd like to hear them, please.
(instance robLoot of Script
(properties)
(method (changeState newState)
(switch (= state newState)
(0 ;N_LOOT
(Narrate 13 self) ;dig through loot
)
(1
(if (Btst digPile)
(= rando (Random 15 16))
(Narrate rando self) ;already got loot
else
(Narrate 14 self) ;get the loot
(ego get: iSilver 30)
(ego get: iGold 5)
(Bset digPile)
)
)
)
)
)