• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

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