Welcome to AC Web.
Results 1 to 12 of 12
  1. #1


    Join Date
    Feb 2013
    Location
    Right Behind You
    Posts
    353

    Lightbulb Mall Speed Custom Script


    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    Hello guys if you needed to change any area speed Like Malls, you can use this script

    Code:
    /*
    	<--------------------------------------------------------------------------->
        - Developer(s): Prince
        - Complete: %100
        - ScriptName: 'mall_speed'
        <--------------------------------------------------------------------------->
    */
         
    #include "ScriptPCH.h"
    
        enum AreaSpeed
        {
    	
    	    AREA_MALL               		    = 5303, // add here your area id
    
        };
             
        class area_speed : public PlayerScript
        {
        public:
            area_speed() : PlayerScript("area_speed") {}
             
            void OnUpdateZone(Player* player, uint32 newZone, uint32 newArea)
            {
                switch (newArea)
                {
    				
                    case AREA_MALL:
    				player->SetSpeed(MOVE_RUN, 2.0f);
    					
                        break;
    				
    
                }
            }
        };
             
        void AddSC_area_speed()
        {
            new area_speed();
        }

  2. #2
    You could do this:

    Code:
    ...
    //   if you want to change the speed, just change this value
    #define AREA_MALL_SPEED          2.0f
    ...
    player->SetSpeed(MOVE_RUN, AREA_MALL_SPEED);
    ...

  3. #3
    Quote Originally Posted by molinita View Post
    You could do this:

    Code:
    ...
    //   if you want to change the speed, just change this value
    #define AREA_MALL_SPEED          2.0f
    ...
    player->SetSpeed(MOVE_RUN, AREA_MALL_SPEED);
    ...
    Quote Originally Posted by Prince View Post
    Hello guys if you needed to change any area speed Like Malls, you can use this script

    Code:
    /*
    	<--------------------------------------------------------------------------->
        - Developer(s): Prince
        - Complete: %100
        - ScriptName: 'mall_speed'
        <--------------------------------------------------------------------------->
    */
         
    #include "ScriptPCH.h"
    
        enum AreaSpeed
        {
    	
    	    AREA_MALL               		    = 5303, // add here your area id
    
        };
             
        class area_speed : public PlayerScript
        {
        public:
            area_speed() : PlayerScript("area_speed") {}
             
            void OnUpdateZone(Player* player, uint32 newZone, uint32 newArea)
            {
                switch (newArea)
                {
    				
                    case AREA_MALL:
    				player->SetSpeed(MOVE_RUN, 2.0f);
    					
                        break;
    				
    
                }
            }
        };
             
        void AddSC_area_speed()
        {
            new area_speed();
        }
    Thank you both for the share!

  4. #4


    Join Date
    Feb 2013
    Location
    Right Behind You
    Posts
    353
    Quote Originally Posted by molinita View Post
    You could do this:

    Code:
    ...
    //   if you want to change the speed, just change this value
    #define AREA_MALL_SPEED          2.0f
    ...
    player->SetSpeed(MOVE_RUN, AREA_MALL_SPEED);
    ...
    and whats the difference....?

    - - - Updated - - -

    Quote Originally Posted by OMGhixD View Post
    Thank you both for the share!
    Yw
    Last edited by Prince; 06-17-2020 at 07:10 PM.

  5. #5
    Quote Originally Posted by Prince View Post
    and whats the difference....?
    This way you don't need access/look/search for the var if you need to modify it.

  6. #6
    Light of the Crusade

    Join Date
    Dec 2010
    Location
    The Forgotten Crusade
    Posts
    1,336
    Quote Originally Posted by Prince View Post
    and whats the difference....?

    - - - Updated - - -



    Yw
    Thanks for the share.

    There's no difference functionally, but there's a difference in facilitating code readability without any "magic numbers" involved that keep developers guessing what randomly thrown numbers refer to.

  7. #7
    Avoid using the #define preprocessor directive for constant values. https://github.com/isocpp/CppCoreGui...s-or-functions

  8. #8
    This function has 1 job and 1 value that's being set. I don't think not having a constant, would make it less readable.

  9. #9
    Quote Originally Posted by Fractional View Post
    Avoid using the #define preprocessor directive for constant values. https://github.com/isocpp/CppCoreGui...s-or-functions
    Then you should scream at the entire Trinity Core code because it has tons of #define used for constants.

    Quote Originally Posted by AlgoCleanser View Post
    This function has 1 job and 1 value that's being set. I don't think not having a constant, would make it less readable.
    Well fuck no, but it's just a tip for future coding.

  10. #10
    Quote Originally Posted by molinita View Post
    Then you should scream at the entire Trinity Core code because it has tons of #define used for constants
    Sure, but I think it's a good idea to avoid bad coding practices. Especially when there are better alternatives, such as constant expressions. But yes, older codebases are often riddled with bad uses for macros that could, and still can be avoided. For this script, it's really a non-issue, but now you know.

  11. #11
    Npc AreaTrigger

    hello friend everything Bom..vc would have some areaTrigger npc script when the player goes through it.
    it teleports the player to another map
    I don't know how to do this in SQL

  12. #12
    running amongst ghouls ..

    Join Date
    Feb 2010
    Location
    Living in real time, dreaming in digits, thinking in binary, talking in melody.
    Posts
    10,891

    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    Quote Originally Posted by molinita View Post
    Then you should scream at the entire Trinity Core code because it has tons of #define used for constants.
    You should think about the reasoning, why at these places there are defines, why at other places we actually see what Fractional suggests and more.
    Well, TC's codebase is large enough that there's not enough developers who work for free to fix it all neatly, however if you do search you'll find that you're partly wrong in your statement.

    I myself would keep this "magic" number, there's nothing wrong with raw numbers as long as they are local entities, in this case it's a single, simple variable which has a range that a is part of a global system anyway.

    P.S. Lmao, some the advice at Fractional's link is hilarious.

    My suggestions would be to 1st add a check if the actual update hook must be executed in full or not, e.g. - already executed/satisfied. 2nd, defer area from speed variable. 3rd build an automatically detecting size storage block instead an enumerator which defaults to a speed rating if no other speed rating has been inserted for all areas input in it.
    After it's run through some memory diagnostic tool it'll make a for a nice, agile script.
    Last edited by AwkwardDev; 08-01-2020 at 12:14 PM.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •