• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • C# Syntax question

    Discussion in 'Community Developer Forum' started by Stringstrider, Jul 1, 2015.

    1. Stringstrider

      Stringstrider New Member

      Joined:
      Mar 24, 2015
      Messages:
      36
      Likes Received:
      0
      Trophy Points:
      0
      So I'm currently trying to add swiftcast to Sodimm's Codex summoner profile, as my pet despawns fairly often, and waiting 6 seconds every time it happens blows a lot of time. I figured I should insert it prior to the pet summon line.

      I attached the original basic rotation, along with the only modification I made (in red), I have some basic/novice Java coding experience, enough that I can usually read and understand 75%ish of code I read, but I'm a total noob when it comes to C#. I'm wondering what the "r =>" does. I know that Swiftcast exists as a spell, because I see the ID for the skill appear when I start the bot, but I would like to know what I'm potentially doing wrong. I assume the parameters in brackets are the casting conditions, and I would love Swiftcast's use to be restricted to when no pets are summoned, but that is certainly over my head.

      With it how it is, it doesnt actually use swiftcast, but it does load.

      Edit: I've tried both spell.cast and spell.apply and neither are working, it's still slowcasting the pet

      Any help appreciated, direct link to his CR below

      Codex profile

      Code:
              public Composite CreateBasicCombat()
              {
                  return new PrioritySelector(ctx => Core.Player.CurrentTarget as BattleCharacter,
                      new Decorator(ctx => ctx != null,
                          new PrioritySelector(
                              CommonBehaviors.MoveToLos(ctx => ctx as GameObject),
                              CommonBehaviors.MoveAndStop(ctx => (ctx as GameObject).Location, PullRange, true, "Moving to unit"),
                              new Decorator(r => !Core.Player.IsCasting, CommonBehaviors.MoveAndStop(ctx => (ctx as GameObject).Location, PullRange, true, "Moving to unit")),
      			[B][COLOR="#FF0000"]Spell.Cast("Swiftcast"),[/COLOR][/B]
                              Spell.Cast(r => WhichPet, r => Core.Player.Pet == null && Actionmanager.HasSpell(WhichPet), r => Core.Player),
                              new Decorator(r => Core.Me.SpellCastInfo != null && Core.Me.SpellCastInfo.SpellData.Name.Equals(WhichPet) && Core.Player.Pet != null, new Action(r => Actionmanager.StopCasting())),
                              Spell.Apply("Bio II"),
                              Spell.Apply("Miasma"),
                              Spell.Apply("Bio"),
                              Spell.Cast("Energy Drain", r => Core.Player.HasAura("Aetherflow") && Core.Player.CurrentManaPercent < WindowSettings.RestEnergyDone),
                              Spell.Cast("Ruin", r => true))));
              }
       
      Last edited: Jul 1, 2015
    2. Cloud30000

      Cloud30000 New Member

      Joined:
      May 9, 2015
      Messages:
      298
      Likes Received:
      7
      Trophy Points:
      0
      The second optional parameter/argument for the Spell.Cast is a true/false conditional; that tells you to cast if true, or not is false.. Use Energy Drain as an example, and just copy the conditional from the pet cast below it like so:
      Code:
      Spell.Cast("Swiftcast", r => Core.Player.Pet == null && Actionmanager.HasSpell("Swiftcast")),
      The => operator is a lambda expression; read about it hear: https://msdn.microsoft.com/en-us/library/bb311046.aspx
       
      Last edited: Jul 1, 2015
    3. Stringstrider

      Stringstrider New Member

      Joined:
      Mar 24, 2015
      Messages:
      36
      Likes Received:
      0
      Trophy Points:
      0
      Should still be the same location as where I put it prior, correct? The line before the pet summon cast?
       
    4. Cloud30000

      Cloud30000 New Member

      Joined:
      May 9, 2015
      Messages:
      298
      Likes Received:
      7
      Trophy Points:
      0
      Yes, it is setup like a tree; it always tries to cast in order from top to bottom.

      To get the exact format of the Spell.Cast, I use the RebornConsole; that tells me if I need to tweak my syntax. I actually don't know the exact parameters needed for Swiftcast and cross-class abilities, so you may need to test it there first before putting it in the CR file.
       
    5. Stringstrider

      Stringstrider New Member

      Joined:
      Mar 24, 2015
      Messages:
      36
      Likes Received:
      0
      Trophy Points:
      0
      Yea, I tried putting in your code snippit and its still not swiftcasting :/

      Upon further testing, I took out the part after the && and now it casts swiftcast atleast, but its still fullcasting the summon, then swiftcasting and then summoning again, I'll figure it out eventually.

      Edit: Just realized I copy pasted before you reedited, trying again
       
      Last edited: Jul 1, 2015

    Share This Page