Page 2 of 3

Re: ACP and ASA

Posted: Wed Jun 01, 2016 7:08 pm
by DanteMccloud
kjLotus wrote:npc:timer
oh nice I didn't know that was even a thing haha. I'll have to look around and see if I can find anything using it so i can get a better idea of how it works thank you ^.^

Re: ACP and ASA

Posted: Wed Jun 01, 2016 7:31 pm
by kjLotus
i don't think anything is using it.. but it just takes time (in ms) as the first param and the function (probably a closure) as the second param

Re: ACP and ASA

Posted: Wed Jun 01, 2016 9:47 pm
by DanteMccloud
kjLotus wrote:i don't think anything is using it.. but it just takes time (in ms) as the first param and the function (probably a closure) as the second param
haha I think I'm using it majorly wrong or something as every variation I've tried just crashes the server :oops: I'll keep playing with it though.

I was hoping to find something using it as then I could pick it apart and learn how that works and such,

Code: Select all

local MandyTest = SpawnMob(-----)

    npc:timer(10000,MandyTest); --This would spawn that monster in 10seconds? 
Or am I way off haha?

so sorry for bugging you with these questions kjLotus, ty for all the help so far though I can't wait to have it working and share ^.^ having a delay/wait function like this will open SO many doors for projects I've been working on in the server. All tiny things but things none the less haha.

Does DSP support LUA 5.2 ? Or any of the windower lua handles?

Re: ACP and ASA

Posted: Thu Jun 02, 2016 12:03 am
by kjLotus

Code: Select all

local trader = player
npc:timer(1000, function(npc) 
    SpawnMob(whatever):updateClaim(trader) 
end )
no to 5.2 or windower stuff (our lua was around long before windowers)

Re: ACP and ASA

Posted: Thu Jun 02, 2016 4:02 pm
by DanteMccloud
kjLotus wrote:

Code: Select all

local trader = player
npc:timer(1000, function(npc) 
    SpawnMob(whatever):updateClaim(trader) 
end )
Thanks Mate!! you are a life saver that seems to be working well, now to just fine tune what i have to work right 100% of the time ^.^

fun note this function HATES :updateClaim() it dies and crashes the server something about line 6081 in Lua_baseentity.cpp way beyond me on why but thought I'd let you know in case you happened to see or know why haha.

"Unhandled exception at 0x01021D4C in DSGame-server.exe: 0xC0000005: Access violation reading location 0xCCCCCCD8."

Code: Select all

/************************************************************************
*                                                                       *
*  updates enmity and claims monster                                    *
*                                                                       *
************************************************************************/

inline int32 CLuaBaseEntity::updateClaim(lua_State *L)
{
    DSP_DEBUG_BREAK_IF(m_PBaseEntity == NULL);
    DSP_DEBUG_BREAK_IF(m_PBaseEntity->objtype != TYPE_MOB);

    //DSP_DEBUG_BREAK_IF(lua_gettop(L) > 1);
    DSP_DEBUG_BREAK_IF(lua_isnil(L, 1) || !lua_isuserdata(L, 1));

    CLuaBaseEntity* PEntity = Lunar<CLuaBaseEntity>::check(L, 1);

    if (PEntity != NULL &&    /*-----------------BREAKS HERE when running debug-----------------*/
        PEntity->GetBaseEntity()->objtype != TYPE_NPC)
    {
        battleutils::ClaimMob((CMobEntity*)m_PBaseEntity, (CBattleEntity*)PEntity->GetBaseEntity());
    }
    return 0;
}

Re: ACP and ASA

Posted: Thu Jun 02, 2016 7:54 pm
by kjLotus
oh yeah, i was hoping the assignment to a local would get around that but I guess not (you can't use a parameter passed into the on(whatever) functions in a closure since it gets destructed immediately after)

normally you could use getTarget or something like that to get it back...
anyways, you'll have to instantiate a new CLuaBaseEntity instead of that assignment - i think you might be able to do local target = CLuaBaseEntity.new(trader), but i have never tried that, and the syntax might be wrong (or entirely impossible)

it's a common use case so i'll have to look into it later if it doesn't work

Re: ACP and ASA

Posted: Thu Jun 02, 2016 8:54 pm
by DanteMccloud
kjLotus wrote:oh yeah, i was hoping the assignment to a local would get around that but I guess not (you can't use a parameter passed into the on(whatever) functions in a closure since it gets destructed immediately after)

normally you could use getTarget or something like that to get it back...
anyways, you'll have to instantiate a new CLuaBaseEntity instead of that assignment - i think you might be able to do local target = CLuaBaseEntity.new(trader), but i have never tried that, and the syntax might be wrong (or entirely impossible)

it's a common use case so i'll have to look into it later if it doesn't work
I think I need to also add timer2 timer3 timer4 etc as when you try to call npc:timer more than once for multiple waves it just sets all previously called timers to the last called ones time. This fight requires several waves of Seed mandragora starts low and adds in more every 1-3 mins until the player has kill 30 of them. I couldn't find a way to make npc:timer work for multiple cases of the timer. Was hopeful that I could get it by use separate local's but that didn't really work either haha.

would likely be easier to just put the timer into the mandy's onMobDeath rather than in the function for the ???'s fight spawn lol.

so that worked in the onmobdeath but they spawn invisible then lol

Re: ACP and ASA

Posted: Thu Jun 02, 2016 9:17 pm
by kjLotus
i'd have to see your code, but it shouldn't be doing that

Re: ACP and ASA

Posted: Fri Jun 03, 2016 12:35 am
by DanteMccloud
kjLotus wrote:i'd have to see your code, but it shouldn't be doing that
Thank you so much for all the guidance kjLotus!! I got it working, I'm still fine tuning it to be as close to retail as i can get. They continue to spawn in waves now until the player kills 30 of them ^.^ then they stop respawning. I'm so happy to have this close to done so i can move on in the story arc and get all of ACP ready to play. ended up putting it in the Seed Mandy's onMobDeath function and used

Code: Select all

mob:timer(30000, function(npc) SpawnMob(17293643,240000) end);
the first batch spawns with updateClaim(player) to start the fight, the rest spawn without hate but they link so it works out. The invisible issue I found has to due with them just respawning too fast as I had it set to 15sec for testing now put up to 30sec and it only happened a few times but ideally it will be random using

Code: Select all

local wait = math.random(60000,180000);
I'll be sure to share the files once it's all working.

Re: ACP and ASA

Posted: Sun Jun 05, 2016 12:44 pm
by TeoTwawki
For the seed mandragora I was just going try having the handling of their spawns in onTick() in a status effect when I had time to look at it. I had no idea I could timer() it.

Besides them there is also the sneak attack mechanic on the seed globlin to do, the dulkfutt tower climb (which I have had sitting on my local copy for awhile), and then the final battlefield mechanics (clones etc).

Also eventually need to redo the tenshodo coffer into need tables, but wasn't going to even bother with it till more of its data was filled in.

...And then ACP will finally be finished. I just haven't had free time nor motivation do get-er-done. Juts moved to a new house and got my internet back on now I need to fix the electrical here so I can use my desktop. I just can't get work done on this laptop, wrecks my flow.