Basic Tutorials on Weapons and Ammo

Tutorials on how weapons and ammo work in Project Spark

What is a weapon?

Weapons are specialist objects which change the animation for attack and shoot depending on their type when equipped. There are 4 types of attack animations, and 3 shoot animations.

This is what happens when you press X (default brain set up)

Hit/Punch (Alternative arms punch)  – no items equipped, some non weapons, bow, blaster
Bladed swing (Right arm only) – swords, axes, torch, some non weapons (acorn for example)
Sweeping club (Right arm only)- club weapons
Flourishing blade (Right arm only) – Daggers, goblin spike

This is what happens when you press Y (default brain set up)

Traditional Archery (Fires arrows) – Upright bows
Crossbow (Fires Arrows) – Horizontally held crossbows
Laser Gun (Fires small lit projectiles) – Guns
Fireball  (Fires a ball of fire)- When no ranged weapon is equipped

How to change the projectile for ranged weapons

In the default brain is this line

WHEN [Y] DO [shoot]

Place an object from the gallery or an IWP templated object as a projectile.

WHEN [Y] DO [shoot][gallery:apple]

So instead of the default object such as an arrow or a fireball they will shoot your chosen object. Please note that objects with interact kode built in (such as the apple) will fire with a B above them. To remove this either:

place the object into your world, remove the kode, and save as a template. Use IWP.

or

place the object in your world, remove the kode, save it as an assembly. Delete it from world.Use assembly gallery to choose it in your kode line.

How to create your own weapons

Choose a weapon as your base with the attack or shoot style you want. You can attach objects to adapt a standard weapon to look different, and/or change the colour attributes. Or if you are making a weapon from scratch, attach the finished article to your base weapon so that it matches the handling point on both, and make the base weapon invisible using properties.

There is an issue with attached objects with collide on. It can cause characters to fly in the air when they touch them, or if they are created with the weapon equipped. If possible try to keep the scale of your new weapon and the old one the same, keep your invisible weapon collidable but invisible, but make your new weapon non-collidable. They will appear to be hitting things with your new weapon, but it will be the base weapon that is colliding. Bear this in mind for any koding – it will need to go in the base weapon not your attached “skin” weapon.

Limited ammo

Create a variable for your ammo

In the object that gives your character ammunition put this:

WHEN [interacted] DO [objvar: player][=][it]
…WHEN DO [objvar:player][numvar:ammo][incremented by][100]

In your player brain

WHEN [ammo][>][0] DO
…WHEN [bow (or whatever weapon)][is equipped] DO
…/…WHEN [Y][pressed] DO [shoot]
…/…/…WHEN DO [numvar:ammo][decremented by][1]

When the player has no more ammo he will not be able to fire, until he has picked up some more.

If you want the player to be able to hold down Y and fire continuously

WHEN [ammo][>][0] DO
…WHEN [bow (or whatever weapon)][is equipped] DO
…/…WHEN [Y] DO [shoot]
…/…/…WHEN DO [numvar:firing][incremented by][1]

…/…/…WHEN [started to][numvar:firing][increased][DO [numvar:ammo][decremented by][1]

Comments are closed.

Powered by WordPress.com.

Up ↑

%d bloggers like this: