Im trying to get the bot to use gadget "Endosmose Grenade".
I have edit'ed MyGadget.cs: But it dosnt cast it. Ideal for me would be that he used it when on 90% health in any fight
I have edit'ed MyGadget.cs: But it dosnt cast it. Ideal for me would be that he used it when on 90% health in any fight
Code:
using System.Linq;
using System.Threading.Tasks;
using Buddy.Wildstar.Game;
namespace Buddy.DefaultRoutine.Classes
{
public class MyGadget : BaseCombatClass
{
private string GadgetAbility = "Endosmose Grenade"; //Name of the gadget used
private int GadgetType = 1; //-1 Gadget hasn't yet been scanned
//1 = Offensive Gadget
//2 = Defensive Gadget
//3 = CC break gadget
//4 = Focus recovery gadget
internal bool ScanGadget()
{
if (HasSpell("Power")) //Increases Assault Power
{
GadgetAbility = "Power";
GadgetType = 1;
}
else if (HasSpell("Savagery")) //Increases Assault Power and next attack auto-crits
{
GadgetAbility = "Savagery";
GadgetType = 1;
}
else if (HasSpell("Disabler")) //Increases PVP Power and chance to snare
{
GadgetAbility = "Disabler";
GadgetType = 1;
}
else if (HasSpell("Shredder")) //Increases PVP Power and Armor Pierce
{
GadgetAbility = "Shredder";
GadgetType = 1;
}
else if (HasSpell("Severity")) //Increases Critical Hit Severity
{
GadgetAbility = "Severity";
GadgetType = 1;
}
else if (HasSpell("Cruelty")) //Increases Critical Hit Rating
{
GadgetAbility = "Cruelty";
GadgetType = 1;
}
else if (HasSpell("Bloodscent")) //Increases Assault Power and Lifesteal
{
GadgetAbility = "Bloodscent";
GadgetType = 1;
}
else if (HasSpell("Precision")) //Increases Strikethrough
{
GadgetAbility = "Precision";
GadgetType = 1;
}
else if (HasSpell("Destruction")) //Deals technology damage to 5 foes
{
GadgetAbility = "Destruction";
GadgetType = 1;
}
else if (HasSpell("Dissolve")) //Increases Armor Pierce
{
GadgetAbility = "Dissolve";
GadgetType = 1;
}
else if (HasSpell("Wisdom")) //Increases Support Power
{
GadgetAbility = "Wisdom";
GadgetType = 1;
}
else if (HasSpell("Intensity")) //Increases Support Power, and next heal auto-crits
{
GadgetAbility = "Intensity";
GadgetType = 1;
}
else if (HasSpell("Erudite")) //Increases all primary stats
{
GadgetAbility = "Erudite";
GadgetType = 1;
}
else if (HasSpell("True Strike")) //Increases Strikethrough and PVP power
{
GadgetAbility = "True Strike";
GadgetType = 1;
}
else if (HasSpell("Wings")) //Increases Movement speed
{
GadgetAbility = "Wings";
GadgetType = 1;
}
else if (HasSpell("Break")) //Breaks Interrupt Armor from your target
{
GadgetAbility = "Break";
GadgetType = 1;
}
else if (HasSpell("Powerup")) //Increases Support Power (Low level pvp gadget)
{
GadgetAbility = "Powerup";
GadgetType = 1;
}
else if (HasSpell("Endosmose Grenade"))
{
GadgetAbility = "Endosmose Grenade";
GadgetType = 1;
}
//Defensive Gadgets
else if (HasSpell("Reserves")) //Restores Shield
{
GadgetAbility = "Reserves";
GadgetType = 2;
}
else if (HasSpell("Rally")) //Heals self and allies, also increases outgoing and incoming healing
{
GadgetAbility = "Rally";
GadgetType = 2;
}
else if (HasSpell("Heal")) //Heals self
{
GadgetAbility = "Heal";
GadgetType = 2;
}
else if (HasSpell("Absorb")) //Grant Absorb to self
{
GadgetAbility = "Absorb";
GadgetType = 2;
}
else if (HasSpell("Tenacity")) //Increases PVP Defense
{
GadgetAbility = "Tenacity";
GadgetType = 2;
}
else if (HasSpell("Parry")) //Increases Deflect Rating
{
GadgetAbility = "Parry";
GadgetType = 2;
}
else if (HasSpell("Buffer")) //Restores shield to self and allies
{
GadgetAbility = "Buffer";
GadgetType = 2;
}
else if (HasSpell("Giant's Growth")) //Increases Maximum health
{
GadgetAbility = "Giant's Growth";
GadgetType = 2;
}
else if (HasSpell("Encase")) //Increases Armor
{
GadgetAbility = "Encase";
GadgetType = 2;
}
else if (HasSpell("Guard")) //Increases Armor and PVP Def
{
GadgetAbility = "Guard";
GadgetType = 2;
}
else if (HasSpell("Dodger")) //Increases Deflect, Deflect Critical, and restores a dash token
{
GadgetAbility = "Dodger";
GadgetType = 2;
}
else if (HasSpell("Juggernaut")) //Adds Interrupt Armor tokens
{
GadgetAbility = "Juggernaut";
GadgetType = 2;
}
else if (HasSpell("Replenish")) //Heals self and allies
{
GadgetAbility = "Replenish";
GadgetType = 2;
}
else if (HasSpell("Unbreakable")) //Grants Absorb and a Interrupt Armor
{
GadgetAbility = "Unbreakable";
GadgetType = 2;
}
else if (HasSpell("Protection")) //Heals self and allies, and grants PVP Def
{
GadgetAbility = "Protection";
GadgetType = 2;
}
else if (HasSpell("Salvation")) //Heals self and allies, and absorb
{
GadgetAbility = "Salvation";
GadgetType = 2;
}
else if (HasSpell("Reinforce")) //Increases PVP Def and Increases Max HP
{
GadgetAbility = "Reinforce";
GadgetType = 2;
}
//CC Break Gadgets
else if (HasSpell("Break Free")) //Breaks free from CC and grants absorb
{
GadgetAbility = "Break Free";
GadgetType = 3;
}
else if (HasSpell("Barrier")) //Breaks free from CC and grants PVP Def
{
GadgetAbility = "Barrier";
GadgetType = 3;
}
//Focus Recovery Gadgets
else if (HasSpell("Second Wind")) //Recovers focus and PVP Def
{
GadgetAbility = "Second Wind";
GadgetType = 4;
}
else if (HasSpell("Recovery")) //Grants absorb and recovers focus
{
GadgetAbility = "Recovery";
GadgetType = 4;
}
else //No gadget equipped
{
GadgetAbility = "None";
GadgetType = 255;
}
DefaultRoutine.Log.Info("Gadget Ability '" + GadgetAbility + "' was found.");
return true;
}
internal override async Task<bool> Combat()
{
return false;
}
//Uses the Gadget ability with different conditions depending on the Gadget type.
//If the gadget hasn't already been scanned, this method will do that instead and save the name and type for future calls.
internal async Task<bool> UseGadget()
{
if (GadgetType == 1 && await SelfCast(GadgetAbility)) //Pops DPS gadgets on CD
{
return true;
}
if (GadgetType == 2 && Me.HealthPercent < 75 && await SelfCast(GadgetAbility)) //Health Remaining Constraint
{
return true;
}
if (GadgetType == 3 && Me.GetActiveCCs().Count > 0 && await SelfCast(GadgetAbility)) //CC'd Constraint
{
return true;
}
//if (GadgetType == 4 && Me.FocusPercent < 75 && await SelfCast(Gadget)) //Focus Constraint
// return true;
if (GadgetAbility == "Invalid" || (!HasSpell(GadgetAbility) && GadgetAbility != "None") || (GadgetAbility == "None" && GadgetEquipped()))
//Checks if Gadget was previously scanned (if it wasn't then Gadget = "Invalid")
{
ScanGadget(); //Also checks if Gadget was changed. If either are true, performs a gadget scan.
}
//Finally checks if a Gadget has recently been equipped, if so also performs a scan.
return false;
}
public int GetType()
{
if (GadgetAbility == "Endosmose Grenade" || (!HasSpell(GadgetAbility) && GadgetAbility != "None") || (GadgetAbility == "None" && GadgetEquipped())) //Same Logic as the UseGadget Above
{
ScanGadget(); //Needed as logical comparisons will be used before determining
}
//Gadget ability activations. The ScanGadget() method needs to be activated
return GadgetType; //before any logical comparisons will properly function.
}
public bool GadgetEquipped()
{
InventoryItem item = GameManager.Inventory.Equipped.Items.FirstOrDefault(i => i.Info.TypeName == "Gadget");
return item != null && item.IsValid;
}
}
}