PDA

View Full Version : How do Mods work? MirAI


remy
11-18-2008, 12:58 PM
I'm currently using the MirAI+Mercenary AI by Miranda Blade w/ edits by Lamech that's hosted on the main AI page on the iROWiki. Just recently, I found a really old PvP Mod on Miranda's home page and I want to test it out. The problem here is that the AI I downloaded on the iROWiki doesn't have a GUI(is that the correct term?) for easy configuration and mod application.

My question here is, does the mod replace the whole function or just parts of it?
A little explanation.

--------------------------------------------------
function ModInit()
-- plugin initialization
--------------------------------------------------
-- Mir AI functions replacement
isKS = PvP_isKS
GetMyEnemy_AttackingMe = PvP_Def_Scan
GetMyEnemy_AnyNoKS = PvP_Atk_Scan
GetEnemyOf = PvP_GetEnemyOf

This part of the PvP Mod tells which functions to (partially?) replace I think. I will use the bolded line for an example.

--------------------------------------------------
function isKS()
-- used in OnCHASE_ST()
--------------------------------------------------
if 0 == IsMonster(MyEnemy) then return false; end -- for PvP mods

-- look at monster target
local mob_target = GetV(V_TARGET, MyEnemy)
if mob_target > 0 then
if not IsMonster2(mob_target) then
if (mob_target == MyID) or (mob_target == OwnerID) or (Friends[mob_target] ~= nil) then
return false
else
Log("MyEnemy was already in battle, action aborted (anti-KS)")
return true
end
end
end

-- look at (not friend) player targets
local actors = GetActors()
for i,v in ipairs(actors) do
if (v ~= OwnerID) and (v ~= MyID) then
if 0 == IsMonster(v) then -- if it is a player
if isNotFriend(v) then -- and not a friend
if GetV(V_TARGET, v) == MyEnemy then
Log("Another player is aiming at MyEnemy, action aborted (anti-KS)")
return true
end
end
end
end
end

return false
end

This is the function when I'm not using any mods.

--------------------------------------------------
function PvP_isKS()
--------------------------------------------------
return false -- there is no KS in PvP
end

This is the what the PvP Mod has.
Now, what usually happens when using a the Mod function on MirAI? Again, does it replace the whole thing or maybe just a part of it(looks like the first line if it is a partial rewrite)?

Biochemist-ness
11-18-2008, 06:39 PM
In this case, the mod is replacing the entire function.

For another example, if you look at the auto shutdown module provided on the Mir homepage, it is rewriting the function by added a few extra commands before (or maybe after, too lazy to go check) the pre-existing functions.

Its really just a matter of how a given module is written.

remy
11-18-2008, 09:32 PM
Ah, thank you very much.

In that case, does anyone know how well this PvP Mod I found on Miranda's home page functions? I usually try to compare different AIs to see what something does but an answer by an expert would be most appreciated.


Edit---I got this PvP Mod to work and to recognize friends so it wouldn't attack allies but every time I 'respawn' my homunculus it forgets who its friends are even though their ID is stored in the Friends document. Any ideas?