Due to the recent resurgence of spam, we have temporarily disabled user creation and page editing/creation as we resolve the issue.

Swap Mod

From Snapwiki
Jump to: navigation, search

It is possible to switch mods on command in SnapMaps, but requires some planning from the map author. By tracking the current weapon/mod and offhand weapon/mod, the current mod can be swapped out.

This patterns is a modified version of the Bigger Loadouts pattern.

This pattern is designed for singleplayer maps. Multiplayer maps will have to modify this pattern to track each player's current weapon, current mod, offhand weapon and offhand mod.

See the example map with ID V9UPXBJ and name "Pattern: Swap Mod".


Sequencer Tree

In this example, the map will have 3 weapons with two mods each.

Weapon Number Weapon Name Mod Number Mod Name
1 Plasma Rifle 1 Static Field
2 Stun
2 Combat Shotgun 1 Charged Burst
2 Explosive Shot
3 Heavy Assault Rifle 1 Micro Missiles
2 Zoom

This pattern uses a tree of Sequencers. The first branch will have the same number of outputs as the number of weapons in the map. We have 3 weapons in this example, so the first sequencer will have 3 outputs. Each weapon is assigned a number 1-3, as shown in the table above. The next branch will have one Sequencer with a toggle configuration for each pair of mods. Each mod will be assigned a number 1 or 2. The tree is shown below with the branches highlighted in yellow.
SequencerTree.png


Whenever a player picks up a new weapon or switches weapons (use a Player Input to track this), update an integer that we'll call "current weapon" to the assigned number (1-3). The off-hand weapon should also be stored as a variable. The "current mod" should also be a variable (1-2), and the offhand mod should be stored.

At the start of the map, give the player a loadout with two weapons and initialize the four variables "Current Weapon", "Current Mod", "Offhand Weapon", and "Offhand Mod". This example loadout gives the Plasma Rifle with Static Field mod and Combat Shotgun with Explosive Shot mod. The variables "Current Weapon" and "Current Mod" are initialized to 1, and the variables "Offhand Weapon", and "Offhand Mod" are set to 2.
SwapModInitialize.PNG

Whenever a player picks up a weapon, set the "Current Weapon" and "Current Mod" variables appropriately. Be sure to disable the Allow Dropping Weapon On Pickup property in Gameplay Settings to prevent a player from picking up a weapon anywhere else. You will also need to prevent randomly spawned weapons if using Item Spawn Settings. Whereber a player can pick up a weapon, you will need to update the "current" variables.
SwapModOnPickedUp.PNG

When the player switches weapons, you'll need to swap the "current" variables with the "offhand" variables. Save off the "current" values in temporary integers, set the "current" values to the "offhand" values then set the "offhand" values to the temporary values.
SwapModSwapWeapon.PNG

When the player uses the terminal (or whatever triggers the mod swap), index the first sequencer to the "current weapon" branch before sending the signal down that branch. On the second sequencer, index to the "current mod" branch and send the signal. The signal will travel down the current mod branch and give the player the other mod while setting the "Current Mod" variable to the proper value. Remember to set the Run One Output Per Signal property to true on all the sequencers in the tree.
SwapModSwapMod.PNG