Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom Monster Detection for Homunculus AIs
Author Message
Ange Offline
Senior Member
****

Posts: 254
Joined: Aug 2009
Post: #1
Custom Monster Detection for Homunculus AIs

HeRO's myriad of custom monsters are often not detected as monsters by homunculus AIs.??This is caused by a bug in Gravity's built in function, IsMonster(id).??Here's a general solution to this that will work for any AI.

First, create a file in your AI called CustomIsMonster.lua and paste the following into it:

Code:
function CustomIsMonster(ID)
    if (IsMonster(ID)==1) then
        return 1
    elseif (CustomMonsters[GetMonsterID(ID)]==true) then
        return 1
    else
        return 0
    end
end

function GetMonsterID(ID)
    return GetV(V_HOMUNTYPE, ID)
end
code tags should let you use indentations to properly display lua, but they don't here.??Yet another thing here that doesn't work.??Anyway, here's it properly formatted: http://pastie.org/8732515

Next, create a file called CustomMonsters.lua and paste the following into it:
Code:
CustomMonsters = {}

CustomMonsters[2590] = true -- Nekoring
CustomMonsters[2502] = true -- Autumn LeafCat

This file is a list of all monsters that are not recognized which you would like the AI to recognize.??Yes, they have to be added manually.??There's a way to get around this, but it makes the homunculus see pets as monsters too, which is no good.

Then, add the following two lines to your AI.lua:
Code:
require "./AI/CustomMonsters.lua"
require "./AI/CustomIsMonster.lua"
Put them with other require statements.??You'll know it when you see it.

Finally, replace every instance of "IsMonster" in the AI with "CustomIsMonster" EXCEPT the one in CustomIsMonster.lua
02-14-2014 04:09 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
Custom Monster Detection for Homunculus AIs - Ange - 02-14-2014 04:09 AM

Forum Jump: