Jump to content

Recommended Posts

Hello, I created what is basically a staff for my character. It currently is able to fire bolts of energy at a target.  However, I would like to know if it would be possible to make it so that the staff can also be used a melee weapon. A little bit like how Gandalf can shoot magic from his stick then beat someone else with it.

 

Attached is my blasting stick. Thanks in advance for anyone able to chip in

item_blaster.lua

You make the staff as if it is a weapon, like a spear. So you can melee with it.

 

Then you attach a component to it, like how the orange staff has blinkstaff.

 

Then you use

AddComponentAction("SCENE", myredcomponent, function(inst, doer, actions, right)	if right and	doer:CanDoAction(ACTIONS.ATTACK) and	inst.replica.health ~= nil and not inst.replica.health:IsDead() and	inst.replica.combat ~= nil and inst.replica.combat:CanBeAttacked(doer) then		table.insert(actions, ACTIONS.THROWFIREBALL)	endend)

Then you implement THROWFIREBALL as an action that makes you go into the attack state with the cane, but spawns a fire projectile to the face of the enemy.

 

Now you attack with left click, and throw fireballs with right click.

Hello,

Sorry for necro'ing this but I have the exact same issue. I used the files that DarkXero provided and made the appropriate changes (spear, wilson) to fit my character. The "Cast Fireball" shows up on the item and the character gets in range of his target but nothing else happens.

I clearly missed something but I cannot see what exactly.
 

How silly of me. I totally forgot to do that. Here it is. This is the default, unedited version so you have something cleaner to work with.

The staff is purely a ranged weapon at the moment. Flings fireballs but cannot be used in melee nor does the little fireball shows any "fire" effect upon landing. Kind of dug into the default prefabs and created a mishmash of code.

char_mod.zip

Edited by Orim

@Orim,

there are two ways to make ranged weapons.

 

You can make them like a staff, where you attach a projectile to the attack.

Or you make it like a boomerang, where you make the weapon the projectile.

 

What I did is add a third way, I added a ranged functionality to a melee weapon, to have a melee/ranged weapon.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...