I've split the shrinker and expander into two weapons. Duke must pick each one up separately. However, there is an issue.
The "gotweapon" member in the player struct is useful and most of the coding was just copy and paste from the shrinker. Only problem is if you accidently hit 7 when you have the shrinker, but don't have the expander yet, you'll get locked out of the shrinker. The only way you can select the shrinker again is if you pick up the expander. Another part of the issue is even if you pick up the expander first, you can't select it until you find the shrinker and can flip back and forth. In other words you need both weapons to switch between one and the other.
I doubt that this is a "never encountered it before issue" but I couldn't find anything on the forums about it.
Does anyone know how to fix this problem?
Page 1 of 1
Splitting the Shrink and Expander Key Binding Issue "Get locked out of the shrinker until you find the expander."
#1 Posted 01 August 2020 - 01:42 AM
#2 Posted 01 August 2020 - 03:26 PM
This is what I have so far:
You can pick up the shrinker and get ammo for it. Even if you don't have ammo you still can pull it up. If you don't have the expander, you still can pull up the shrinker if you have it. If you only have the expander and have ammo for it, you can pull it up without the shrinker.
You can have either weapon with its ammo and pull it up without the need for the other weapon. The only problem is if you have the shrinker, but not the expander weapon, and get expander ammo, you get locked out of the shrinker even if the shrinker has ammo. The opposite is not true the other way around for the expander weapon.
The code below seems to have no effect.
However it is now possible to pick up the shrinker without the expander just as long as you don't get any expander ammo. Contradictory to the previous statement, you can pick up the expander and get ammo for it while at the same time get ammo for the shrinker. Even if you don't have the shrinker weapon, you can still use the expander without getting locked out of it.
This is weird.
Please share some ideas. I'm sure there is a solution. Before you answer, run both sets of code to see exactly what I'm talking about.
Uhh, HELLMOUSE. There is no expander actor! How can we test it if it does not exist!
Here it is with the shrinker as well. Don't worry, tile 32 should be the expander. If not, then you can use another art tile with this picture. I've made a few changes with the displayed weapon in the game and will make changes to this art tile for the actor, eventually.
NEEDED FOR SH-EX TEST.TXT (1.96K)
Number of downloads: 135
Right click for options and save as a PNG.
// put this somewhere above APLAYER gamevar GUN_FUDGE_SH 0 1 gamevar GUN_FUDGE_EX 0 1 // put this under APLAYER actor getplayer[].gotweapon 6 GUN_FUDGE_SH getplayer[].gotweapon 11 GUN_FUDGE_EX ifvare GUN_FUDGE_EX 0 setplayer[].bsubweapon 6 1 else ifvare GUN_FUDGE_SH 0 setplayer[].bsubweapon 11 1
You can pick up the shrinker and get ammo for it. Even if you don't have ammo you still can pull it up. If you don't have the expander, you still can pull up the shrinker if you have it. If you only have the expander and have ammo for it, you can pull it up without the shrinker.
You can have either weapon with its ammo and pull it up without the need for the other weapon. The only problem is if you have the shrinker, but not the expander weapon, and get expander ammo, you get locked out of the shrinker even if the shrinker has ammo. The opposite is not true the other way around for the expander weapon.
The code below seems to have no effect.
// put this somewhere above APLAYER gamevar GUN_FUDGE_AMMO 0 1 // put this under APLAYER actor getplayer[].ammo_amount 11 GUN_FUDGE_AMMO ifvarg GUN_FUDGE_AMMO 0 ifvare GUN_FUDGE_EX 0 setplayer[].bsubweapon 6 1
However it is now possible to pick up the shrinker without the expander just as long as you don't get any expander ammo. Contradictory to the previous statement, you can pick up the expander and get ammo for it while at the same time get ammo for the shrinker. Even if you don't have the shrinker weapon, you can still use the expander without getting locked out of it.
This is weird.
Please share some ideas. I'm sure there is a solution. Before you answer, run both sets of code to see exactly what I'm talking about.
Uhh, HELLMOUSE. There is no expander actor! How can we test it if it does not exist!
Here it is with the shrinker as well. Don't worry, tile 32 should be the expander. If not, then you can use another art tile with this picture. I've made a few changes with the displayed weapon in the game and will make changes to this art tile for the actor, eventually.
NEEDED FOR SH-EX TEST.TXT (1.96K)
Number of downloads: 135
Right click for options and save as a PNG.
This post has been edited by HELLMOUSE: 01 August 2020 - 04:18 PM
#3 Posted 01 August 2020 - 04:49 PM
What does setting the bsubweapon x member of the player struct do? I've never seen that before and it's not listed in the wiki.
#4 Posted 01 August 2020 - 05:58 PM
It is used to remember if the player had the shrinker or expander up last time. So, if the player hits the shrinker/expander key the last one that was selected comes up. I wasn't completely sure how it worked but used it to set what weapon the player can bring up. It was a way to force the player to not select the other weapon. It does not look like it is listed in the "Members of the player structure".
Structure members
---Members of the player structure
------subweapon
---------bsubweapon
Under the subweapon description there is a sentance that has a link to bsubweapon in it. "Identical to bsubweapon, except it interprets the value as true/false for each weapon."
here is the link: https://wiki.eduke32...wiki/Bsubweapon
I stumbled on to it from "spritebridge" (the link you gave me). Then I went to "Player structure members" and that took me to the "Category:Player structure members" page.
Another way to get to it is at the very bottom of "Members of the player structure" click "Player manipulation".
Then on the "Category:Player manipulation" page, under subcategory "P", there is "Player structure members (151 P)".
On the "Category:Player structure members" page, under B, is the "Bsubweapon" and, under S, is "Subweapon".
It is a little counterintuitive to find it.
Structure members
---Members of the player structure
------subweapon
---------bsubweapon
Under the subweapon description there is a sentance that has a link to bsubweapon in it. "Identical to bsubweapon, except it interprets the value as true/false for each weapon."
here is the link: https://wiki.eduke32...wiki/Bsubweapon
I stumbled on to it from "spritebridge" (the link you gave me). Then I went to "Player structure members" and that took me to the "Category:Player structure members" page.
Another way to get to it is at the very bottom of "Members of the player structure" click "Player manipulation".
Then on the "Category:Player manipulation" page, under subcategory "P", there is "Player structure members (151 P)".
On the "Category:Player structure members" page, under B, is the "Bsubweapon" and, under S, is "Subweapon".
It is a little counterintuitive to find it.
#5 Posted 01 August 2020 - 08:16 PM
Making new subweapons are a pain. Personally, I find it goes more smoothly if you just allow the shrinker/expander to be a set (getting one gives the other) instead of fighting the hardcoding. When I want to make a new subweapon that isn't linked that way to an existing weapon, I don't usually put it on the shrinker slot. It takes some work, but you can do it using your own gamevars and hacking events such as next/prev weapon to make it switch to your new weapon in the right place in the lineup. Also add code to the appropriate number key event. There are examples of this in Alien Armageddon and my older mods, although AA probably has the best implementation of it and there are several of them. It might be hard to read the code because there are multiple characters and lots of other stuff to wade through.
#6 Posted 02 August 2020 - 09:09 PM
Solved it. I'm not 100% sure why this works but I don't get locked out of either weapon with any of the in-game situations. This seems to be the only combination of subweapon and bsubweapon that works. I've also allowed for Duke to have an overcharge for each weapon in case the ammo is full and then he picks up the weapon. Of course I had to have a safeguard in my Double Ammo Actors', Boother Math state.
// This goes above APLAYER actor gamevar HAVE_SHRINKER 0 1 gamevar HAVE_DARKEXP 0 1 // This goes under APLAYER actor // **** Shrinker and Dark Expander split fix **** // This is needed so the player does not get locked out of the // other weapon until it is picked up. It also prevents the HUD // from showing the wrong ammo status if the player hits “7” again // expecting the other weapon to show up when Duke does not have it. getplayer[].gotweapon 6 HAVE_SHRINKER getplayer[].gotweapon 11 HAVE_DARKEXP ifvare HAVE_DARKEXP 0 setplayer[].subweapon 6 else ifvare HAVE_SHRINKER 0 setplayer[].bsubweapon 11 1
#7 Posted 02 August 2020 - 11:34 PM
Danukem, on 01 August 2020 - 04:49 PM, said:
What does setting the bsubweapon x member of the player struct do? I've never seen that before and it's not listed in the wiki.
It's the same as subweapon, except it works like this:
setplayer[].bsubweapon GROW_WEAPON 1
#8 Posted 03 August 2020 - 01:18 PM
I've listed a few ways to find in on post #4. It is not easy to find.
"setplayer[].bsubweapon 11 1" did not yield the same results as "setplayer[].subweapon 11 1". "setplayer[].subweapon 11 1" locked me out of the expander when I picked-up shrinker ammo without the shrinker.
Using 11 or GROW_WEAPON is the same. "bsubweapon" is expecting a binary value of either 1 or 0. Maybe that's what the "b" stands for.
From Wiki:
"This value is used to "remember" if the player has the Shrinker or Expander selected when changing weapon.
Identical to subweapon, except the it interprets the value as a bitfield for each weapon."
I really don't have anything more than that. Like I said I just started playing around with them and this worked. Maybe "bsubweapon" was a fudge-it factor just for the expander when the makers of Duke Nukem created the Plutonium addition. I can't really tell you more than what the Wiki says and my experiment's results. I was just testing every in-game situation against the positions of "subweapon" vs "bsubweapon" and using one or the other in both "setplayer[]" commands.
Thinking about it. It kind of makes sense. This weird "bsubweapon" only works correctly with the expander not the shrinker, and "subweapon" only works with the shrinker not the expander. That code I have also keeps the ammo set to the shrinker if Duke does not have the expander yet. Before, hitting 7 again with the shrinker would display the expander's ammo which is incorrect.
By the way, I did give both weapons an ammo value of 5 and not 0. Doing that just gives you the ability to pick-up the expander to look at it with 5 rounds. When it was 0 you couldn't bring it up to see 0 and have Duke put it away again. That really didn't mean anything because there is no ammo in it so what's the point?
Well, now people know how to split the shrinker and expander in case they ever want to.
All of this just from a question about a spritebridge.
"setplayer[].bsubweapon 11 1" did not yield the same results as "setplayer[].subweapon 11 1". "setplayer[].subweapon 11 1" locked me out of the expander when I picked-up shrinker ammo without the shrinker.
Using 11 or GROW_WEAPON is the same. "bsubweapon" is expecting a binary value of either 1 or 0. Maybe that's what the "b" stands for.
From Wiki:
"This value is used to "remember" if the player has the Shrinker or Expander selected when changing weapon.
Identical to subweapon, except the it interprets the value as a bitfield for each weapon."
I really don't have anything more than that. Like I said I just started playing around with them and this worked. Maybe "bsubweapon" was a fudge-it factor just for the expander when the makers of Duke Nukem created the Plutonium addition. I can't really tell you more than what the Wiki says and my experiment's results. I was just testing every in-game situation against the positions of "subweapon" vs "bsubweapon" and using one or the other in both "setplayer[]" commands.
Thinking about it. It kind of makes sense. This weird "bsubweapon" only works correctly with the expander not the shrinker, and "subweapon" only works with the shrinker not the expander. That code I have also keeps the ammo set to the shrinker if Duke does not have the expander yet. Before, hitting 7 again with the shrinker would display the expander's ammo which is incorrect.
By the way, I did give both weapons an ammo value of 5 and not 0. Doing that just gives you the ability to pick-up the expander to look at it with 5 rounds. When it was 0 you couldn't bring it up to see 0 and have Duke put it away again. That really didn't mean anything because there is no ammo in it so what's the point?
Well, now people know how to split the shrinker and expander in case they ever want to.
All of this just from a question about a spritebridge.
#9 Posted 06 August 2020 - 07:39 PM
Share this topic:
Page 1 of 1