question about the NPCs

07/04/2013 22:25 shakalaka_boom#1
Good day! Comrades ...
I have a question about the NPCs ... I can somehow spawn NPCs in a certain place?

I have one idea, and I would like to implement it, but I do not know how.. I need to that after the capture of one of the altar, SPAWN a group of monsters, that I can, and one NPCs, its I cant ..

it is real? NPCs spawn like a monster.
...
yeah, I forgot, I would like to do this with the custom ai
07/06/2013 14:44 nubness#2
I'm afraid this is impossible.
07/07/2013 07:07 shakalaka_boom#3
Quote:
Originally Posted by nubness View Post
I'm afraid this is impossible.
Okay .. as I understand a
custom ai, I can create and delete any monster ..
but I do not understand how can I get the time counter ...
I need that would be after the capture of the altar, he is every hour SPAWN one group of monsters, each 4 hours of other monsters....
and after ~ 6 hours, altar should remove himself, and put the other altar..
I know through AI, can remove a different monster, but whether he will remove himself?

I'm interested in how to make a counter, I have not figured out how.
and a monster will remove the myself? to replace themselves, in other words

something of this possible?
07/07/2013 23:53 castor4878#4
I assume you are dealing with .lua scripts and not files within AI directory (I also assume your "AI" stands for ... "AI" and not for a name of file or directory but I prefer to clarify it).

nubness did start a thread focused on the .lua script.
among other listed verbs, the 'LuaDeleteMob' one will very likely remove a mob.
regarding scheduled actions, I'm afraid it is not possible; I can't have proof for that but all facts (including lua callbacks) show that the mob actions are actually answers to players actions (and not actions initied by the mob itself).
07/08/2013 15:49 sominus#5
As they said Mob:LuaDeleteMob( MobID, 1, 0.0, 0.0 ) will remove a mob, even himself. (Check how the fake Exiel removes himself after moving away)

For counters I would use something like (not sure of the code logic tho xD):
Code:
myTimer = 0
myCount = 0
...
...
function WhileCombat( dwTime, dwHPPercent, dwAttackedCount )
if ( dwTime >= myTimer ) then
	if ( myCount >= 10 ) then //every 10 minutes
                do_something_here... //perform an action
                myCount = 0
        end
       myCount = MyCount + 1
	myTimer = dwTime + 60000 //each 60 seconds
end

...
end
That is every 60 seconds, add 1 to the counter, when the counter reaches 10, do something and start counting again. Now, counting 6 hours, I don't know...

Of course that will loop only if the mob is being constantly attacked without a reset. As castor said they respond to player actions only, and I dont think we can do a loop on the Init() function.
07/08/2013 23:01 castor4878#6
mob respond to players' actions, that's certain.
but is it actually a blocking point?

the fact that the mob does not generate event when there are no players is definitely something that does not matter ... since there are no players to be involved in this event.

if I rewrite the requirement "after ~ 6 hours, altar should remove himself" as "after ~ 6 hours, any actions on altar remove it", the coding becomes obvious.

Code:
-- -----------------------------
-- AI script for test mob 58 (or any other)
-- -----------------------------

Mob = LuaMob(CMob)

-- -----------------------------
-- instance members

dwDeathTime	= 0

-- -----------------------------

function Init()

-- set death time to current time + 6 hrs
-- (see http://lua-users.org/wiki/OsLibraryTutorial)
--	dwDeathTime = os.time() + 6 * 60 * 60

	-- set delay to 30 sec for tests
	dwDeathTime = os.time() + 30

--	Mob:LuaSay('Mob:Initied', 20)

end

-- -----------------------------

function OnMoveEnd( dwTime )
end

-- -----------------------------

function OnAttacked( dwTime, dwCharID )
	-- this callback is never called by my ps_game
end

-- -----------------------------
-- invoked each time a new aggro / attack occurs

function OnAttackable( dwTime, dwCharID )

	Mob:LuaSay('Mob:OnAttackable', 20)

-- test for new aggro/attack after a reset
	if (os.time() > dwDeathTime) then
		Mob:LuaDeleteMob( 58, 1, 0.0, 0.0 )
	end

end

-- -----------------------------

function OnNormalReset( dwTime )
end

-- -----------------------------

function OnDeath( dwTime, dwAttackedCount )
end

-- -----------------------------

function OnReturnHome( dwTime, dwAttackedCount )
end

-- -----------------------------

function WhileCombat( dwTime, dwHPPercent, dwAttackedCount )

	-- debug feedback
	Mob:LuaSay('in combat at ' .. os.time() .. ' HP: ' .. dwHPPercent .. ' Count: ' .. dwAttackedCount, 20 )

	if (os.time() > dwDeathTime) then
		Mob:LuaDeleteMob( 58, 1, 0.0, 0.0 )
	end

end

with my ps_game the OnAttacked() callback is never invoked, I so don't use in to ckeck status.
the LuaGetMobUID [Only registered and activated users can see links. Click Here To Register...] is also not present in my ps_game, I so hard code the mob ID '58' of course one would prefer to dynamically recover the ID of the mob to remove it.

when the mob lost aggro (reset) and returns to home, it resets its HP but all LUA data are kept inchanged, this include our 'dwDeathTime' variable as well as some parameters transmitted to methods (including dwAttackedCount that will count the number of attacks received by the mob during its whole life); the mob can so remove itself after a given delay or a number of attacks.

also, since the dwDeathTime is not resetted, the counter (actually the dead line) will be valid forever and the test in OnAttackable will remove the mob (little visual glitch) if an aggro starts while the 6hr are elapsed.
this grants the requirement "the mob leasts for at most 6 hrs" (it can be present a longer time but only if there are no players to be aware of that).
OOH it is not possible to grant that "the mob (altar) is replaced by another mob (altar) after exactly 6 hrs", still it can be replaced by another mob as soon as the delay is expired *and* a player aggros or attacks it.
07/09/2013 00:30 shakalaka_boom#7
Thanks guys ...