Save-Point

Full Version: Save-Point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Board Message
Sorry, you do not have permission to access this resource.
Save-Point - A.I. Generation Threat System for the GTBS

Save-Point

Full Version: A.I. Generation Threat System for the GTBS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Greetings!
I want to create a script to time, I like to call "Generation Threat". Basically, diverts attention from attackers controlled by the AI that have greater "threat". "Threat" is a variable that must depend on several things. Some possible examples:

Every 100 in HP points = +1 Threat
Every 10 in PDEF points = +1 Threat
Each actor class Id 01 = +2 Threat
Each actor class Id 03 = +1 Threat

Also, I wish there were basic values​​. That is, each actor and each enemy would have their values ​​minimal threat set in the script.
Who has a greater degree of threat will be preferentially attacked by the AI.

I am aware that this is a tall order, so if you can guide me or at least make a small part of where I can continue, I thank you. One day I'll know RGSS. = s

Thank you.
I changed your topic's title so members with suitable skills may find interest. Winking Helps if you want to go back to a topic with a specific name.
Ok, thanks for that!
I did not realize it had been nonspecific.

Thank you again.
I await answers.
I can at least get you started. There is a method called "closest_enemy" that the AI uses to choose a target. Default behavior has it choosing based on distance only, You could modify it so it chooses enemies based on 'distance - threat' instead.
Thanks, I already have a starting point. I found this method in GTBS_v1.5.1 Battle_Scene, hope one day to be able to understand enough to run what I want. I could easily set a variable to accumulate the value of "threat" based on the items that I mentioned, but did not know how to implement this variable in Script.

If any of you know the next step, I'll be grateful :)
I'd be happy to walk you through it. Looking at the 'closest_enemy' method:
Code:
battler = @active_battler
    if battler.is_a?(Game_Enemy)
      away = actors + neutral
    else
      away = enemies
    end
    en = nil
    distance = 999
This is all set up. the chosen enemy 'en' is set to nothing, and the chosen 'distance' is set to some high number.

Code:
for enemy in away
      dist = pos_distance(battler, enemy)
      if dist < distance
        en = enemy
        distance = dist
      end
    end
    return [en, distance]
"for enemy in away" is a loop, that goes through all the elements in the 'away' list. The 'enemy' variable is used to look at which thing in 'away' we are on.
'dist' is then set to the distance between the battler and enemy using a method. If it is less than the current 'distance' than 'distance' is changed to this smaller value and this enemy is recorded in 'en' as the potential closest enemy.
We repeat this for all enemies, so we'll find a closest one!

The easiest way to do what you want is to modify 'dist' after it is calculated. So after the "dist = pos_distance(battler, enemy)" line we could do something like
Code:
if enemy.class_id == 1
  dist -=2
end
Thanks again, friend.
Enemy.class_id This refers to the id of the enemy in the database or the 'class' of the enemy that is configured in Setup GTBS_Enemy? Because if the latter, do not have a number, just names. See:

class Game_Enemy <Game_Battler
Enemy_Classes = {1 => "Golbin", 33 => 'Guard', 34 => 'General', 35 => 'Archer'
36 => 'Blood Mage', 37 => 'Elite Guard', 38 => "Gaurd"}

And where can I see more methods / constants like this (enemy.class_id)? So that I can improve my system threat basing myself on more things.
You'll want to do 'enemy.class_name' instead then, maybe. For your threat system, you can use anything defined in Game_Actor, Game_Enemy, or GTBS_Enemy Setup.