Weapons/Armor Changing Sprites Depending On Variables

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!)
User avatar
SwiftFunk
Posts: 86
Joined: Thu Dec 22, 2016 1:39 pm
Graphics Processor: Intel (Modern GZDoom)
Location: here and there, at the same time

Weapons/Armor Changing Sprites Depending On Variables

Post by SwiftFunk »

Was making a mod with a randomizer to add different looks for weapons and armor depending on an internal rolled number, I would like to know how I would go about doing this, or where a tutorial would be that would help.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Weapons/Armor Changing Sprites Depending On Variables

Post by Apeirogon »

Code: Select all

a_jumpif( "internal_rolled_number" == first_defined_value, "state_dependent_on_first_defined_value")
a_jumpif( "internal_rolled_number" == second_defined_value, "state_dependent_on_second_defined_value")
...
Repeat until define all wished sprite sheet in armor/weapon.
User avatar
SwiftFunk
Posts: 86
Joined: Thu Dec 22, 2016 1:39 pm
Graphics Processor: Intel (Modern GZDoom)
Location: here and there, at the same time

Re: Weapons/Armor Changing Sprites Depending On Variables

Post by SwiftFunk »

What would these defined values be? would they be the sprites or something? Also, what's the ... part for? I'm sorta new to this scripting thing.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Weapons/Armor Changing Sprites Depending On Variables

Post by Apeirogon »

How much you know?
Can you code simple, working weapon, than can shoot/bob/reload/make coffee at morning? Pistol, shootgun, magick wand, boomstick, anything?
User avatar
SwiftFunk
Posts: 86
Joined: Thu Dec 22, 2016 1:39 pm
Graphics Processor: Intel (Modern GZDoom)
Location: here and there, at the same time

Re: Weapons/Armor Changing Sprites Depending On Variables

Post by SwiftFunk »

I know how to make a menu, and I found weasels old decorate tutorials. I do know how to make a weapon that fires at least bullets and shotgun shells.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Weapons/Armor Changing Sprites Depending On Variables

Post by Apeirogon »

SwiftFunk wrote:different looks for weapons and armor depending on an internal rolled number
How much "looks" and what number you wish to use?
User avatar
SwiftFunk
Posts: 86
Joined: Thu Dec 22, 2016 1:39 pm
Graphics Processor: Intel (Modern GZDoom)
Location: here and there, at the same time

Re: Weapons/Armor Changing Sprites Depending On Variables

Post by SwiftFunk »

at least the colors yellow, red, and cyan for weapons and armor. so the number range would be 1-3 cause 3 colors.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Weapons/Armor Changing Sprites Depending On Variables

Post by Apeirogon »

Here example with CVARs.

Code: Select all

actor colorful_armor:bluearmor
{states
{
spawn:
sprite letter number a_jumpif(getcvar("inventory_color") == 1, "red_armor")//getcvar return server float Console VARiable you can assign any number for any color, it just example
sprite letter number a_jumpif(getcvar("inventory_color") == 2, "cyan _armor")//jump perform only if all conditions inside a_jumpif will become true
sprite letter number a_jumpif(getcvar("inventory_color") == 3, "yellow_armor")//two = because programming feature, single = means "make staff from left part eaqule to right", two means "if left part eaqule right"
loop

red_armor://this state has sprite of yellow armor
sprite letter number a_jumpif(getcvar("inventory_color") == 0, "spawn")//if no cvar set go back to standart sprite
sprite letter number a_jumpif(getcvar("inventory_color") == 2, "cyan _armor")//in case if you tired from red color and want switch to another
sprite letter number a_jumpif(getcvar("inventory_color") == 3, "yellow_armor")
loop

cyan _armor://as write higher
sprite letter number a_jumpif(getcvar("inventory_color") == 0, "spawn")
sprite letter number a_jumpif(getcvar("inventory_color") == 2, "cyan _armor")
sprite letter number a_jumpif(getcvar("inventory_color") == 3, "yellow_armor")
loop

yellow_armor://-
sprite letter number a_jumpif(getcvar("inventory_color") == 0, "spawn")
sprite letter number a_jumpif(getcvar("inventory_color") == 2, "cyan _armor")
sprite letter number a_jumpif(getcvar("inventory_color") == 3, "yellow_armor")
loop

}}
You can set cvar using menu.
More here
https://zdoom.org/wiki/CVARINFO

Return to “Scripting”