Item Manager
From Graal Bible
This section will go over how to create and add an item (gun, melee, items...) to your character.
Step1
In the weapon: 3D/Player/Item/Manager
in the function onCreated() and to the variable this.allItems add your item using this format:
| {name Of Item, associated Weapon, icon Prefab for UI} |
|---|
Step2
Create the associated Weapon for the item you want to create.
Check 3D/Player/Item/Weapons/Ranged/Gun/M16 for example.
//#CLIENTSIDE
function onCreated() {
this.isEquipped = false;
this.prefabName = "M16";
this.muzzleScale = 0.56;
this.firerate = 0.2;
this.bulletSpread = 1;
this.bulletPerShot = 1;
this.maxMagazineAmmo = 30;
this.reloadSpeed = 2;
this.maxRange = 14;
this.isBow = false;
settimer(9999);
this.shootCD = 0;
}
function onUpdate() {
if (this.shootCD < 0 || !this.isEquipped) return;
this.shootCD -= Time::deltaTime;
}
public function onAction() {
if (!this.isEquipped) {
RANGEDBASE.equipRanged(this.prefabName, this.muzzleScale, this.firerate, this.bulletSpread, this.bulletPerShot, this.maxMagazineAmmo, this.reloadSpeed, this.maxRange, this.isBow);
this.isEquipped = true;
} else if (this.shootCD < 0) {
RANGEDBASE.onShootBullet(this.bulletPerShot);
this.shootCD = this.firerate;
}
}
public function unEquip() {
if (!this.isEquipped) return;
this.isEquipped = false;
RANGEDBASE.unEquip();
}