Fancy_Fox_Pers Posted February 6, 2017 Share Posted February 6, 2017 Hi, I have used the waterprojectiles code from the game and copy/pasted around until I got a working projectile. The projectile works just fine, however, I don't know how to make it do damage on impact. I added a weapon component and added the damage (5) but it still doesn't do anything. There might be a correlation with the fact that the game log tells me everytime that there was already a weapon component, but I don't quite know why. Must have something to do with the components, can't find anything though. Can someone have a look at the code and tell me what's wrong, please? I just need it to do damage. Thank you! tarte_micka.lua waterprojectiles.lua Link to comment https://forums.kleientertainment.com/forums/topic/73848-projectiles-need-help/ Share on other sites More sharing options...
. . . Posted February 6, 2017 Share Posted February 6, 2017 (edited) If you add change this local function OnHit(inst, attacker, target) -- inst.SoundEmitter:PlaySound("dontstarve/creatures/pengull/splash") -- Crashes??? -- SpawnPrefab("waterballoon_splash").Transform:SetPosition(inst.Transform:GetWorldPosition()) -- inst.components.wateryprotection:SpreadProtection(inst) inst:Remove() end to this maybe you'll be able to damage to things when it hits the ground or "explodes"? I dunno, but hopefully this works for you !! local function OnHit(inst, attacker, target) local radius_1 = TheSim:FindEntities(x, y, z, 5,{"_health", "_combat"}) for k, v in pairs(radius_1) do if v and v.components.health and not v.components.health:IsDead() then v.sg:GoToState("hit") v.components.health:DoDelta(-999) end end inst:DoTaskInTime(.25, function() inst:Remove() end) end EDIT: If this works then you don't need the weapon component . Edited February 6, 2017 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/73848-projectiles-need-help/#findComment-864205 Share on other sites More sharing options...
Fancy_Fox_Pers Posted February 6, 2017 Author Share Posted February 6, 2017 Thanks! Link to comment https://forums.kleientertainment.com/forums/topic/73848-projectiles-need-help/#findComment-864240 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