--------------------------------------------------------------------------------------------------------------- Multi Projectile Weapons Tutorial --------------------------------------------------------------------------------------------------------------- This tutorial shows you how to make weapons that use multiple projectiles that can be cycled through. For the case of simplicity, the 'beacon::onUse' function was used for cycling projectile types when beacons aren't being placed (ie: not looking at the ground). Step #1 // ------------------------------------------ // NameofWeapon.cs // ------------------------------------------ 1a) Any weapons that will use multiple projectile's needs to have more datablocks added. Make as many copies of the weapons origional projectile datablock as desired and rename each one to a different name. Next modify each new datablock to the settings you desire. 2a) In the weaponImage datablock of the weapon we're giving multiple projectiles, add this code: numprojectiles = x; //Where x is number of different projectiles being used projectile2 = "NameofProjectile2Datablock"; //Repeat these three lines for as many projectileType2 = "TypeofProjectile2DataBlock"; //projectiles as the weapon has. item2 = "NameofWeaponWhileUsingProjectile2"; //Incrementing each time. (ex: Item2 -> Item3) Step #2 // ------------------------------------------ // item.cs // ------------------------------------------ as said earlier, this tutorial simply uses a part of the beacon::onUse function for cycling weapons. You can instead bind this to other functions, such as 'use healthkit' if prefered. The last 6 lines of code that use bottomprint are optional if you want to bottomprint a message stating what projectile is being used. This is setup to bottomprint up to 3 different projectiles. Add more if needed. function Beacon::onUse(%data, %obj) { //Leave code above here alone if(!%searchResult ) { //lines in here need removed. } //Leave code below here alone } replaced with: function Beacon::onUse(%data, %obj) { if(!%searchResult ) { %numproj = %obj.client.player.getMountedImage($WeaponSlot).numprojectiles; if ((%numproj !$= "") && (%numproj > 1)) { if (%obj.client.player.changeprojectile $= "") %obj.client.player.changeprojectile = 1; else %obj.client.player.changeprojectile += 1; if (%obj.client.player.changeprojectile >= %numproj) %obj.client.player.changeprojectile = 0; if (%obj.client.player.changeprojectile == 2) bottomPrint(%obj.client, %obj.client.player.getMountedImage($WeaponSlot).item3, 1, 1); else if (%obj.client.player.changeprojectile == 1) bottomPrint(%obj.client, %obj.client.player.getMountedImage($WeaponSlot).item2, 1, 1); else bottomPrint(%obj.client, %obj.client.player.getMountedImage($WeaponSlot).item, 1, 1); } } } Step #3 // ------------------------------------------ // Projectile.cs // ------------------------------------------ 3a) This gets added to the top of the function ShapeBaseImageData::onFire(%data, %obj, %slot). It handles up to 3 projectiles. Add more if needed. if ((%data.numprojectiles !$= "") && (%data.numprojectiles > 1)) { if (%obj.client.player.changeprojectile == 2) //Third Projectile { %datab = %data.projectile3; %datat = %data.projectileType3; } else if (%obj.client.player.changeprojectile == 1) //Second Projectile { %datab = %data.projectile2; %datat = %data.projectileType2; } else //Default Projectile { %datab = %data.projectile; %datat = %data.projectileType; } if (%datat $= "") %datat = %data.projectileType; //Don't need to specify projectileType in datablock if same as default. } else { %datab = %data.projectile; %datat = %data.projectileType; } 3b) In the same function find both instance of dataBlock = %data.projectile; and replace with dataBlock = %datab; Next find both instances of %p = new (%data.projectileType) and replace with %p = new (%datat) Step #4 // ------------------------------------------ // Weapons.cs // ------------------------------------------ This final code handles displaying the name of the weapon when first mounted(optional), and a memory retention code that remembers the last projectile used for each weapon, so people's favorites will be ready next time they cycle back to the weapon. 4a)Add this to the bottom of function WeaponImage::onMount(%this,%obj,%slot). The lines with bottomprint are optional and handle up to 3 projectiles. Add more as needed. The top part recalls the last projectile this player used for the weapon. if (%obj.client.favproj[%this.item]) %obj.client.player.changeprojectile = %obj.client.favproj[%this.item]; if (%this.numprojectiles > 1) //This down is the optional bottomprint part { if (%obj.client.player.changeprojectile == 2) bottomPrint(%obj.client, %this.item3, 1, 1); else if (%obj.client.player.changeprojectile == 1) bottomPrint(%obj.client, %this.item2, 1, 1); else bottomPrint(%obj.client, %this.item, 1, 1); } else bottomPrint(%obj.client, %this.item, 1, 1); 4b)Add this to the top of function WeaponImage::onUnmount(%this,%obj,%slot). This saves the last projectile this player used for the projectile. if ((%this.numprojectiles > 0) && (%this.numprojectiles !$= "")) %obj.client.favproj[%this.item] = %obj.client.player.changeprojectile;