Cutstuff Forum

Mega Man 8-bit Deathmatch => Bugs/Suggestions => MM8BDM Discussion => Rejected => Topic started by: Xhatahx on September 30, 2016, 12:32:17 PM

Title: [Suggestion for modding] Add a user variable
Post by: Xhatahx on September 30, 2016, 12:32:17 PM
Say someone wants to make a weapon that does something special, like firing projectiles in a sine wave. There are two ways of doing this: the honestly wasteful Wave Burner implementation, or using a user variable and use sin(user_var) as the angle.

However, user variables can only be defined for weapons in the player class, so you have to add the variable to the player itself.

Maybe user variables can be used in some old weapons(e.g. Wave Burner).
Title: Re: [Suggestion for modding] Add a user variable
Post by: CutmanMike on September 30, 2016, 12:57:41 PM
I've been tinkering with user variables and they seem to work fine online so all seems good. I'm not sure if defining them in the player class for weapon specific things is correct though. What if a custom made inventory item also wants to access these variables? Or an ACS script? I know they don't work in weapons (I tried it) but I can't help but feel there's a more elegant way to do this.

Edit: Wait, how would you access and set these said variables in a weapon?
Title: Re: [Suggestion for modding] Add a user variable
Post by: Xhatahx on September 30, 2016, 01:45:48 PM
Like this:

Code: [Select]
Ready:
FLSB T 0 ACS_ExecuteAlways(998,0,86)
FLSB T 0 A_SetUserVar("user_var",0)
FLSB T 1 A_WeaponReady
Goto Ready+2
Fire:
FLSB T 0 A_JumpIfNoAmmo("NoAmmo")
FLSB T 0 A_PlaySoundEx("misc/fakeshot","Weapon")
FLSB T 0 A_FireCustomMissile("BassShot",0,1,8,0)
FLSB T 0 A_FireCustomMissile("BassShot",10+ACS_ExecuteWithResult(112)*2,0,8,0)
FLSB T 0 A_FireCustomMissile("BassShot",-(10+ACS_ExecuteWithResult(112)*2),0,8,0)
FLSB UV 2
FLSB T 0 A_JumpIf(user_var>=14,"EndFire")
FLSB T 0 A_SetUserVar("user_var",ACS_ExecuteWithResult(112)+1)
FLSB T 0 A_Refire
Goto Ready+1
EndFire:
FLSB UV 6
FLSB T 20
Goto Ready+1

<Meanwhile, in ACS...>
script 112 (void)
{
SetResultValue(GetUserVariable(0,user_var));
}
Title: Re: [Suggestion for modding] Add a user variable
Post by: CutmanMike on September 30, 2016, 02:20:29 PM
I'll have to talk this over with Lego. I'm worried that if we assign a bunch of random generic user variables to the player class, all sorts of things could end up wanting to use them and cause issues if more than one thing wants to access them. I am all for doing away with inventory jumps and all that garbage, but want to make sure it is done correctly.

For now though, for something as simple as this, you could use Args and A_SetArg (http://zdoom.org/wiki/A_SetArg). You don't even need ACS this way. These are still bound to the playerclass and not the weapon, though.
Title: Re: [Suggestion for modding] Add a user variable
Post by: Xhatahx on September 30, 2016, 04:07:46 PM
For now though, for something as simple as this, you could use Args and A_SetArg (http://zdoom.org/wiki/A_SetArg).
Oh, right. Derp. You can lock this topic now.