Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Lua Ideas?

Elite Diviner
Joined
Sep 12, 2020
Messages
442
Reaction score
224
Anyone know why this lua would not work in game ?

Code:
-- MirrorWorld 224 
function lua_smallMoveAttack()
        local OwnerID = 106487
--How far, how often do you move, and how far you move at a time
        SetRandMove( OwnerID(), 15, 15, 15)
end

No matter what i add it just does not work , sometimes it crashes client also ?
Its like SetRandMove is not working, i know its in there i check lua in source ...

Code:
        LuaRegisterFunc( "OwnerID"            , int()                                    , OwnerID               );
        LuaRegisterFunc( "TargetID"            , int()                                    , TargetID                );

        LuaRegisterFunc( "Rand"                , int(int)                                , Random                );
        LuaRegisterFunc( "RandRange"        , int(int,int)                          , RandRange                );

        LuaRegisterFunc( "SysPrint"            , void(const char*)                     , SysPrint                );
        LuaRegisterFunc( "MoveTarget"        , int(int,int)                            , MoveTarget            );
        LuaRegisterFunc( "Move"                , int(int,float,float,float)            , Move                    );
        LuaRegisterFunc( "MoveDirect"        , int(int,float,float,float)            , MoveDirect            );

        LuaRegisterFunc( "SetRandMove"        , void(int, int, int,int)               , SetRandMove            );

and everything looks ok ?

    void SetRandMove( int ID , int Range , int Freq, int Dist )
    {
        BaseItemObject *OtherClass    = BaseItemObject::GetObj( ID );    
        if( OtherClass == NULL  )
            return;

        NPC_RandomMoveStruct& RandomMove = OtherClass->Role()->TempData.RandomMove;

        RandomMove.Active = __max( 1 , Freq );
        RandomMove.CenterX = OtherClass->Role()->Pos()->X;
        RandomMove.CenterZ = OtherClass->Role()->Pos()->Z;

        RandomMove.CountDown = 0;
        RandomMove.MaxRange  = (float)Range;
        RandomMove.Dist      = (float)Dist;

        RandomMove.Enable    = true;

        return;
    }



Janebug
 

fht

Newbie Spellweaver
Joined
Dec 8, 2016
Messages
53
Reaction score
59
Variable OwnerID is declared but never being used (you call OwnerID() which gets you the ID of the object that runs the plot). I think I can help you there, but you need to give me some more information about what‘s supposed to happen.
 
Upvote 0
Elite Diviner
Joined
Sep 12, 2020
Messages
442
Reaction score
224
It should have the NPC walk around a small area 15 x 15. after 15 sec

Its been standard ingame for awhile however its just does not work no matter how i add it even

Code:
function lua_smallMoveAttack()
--How far, how often do you move, and how far you move at a time
        SetRandMove( OwnerID(), 15, 15, 15)
end

should work , how ever it does not?
 
Upvote 0

fht

Newbie Spellweaver
Joined
Dec 8, 2016
Messages
53
Reaction score
59
I just did a quick test spawning a wolf cub and it works like intended.




Code:
function LuaS_Testing0915()
    local RoomID = ReadRoleValue( OwnerID() , EM_RoleValue_RoomID ) 
    local X = ReadRoleValue( OwnerID() , EM_RoleValue_X )
    local Y = ReadRoleValue( OwnerID() , EM_RoleValue_Y )
    local Z = ReadRoleValue( OwnerID() , EM_RoleValue_Z )
    local Dir = ReadRoleValue(OwnerID() , EM_RoleValue_Dir )
    local wolf = CreateObj( 100054 , X , Y , Z , Dir , 1 )
        SetModeEx( wolf , EM_SetModeType_Strikback, true )
        SetModeEx( wolf , EM_SetModeType_SearchenemyIgnore, false )
        SetModeEx( wolf , EM_SetModeType_Obstruct, false )
        SetModeEx( wolf , EM_SetModeType_Mark, true )
        SetModeEx( wolf , EM_SetModeType_Move, true )
        SetModeEx( wolf , EM_SetModeType_HideName, false )
        SetModeEx( wolf , EM_SetModeType_ShowRoleHead, true )
        AddToPartition( wolf , RoomID ) 
        SetRandMove( wolf , 15 , 15 , 15 )
end
 
Upvote 0
Elite Diviner
Joined
Sep 12, 2020
Messages
442
Reaction score
224
Thanks @fht

How ever this will create a buddy after you spawn in 100054, If i understand this correctly and yes it does work correctly.

Code:
function lua_smallMoveAttack()
--How far, how often do you move, and how far you move at a time
        SetRandMove( OwnerID() , 15, 15, 15 )
end

This here is suppose to allow the npc you spawn in and after adding lua_smallMoveAttack to "Inital plot"
should also do the same thing to just the single 100054, with out it creating another.

 
Last edited:
Upvote 0
Back
Top