Unsafe state call in state <unknown> which accesses user variables, reached by Marksman.Fire.

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
bfg_mnogo_tishiach

Unsafe state call in state <unknown> which accesses user variables, reached by Marksman.Fire.

Post by bfg_mnogo_tishiach »

I have troubles with variables and didn't find any answer in internet

actor "Marksman" : Weapon
{
var int user_dist;
Weapon.SelectionOrder 3700
Weapon.Kickback 100
Weapon.AmmoUse 0
Obituary "%o's head was sold"
+WEAPON.AMMO_OPTIONAL
Decal "BulletChip"
States
{
Spawn:
REVO A -1
Stop
Select:
REVO A 1 A_Raise
Goto Ready
Deselect:
REVO A 1 A_Lower
loop
Ready:
REVO A 1 A_WeaponReady
loop
Fire:
REVO B 2 A_FireBullets (0,0,-1,4,"BulletPuff")
TNT1 A 0 A_SetUserVar("user_dist",0)
Goto Fire2
Fire2:
TNT1 A 0 A_SpawnItem("Jump",3*user_dist)
TNT1 A 0 A_SetUserVar("user_dist",user_dist++)
Goto Check
Check:
TNT1 A 0 A_JumpIfInventory("WallHit", 1, "FireEnd")
Goto Fire2
FireEnd:
REVO CDEFGHIJKL 2
Goto Ready
}
}

wallhit is default inventory token item whitch obtained only by "jump" actor
ACTOR jump
{
Radius 3
Height 2
Mass 0
+DONTTHRUST
+NOBLOOD
States
{
Spawn:
TNT1 A 0 A_CheckProximity("Getit", "BulletPuff", 2)
MDLA A 3
Loop
Getit:
TNT1 A 0 A_GiveInventory ("WallHit", 1, 0)
Stop
}
}
Jarewill
 
 
Posts: 1759
Joined: Sun Jul 21, 2019 8:54 am

Re: Unsafe state call in state <unknown> which accesses user variables, reached by Marksman.Fire.

Post by Jarewill »

Wiki wrote:Weapon:
- The player itself must have the user variables. Defining the user variables is completely unnecessary on weapons as they are never stored.
As this wiki page states, weapons can't have user variables defined in them, because weapon functions are called in player scope, meaning they can only affect the variables inside the player class.
yum13241
Posts: 780
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

Re: Unsafe state call in state <unknown> which accesses user variables, reached by Marksman.Fire.

Post by yum13241 »

Variables don't exist in DECORATE, which is what OP is using. If you are NOT modding for Zandronum (or modifying a DECORATE Actor), I'd use ZScript if I were you.
Jarewill
 
 
Posts: 1759
Joined: Sun Jul 21, 2019 8:54 am

Re: Unsafe state call in state <unknown> which accesses user variables, reached by Marksman.Fire.

Post by Jarewill »

yum13241 wrote: Tue Dec 06, 2022 10:19 am Variables don't exist in DECORATE, which is what OP is using. If you are NOT modding for Zandronum (or modifying a DECORATE Actor), I'd use ZScript if I were you.
That is incorrect.
DECORATE has access to variables for most actors, however weapons can't use them due to how pointers work.
I even linked to the wiki page with information about custom variables in DECORATE.
yum13241
Posts: 780
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

Re: Unsafe state call in state <unknown> which accesses user variables, reached by Marksman.Fire.

Post by yum13241 »

What I meant is that you can't make your own.
Jarewill
 
 
Posts: 1759
Joined: Sun Jul 21, 2019 8:54 am

Re: Unsafe state call in state <unknown> which accesses user variables, reached by Marksman.Fire.

Post by Jarewill »

Again, please read the wiki article I linked to above.
You can create custom variables within actors in DECORATE and use them with a few limitations, which are written on the wiki page.
Post Reply

Return to “Scripting”