• Visit Rebornbuddy
  • Object reference not set ... UGH

    Discussion in 'Community Developer Forum' started by Exmortem, Feb 3, 2014.

    1. Exmortem

      Exmortem Community Developer

      Joined:
      Mar 28, 2010
      Messages:
      799
      Likes Received:
      16
      Trophy Points:
      18
      I can't figure out why i'm getting an object reference error here.

      Code:
                      new Decorator(ret =>
                      {
                      if (!Core.Player.HasTarget)
                          return false;
      
      
                      if (!(Core.Player.CurrentTarget as BattleCharacter).IsCasting)
                          return false;
      
      
                      if (!Actionmanager.CanCast("Blunt Arrow", Core.Player.CurrentTarget))
                          return false;
      
      
                      return true;
                      },
                      new Action(ret =>
                      {
                      string[] interrupts = { "Cure", "Cure II", "Cure III", "Medica", "Medica II", "Raise", "Heartstopper", "Thunder", "Fortis" };
      
      
                      var castingspell = (Core.Player.CurrentTarget as BattleCharacter).SpellCastInfo;        
                      foreach (string s in interrupts)
                      {
                          if (s != "")
                          {
                              if (castingspell.SpellData.Name.Contains(s))
                              {
                                  Actionmanager.DoAction("Blunt Arrow", Core.Player.CurrentTarget);
                              }
                              return;
                          }
      
      
                      }
                      })),
      
      I'm only beginning at this so I don't know if the code is even close to correct. I'm just trying to get it to interrupt whenever the string array matches to whatever my current target is casting. I'm stuck, I get an object reference error...

      Code:
      [15:46:04.280 D] System.NullReferenceException: Object reference not set to an instance of an object.
         at Kupo.Rotations.ArcherBard.<CreateCombat>b__b(Object ret) 
      
      It only happens whenever the current target is actually casting a spell and it doesn't crash the bot, just pauses it till the spell is done being cast and then continues with the rotation. If anyone can point my error out to me i'd appreciate it!
       
    2. Exmortem

      Exmortem Community Developer

      Joined:
      Mar 28, 2010
      Messages:
      799
      Likes Received:
      16
      Trophy Points:
      18
      So i've tried this code ...

      Code:
                      new Decorator(ret => 
                      {
                          if (!(Core.Player.CurrentTarget as BattleCharacter).IsCasting)
                              return false;
      
      
                          if ((Core.Player.CurrentTarget as BattleCharacter).SpellCastInfo != null)
                          {
                             return true;
                          }
      
      
                          return false;
                      },
                      new Action(ret => {
                          Cast("Blunt Arrow");
                      })),
      
      and it's never used Blunt Arrow on an enemy casting a spell, so obviously that means that SpellData is returning null. I don't know how to correct that.
       
    3. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,235
      Likes Received:
      365
      Trophy Points:
      83
      Code:
      string[] interrupts = { "Cure", "Cure II", "Cure III", "Medica", "Medica II", "Raise", "Heartstopper", "Thunder", "Fortis" };
      
      move this outside the function definition then use

      Code:
      Cast("Blunt Arrow", r => (Core.Player.CurrentTarget as BattleCharacter) != null && interrupts.Contains((Core.Player.CurrentTarget as BattleCharacter).SpellCastInfo.Name)),
      
      That should work fine, if not open up the rebornconsole and try something like

      Code:
      Log((Core.Player.CurrentTarget as BattleCharacter).SpellCastInfo.Name);
      
      and see what it spits out while the target is casting.
       
    4. Exmortem

      Exmortem Community Developer

      Joined:
      Mar 28, 2010
      Messages:
      799
      Likes Received:
      16
      Trophy Points:
      18
      I'll give that shot, thanks much! Totally forgot about the reborn console!
       
    5. Exmortem

      Exmortem Community Developer

      Joined:
      Mar 28, 2010
      Messages:
      799
      Likes Received:
      16
      Trophy Points:
      18
      SpellData is returning null it seems.

      Code:
      System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
         at ff14bot.Objects.SpellCastInfo.get_Name()
         at Driver.Run() in c:\Users\David\Desktop\RB\Plugins\RebornConsole\Temp\yx3wf1hl.0.cs:line 29
      
      That was run through the console.
       
    6. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,235
      Likes Received:
      365
      Trophy Points:
      83
      Don't use spelldata, spellcast is not guaranteed to be a spell.
       
    7. Exmortem

      Exmortem Community Developer

      Joined:
      Mar 28, 2010
      Messages:
      799
      Likes Received:
      16
      Trophy Points:
      18
      My mistake, this is what I used.
      Code:
      [COLOR=#333333]Log((Core.Player.CurrentTarget as BattleCharacter).SpellCastInfo.Name);[/COLOR]

      It's the code you provided for the console, it's SpellCastInfo, not SpellData, it's returning an object reference error when I run the code and the enemy is casting. I'm sorry if i'm misunderstanding what you meant.
       
    8. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,235
      Likes Received:
      365
      Trophy Points:
      83
      What enemy are you testing it on?
       
    9. Exmortem

      Exmortem Community Developer

      Joined:
      Mar 28, 2010
      Messages:
      799
      Likes Received:
      16
      Trophy Points:
      18
      I've tried it on multiple enemies out the Ceruleum Processing Plant area.

      lvl49 Earth Sprite casting Stone.
      lvl49 Cohort casting Fortis
      lvl49 Cohort Signifier casting Thunder

      All return object error.
       
    10. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,235
      Likes Received:
      365
      Trophy Points:
      83
      Thanks, ill look into it.
       
    11. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,235
      Likes Received:
      365
      Trophy Points:
      83
      Looks like the database got truncated a bit in the last release. I'll push a version out in a bit with a fix.
       
    12. Exmortem

      Exmortem Community Developer

      Joined:
      Mar 28, 2010
      Messages:
      799
      Likes Received:
      16
      Trophy Points:
      18
      Thanks very much!
       

    Share This Page