Jester111 Posted April 13, 2015 Share Posted April 13, 2015 I would like to make a character with a strength aura, that would augment surrounding players' damage, but I don't know how. Could someone help me? Link to comment Share on other sites More sharing options...
DarkXero Posted April 13, 2015 Share Posted April 13, 2015 You can hook up CalcDamage from the combat component. From there, you can either make auras like sanity: local aura_delta = 0 local x,y,z = self.inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x,y,z, TUNING.SANITY_EFFECT_RANGE, nil, {"FX", "NOCLICK", "DECOR","INLIMBO"} ) for k,v in pairs(ents) do if v.components.sanityaura and v ~= self.inst then local distsq = self.inst:GetDistanceSqToInst(v) local aura_val = v.components.sanityaura:GetAura(self.inst)/math.max(1, distsq) if aura_val < 0 then aura_val = aura_val * self.neg_aura_mult end aura_delta = aura_delta + aura_val end endbut with multipliers, that would be granted by proximity to entities to a also newly created combataura component, which would be a copy of sanity aura, but with multipliers, instead of auras. The difference between auras and multipliers is that their number range is different. Or instead of using FindEntities, you can cycle through players, like this (in modmain):AddComponentPostInit("combat", function(self) local old = self.CalcDamage function self:CalcDamage(target, weapon, multiplier) if self.inst:HasTag("player") then local bonusmult = 1 for k, v in pairs(GLOBAL.AllPlayers) do if (v:HasTag("combataura")) and (not self.inst == v) and (self.inst:GetDistanceSqToInst(v) < 25) then bonusmult = bonusmult + 0.5 end end multiplier = (multiplier or 1) * bonusmult end return old(target, weapon, multiplier) endend)so when somebody hits something, the game will check if there are players with the tag "combataura" nearby. For one player nearby, the bonus is 1.5, for two, 2, for three, 2.5, for four, 3 and so on... And you can mix the distance calculations to make different bonuses based on distance value, or create a combataura component that replaces the combataura tag and provides a custom multiplier bonus, like with sanity auras. Up to you. Link to comment Share on other sites More sharing options...
Maris Posted April 13, 2015 Share Posted April 13, 2015 And how it will work on pvp server? Link to comment Share on other sites More sharing options...
Talintid Posted May 22, 2015 Share Posted May 22, 2015 also... how would you do this to create an aura that damages nearby mobs and changes an instance of an prefab to another? ei: change a flower to an evil one if you get too close. Link to comment Share on other sites More sharing options...
polygone Posted May 22, 2015 Share Posted May 22, 2015 You'd want a more constant check, something like hungerdelta or some such. Then just check for the flower prefab and change it to an evil flower. Link to comment Share on other sites More sharing options...
Talintid Posted May 22, 2015 Share Posted May 22, 2015 do you have a sample for reference? Link to comment Share on other sites More sharing options...
rons0n Posted August 3, 2015 Share Posted August 3, 2015 I decided to use this thread instead of making a new one because I felt like my question is similar. Well sort of, I kind of want to do the opposite effect where people surrounding my character will receive a damage multiplier(Strength) and health absorption(Defense) aura. This aura will not effect the character with the aura ability. Any help would be appreciated! Link to comment Share on other sites More sharing options...
DarkXero Posted August 4, 2015 Share Posted August 4, 2015 @rons0n, instead of looping through AllPlayers or using FindEntities, I decided to try another approach:local my_auras = {}AddPrefabPostInit("wilson", function(inst) if not GLOBAL.TheWorld.ismastersim then return end my_auras[inst.GUID] = { range = 10, bonus_per = 0.25, life_per = 0.25 } inst.OnDespawn = function(inst) my_auras[inst.GUID] = nil endend)AddPlayerPostInit(function(inst) if not GLOBAL.TheWorld.ismastersim then return end local old_cd = inst.components.combat.CalcDamage inst.components.combat.CalcDamage = function(self, target, weapon, multiplier) local damage = old_cd(self, target, weapon, multiplier) local aura_delta = 0 for k, v in pairs(my_auras) do local p = GLOBAL.Ents[k] if p ~= self.inst and p:IsNear(self.inst, v.range) then aura_delta = aura_delta + damage * v.bonus_per end end return damage + aura_delta end inst:ListenForEvent("onhitother", function(inst, data) for k, v in pairs(my_auras) do local p = GLOBAL.Ents[k] if p ~= inst and p:IsNear(inst, v.range) then inst.components.health:DoDelta(data.damage * v.life_per, nil, "LifeSteal Aura", nil, p) end end end)end)Auras get added to a table as Wilsons join the game.This way I loop strictly through the few entities needed.I put the lifesteal away from the CalcDamage so in pvp the lifesteal comes from damage applied to health. Link to comment Share on other sites More sharing options...
rons0n Posted August 4, 2015 Share Posted August 4, 2015 (edited) @DarkXero, Thanks! But it seems we may have hit a misunderstanding. My apologies on my half, I really suck at conveying the messages correctly that pop in my noggin. When I meant health absorbtion I meant having an aura that gives people a Defense boost(Like Armor) when getting attacked by creatures. Sorry about that. Everything else works just as intended though! Edited August 4, 2015 by rons0n Link to comment Share on other sites More sharing options...
DarkXero Posted August 4, 2015 Share Posted August 4, 2015 @rons0n, how about this:local my_auras = {} AddPrefabPostInit("wilson", function(inst) if not GLOBAL.TheWorld.ismastersim then return end my_auras[inst.GUID] = { range = 10, mult_bonus = 1.25, absorb_per = 0.25 } inst.OnDespawn = function(inst) my_auras[inst.GUID] = nil endend) AddPlayerPostInit(function(inst) if not GLOBAL.TheWorld.ismastersim then return end local old_cd = inst.components.combat.CalcDamage inst.components.combat.CalcDamage = function(self, target, weapon, multiplier) for k, v in pairs(my_auras) do local p = GLOBAL.Ents[k] if p ~= self.inst and p:IsNear(self.inst, v.range) then multiplier = (multiplier or 1) * v.mult_bonus break end end return old_cd(self, target, weapon, multiplier) end local old_ga = inst.components.combat.GetAttacked inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli) if damage ~= nil then for k, v in pairs(my_auras) do local p = GLOBAL.Ents[k] if p ~= self.inst and p:IsNear(self.inst, v.range) then damage = damage * (1 - v.absorb_per) break end end end return old_ga(self, attacker, damage, weapon, stimuli) endend)Also, in this scenario auras don't stack. Link to comment Share on other sites More sharing options...
rons0n Posted August 4, 2015 Share Posted August 4, 2015 @DarkXero, Yay! This seems to be what I was looking for. As always, your help is always greatly appreciated. A shutout in description as usual! Link to comment 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