Jump to content

"Variable Ammo10mm is undefined" - Adding ammo script.


21stcenturybreakdown

Recommended Posts

Still trying to get this to work somehow.

I want to have unlimited ammo without needing to constantly redo a bat file or using god mode.

However, nothing I try has been working.

At first, I tried setting ammo types to none on all weapons, but that completely failed because changing ammo types in F4 results in the damage being messed up.

 

I was recommended to use a hidden container with an exactif conditional for the ammo count, but I have no clue on how to do that or how to have the ammo in a container actually be used

 

So I tried writing a script that would be activated via a magic effect whenever the player had the specific weapon equipped. Here's the script I used;

 

-------------------

 

Scriptname MODAmmo10mmEffectTest extends activemagiceffect
Event OnEffectStart(Actor akTarget, Actor akCaster)
if (Game.GetPlayer().GetItemCount (Ammo10mm) < 150)
Game.GetPlayer().AddItem(Ammo10mm, 300, true)
endIf
EndEvent
-------------------
Unfortunately, every attempt to compile it just comes up with;
Papyrus Compiler Version 2.8.0.4 for Fallout 4
Copyright © ZeniMax Media. All rights reserved.
Starting 1 compile threads for 1 files...
Compiling "MODAmmo10mmEffectTest"...
C:\Users\brent\AppData\Local\Temp\PapyrusTemp\MODAmmo10mmEffectTest.psc(5,36): variable Ammo10mm is undefined
C:\Users\brent\AppData\Local\Temp\PapyrusTemp\MODAmmo10mmEffectTest.psc(6,29): variable Ammo10mm is undefined
No output generated for MODAmmo10mmEffectTest, compilation failed.
Can someone please troubleshoot this for me?

 

Link to comment
Share on other sites

Outside of your event, add:

 

Ammo Property Ammo10mm Auto

 

(For example, see lines 17, 213, 243: https://pastebin.com/u7p114FH . Ignore the while loop, I should've simply added Max - Current.)

 

Then do this:

 

You have an unfilled property. To define Ammo10mm, open your activemagiceffect entry in CK. Highlight the script name. Click properties. The unfilled property should be in red text. At this point you should see buttons to assign/edit. You will need to find the form for Ammo10mm and assign it. Once done, the text will change from red to black. Ok. Save. Etc.

 

I came from a 100% text coding background, so the hybrid of Creation Kit and Notepad was weird to me. But once you get used to it, the CK cuts script work in half.

Link to comment
Share on other sites

Outside of your event, add:

 

Ammo Property Ammo10mm Auto

 

(For example, see lines 17, 213, 243: https://pastebin.com/u7p114FH . Ignore the while loop, I should've simply added Max - Current.)

 

Then do this:

 

You have an unfilled property. To define Ammo10mm, open your activemagiceffect entry in CK. Highlight the script name. Click properties. The unfilled property should be in red text. At this point you should see buttons to assign/edit. You will need to find the form for Ammo10mm and assign it. Once done, the text will change from red to black. Ok. Save. Etc.

 

I came from a 100% text coding background, so the hybrid of Creation Kit and Notepad was weird to me. But once you get used to it, the CK cuts script work in half.

Hi. I did as you said on the script side, adding in that extra line, and it compiled. However, when I clicked on properties, there was no red text. There seemed to be a black text "Ammo10mm" but no buttons to edit or assign.

 

I assumed it would be ok, and I loaded up the script, putting a condition on thw magic effect that it would load if the 10mm pistol was equipped, but nothing seemed to happen in game during my test.

 

EDIT:

May have figured it out. Will take into game and test again.

Edited by 21stcenturybreakdown
Link to comment
Share on other sites

It's no real rush, if you can look at it at all within the next few days or week or so, I would be grateful. I just posted the .rar file which contains the .esp.

 

I'll try to explain it all anyway. I created a magic effect. The conditional on that magic effect is an equipped 10mm pistol. I believe it's set to player equip. From there, the effect is set to a script effect, and it's got the script I made with the addition you advised on. I went to the properties, where it had something to do with 10mm ammo, but I hit the assign button anyway and selected 10mm ammo and let it do its thing. That was pretty much it. Added it to a .rar file, imported into the NMM, and installed and ran the game through there. Dropped my current amount of 10mm ammo until I was near the amount on the script, and fired a bunch of rounds until it went below and nothing happened from there.

Link to comment
Share on other sites

Haven't had a chance to look, but it sounds like a case of bad timing:

 

- Pistol is equipped

- Magic effect starts

- OnEffectStart event fires

- Your ammo is adequate

- Event is done

- You deplete ammo

- Nothing happens because event is over and no longer listening?

 

If you unequip does the magic effect go away?

 

If you re-equip after ammo is down, do you get more ammo?

Link to comment
Share on other sites

Possible. I'd thought it would be continuous. I'm pretty sure I clicked that when setting up the initial effect.

Either way, I tried putting away the pistol and equipping it again, and still not getting anything, unless I actually need to choose a different weapon and then get out the 10mm again. I'll try that tonight.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...