Save-Point
Help with Computer controlled actors and AIBC - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: Help with Computer controlled actors and AIBC (/thread-4723.html)

Pages: 1 2


Help with Computer controlled actors and AIBC - ZeroSum - 07-06-2013

Hi there,

First off: Lovely forum you have here. The scripts and threads have inspired me to start my RPG maker hobby again.

Now for the reason I'm posting here. I've been putting together the scripts I want for my project, but I've run into a problem I can't seem to fix on my own.
I want to make use of 1 computer controlled ally. Found and tried to use two different scripts for that: Trickster's Ally AI and Claihm's Automatic Battle Actions.
They both work fine when using the normal ''Attack'', but as soon as the computer controlled char tries to use a skill I get a ''NoMethodError'' undefined method for 'skills' for nil:NilClass.
The script and line it refers to is part of the Advanced Individual Battle Commands by Trickster. (AIBC)

The part the system (error) reffers me to: (this is part of the Class Modification script from AIBC, full script listed bellow)

Code:
#--------------------------------------------------------------------------
  # * Skill Can Use?
  #--------------------------------------------------------------------------
  alias_method :trick_aibc_actor_skill_can_use?, :skill_can_use?
  def skill_can_use?(skill_id)
    # Get Flags
    flag, flag2 = trick_aibc_actor_skill_can_use?(skill_id), false
    # If in Scene_Battle
    if $game_temp.in_battle
      # If the Skills Parameter has been used
      flag2 = !self.current_action.command.skills.empty?    <<<<<< This line comes up in the error
      # If the Skill Id Parameter equals the skill id sent
      flag2 ||= self.current_action.command.skill_id == skill_id
      # call Game_Battler skill_can_use?
      flag2 &&= super
    end
    # Return flag
    return flag || flag2
  end

I realise the problem comes from the AIBC script rewriting the way my Battle commands work. As I get the same error when using either Claimh'sor Trickster's script for computer controlled allies.

As I have very little script experience, I'd like to know if there is a solution to this while using the AIBC script, or if I should accept this as a compatibility issue and give up on using this combination of scripts. If it's the latter, does anyone have a suggestion to make use of a computer controlled ally script/event together with costumized Battle Commands? The comp contr. char only has to be able to use attack and 1 or 2 regular skills every now and then.


Not really sure which codes to link here for people to look at. I'll just paste the onesI think are relevant. I would preffer getting Claihm's system to work. Listed at bottom.
Sorry if I went overkill on information, thought I'd be as thorough is I could. Thank you! Very cheery

Advanced Individual Battle Commands
setup:
Content Hidden

Data structure
Content Hidden

Windows:
Content Hidden

Class Modification: (part where the error occurs)
Content Hidden

Load and Save
Content Hidden

Automatic Battle Actions by Claimh

Content Hidden



RE: Help with Computer controlled actors and AIBC - MechanicalPen - 07-06-2013

I think I can see the probelm. When the AI selects a skill, it probably doesn't set the 'skills' bit because it didn't use the command list to pick it. try something like

Code:
flag2 = self.current_action.command.skills == nil || !self.current_action.command.skills.empty?



RE: Help with Computer controlled actors and AIBC - ZeroSum - 07-06-2013

Thanks for the reply. I appreciate you thinking it over. I replaced the old code with yours but sadly it gave me the same error, same line.

Also did some testing in the Demo of AIBC, to eliminate any errors with other scripts my project uses or maybe some configure mistakes I made. But I get the same result. The AI character can use skills when the AI is turned off (regular manual skill selecting). But bugs out when the AI is turned on.


RE: Help with Computer controlled actors and AIBC - MechanicalPen - 07-07-2013

try flipping the order of your AI script and AIBC.


RE: Help with Computer controlled actors and AIBC - DerVVulfman - 07-07-2013

Yep... Just as MechanicalPen suggested, try changing the position of Trickster's AI and Battle Sction scripts. Sometimes script 'placement' makes a difference. At the same time, I do have to ask whether you are including the SDK (Standard Development Kit) that is in Trickster's demo within your game. It is pretty much a necessity with his later scripts, though you may have noticed that. I would 'assume' his scripts work together.

Oh, and I put the scripts you posted in the spoilers within their own [Code] bbcodes.


RE: Help with Computer controlled actors and AIBC - ZeroSum - 07-07-2013

Cheers for the feedback guys Happy I've tried using different positions of the scripts before, but I tried it some more now with both AI scripts but no luck. Same error.

I did notice that the use of items (battle dmg items like bombs/vials etc) by the AI gives no issues. But when the Ai decides to use a skill (like a regular fire), it gives the error.

I am using the appropriate SDK, also the RSC and MACL from Tricksters Demo's.


RE: Help with Computer controlled actors and AIBC - MechanicalPen - 07-07-2013

Uh huh it is the "skill_can_use?" method messing up. You could always write a "skill_ai_can_use?" method that ignores all the individual battle command stuff, and use that method where ever the Ally AI script uses it.

EDIT: Or, you can just call Game_Battler's "skill_can_use?" If AIBC is BEFORE Ally AI, replace the [ skill_can_use? ] in the Ally AI script with [ trick_aibc_actor_skill_can_use? ]


RE: Help with Computer controlled actors and AIBC - ZeroSum - 07-07-2013

Hm, oke. I think understand the general idea of what you are suggesting. Adjusting the scripts to either replace or bypass the current skill_can_use? method within AIBC.

However I'm afraid my understanding of the ruby language isn't good enough yet to apply this. I wouldn't really know how to write a new method, or how to call Game_Battler's ''skill_can_use?'' like you suggested. Got any tips on how to approach this as a noobie? I dont mind learning.


RE: Help with Computer controlled actors and AIBC - MechanicalPen - 07-07-2013

it's super easy!

find (control+shift+F)
Code:
if $data_skills[skill_id].is_healing? && @actor.skill_can_use?(skill_id)
and replace it with
Code:
if $data_skills[skill_id].is_healing? && @actor.trick_aibc_actor_skill_can_use?(skill_id)

The naming is counter-intuitive. trick_aibc_actor_skill_can_use? is actually the old, unmodified skill_can_use? that was replaced with the one in AIBC. We call this aliasing.


RE: Help with Computer controlled actors and AIBC - DerVVulfman - 07-07-2013

You left an extra ] bracket in your replacement code before the 'if' (part of your [code] bbcode). I edited it out just now.

Posting this in case he tries pasting the replacement before the fix and was unaware about the ']' being present.