heRO-Server Forum
Custom Monster Detection for Homunculus AIs - Printable Version

+- heRO-Server Forum (https://www.pandoraonline.net/forum)
+-- Forum: Game Related (/forumdisplay.php?fid=1)
+--- Forum: Guides (/forumdisplay.php?fid=85)
+--- Thread: Custom Monster Detection for Homunculus AIs (/showthread.php?tid=27012)



Custom Monster Detection for Homunculus AIs - Ange - 02-14-2014 04:09 AM

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


RE: Custom Monster Detection for Homunculus AIs - The Legendary Joe - 05-01-2014 04:28 PM

hmm, I must be doing something wrong... I'm getting a buncha error messages saying stuff is coming up as a Nill value after modding the AI.lua


RE: Custom Monster Detection for Homunculus AIs - Laenaya - 05-02-2014 02:34 PM

You might have replaced "IsMonster2" for "CustomIsMonster2" while replacing "IsMonster" for "CustomIsMonster".

If this isn't the case, you could have placed the newly created files (CustomIsMonster.lua and CustomMonsters.lua) inside "<heRO folder>/AI/USER_AI", but referenced them as if they were one level up:

require "./AI/CustomMonsters.lua"
require "./AI/CustomIsMonster.lua"

If that's the case change them to:

require "./AI/USER_AI/CustomMonsters.lua"
require "./AI/USER_AI/CustomIsMonster.lua"

A last possibility would be that you're editing the lua files in "<heRO folder>/AI/" (official AI), instead of the ones in "<heRO folder>/AI/USER_AI" (custom AI).

If anything, I can test this later and give you a copy of my mirAI with this mode, if you use/want it of course.



RE: Custom Monster Detection for Homunculus AIs - The Legendary Joe - 05-02-2014 11:06 PM

(05-02-2014 02:34 PM)Laenaya Wrote:  
You might have replaced "IsMonster2" for "CustomIsMonster2" while replacing "IsMonster" for "CustomIsMonster".

If this isn't the case, you could have placed the newly created files (CustomIsMonster.lua and CustomMonsters.lua) inside "<heRO folder>/AI/USER_AI", but referenced them as if they were one level up:

require "./AI/CustomMonsters.lua"
require "./AI/CustomIsMonster.lua"

If that's the case change them to:

require "./AI/USER_AI/CustomMonsters.lua"
require "./AI/USER_AI/CustomIsMonster.lua"

A last possibility would be that you're editing the lua files in "<heRO folder>/AI/" (official AI), instead of the ones in "<heRO folder>/AI/USER_AI" (custom AI).

If anything, I can test this later and give you a copy of my mirAI with this mode, if you use/want it of course.
Oh derp, both of those were the cause. thanks for the troubleshoot. Up and running without any noticable problems.


RE: Custom Monster Detection for Homunculus AIs - demishock - 05-07-2014 12:14 AM

Thanks so much for this! I don't know how I missed the original thread when it came up, but I'm glad I finally saw it now.

I've compiled a list of all the custom monsters I could think of, for copy/paste-ability, in three formats...

In order by ID number: http://pastie.org/9147690

In order by monster name: http://pastie.org/9147687

In order by map/category: http://pastie.org/9147680
*Neko Island
*True Poring Island
*Muspelheim
*Orcus Dungeon
*Byalan Dungeon
*Magma Dungeon
*Christmas
*Halloween
*Fairy Paradise

ETA: I've added a link to this thread to the Homunculus page on the heRO wiki.


RE: Custom Monster Detection for Homunculus AIs - kysp - 05-22-2014 07:51 AM

(05-07-2014 12:14 AM)demishock Wrote:  ...

In order by map/category: http://pastie.org/9147680
*Neko Island
*True Poring Island
*Muspelheim
*Orcus Dungeon
*Byalan Dungeon
*Magma Dungeon
*Christmas
*Halloween
*Fairy Paradise

ETA: I've added a link to this thread to the Homunculus page on the heRO wiki.

Thanks for the list! No1

(05-02-2014 02:34 PM)Laenaya Wrote:  You might have replaced "IsMonster2" for "CustomIsMonster2" while replacing "IsMonster" for "CustomIsMonster".

I did that too. So turn on "Match whole word only" or something similar in the Search & Replace dialog.


RE: Custom Monster Detection for Homunculus AIs - Blake81 - 09-25-2014 03:51 PM

Could someone please upload their modified lua files here? I've been trying to get this working for the last two hours and I still get the Nil Value error message, and I've done all it says here....


RE: Custom Monster Detection for Homunculus AIs - whitedraw - 09-25-2014 09:54 PM

I think this post was once before the SVN updated, I think it might be better for you to check out others AIs that support this new update. Some similar configuration might be required though


RE: Custom Monster Detection for Homunculus AIs - GM-Garr - 09-26-2014 04:56 AM

Actually, homunculus AI is client-side thing, and has nothing to do with SVNs. So this will still work regardless. I haven't tried it much, but I think it works. At least it ignored custom monster I set it to ignore in the configuration.

(Place it inside USER_AI directory, replacing AI.lua. Also, don't forget to use /hoai ingame to switch to custom AI)