Mario384 Posted May 17, 2015 Share Posted May 17, 2015 Basically, I want a character's attack to be a melee, but instead it seems this won't work: local function EquipWeapon(inst) if inst.components.inventory and not inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) then local weapon = CreateEntity() --[[Non-networked entity]] weapon.entity:AddTransform() weapon:AddComponent("weapon") weapon.components.weapon:SetDamage(inst.components.combat.defaultdamage) weapon.components.weapon:SetRange(inst.components.combat.attackrange, inst.components.combat.attackrange+4) weapon.components.weapon:SetProjectile("bishop_charge") weapon:AddComponent("inventoryitem") weapon.persists = false weapon.components.inventoryitem:SetOnDroppedFn(inst.Remove) weapon:AddComponent("equippable") inst.components.inventory:Equip(weapon) endend When the player recieves it, the game crashes. Any way I can fix it, or do I have to make my own weapon? Link to comment https://forums.kleientertainment.com/forums/topic/54106-equip-weapon-not-working-on-players/ Share on other sites More sharing options...
Seiai Posted May 17, 2015 Share Posted May 17, 2015 @Mario384, this all looks a bit confusing to me. if u attack something without any weapon equipped, your character automatically attacks melee(use Crtl to force attack), so i dont know why u would try to add anything to your character anyway? also, i assume this code is support to be in the prefab of an item, or is it? if its supposed to be an item, and melee, why dont just base it on the spear? to me this code looks like to copypasted stuff together without knowing what it does.... Link to comment https://forums.kleientertainment.com/forums/topic/54106-equip-weapon-not-working-on-players/#findComment-638312 Share on other sites More sharing options...
Mario384 Posted May 17, 2015 Author Share Posted May 17, 2015 (edited) @Mario384,This all looks a bit confusing to me.if you attack something without any weapon equipped, your character automatically attacks melee(use Crtl to force attack), so I dont know why you would try to add anything to your character anyway?also, I assume this code is support to be in the prefab of an item, or is it?if its supposed to be an item, and melee, why dont just base it on the spear? ( Insult here, if it's confusing to you, don't tell people they have no idea what they're doing.) This is the weapon the Bishop uses. It allows him to fire a special bolt which occurs in his attacks. This is in his prefab, and it is equipped when he spawns. I know precisely that the player can use crtl and left click, and this is not a melee weapon. Edited May 17, 2015 by Mario384 Link to comment https://forums.kleientertainment.com/forums/topic/54106-equip-weapon-not-working-on-players/#findComment-638332 Share on other sites More sharing options...
DarkXero Posted May 17, 2015 Share Posted May 17, 2015 @Mario384, equip your bishop with this:bishopweapon.lua Link to comment https://forums.kleientertainment.com/forums/topic/54106-equip-weapon-not-working-on-players/#findComment-638338 Share on other sites More sharing options...
Seiai Posted May 17, 2015 Share Posted May 17, 2015 ( Insult here, if it's confusing to you, don't tell people they have no idea what they're doing.)well, i help a lot of pple, who actually just copypaste stuff together without knowing what they are actually doin (and who mostly also admit it) and u talking about your character just attacking with melee, while your code creates projectiles and looks like a function from a weaponprefab didnt make much sense to me, thats why i assumed it. also, i didnt say anything like "dont just copypaste stuff together", i specifically worded it, that iam confused and it looks to me, like u copypasted it together. and yes, it was new to me that creating a weaponentity on the fly like that is a thing. Link to comment https://forums.kleientertainment.com/forums/topic/54106-equip-weapon-not-working-on-players/#findComment-638416 Share on other sites More sharing options...
Mario384 Posted May 18, 2015 Author Share Posted May 18, 2015 @Mario384, equip your bishop with this: Thank you again, my friend, your wonders may never cease. Link to comment https://forums.kleientertainment.com/forums/topic/54106-equip-weapon-not-working-on-players/#findComment-638632 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now