Abandoned_Account Posted June 6, 2023 So im recently planning to make a simple mod for doom that change weapons and monsters a little. Like you have a gun with three colors (Red is deafult), and alt fire will change the color of a gun (Red -> Yellow -> blue -> Red again), and i need help with tokens to make that happen. Like how to create a token and how to make gun check the token? I cant find anything online so yeah i really appreciate your help! Also if you wanna know what mod im working on i call this Color Doom, u have monsters that will spawn randomly with one of three colors (Red, Blue, Yellow) and your gun have to match the color of your target to wound it (Melee weapons and BFG gonna deal damage to any color of demon and bosses probably gonna be damaged by every color). Dont worry damage types and random monsters spawn i figure probably myself hopefully. So back to the topic, how to create tokens and how to make them to let alt fire switch weapon mode? 0 Share this post Link to post
Kan3 Posted June 6, 2023 "Tokens" are very easy to make, they're just dummy inventory item with no purpose, so everything you have to do is to define them as such: Actor YellowToken : Inventory { Inventory.MaxAmount 1 } (I take for granted that you're working with DECORATE) Once you have your tokens, all you need to do to check for them is to use functions such as A_JumpIfinventory. Though, to switch weapons fire modes is not very immediate to make. You can achieve that in 2 ways (that come to mind): You check for the tokens in every weapon state and jump to a unique state for each different token. You'll need quite a lot of states. You create 1 weapon for each different token and, instead of jumping to different states depending on the token, you remove from the player inventory the current weapon and give him another one corresponding the right token. I prefer the second option because the first one can result in a bit of a mess to navigate, but it depends on the weapon. Remember that you have to give the player 1 of the tokens right at the start. You can do this by just calling once for A_GiveInventory in the raise state for example. The important part is the switching code: AltFire: TNT1 A 0 A_JumpIfInventory("YellowToken", 1, "SwitchToBlue") //Check if the player has at least 1 yellow token and go to the switching state. TNT1 A 0 A_JumpIfInventory("BlueToken", 1, "SwitchToRed") //Same, but for the blue. TNT1 A 0 A_JumpIfInventory("RedToken", 1, "SwitchToYellow") //You can switch the order of this stuff, depending on which token you want to be first etc. Goto Ready //Just in case. SwitchToBlue: TNT1 A 0 A_JumpIf(CountInv("BlueToken") == 0, "SwitchToRed") //This will check if the player has a blue token and if not it will try to switch to another color (If you intend to always let the player being able to switch fire mode, then this is unnecessary of course). TNT1 A 0 A_GiveInventory("BlueToken", 1) //Give the blue and take the yellow. TNT1 A 0 A_TakeInventory("YellowToken", 1) //You can add your animation if you have one to replace TNT1 A 0. Goto Ready //Same for every other token. You'll have to use something like this if you go for the 1st option (you'll need to add the same 3 lines of code that you have in this AltFire state example in every "normal" weapon state, jumping to 3 different custom states). AltFire: TNT1 A 0 A_GiveInventory("BlueWeapon", 1) //You give the player the blue version of the weapon. TNT1 A 0 A_TakeInventory("YellowWeapon", 1) //You take the current yellow version. TNT1 A 0 A_SelectWeapon("BlueWeapon") //You select the blue. Goto Ready //You don't need other checks, but you have to create 3 exact copies of the same weapon, changing the switch-to. This is what you need if going for the 2nd option instead. (I left the token checks though, if you need to check if the player has or not the specific token, then you need to copy the code from before and replace the 2 bottom lines of the custom SwitchToX custom states with these 3 lines). That's basically it 0 Share this post Link to post
Abandoned_Account Posted June 6, 2023 3 minutes ago, Kan3 said: "Tokens" are very easy to make, they're just dummy inventory item with no purpose, so everything you have to do is to define them as such: Actor YellowToken : Inventory { Inventory.MaxAmount 1 } (I take for granted that you're working with DECORATE) Once you have your tokens, all you need to do to check for them is to use functions such as A_JumpIfinventory. Though, to switch weapons fire modes is not very immediate to make. You can achieve that in 2 ways (that come to mind): You check for the tokens in every weapon state and jump to a unique state for each different token. You'll need quite a lot of states. You create 1 weapon for each different token and, instead of jumping to different states depending on the token, you remove from the player inventory the current weapon and give him another one corresponding the right token. I prefer the second option because the first one can result in a bit of a mess to navigate, but it depends on the weapon. Remember that you have to give the player 1 of the tokens right at the start. You can do this by just calling once for A_GiveInventory in the raise state for example. The important part is the switching code: AltFire: TNT1 A 0 A_JumpIfInventory("YellowToken", 1, "SwitchToBlue") //Check if the player has at least 1 yellow token and go to the switching state. TNT1 A 0 A_JumpIfInventory("BlueToken", 1, "SwitchToRed") //Same, but for the blue. TNT1 A 0 A_JumpIfInventory("RedToken", 1, "SwitchToYellow") //You can switch the order of this stuff, depending on which token you want to be first etc. Goto Ready //Just in case. SwitchToBlue: TNT1 A 0 A_JumpIf(CountInv("BlueToken") == 0, "SwitchToRed") //This will check if the player has a blue token and if not it will try to switch to another color (If you intend to always let the player being able to switch fire mode, then this is unnecessary of course). TNT1 A 0 A_GiveInventory("BlueToken", 1) //Give the blue and take the yellow. TNT1 A 0 A_TakeInventory("YellowToken", 1) //You can add your animation if you have one to replace TNT1 A 0. Goto Ready //Same for every other token. You'll have to use something like this if you go for the 1st option (you'll need to add the same 3 lines of code that you have in this AltFire state example in every "normal" weapon state, jumping to 3 different custom states). AltFire: TNT1 A 0 A_GiveInventory("BlueWeapon", 1) //You give the player the blue version of the weapon. TNT1 A 0 A_TakeInventory("YellowWeapon", 1) //You take the current yellow version. TNT1 A 0 A_SelectWeapon("BlueWeapon") //You select the blue. Goto Ready //You don't need other checks, but you have to create 3 exact copies of the same weapon, changing the switch-to. This is what you need if going for the 2nd option instead. (I left the token checks though, if you need to check if the player has or not the specific token, then you need to copy the code from before and replace the 2 bottom lines of the custom SwitchToX custom states with these 3 lines). That's basically it Thanks! It helped me with tokens because i started trying stuff myself with a help of someone and i got stuff but tokens we broken. Now when i fixed those i have only one issue, idk why but when i fire red pistol it stays, yellow stays yellow, but blue switches to red when shooting xD I think im blind and dont see the problem, here how it looks in Decorate: //X=Red //Y=Yellow //Z=Blue ACTOR TokenX : Inventory { Inventory.MaxAmount 1 } ACTOR TokenY : Inventory { Inventory.MaxAmount 1 } ACTOR TokenZ : inventory { Inventory.MaxAmount 1 } ACTOR CPistol : DoomWeapon Replaces Pistol { Weapon.SelectionOrder 1900 Weapon.AmmoUse 1 Weapon.AmmoGive 20 Weapon.AmmoType "CClip" Obituary "$OB_MPPISTOL" +WEAPON.WIMPY_WEAPON Inventory.Pickupmessage "$PICKUP_PISTOL_DROPPED" Tag "$TAG_PISTOL" States { Select: TNT1 A 0 A_JumpIfInventory("tokenx",1,"SelectX") TNT1 A 0 A_JumpIfInventory("tokeny",1,"SelectY") TNT1 A 0 A_JumpIfInventory("tokeny",1,"SelectZ") Ready: TNT1 A 0 A_JumpIfInventory("tokenx",1,"ReadyX") TNT1 A 0 A_JumpIfInventory("tokeny",1,"ReadyY") TNT1 A 0 A_JumpIfInventory("tokeny",1,"ReadyZ") ReadyX: PIRG A 1 A_WeaponReady Loop ReadyY: PIYG A 1 A_WeaponReady Loop ReadyZ: PIBG A 1 A_WeaponReady Loop Deselect: "XXXX" A 0 A_Lower Loop SelectX: PIRG A 1 A_Raise Loop SelectY: PIYG A 1 A_Raise Loop SelectZ: PIBG A 1 A_Raise Loop Fire: TNT1 A 0 A_JumpIfInventory("tokenx",1,"FireX") TNT1 A 0 A_JumpIfInventory("tokeny",1,"FireY") TNT1 A 0 A_JumpIfInventory("tokeny",1,"FireZ") FireX: PIRG A 4 PIRG B 6 A_FirePistol PIRG C 4 PIRG B 5 A_ReFire Goto ReadyX FireY: PIYG A 4 PIYG B 6 A_FirePistol PIYG C 4 PIYG B 5 A_ReFire Goto ReadyY FireZ: PIBG A 4 PIBG B 6 A_FirePistol PIBG C 4 PIBG B 5 A_ReFire Goto ReadyZ Altfire: TNT1 A 0 A_JumpIfInventory("tokenx",1,"AltFireX") TNT1 A 0 A_JumpIfInventory("tokeny",1,"AltFireY") TNT1 A 0 A_JumpIfInventory("tokenz",1,"AltFireZ") AltFireX: PIRG A 5 A_TakeInventory("Tokenx",1) PIYG A 5 A_GiveInventory("Tokeny",1) Goto ReadyY AltFireY: PIYG A 5 A_TakeInventory("Tokeny",1) PIBG A 5 A_GiveInventory("Tokenz",1) Goto ReadyZ AltFireZ: PIBG A 5 A_TakeInventory("Tokenz",1) PIRG A 5 A_GiveInventory("Tokenx",1) Goto ReadyX Flash: PISF A 7 Bright A_Light1 Goto LightDone PISF A 7 Bright A_Light1 Goto LightDone Spawn: PIST A -1 Stop } } 1 Share this post Link to post
Kan3 Posted June 6, 2023 (edited) 24 minutes ago, AuroraFox said: Fire: TNT1 A 0 A_JumpIfInventory("tokenx",1,"FireX") TNT1 A 0 A_JumpIfInventory("tokeny",1,"FireY") TNT1 A 0 A_JumpIfInventory("tokenY",1,"FireZ") That's your issue. When you have the blue token (z) you don't check for it and the weapon goes straight to FireX turning into red 0 Share this post Link to post
Abandoned_Account Posted June 6, 2023 (edited) 12 minutes ago, Kan3 said: That's your issue. When you have the blue token (z) you don't check for it and the weapon goes straight to FireX turning into red Oh thanks! It sometimes hard to notice those errors and easy to skip when writing hah. Muscle memory just hits and you write twice the same thing haha 1 Share this post Link to post
Kan3 Posted June 6, 2023 2 hours ago, AuroraFox said: Oh thanks! It sometimes hard to notice those errors and easy to skip when writing hah. Muscle memory just hits and you write twice the same thing haha I can't even guess how many times it also happened to me x) 0 Share this post Link to post