AI Switcher
Re: AI Switcher
but it's not what they drop, it's what drops when it hits the monster, which happens when you mouse-toss something
Finished Dungeons - complete mods to play
Re: AI Switcher
This ?Komag wrote:You can take a look at my snail king fight code (in snailWallScript on level 7) which solves this by counting all projectiles (they don't all count the same way either) and spawning the ones that are stuck "inside" the monster on the floor at the time of "teleport" or destroying the monster. I used onDie and onProjectileHit hooks. Part of the code has to account for possible "mouse thrown" projectiles which don't stick but do register as projectile hits.
snailWallScript:
Code: Select all
function snailDie()
_restoreProj()
end
function projHit(proj) -- trig by snail_king onProjectileHit hook
pr.nt("snail king hit by "..proj.name)
local p = {"cold_arrow", "fire_arrow", "poison_arrow", "shock_arrow", "arrow"}
local q = {"cold_quarrel","fire_quarrel","poison_quarrel","shock_quarrel","quarrel"}
local r = {"throwing_knife","shuriken","throwing_axe"}
for i=1,5 do
if proj.name == p[i] then snailArrows = snailArrows + 1 end
if proj.name == q[i] then snailQurrls = snailQurrls + 1 end
end
if proj.name == r[1] then snailKnives = snailKnives +1 end
if proj.name == r[2] then snailShrkns = snailShrkns +1 end
if proj.name == r[3] then snailAxes = snailAxes +1 end
end
snailArrows = 0
snailQurrls = 0
snailKnives = 0
snailShrkns = 0
snailAxes = 0
function _restoreProj() -- trig by snailDie()
local cArws = 0
local cQrls = 0
local cKnvs = 0
local cShks = 0
local cAxes = 0
for i in entitiesAt(7,10,31) do
if i.name == "arrow" then cArws = cArws + 1
elseif i.name == "quarrel" then cQrls = cQrls + 1
elseif i.name == "throwing_knife" then cKnvs = cKnvs + 1
elseif i.name == "shuriken" then cShks = cShks + 1
elseif i.name == "throwing_axe" then cAxes = cAxes + 1
end
end
local a = snailArrows - cArws
local b = snailQurrls - cQrls
local c = snailKnives - cKnvs
local d = snailShrkns - cShks
local e = snailAxes - cAxes
local t1 = {"arrow","quarrel","throwing_knife","shuriken","throwing_axe"}
local t2 = {a,b,c,d,e}
for h=1,5 do
if t2[h] > 0 then for i = 1,t2[h] do
local c=math.random(1,2) local d=1 if c==1 then d=-1 end
local e=math.random(1,2) local f=1 if e==1 then f=-1 end
local g=math.random(1,2) local z=1 if g==1 then z= 3 end
spawn(t1[h],7,10,31,z)
:setSubtileOffset(math.random()*d,math.random()*f)
end end
end
end
Code: Select all
onDie = function(self)
snailWallScript.snailDie()
return false
end,
onProjectileHit = function(self,proj,amt,type)
snailWallScript.projHit(proj)
end,
Orwak - MOD - Beta version 1.0
Re: AI Switcher
Yes, it's not that easy however, for two reasons:
1) the AI switcher can be used on whatever dungeons and has no knowledge of what the throwing weapons in that dungeon are - it needs to tell between fragile projectiles, sharp projectiles and the others since only non-fragile sharp projectiles should be preserved. This adds a burden of configuration to be done by who uses AI switcher (though I fear there is no way out of this, unless I'm missing something).
2) the monsters to be managed are a ton and in different forms - so this means having to keep a per-instance context of every-monster which is something that can be useful anyway but I was keen to avoid for simplicity.. but I guess I can't procrastinate it any longer
Will try to get the hands dirty on it soon and see what I can do regarding this.
1) the AI switcher can be used on whatever dungeons and has no knowledge of what the throwing weapons in that dungeon are - it needs to tell between fragile projectiles, sharp projectiles and the others since only non-fragile sharp projectiles should be preserved. This adds a burden of configuration to be done by who uses AI switcher (though I fear there is no way out of this, unless I'm missing something).
2) the monsters to be managed are a ton and in different forms - so this means having to keep a per-instance context of every-monster which is something that can be useful anyway but I was keen to avoid for simplicity.. but I guess I can't procrastinate it any longer
Will try to get the hands dirty on it soon and see what I can do regarding this.
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
Re: AI Switcher
I got some hacky idea, but don't know if it really works: Instead of destroying the monster when the AI switch happens, just move the monster in to a some wall-tile (with monster:setPosition), and when the active monster dies kill the one in wall tile too (with damageTile), and move dropped items to the location of the active monster (by destroying and recreating them, should be easy with grimq).
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
Re: AI Switcher
Not sure if moving a monster in a wall works...
Re: AI Switcher
I tested it and moving monster in a wall works (and killing it when it's in a wall), but the tile must be surrounded with another wall tiles, otherwise the monster can escape from it. I didn't test it in game, only in editor.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
Re: AI Switcher
Good idea.. the only problem I foresee with that is the loot, which would get potentially duplicated many times, but I can work around that by taking care myself of the loot process in place of the game engine.
Will test and report! Thanks!
Will test and report! Thanks!
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
Re: AI Switcher
I'm trying both solutions.
Solution 1 - keeping a list of all the projectiles hitting a monster and respawning them later.
This seem to work but is cheatable. For example take a shuriken, throw (not shoot!) to the monster, now the shuriken is duplicated (as if thrown with the mouse and not by an attack, it still counts as a projectile but does not stuck in the monster).
Solution 2 (monster moved to walls) is giving me even more problems, but will try again tomorrow (at the very least, there is the problem of not counting projectiles shoot by the monster itself when inside the wall, plus not being able to preserve the monster id as killing does not remove the id immediately - there are severe timing issues with this method).
Solution 1 - keeping a list of all the projectiles hitting a monster and respawning them later.
This seem to work but is cheatable. For example take a shuriken, throw (not shoot!) to the monster, now the shuriken is duplicated (as if thrown with the mouse and not by an attack, it still counts as a projectile but does not stuck in the monster).
Solution 2 (monster moved to walls) is giving me even more problems, but will try again tomorrow (at the very least, there is the problem of not counting projectiles shoot by the monster itself when inside the wall, plus not being able to preserve the monster id as killing does not remove the id immediately - there are severe timing issues with this method).
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
Re: AI Switcher
That's why I have the script count any on the ground first and subtract that from the total. If the monster can move around a lot it's harder, but the ground could be searched a moment after every projectile hit registers, to see if a new item is found, indicated the player threw it instead of shooting it, and not add it to the total.Xanathar wrote:...This seem to work but is cheatable. For example take a shuriken, throw (not shoot!) to the monster, now the shuriken is duplicated (as if thrown with the mouse and not by an attack, it still counts as a projectile but does not stuck in the monster).
Finished Dungeons - complete mods to play