DarianStephens Posted February 9, 2018 Share Posted February 9, 2018 (edited) If I use that function in my if statement, not even the ELSE part will run if it should be false. I know it's getting down to that point, since if I re-enable the console print just above it, it tells me if "Ammo is Formlist", but nothing in the if is going. Heck, not even the part to reload the weapon will work more than once if I don't reset the quest.I'm sure I've made tons of logical errors, and I know it could be more efficient (I actually deliberately made it less efficient in certain parts to try and debug this), but this has gotten me a little frustrated. scn PFAPowerAmmoQuestScript ref PreviousAmmoType ref WeaponAmmoUsed ref PlayerWeapon int WeaponClipSize begin Gamemode if player.GetEquipped WeaponsMeleeWithAmmo ;printc "Melee with Ammo Equipped" set PlayerWeapon to Player.getEquippedObject 5 set WeaponClipSize to 10 ; Placeholder until I find the right function for max clip size ;GetWeaponClipRounds PlayerWeapon set WeaponAmmoUsed to GetWeaponAmmo PlayerWeapon if PreviousAmmoType == 0 set PreviousAmmoType to player.getcurrentammo printc "No ammo type saved, saving..." elseif GetType WeaponAmmoUsed == 85 ;printc "Ammo is Formlist" if PreviousAmmoType.IsInList WeaponAmmoUsed printc "Saved ammo is in formlist, player is using same weapon" else ; Saved ammo isn't used by weapon at all printc PreviousAmmoType set PreviousAmmoType to player.getcurrentammo printc "Saved ammo different than ammo used by saved weapon, updating saved ammo..." endif elseif GetType WeaponAmmoUsed == 41 ;printc "Ammo is single ammo type" if (PreviousAmmoType == WeaponAmmoUsed) != 1 set PreviousAmmoType to player.getcurrentammo printc "Saved ammo type different than current ammo, updating saved ammo..." else printc "Saved ammo is same type, player is using same weapon" endif endif if PreviousAmmoType != player.getcurrentammo ; Player switched ammo types printc "Player switched ammo types!" ; New reload "Animation", don't know if it'll work DisablePlayerControls 0 0 1 0 0 EnablePlayerControls 0 0 1 0 0 TapControl 4 SetPlayerCurrentAmmoRounds WeaponClipSize endif if GetPlayerCurrentAmmoRounds == 0 && player.getitemcount PreviousAmmoType < 1 printc "Player clip is empty and no extra ammo, do nothing" ; Empty Clip and no more ammo endif if GetPlayerCurrentAmmoRounds == 0 && player.getitemcount PreviousAmmoType > 0 ; Emptied clip but has more ammo printc "Player clip is empty but has more ammo, reload" ; New reload "Animation", don't know if it'll work DisablePlayerControls 0 0 1 0 0 EnablePlayerControls 0 0 1 0 0 TapControl 4 SetPlayerCurrentAmmoRounds WeaponClipSize endif endif end I have no idea what's going on with the coloring of that code, and I don't know how to fix it or if anyone else sees it. Edited February 9, 2018 by DarianStephens Link to comment Share on other sites More sharing options...
dubiousintent Posted February 9, 2018 Share Posted February 9, 2018 Variable "WeaponAmmoUsed" is a "type code" (integer). "IsInList" needs "the calling reference's base object" (BaseID) of the ammo. PrintC requires a message string (with optional format specifiers): e.g. 'PrintC "AmmoType [%g].", PreviousAmmoType'. As it stands that "Else" block PrintC statement fails as invalid syntax as the variable is not a string. I would expect the second one in the "Else" block to succeed though. The NVSE equivalents are more flexible. Take a look at the 'TIP: Debugging Compound Conditionals' in the wiki "Getting started creating mods using GECK" article. Also try putting your function calls in a conditional inside of (parenthesis) just as insurance the result gets parsed/interpreted as a boolean. Ex: "If (PreviousAmmoType.IsInList WeaponAmmoUsed)". Next time put your code in "code tags" (the blue "<>" icon in the second line of the "Reply to" window), without line numbers to avoid the alternate line coloring. (I just selected/highlighted it all in order view it as it currently is.) -Dubious- Link to comment Share on other sites More sharing options...
DarianStephens Posted February 9, 2018 Author Share Posted February 9, 2018 (edited) Thank you for taking the time to help; this is the biggest thing I've attempted so far. Not that I've attempted particularly large things in the past, but this is much more advanced.Huh, I did use the <> thing, but the lines went coloured after I edited my post. I thought the 'Start Number' thing would highlight the line I told it to, oh well.Anyway, I've put the check in to a variable first, and that seems to work. However, now a new issue has cropped up that I'm not sure about.I've also done a bit more work in general, but while attempting to implement a custom reload animation (It's not a real animation, I'm just trying to make it force the player to holster the weapon for a few seconds, then pull it back out to simulate it), according to NVAC, I've introduced a syntax error. scn PFAPowerAmmoQuestScript ref PreviousAmmoType ref WeaponAmmoUsed ref PreviousWeapon ref PlayerWeapon int WeaponClipSize int TestAmmoTypeCheck int CurrentWeaponRounds int PlayerCurrentAmmoCount string_var AmmoDisplay int AmmoDisplayDelay int ReloadAnimDelay begin Gamemode if player.GetEquipped WeaponsMeleeWithAmmo ;printc "Melee with Ammo Equipped" set PlayerWeapon to Player.getEquippedObject 5 set WeaponClipSize to GetWeaponClipRounds PlayerWeapon ;10 ; Placeholder until I find the right function for max clip size ; Found it, I think set CurrentWeaponRounds to GetPlayerCurrentAmmoRounds set PlayerCurrentAmmoCount to player.getitemcount PreviousAmmoType if AmmoDisplayDelay == 0 ;if ReloadAnimDelay > 0 ; MessageEx "Reloading..." ;else let AmmoDisplay := Sv_Construct "%g / %g" CurrentWeaponRounds, PlayerCurrentAmmoCount let AmmoDisplayDelay := 60 MessageEx $AmmoDisplay Sv_Destruct AmmoDisplay ;endif ;else ; let AmmoDisplayDelay -= 1 endif ;if ReloadAnimDelay > 0 ; printc "Reload anim counting down" ; if ReloadAnimDelay < 3 ; printc "Reload anim nearly there" ; EnablePlayerControls 0 0 1 0 0 ; ;if player.IsWeaponOut == 0 ; if ReloadAnimDelay < 2 ; printc "Reload anim finale" ; TapControl 4 ; endif ; else ; printc "Reload not happening yet, block player controls" ; DisablePlayerControls 0 0 1 0 0 ; let ReloadAnimDelay -= 1 ; endif ;endif set WeaponAmmoUsed to GetWeaponAmmo PlayerWeapon if PreviousAmmoType == 0 set PreviousAmmoType to player.getcurrentammo printc "No ammo type saved, saving..." endif if PreviousWeapon == 0 set PreviousWeapon to player.getEquippedObject 5 endif if PreviousWeapon != PlayerWeapon ;Player has switched weapons! set PreviousWeapon to PlayerWeapon set PreviousAmmoType to Player.getcurrentammo printc "Player switched weapons, reset stuff" endif ;if GetType WeaponAmmoUsed == 85 ; ;printc "Ammo is Formlist" ; set TestAmmoTypeCheck to PreviousAmmoType.IsInList WeaponAmmoUsed ; printc TestAmmoTypeCheck ; if PreviousAmmoType.IsInList WeaponAmmoUsed ; printc "Saved ammo is in formlist, player is using same weapon" ; else ; Saved ammo isn't used by weapon at all ; printc PreviousAmmoType ; set PreviousAmmoType to player.getcurrentammo ; printc "Saved ammo different than ammo used by saved weapon, updating saved ammo..." ; endif ;elseif GetType WeaponAmmoUsed == 41 ; ;printc "Ammo is single ammo type" ; if (PreviousAmmoType == WeaponAmmoUsed) != 1 ; set PreviousAmmoType to player.getcurrentammo ; printc "Saved ammo type different than current ammo, updating saved ammo..." ; else ; printc "Saved ammo is same type, player is using same weapon" ; endif ;endif if PreviousAmmoType != player.getcurrentammo ; Player switched ammo types printc "Player switched ammo types!" ; New reload "Animation", don't know if it'll work ;DisablePlayerControls 0 0 1 0 0 ;EnablePlayerControls 0 0 1 0 0 ;TapControl 4 ; This and the above two were commented out for the one below ;set ReloadAnimDelay to 60 SetPlayerCurrentAmmoRounds WeaponClipSize set PreviousAmmoType to player.getcurrentammo endif if GetPlayerCurrentAmmoRounds == 0 && player.getitemcount PreviousAmmoType < 1 printc "Player clip is empty and no extra ammo, do nothing" ; Empty Clip and no more ammo endif if GetPlayerCurrentAmmoRounds == 0 && player.getitemcount PreviousAmmoType > 0 ; Emptied clip but has more ammo printc "Player clip is empty but has more ammo, reload" ; New reload "Animation", don't know if it'll work ;DisablePlayerControls 0 0 1 0 0 ;EnablePlayerControls 0 0 1 0 0 ;TapControl 4 ;set ReloadAnimDelay to 60 SetPlayerCurrentAmmoRounds WeaponClipSize set PreviousAmmoType to player.getcurrentammo endif endif end It's a shame there's nothing that can simulate running a Geck script, it would make this so much easier.I also need to learn how to make a hud element, so I can emulate the ammo counter for real, instead of through messages. EDIT:I've made a few more changes (Mostly removing the commented-out code for legibility), but it's still saying there's a syntax error. It's weird, because I didn't think I changed all that much. scn PFAPowerAmmoQuestScript ref PreviousAmmoType ref WeaponAmmoUsed ref PreviousWeapon ref PlayerWeapon int WeaponClipSize int TestAmmoTypeCheck int CurrentWeaponRounds int PlayerCurrentAmmoCount string_var AmmoDisplay int AmmoDisplayDelay int ReloadAnimDelay begin Gamemode if player.GetEquipped WeaponsMeleeWithAmmo ;printc "Melee with Ammo Equipped" set PlayerWeapon to Player.getEquippedObject 5 set WeaponClipSize to GetWeaponClipRounds PlayerWeapon ;10 ; Placeholder until I find the right function for max clip size ; Found it, I think set CurrentWeaponRounds to GetPlayerCurrentAmmoRounds set PlayerCurrentAmmoCount to player.getitemcount PreviousAmmoType if AmmoDisplayDelay == 0 let AmmoDisplay := Sv_Construct "%g / %g" CurrentWeaponRounds, PlayerCurrentAmmoCount let AmmoDisplayDelay := 60 MessageEx $AmmoDisplay Sv_Destruct AmmoDisplay else let AmmoDisplayDelay -= 1 endif set WeaponAmmoUsed to GetWeaponAmmo PlayerWeapon if PreviousAmmoType == 0 set PreviousAmmoType to player.getcurrentammo printc "No ammo type saved, saving..." endif if PreviousWeapon == 0 set PreviousWeapon to player.getEquippedObject 5 endif if PreviousWeapon != PlayerWeapon ;Player has switched weapons! set PreviousWeapon to PlayerWeapon set PreviousAmmoType to Player.getcurrentammo printc "Player switched weapons, reset stuff" endif if PreviousAmmoType != player.getcurrentammo ; Player switched ammo types printc "Player switched ammo types!" SetPlayerCurrentAmmoRounds WeaponClipSize set PreviousAmmoType to player.getcurrentammo endif if GetPlayerCurrentAmmoRounds == 0 && player.getitemcount PreviousAmmoType < 1 printc "Player clip is empty and no extra ammo, do nothing" ; Empty Clip and no more ammo endif if GetPlayerCurrentAmmoRounds == 0 && player.getitemcount PreviousAmmoType > 0 ; Emptied clip but has more ammo printc "Player clip is empty but has more ammo, reload" SetPlayerCurrentAmmoRounds WeaponClipSize set PreviousAmmoType to player.getcurrentammo endif endif end EDIT Number 2:Found it, I was trying to use the 'PreviousAmmoType' reference before declaring it! Heh! Edited February 9, 2018 by DarianStephens Link to comment Share on other sites More sharing options...
DarianStephens Posted February 9, 2018 Author Share Posted February 9, 2018 Okay, I now have an apparently-functional melee ammo system!All I need to do now is learn how to add an XML element to emulate the normal ammo counter... It seems totally usable now, but the ammo counter is displayed with the message box system, which gets tiresome during a fight.If anyone could direct me to a resource or person that could help, I would appreciate it. Link to comment Share on other sites More sharing options...
dubiousintent Posted February 9, 2018 Share Posted February 9, 2018 (edited) Congrats. Please see 'XML' references under the 'Misc Topics' section of the wiki "Getting started creating mods using GECK" article. Then take a look at the "Data\Menus\main\hud_main_menu.xml" file. There were a couple of mods in Oblivion that added custom elements the HUD. They might be of some inspiration, as there doesn't (to my inexpert eye) appear to much difference in XML between the two games. But basically it seems you pick an unused area of the HUD screen, establish a "Rect" placement there for your information, and populate it. And that's the extent of my "experience" with creating/editing XML. Just observation of others work. -Dubious- Edited February 9, 2018 by dubiousintent Link to comment Share on other sites More sharing options...
DarianStephens Posted February 14, 2018 Author Share Posted February 14, 2018 (edited) Alright, I've figured that xml thing out. It wasn't as bad as I thought, though some things were a bit unintuitive (Like justify being a float when it's always set with strings in the vanilla menus... 4 is justifying from the right).I could have probably released it then and there, but I'm going through another rewrite to eliminate the remaining gamebryo issues with ammod melee weapons, primarily the lack of power attacks and repeating hit (Ripper, for example) not working right.I've already got the mod to a state where you literally just need to configure the weapon like any other and the script handles the rest (Formlist was eliminated, it detects it on its own and will soon remove the reload animation, which is buggy since these weapons aren't set up model-wise for them), but in order to fix the power attack issue, I'm removing the ammo from the melee weapons as they're equipped, so all normal controls work. I've already got my custom ammo system, so that's not much of an issue.It shouldn't technically be too hard to replicate the abbreviated ammo type name either, though it kinda sucks to lose the vanilla implementation of that.I also need to handle ammo switching myself now, and now would be as good a time as any to also fix switching ammo in your inventory, since that just didn't work with melee weapons.The only problem is I'm not sure there's a function to set the player's currently equipped ammo type. I would guess that it's 'SetPlayerCurrentAmmo', but the only reference to it on technodeep is a red link in 'GetPlayerCurrentAmmo'. I'll be testing that tomorrow.If it doesn't work, I've got another idea to work around the workaround. I'm also trying to reimplement the reload time, but a bit differently. Edited February 14, 2018 by DarianStephens Link to comment Share on other sites More sharing options...
dubiousintent Posted February 14, 2018 Share Posted February 14, 2018 A "red link" means there is intended to be an article, but it doesn't exist yet. The "technodeep" / "GECK Wiki" site is the community driven version of the Bethesda GECK Wiki, so if you do work it out, they would be interested in an article on it. Contact any of the admins in the main page. -Dubious- Link to comment Share on other sites More sharing options...
DarianStephens Posted February 15, 2018 Author Share Posted February 15, 2018 It doesn't seem like SetPlayerCurrentAmmo actually exists, which removes a big way I was hoping to circumvent the problem.It also seem like there's no way to remove a weapon's ammo, since the game at least stores the current ammo, which means I'd need a way to nullify the player's equipped ammo, using the command above or one dedicated to removing it (But then if I can just remove it, I need a way to set it again, or I'll have to do some really hacky counting tricks).As it stands, this seems to be quite a roadblock to making this work flawlessly. At the very least, I could release the previous version without power attacks (After backporting the reload delay) and ask JIP for the function, since they seem like my only hope. Unless I learn how to make my own NVSE plugin, but that's at least a little bit further down the line.On the plus side, in my experimentations with XML, I've managed to create a mod I've been thinking about for a while:Replacing Atomic!'s message with a dedicated hud element. It looks pretty snazzy, and I've even got it activated the same way as the perk, and the quest is stopped when there's no point to it running. It also changes based on just how much radiation is in the area, instead of a flat rate.I'll either release that before, at the same time as, or after the Melee Ammo Framework (And example mod). Link to comment Share on other sites More sharing options...
Recommended Posts