KatAngel Posted March 18, 2009 Share Posted March 18, 2009 I'm just baffled right now because things that should work, aren't working. I'm trying to use a gamemode block, but it's acting strange... The script is attached to a weapon. The block basically checks to see if there is any ammo for the current weapon, and if there isn't, it opens a menu - so right after the player fires their last bullet for that weapon, they get a set of options presented to them. The block looks like this: begin GameMode if player.GetItemCount Ammo10mm == 0 && showmenu == 1 set showmenu to 0 showmessage 10mmPistolAmmoSelectMsg endif end It works properly... what I don't understand is that it works properly 11 times. You'd think this would open the menu once, right? But it doesn't. It opens it 11 times, and that doesn't make any sense! To make things even better, it seems at this point to forget that the script is attached to the weapon, so whatever option I choose, nothing at all happens. (I open the same message during an OnEquip block and it works perfectly, so it's nothing to do with the message or the MenuMode block of my script.) Any idea why this is happening? Is this a known issue? Is there any way around it? Am I going about this COMPLETELY the wrong way? Link to comment Share on other sites More sharing options...
nosisab Posted March 18, 2009 Share Posted March 18, 2009 I'm just baffled right now because things that should work, aren't working. I'm trying to use a gamemode block, but it's acting strange... The script is attached to a weapon. The block basically checks to see if there is any ammo for the current weapon, and if there isn't, it opens a menu - so right after the player fires their last bullet for that weapon, they get a set of options presented to them. The block looks like this: begin GameMode if player.GetItemCount Ammo10mm == 0 && showmenu == 1 set showmenu to 0 showmessage 10mmPistolAmmoSelectMsg endif end It works properly... what I don't understand is that it works properly 11 times. You'd think this would open the menu once, right? But it doesn't. It opens it 11 times, and that doesn't make any sense! To make things even better, it seems at this point to forget that the script is attached to the weapon, so whatever option I choose, nothing at all happens. (I open the same message during an OnEquip block and it works perfectly, so it's nothing to do with the message or the MenuMode block of my script.) Any idea why this is happening? Is this a known issue? Is there any way around it? Am I going about this COMPLETELY the wrong way?Obviously the showmenu variable is set elsewhere or the message would not be presented at all. You don't show us the variable type too, I shall assume it is boolean or integer. Not significant in this case but good habit is placing conditions into ( ). Hint: GameMode runs at each frame as opposed most others Begin blocks (quest runs at fixed intervals) and must be used with care or it may give major performance impact in game. Since I'm not used to GECK specifics I can't be sure here too, but lack of ammo shall trigger an event; if so try using it instead a GameMode block. So, you may not get a direct answer here, since the block control is unknown to us. Where are you setting showmenu to 1? PS: maybe you shall try isolating the variable control from the block control itself, using something like a variable DoOnce and setting the showmenu variable in there. Link to comment Share on other sites More sharing options...
KatAngel Posted March 18, 2009 Author Share Posted March 18, 2009 showmenu gets set to 1 at the start of the menumode block. I realized that could possibly have been the problem, so I changed it to this: begin GameMode if player.GetItemCount Ammo10mm == 0 && showmenu == 0 set showmenu to 1 endif if showmenu == 1 set showmenu to 0 showmessage 10mmPistolAmmoSelectMsg endif end It still does the same thing. A blocktype for running out of ammo would be awesome, but there isn't one. Or if there is, it's not in the GECK documentation. Link to comment Share on other sites More sharing options...
nosisab Posted March 18, 2009 Share Posted March 18, 2009 showmenu gets set to 1 at the start of the menumode block. I realized that could possibly have been the problem, so I changed it to this: begin GameMode if player.GetItemCount Ammo10mm == 0 && showmenu == 0 set showmenu to 1 endif if showmenu == 1 set showmenu to 0;<--------- note than this will enable the message reprise before the player have a chance to recharge showmessage 10mmPistolAmmoSelectMsg endif end It still does the same thing. A blocktype for running out of ammo would be awesome, but there isn't one. Or if there is, it's not in the GECK documentation.The problem arises because the message the way it is put does not interrupts the game and so you need to check again the GetItemCount function so to reset the message inhibitor. You did almost right, just tested the wrong control. Place the message in the first test and set showmenu to inhibit the next ones. Now, in the second "if" test the ammo for > 0 values and enable the message to be shown again to when it reaches 0. I would test ammocount <= 0 just to be in the safe side. * see example comment I put at your code PS: If you want I will place the code, but I think it's better you figure the logic by yourself. Addendum: Inventory functions should not be used in GameMode block control, because they are among the most resource consuming. If it's really necessary you should seek for a way to minimize the load reducing the main test to variable tests, or have some timing or even putting the code under a quest script, since to me it looks as not being so critical that need to run at each frame. I checked the Geck docs and understand the GetItemCount ammo10m will test for the "ammo10m" you have in your inventory and not in the weapon. So maybe it works better as a memo if you test for a minimal threshold instead 0. But I may be wrong in my assumptions. Link to comment Share on other sites More sharing options...
KatAngel Posted March 18, 2009 Author Share Posted March 18, 2009 The ammo in your weapon still appears in your inventory. It fires properly when you shoot the last bullet, the only problem is that it fires 11 times and then the menumode block doesn't seem to fire on the weapon, for whatever reason. Since you seem to misunderstand, the showmenu variable is just my own version of a doonce variable. Since I have multiple things in my script that need to only happen once, it's easier to give them each a name. That's why I set showmenu to 0 immediately. It's testing the ammo count correctly, firing correctly - by all accounts it should be working! But after I close the menu, it opens again ten more times before I can return to gamemode, and then nothing that was in the menumode block fires at all. Link to comment Share on other sites More sharing options...
nosisab Posted March 18, 2009 Share Posted March 18, 2009 Edited: Sorry, double post for mistake, the following is the same as this. Link to comment Share on other sites More sharing options...
nosisab Posted March 18, 2009 Share Posted March 18, 2009 The ammo in your weapon still appears in your inventory. It fires properly when you shoot the last bullet, the only problem is that it fires 11 times and then the menumode block doesn't seem to fire on the weapon, for whatever reason. Since you seem to misunderstand, the showmenu variable is just my own version of a doonce variable. Since I have multiple things in my script that need to only happen once, it's easier to give them each a name. That's why I set showmenu to 0 immediately. It's testing the ammo count correctly, firing correctly - by all accounts it should be working! But after I close the menu, it opens again ten more times before I can return to gamemode, and then nothing that was in the menumode block fires at all.Maybe I sounded confusing, to me the showmenu variable is the control to... errr... show the menu... and the purpose of another variable would be to control the GameMode block itself. But this is for performance concerns only and not a logic issue. Yet, the issue I pointed in the last post applies. in that code, once the ammo gets to zero the message will spawn endlessly until the player gets the ammo again. I did understand that message is shown as a line at the top left on the screen. I could be totally wrong if it is a menu, someway the message service seems different in GECK it was in Oblivion and so I'm not the better to help in this specific. Because of it the suggestion of you inhibiting the message by the variable and testing again not the variable but the itemcount is valid yet. The message or menu or whatever will be re enabled only after the player get the ammo someway. To it the message returns to the first "if" and the inhibitor is set. afterwards the ammocount is checked again and if greater than 0 the inhibitor (showmenu) is reset.Such will be a performance dirty code... but will work. Indeed you can swap the test order and if the ammocount is greater than zero you can skip all the rest.To make things clearer: the block control shall test only the ammocount (the GetItemCount function itself), and not including the message inhibitor (showmenu) in the condition. The message control is another, different, thing. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.