Jump to content

MegaStorm

Members
  • Posts

    17
  • Joined

  • Last visited

Nexus Mods Profile

About MegaStorm

Profile Fields

  • Country
    None

MegaStorm's Achievements

Apprentice

Apprentice (3/14)

  • First Post
  • Collaborator
  • Conversation Starter
  • Week One Done
  • One Month Later

Recent Badges

0

Reputation

  1. Well, I didn't think so, but it still sucks to hear that. :sad:
  2. Is there a means to display a message to the user when compiling in release/release-final mode? In other words, is there a "release mode" equivalent to Debug.Notification?
  3. I can't find anything relevant defined on the Actor class, so I'm not hopeful, but is there a way to determine if the player is currently using the transfer menu? You know, the transfer menu that pops up to buy/sell/trade items, either when you are trading with some NPC or even just opening a container. For the longest time, I stupidly thought Utility.IsInMenuMode() would tell you, but I just figured out that only applies to the Main menu, i.e., when the user presses ESC. :confused: I don't want to do anything specific with the menu; I just need to know so I can block my mod's timers. ETA: Don't know if it's possible, but maybe intercept the player's container OnActivate/OnDeactive events (if there is such a thing)?
  4. So for posterity, here's the full working code: ;----- ;Note: PlayerRef = Game.GetPlayer() which I set when the mod initialized ;----- Form frmLastItem = none ; receive item added events from player Event ObjectReference.OnItemAdded( ObjectReference akSender, \ Form akBaseItem, \ int aiItemCount, \ ObjectReference akItemReference, \ ObjectReference akSourceContainer ) if akSender == PlayerRef ;--------------------------------------- ; Ignore Item If Script Generated ;--------------------------------------- if frmLastItem == none ObjectReference item = PlayerRef.DropObject( akBaseItem, aiItemCount ); if( item ) ;destroy item now that we are done with it DestroyItem( item ) ;now silently add it back to player's inventory frmLastItem = akBaseItem PlayerRef.AddItem( akBaseItem, aiItemCount, true ) endIf else frmLastItem = none ;clear endif endif EndEvent Function DestroyItem( ObjectReference p_orefItem ) if( p_orefItem ) p_orefItem.Disable() p_orefItem.Delete() endif EndFunction I removed the log traces in the above for readability's sake, but here's the log of the above of my emptying a toolbox in-game. What's important here is to note that the object reference ID is identical for each 'Dropped' item meaning my DropItem()/DestroyItem() solution shouldn't cause any save game bloat or whatnot. [12/15/2017 - 05:10:39PM] InitializeMod(): Reinitializing Mod [12/15/2017 - 05:10:39PM] InitializeMod(): Mod Initialized! [12/15/2017 - 05:10:45PM] OnItemAdded(): Bottlecap [MiscObject < (0000000F)>], Count = 5 [12/15/2017 - 05:10:45PM] DestroyItem(): Bottlecap [ObjectReference < (FF007D34)>] [12/15/2017 - 05:10:46PM] OnItemAdded(): Bottlecap [MiscObject < (0000000F)>], Count = 5 [12/15/2017 - 05:10:46PM] OnItemAdded(): Gold Plated Flip Lighter [Form < (00060E88)>], Count = 1 [12/15/2017 - 05:10:46PM] DestroyItem(): Gold Plated Flip Lighter [ObjectReference < (FF007D34)>] [12/15/2017 - 05:10:46PM] OnItemAdded(): Gold Plated Flip Lighter [Form < (00060E88)>], Count = 1 [12/15/2017 - 05:10:46PM] OnItemAdded(): Duct Tape [Form < (0004D1F2)>], Count = 1 [12/15/2017 - 05:10:46PM] DestroyItem(): Duct Tape [ObjectReference < (FF007D34)>] [12/15/2017 - 05:10:46PM] OnItemAdded(): Duct Tape [Form < (0004D1F2)>], Count = 1 [12/15/2017 - 05:10:46PM] OnItemAdded(): Fuse [MiscObject < (00059ACC)>], Count = 1 [12/15/2017 - 05:10:46PM] DestroyItem(): Fuse [ObjectReference < (FF007D34)>] [12/15/2017 - 05:10:46PM] OnItemAdded(): Fuse [MiscObject < (00059ACC)>], Count = 1 [12/15/2017 - 05:10:46PM] OnItemAdded(): Wrench [Form < (0004D1F7)>], Count = 1 [12/15/2017 - 05:10:46PM] DestroyItem(): Wrench [ObjectReference < (FF007D34)>] [12/15/2017 - 05:10:46PM] OnItemAdded(): Wrench [Form < (0004D1F7)>], Count = 1
  5. Well, that relates to my follow-up question. Oh, wait, that gives me an idea. Within my AddItem, I can call DropObject like so... Event ObjectReference.OnItemAdded( ObjectReference akSender, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer ) ObjectReference item = Game.GetPlayer().DropObject( akBaseItem, aiItemCount ); if( item ) MyTrace( "Got reference! Yay!" ) else MyTrace( "Bummer. No reference." ) endIf endif EndEvent Hmmm.. just test that in-game, and it works! Interestingly, I'm not sure with the item gets dropped to because it's certainly no where near my player. :huh: But the above does give me a valid reference (which is all I'm after), and for cleanliness, I can simply call Disable() and Delete() on the reference once I'm done with it. Okay, well, never mind! I seemed to figure out it, but thanks!
  6. So this is either stupidly simple and so obvious that's I'm just overlooking the solution, or it's impossible. No combination of keyword searches on here or on Google yield any info, either. :confused: The short of it is that I want to monitor the items my player places in his inventory and, more importantly, do specific things based on the type of object it is. I'm successfully capturing OnAddItem(), but the problem is the event only provides the Form of the object, and that's pretty useless for what I want to do. (All the relevant methods are defined in the ObjectReference class, not it's base Form class.) I know simply upcasting it to an ObjectReference doesn't work: Event ObjectReference.OnItemAdded( ObjectReference akSender, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer ) ObjectReference item = akBaseItem as ObjectReference; if( item ) MyTrace( "Got reference! Yay!" ) else MyTrace( "Bummer. No reference." ) endIf endif EndEventDo I need to attach a script to my quest that extends ObjectReference and attach an OnItemAdded event to it? On a related subject, is there any way of iterating through the player's inventory without using F4SE? And even with F4SE, he simply returns an array of, again, Forms which is pretty useless, i.e., you can't really do much with that. --------- Or let me ask this another way. 99% of the time, inventory items are just virtual things--they don't really exist in the world. That's why containers simply are just list of Forms and their count. I get that. (Also, that's why the 'akItemReference' parameter is usually set to None with Holotapes and Holotags being an exception, but I'm sure not the only exception.) Is there a way for me to temporarily create an object (so I'll get a true ObjectReference object) and then delete it with just the Form ID? Dynamically, I mean, directly inside the OnAddItem() event handler.
  7. Eureka! The HC_Manager quest (and, more importantly, its script) showed me the simple thing that I was doing wrong. So, ThoraldGM, you were exactly right in that I needed to register for the OnPlayerLoadGame event, but my mistake was in how I was defining the event handler. Original Event OnPlayerLoadGame(actor aSender) MyTrace( "OnPlayerLoadGame()" ) EndEvent This yields the "script must be native" errors I was talking about. Updated Event Actor.OnPlayerLoadGame(actor aSender) MyTrace( "Actor.OnPlayerLoadGame()" ) EndEvent (For those who can immediately see the difference, note that I originally left out the Actor base class.) So for posterity, here's the bare-bones script: Scriptname Neutrino:MainScript extends Quest String property g_szScriptName = "Neutrino:MainScript" auto const Actor PlayerRef Event OnInit() MyTrace( "OnInit()" ) PlayerRef = Game.GetPlayer() RegisterForRemoteEvent( PlayerRef, "OnPlayerLoadGame" ) OnGameStart() EndEvent Event Actor.OnPlayerLoadGame(actor aSender) MyTrace( "Actor.OnPlayerLoadGame()" ) OnGameStart() EndEvent Function OnGameStart() MyTrace( "OnGameStart()" ) String szMsg = "Player has " + PlayerRef.GetGoldAmount() + " caps." MyTrace( szMsg ) EndFunction Function MyTrace( String p_szMsg ) String szMsg = "[" + g_szScriptName + "] " + p_szMsg; Debug.Trace ( szMsg ) Debug.MessageBox ( szMsg ) Debug.Notification( szMsg ) EndFunction In the above, I'll add back my timer event and also register for and override any other applicable event (OnHit, OnItemEquipped, OnItemAdded, etc.) Thanks, guys!!
  8. Speaking of that, I've been looking through the game's quests/scripts, and the AO_Dogmeat_FindItem quest seems to provide an example of how to setup a reference to the player. Of course, neither of the two attached scripts reference that reference, so maybe not...... Anyway, I'll keep digging through Bethesda's game code. Certainly, there is something there that mimics what I am trying to accomplish.
  9. Well, yeah, I had that going from the get-go, and as I reported back in my 2nd post, my simply starting a timer in the initial (and one-time only) OnQuestInit() call seems to persist across game sessions. The solution I am looking for, though, is to be able to detect when my mod initially loads, i.e., when I first load a save game. Alas, with the changes in the engine, I'm thinking I'm going to have just bite the bullet and maybe give my player self some custom object or something. I would still like to know, though, about how to go about aliasing the player like you guys (and other posts) talk about. Citing the wiki page is no helpful because that give zero context to the setup involved. For instance, your most recent wiki reference simply cites Alias_JohnDoe.ForceRefTo(self) :huh: I guess maybe change that to Game.GetPlayer().ForceRefTo(self)? Wiki is not very clear or detailed.
  10. Not MUD (had to Google that! :cool:), but I am a software engineer. C, C++, C#, Java, JavaScript, most of the various now arcane languages (Fortran, Ada, Pascal, Cobol, Lisp [though this isn't really arcane, I guess], Prolog, etc.), and more assembly languages than I care to count. No, heartbeat task running in the background is a common feature in most diagnostic subsystems: something that monitors the system and does self-tests periodically. That was my idea for my mod back in Fallout 3, hence the name/description. :happy:
  11. Sounds like a good idea, but it's a catch-22. So following that wiki, it turns out that the YourPlayerAliasScript is not being invoked at all. The OnInit() in my trace is strictly from my main quest script. So I could register for the event, but I have no where to put the handler. This might be related to SMB's suggestion (below), and I'm doing something wrong. So the "try putting the player in alias with a script" part... specifically, how does one do that? I'm still a little fuzzy on this new aliasing aspect of the engine. Is it as simple as adding... Player property PlayerRef auto...one's script, or do I do it via a property box or something in the creation kit?
  12. @SKK50, Are you sure your OnPlayerLoadGame() event handler is being called like you think it is? I can't get it to work. I followed the wiki's sample code to the letter, but it's never being called. Reference: https://www.creationkit.com/index.php?title=Complete_Example_Scripts#Maintenance.2Fupdate_code_which_runs_once_per_save_load_and_shows_a_message_when_a_mod_is_updated_or_first_loaded On a fresh save, I getting the following: [12/13/2017 - 06:05:22PM] [Neutrino] OnInit() [12/13/2017 - 06:05:23PM] [Neutrino] OnGameStart() [12/13/2017 - 06:05:23PM] [Neutrino] OnQuestInit() [12/13/2017 - 06:05:23PM] [Neutrino] OnGameStart() [12/13/2017 - 06:05:23PM] [Neutrino] OnReset() [12/13/2017 - 06:05:23PM] [Neutrino] OnInit() [12/13/2017 - 06:05:23PM] [Neutrino] OnGameStart() (OnGameStart() is my renaming of the wiki's Maintenance() example.) If I then save and reload, I get no events at all. @SMB92, It's kind of like a utility/maintenance script I like to have running in the background. I had a lot of fun with it in Fallout 3. Sort a minor cheat script, but more of a tedium removal tool. With F3SE, I would create hotkeys to do things like sell certain junk items, ammo, and weapons (using custom form lists), give and equip targets with specific armor, etc. Cheat-aspect is I would monitor my ammo and/or caps to make sure that they did not go below a certain level. Also, adjust the weight of my current items. (Super trivial via script as opposed to permanently replacing the all items in the game.) Things like that. At this stage, though, I'm just trying to figure out how to hook into the game reliably. There has to be a way. By reliable, I mean I need to have a means to know when a game is loaded, and I'm trying to avoid doing things like creating a dummy cell with a dummy static object and then attach to that dummy object. It'd work, I suppose, but there has to be a way to do this via a quest script I would think.
  13. I tried the OnPlayerLoadGame() because that's something I need desperately (since OnQuestInit() is only called once per new save), but I get a compile error stating that the script needs to be native: C:\Users\Neutrino\AppData\Local\Temp\PapyrusTemp\Neutrino\MainScript.psc(70,0): new event onplayerloadgame cannot be defined because the script is not flagged as native And making the script native isn't an option, I don't believe, because I get a lot more errors if I try that. :ohmy: ETA: I suppose to elaborate more, I can't make my script Native because then I have no way (that I know of) of defining my 'global' variables. (Some things I need to keep global like my timer IDs, custom formlist references, etc.) ETA #2: Baby steps, I suppose. I created a Quest Alias (and within, a reference alias to 'Player'), and then I attached a script to that. In that script, I have both OnInit() and OnPlayerLoadGame() event handlers defined, but only OnInit() ever gets called. (It's called every time I load a game.) Heh, I suppose I can be very hacky-ish and just use that script as my entry point and ditch the script quest altogether. Nope, never mind. Like OnQuestInit(), OnInit() is getting called once and only once. Once I save the game and then reload, it doesn't get called.
×
×
  • Create New...