Launius Posted May 11, 2011 Share Posted May 11, 2011 (edited) I am working on a script that will take one item and replace it with another, but I'm having a little bit of trouble accomplishing my goals. I was hoping to use GetPos and SetPos in conjunction with one another, but I'm not sure how to put it into practice. Can someone give me a good whack in the right direction? Any thoughts on what my code has evolved into? scn PoisonFoodScript Ref Object short MyKey short Keydown short PosX short PosY short PosZ Begin GameMode if (player.GetAV Alchemy < 50) || (player.GetItemCount DarkPoison < 1) Return elseif (player.GetAV Alchemy >= 50) && (player.GetItemCount DarkPoison >= 1) Set MyKey to 27 if (IsKeyPressed3 MyKey) && (Keydown == 0) Set Keydown to 1 elseif (IsKeyPressed3 MyKey == 0) && Keydown Set Keydown to 0 endif if (Keydown != 1) Return elseif (GetCrosshairRef == Breadloaf) && (Keydown == 1) MessageBox "Do you want to poison this Breadloaf?" "Yes" "No" if (GetButtonPressed == 1) Return elseif (GetButtonPressed == 0) Set PosX to Breadloaf.GetPos X Set PosY to Breadloaf.GetPos Y Set PosZ to Breadloaf.GetPos Z Player.PlaceAtMe Dark10Breadloaf Set Dark10Breadloaf.SetPos to PosX Set Dark10Breadloaf.SetPos to PosY Set Dark10Breadloaf.SetPos to PosZ Set Object to Player.PlaceAtMe Breadloaf Object.DeleteReference endif endif endif End Edited May 11, 2011 by Launius Link to comment Share on other sites More sharing options...
QQuix Posted May 11, 2011 Share Posted May 11, 2011 In this case you don't need GetPos and SetPos.Something like this works: Set Object to GetCrosshairRef . . . if Object.getbaseobject == breadloaf Object.placeatme Dark10Breadloaf Object.disable Endif PlaceAtMe will place the new object exactly at the same XYZ position and angles as the calling obejct.DeleteReference can only be used on dynamically created objects, not on original game objects. Better just disable them. Link to comment Share on other sites More sharing options...
David Brasher Posted May 11, 2011 Share Posted May 11, 2011 This may not have any bearing on how you want to build your mod, but PlaceAtMe has been banned by the Geneva Convention and is not used in mainstream mods. PlaceAtMe creates savegame bloat that in the very worst cases can ruin savegames so that players have to stop playing them and start new characters. But other then that it is a really cool command. Link to comment Share on other sites More sharing options...
Launius Posted May 11, 2011 Author Share Posted May 11, 2011 @ QQuix -- Thanks for the info. I've got a lot to learn about scripting and I appreciate everyone on this forum helping me with my problems. @ David Brasher -- I'm glad you pointed that out, because it certainly will have some effect on how I build my mod. I'm making the mod for me, but I want others to be capable of enjoying it too. Would it still cause save game bloat if I let the newly placed object be deleted after a few minutes? Link to comment Share on other sites More sharing options...
QQuix Posted May 11, 2011 Share Posted May 11, 2011 Good you mentioned it, David Brasher. An update: the Geneva Convention downgraded the "PlaceAtMe Ban" to a Severe Warning status when OBSE added the DeleteReference function to Oblivion scripting. The ban was mostly because, once you created an object with PlaceAtMe (non-carriable objects in particular), there was no way to remove it from the save game, once done with it, thus, bloating the savegame with garbage data. (well, there was a way using RefStuff, but not well known). Now, with the availability of DeleteReference, a conscientious modder may use PlaceAtMe at will, provided he removes the objects with DeleteReference, when not needed anymore. So, Launius, check you mod for the right moment to remove your Dark10Breadloaf from the game. And, by the same token, the CloneForm function should have a Geneva Convention ban or, at least, a Severe Warning status, as it creates a new Base Object in the game and, to date, there is no way to remove it. Not as bad as PlaceAtMe used to be because a mod might use PlaceAtMe thousands of times, while there hardly would be the need to use CloneForm that many times, . . . but still . . . Link to comment Share on other sites More sharing options...
Launius Posted May 11, 2011 Author Share Posted May 11, 2011 Sounds good. Link to comment Share on other sites More sharing options...
Recommended Posts