Weapon and ability system questions

So imagine you are making a combat battlegrounds game and you expect to add in more and more abilities and different weapons that varies a lot into the game in the future.

Now imagine you need to make a ability that say will only clear all abilities that has tag of “water skills” in a range or so. And there may be alot of special things to do with specific abilities, how do you make sure you have correct tags to the abilities so that I can terminate or manipulate their behaviours later? This may not be only confined to abilities, but how do you pactically add tags to different instances so that we can make changes to them according to their tags?

Haven’t got deep into tags but, will this require collection service? Or what else other than tags can you utilize to achieve the same goal?

2 Likes

You should use a functional pattern for this, where each ability can have a property with a name and value, and a function is used to apply an action to each ability with a specific condition. Ideally you’d design it so you can write things like this:

local effectFunction = 
    function(ability) 
        ability.ResetCooldown() 
    end

--Reset cooldowns on all Abilities whose Element property is equal to "Water"
Abilities.AllWithProperty("Element", "Water", effectFunction)

How you choose to store properties is up to you but the simplest way is just in a table with string keys.

Thanks for the advice but the thing here I want to say is when I active my ability such as terminate all water element abilities, how am I to detect if the abilities in range are water abilities? Should I use tags or what?

1 Like

(Earlier post deleted because I posted early by accident)

Ok general outline would be:

Use Ability -> Check nearby players -> Get their abilites -> 
Loop through abilities and check for tags -> 
If water tag then 
 pull_the_lever_kronk.exe
end

So, I see two main ways of doing this;

  1. Construct a physical library of abilities in the server storage, and clone abilities to give to players as needed. A local script in the PlayerScripts would handle activating abilities – however you choose to do so – and fire a remote_event to the server that tells it to check for a specific ability value in the player (or wherever you choose to store the object) and if present runs the ability code:
Check nearby characters -> if character:Isnt_NPC() then ->
Loop through players abilities (Stored in either the player or a player data tree somewhere) 
if plr.Abilities.ability_Object:HasTag("water_Atribute") or plr.Abilities.ability_Object:GetAttribute("element_Attribute") == "Water" then 
 Get_Got_My_Guy() -- or whatever you it is you wanna do
end
  1. Store all a players data in a master script of sorts, including their abilities, which also hold their respective tags, functions, data, etc. and then use a BindableFunction to retrieve and update data to the table as needed. Regarding your question, general outline:
PlayerAdded / Similar Events 
 plr_Data[new_Plr.Name] = {stats, 
{Inventory = {
 Abilities = {
  ["Ability1"] = {
   element_Type = "Water";
   base_Damage = 10;
};
 };
};
 etc.}
--------------
Ability fires -> Get nearby chars / plrs -> 
plr_Data[nearby_Plr].Inventory.Abilities:GetKiddos() -> loop-de-loop,
 if v.element_Type == "Water" then 
  zoinks_Scoob("ruh_Roh") -- For the damp abilities
 end
end

Personally I’d go for the physical representation as it tends to be easier to work with when you can visualize it, and the option of using attributes and tags on the templates means you know they will be there, what their default values are, and can customize from there. The same can be done with OOP but debugging gets trickier when your in your 5th nested table.

1 Like

Thanks for the great reply and idea outline! Actually another thing I’ve seen a lot of people using ; after or between (sub) tables/dictionaries etc just like in your example code, why? Is it because it make something like:

main.StartTween({FadeScreen = {Info=TInfo(FadeInTime,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut),
		Properties={BackgroundTransparency=0}}})

cleaner with the nests?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.