Enumerating Units using an Arcemu Core? menu

User Tag List

Results 1 to 6 of 6
  1. #1
    TelepathicIndian's Avatar Member
    Reputation
    39
    Join Date
    Aug 2008
    Posts
    81
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Enumerating Units using an Arcemu Core?

    Hi, I'm not sure if the is the correct section (I hope it is ) but I need help with a little C++ programming.
    I'm using Keazains ULTIMATE Arcemu Trunk 2537 (I think :P I know the 2537 is correct, atleast) and I'm wanting to enumerate all units (NPC's, Players and (if possible) GO's) inrange of the player and perform a function on them. However, I have no clue on where to start

    If anyone can help, that'll be great
    Plus, if you set out a code, could you please use "//-- Place Funtion Here --\\" or something similar so I know where to place the functions to be performed on the units.
    Oh, and I'm fine with editting (spelling?) the core and recompiling, I'm doing it all the time :P (never did learn how to use C++ scripts ^^)

    Thanks.
    Last edited by TelepathicIndian; 06-30-2009 at 08:20 AM.
    Barely on MMOwned anymore sorry :/ Can't find anything to post about.

    Enumerating Units using an Arcemu Core?
  2. #2
    TelepathicIndian's Avatar Member
    Reputation
    39
    Join Date
    Aug 2008
    Posts
    81
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can no-one even point me in the right direction? (or tell me whether I posted this in the correct section? ^^)
    I'd really appreciate (*cough* +Rep) the help
    Barely on MMOwned anymore sorry :/ Can't find anything to post about.

  3. #3
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure how to do it in C++ but in Lua it can be done easily.
    Well depending on the LuaEngine (Have no idea if default ArcEmu one works with these commands) you can use the functions to check where a player is, then do something.
    Here is a list of events we can register:

    Code:
     enum QuestEvents
    {
        QUEST_EVENT_ON_ACCEPT = 1,
        QUEST_EVENT_ON_COMPLETE = 2,
        QUEST_EVENT_ON_CANCEL = 3,
        QUEST_EVENT_GAMEOBJECT_ACTIVATE = 4,
        QUEST_EVENT_ON_CREATURE_KILL  = 5,
        QUEST_EVENT_ON_EXPLORE_AREA = 6,
        QUEST_EVENT_ON_PLAYER_ITEMPICKUP = 7,
        QUEST_EVENT_COUNT,
    };
    
    enum CreatureEvents
    {
        CREATURE_EVENT_ON_ENTER_COMBAT        = 1,
        CREATURE_EVENT_ON_LEAVE_COMBAT        = 2,
        CREATURE_EVENT_ON_TARGET_DIED        = 3,
        CREATURE_EVENT_ON_DIED        = 4,
        CREATURE_EVENT_ON_TARGET_PARRIED        = 5,
        CREATURE_EVENT_ON_TARGET_DODGED        = 6,
        CREATURE_EVENT_ON_TARGET_BLOCKED        = 7,
        CREATURE_EVENT_ON_TARGET_CRIT_HIT        = 8,
        CREATURE_EVENT_ON_PARRY        = 9,
        CREATURE_EVENT_ON_DODGED        = 10,
        CREATURE_EVENT_ON_BLOCKED        = 11,
        CREATURE_EVENT_ON_CRIT_HIT        = 12,
        CREATURE_EVENT_ON_HIT        = 13,
        CREATURE_EVENT_ON_ASSIST_TARGET_DIED        = 14,
        CREATURE_EVENT_ON_FEAR        = 15,
        CREATURE_EVENT_ON_FLEE        = 16,
        CREATURE_EVENT_ON_CALL_FOR_HELP        = 17,
        CREATURE_EVENT_ON_LOAD        = 18,
        CREATURE_EVENT_ON_REACH_WP        = 19,
        CREATURE_EVENT_ON_LOOT_TAKEN        = 20,
        CREATURE_EVENT_ON_AIUPDATE        = 21,
        CREATURE_EVENT_ON_EMOTE        = 22,
        CREATURE_EVENT_COUNT,
    };
    
    enum GameObjectEvents
    {
        GAMEOBJECT_EVENT_ON_CREATE            = 1,
        GAMEOBJECT_EVENT_ON_SPAWN            = 2,
        GAMEOBJECT_EVENT_ON_LOOT_TAKEN        = 3,
        GAMEOBJECT_EVENT_ON_USE                = 4,
        GAMEOBJECT_EVENT_AIUPDATE            = 5,
        GAMEOBJECT_EVENT_ON_DESPAWN            = 6,
        GAMEOBJECT_EVENT_COUNT,
    };
    
    enum PlayerObjectEvents
    {
        PLAYEROBJECT_EVENT_DEALDAMAGE        = 1,
        PLAYEROBJECT_EVENT_COUNT,
    };
    
    enum GossipEvents
    {
        GOSSIP_EVENT_ON_TALK            = 1,
        GOSSIP_EVENT_ON_SELECT_OPTION    = 2,
        GOSSIP_EVENT_ON_END             = 3,
        GOSSIP_EVENT_COUNT,
    };
    
    enum RandomFlags
    {
        RANDOM_ANY           = 0,
        RANDOM_IN_SHORTRANGE = 1,
        RANDOM_IN_MIDRANGE   = 2,
        RANDOM_IN_LONGRANGE  = 3,
        RANDOM_WITH_MANA     = 4,
        RANDOM_WITH_RAGE     = 5,
        RANDOM_WITH_ENERGY   = 6,
        RANDOM_NOT_MAINTANK  = 7,
        RANDOM_COUNT,
    


    Each one is a different type of event.
    I'll help with the npc one.
    This is the script on how you would do it, just change the stuff and edit it to a different event type for gameobject and player etc.


    Code:
    
    function OnSpawnWeCheckForPlayer(pUnit, Event)
        pUnit:RegisterEvent("OnPlayerComesClose", 1000, 0)
    end
    
    function OnPlayerComesClose(pUnit, Event)
        local TargeTwo = pUnit:GetClosestPlayer()
        local DistancTwo = pUnit:GetDistance(TargeTwo)
        if DistancTwo < 10 then -- if player is less than 10 distance (measurements are weird)
        pUnit:RemoveEvents()
        else
        pUnit:FullCastSpellOnTarget(48135, TargeTwo) -- do this if he is more than 10 distance
        end
    end
    
    RegisterUnitEvent(npcid, 18, "OnSpawnWeCheckForPlayer")
    

  4. #4
    TelepathicIndian's Avatar Member
    Reputation
    39
    Join Date
    Aug 2008
    Posts
    81
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, I'm abit unsure on whether this has answered my question (it may have) but I'll have a look now, see if I can do anything with it
    Thanks for the response, I'll post a reply on whether it helped or not
    Barely on MMOwned anymore sorry :/ Can't find anything to post about.

  5. #5
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    "I'm wanting to enumerate all units (NPC's, Players and (if possible) GO's) inrange of the player and perform a function on them"

    Yeah it does answer that but in Lua not C++. You just need to enable Lua in world config and then chuck the file .lua into the scripts folder and restart your server Anyway hope it helps, I know you requested C++ but to be honest I doubt anyone will help you (the people who do know C++ rarely check questions).


  6. #6
    TelepathicIndian's Avatar Member
    Reputation
    39
    Join Date
    Aug 2008
    Posts
    81
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    "I'm wanting to enumerate all units (NPC's, Players and (if possible) GO's) inrange of the player and perform a function on them"

    Yeah it does answer that but in Lua not C++. You just need to enable Lua in world config and then chuck the file .lua into the scripts folder and restart your server Anyway hope it helps, I know you requested C++ but to be honest I doubt anyone will help you (the people who do know C++ rarely check questions).

    Turns out it helped alot :D
    I went into the LuaEngine.cpp and went and found the GetClosestPlayer() function (am I right in saying "function"?) and checked the C++ version of it (seeing as every Lua command is pretty much just labelled C++) and I found this:
    Code:
    int luaGameObject_GetClosestPlayer(lua_State * L, GameObject * ptr)
    {
    	if(!ptr)
    		return 0;
    
    	float dist, d2;
    	Player * ret=NULL;
    
    	for(set<Player*>::iterator itr = ptr->GetInRangePlayerSetBegin(); itr != ptr->GetInRangePlayerSetEnd(); ++itr)
    	{
    		d2=(*itr)->GetDistanceSq(ptr);
    		if(!ret||d2<dist)
    		{
    			dist=d2;
    			ret=*itr;
    		}
    	}
    
    	if(ret==NULL)
    		lua_pushnil(L);
    	else
    		Lunar<Unit>::push(L,((Unit*)ret),false);
    
    	return 1;
    }
    then used the "for(){ }" part of it in the context I needed it in, and it performed my script on all players inrange so I'm trying it with creatures aswell now

    Btw,
    Yeah it does answer that but in Lua not C++.
    that's not what I meant, I was looking for all units, not just players but turns out the code did help with them too (gonna try swapping "Player *Ret=NULL;" with something like Unit or Creature)
    Barely on MMOwned anymore sorry :/ Can't find anything to post about.

Similar Threads

  1. can i use an ncdb for aspire on an arcemu core?
    By darkmagishin in forum WoW EMU Questions & Requests
    Replies: 5
    Last Post: 12-13-2008, 08:35 PM
  2. Aspire and Arcemu Cores and other files.
    By Evilkitten in forum WoW EMU General Releases
    Replies: 4
    Last Post: 11-16-2008, 10:29 PM
  3. *HELP* ArcEmu Core strange bug ?
    By thegame240 in forum WoW EMU Questions & Requests
    Replies: 15
    Last Post: 10-22-2008, 09:34 AM
  4. ArcEmu Core Questions
    By fokui in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 10-02-2008, 06:30 PM
  5. Table structure for DB's used in Arcemu 2.43 servers
    By kreegoth in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 08-15-2008, 11:46 PM
All times are GMT -5. The time now is 01:47 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search