Introduction
A whole lot has changed since the beginning of the LuaHypArc "era".
Today ArcEmu no longer uses LuaHypArc, they now use LuaBridge instead which has been implemented by Paroxysm.
There are some changes you should know about as a scripter.
LuaBridge now easily allows developers to easily bind classes, which makes it easy to use C++ methods from Lua with a single line of code.
The syntax has changed
The syntax has changed slightly.
While an old function would look like this:
pCreature:RegisterAIUpdateEvent(1000)
It would today look like this:
pCreature:GetScript():RegisterAIUpdateEvent(1000)
Whereas pCreature stands for pointerCreature, GetScript() is the class and RegisterAIUpdateEvent is the method and within the method parenthesis is the arguments.
Pointer:Class():Method(args)
Things you should know
- LuaBridge will only function on Windows 2008 Server / Vista or newer.
- Any Unit method can be invoked on either Unit, GameObject, Creature or Player Object.
- To avoid any unnecessary errors the following code should put at the top of every script.
Code:
if not MapMgr then return end
-- You can also only run your script on a specific map if you want.
if not MapMgr:GetMapInfo().mapid == ### then return end
-- If you do this your script will cease running on the Map unless it matches the chosen Map ID.
Methods
Unit Methods
Code:
:GetAIInterface()
:IsPVPFlagged()
:SetPvPFlag()
:RemovePvPFlag()
:IsFFAPvPFlagged()
:SetFFAPvPFlag()
:RemoveFFAPvPFlag()
:IsSanctuaryFlagged()
:SetSanctuaryFlag()
:RemoveSanctuaryFlag()
:setAttackTimer()
:isAttackReady()
:getLevel()
:setLevel()
:modLevel()
:getClassMask()
:getRaceMask()
:getStandState()
:addStateFlag()
:hasStateFlag()
:clearStateFlag()
:GetAP()
:GetRAP()
:CastSpell(Unit*,uint32,bool)
:CastSpellAoF()
:IsCasting()
:IsInInstance()
:Demorph()
:IsDazed()
:GetStealthLevel()
:GetStealthDetectBonus()
:IsStealthed()
:SetInvisibility()
:IsInvisible()
:HasAura()
:GetAuraStackCount()
:HasAuraWithMechanic()
:RemoveAura(uint32)
:RemoveAllAuras()
:isAlive()
:IsDead()
:RemoveNegativeAuras()
:RemoveAllNonPersistentAuras()
:setAItoUse()
:GetThreatModifyer()
:ModThreatModifyer()
:GetGeneratedThreatModifyer()
:ModGeneratedThreatModifyer()
:IsPacified()
:IsStunned()
:IsFeared()
:Heal()
:Energize()
:setEmoteState()
:GetOldEmote()
:GetFaction()
:GetHealthPct()
:SetFaction()
:SendChatMessage()
:SendChatMessageToPlayer()
:SendChatMessageAlternateEntry()
:SetHealthPct()
:GetManaPct()
:GetCurrentSpell()
:SetCurrentSpell()
:RemoveStealth()
:RemoveInvisibility()
:create_guardian()
:DisableAI()
:EnableAI()
:IsSpiritHealer()
:Phase()
:SetFacing()
:SetMinDamage()
:GetMinDamage()
:SetMaxDamage()
:GetMaxDamage()
:SetMinOffhandDamage()
:GetMinOffhandDamage()
:SetMaxOffhandDamage()
:GetMaxOffhandDamage()
:SetMaxRangedDamage()
:GetMaxRangedDamage()
:SetMount()
:GetMount()
:SetCreatedBySpell()
:GetCreatedBySpell()
:SetStat()
:GetStat()
:SetResistance()
:GetResistance()
:SetBaseMana()
:SetBaseHealth()
:SetAttackPower()
:GetAttackPower()
:GetRangedAttackPower()
:SetRangedAttackPower()
:getRace()
:setRace()
:getClass()
:setClass()
:getGender()
:setGender()
:SetPowerType()
:GetPowerType()
:SetHealth()
:GetHealth()
:SetMaxHealth()
:GetMaxHealth()
:ModHealth()
:ModMaxHealth()
:SetPower()
:ModPower()
:GetPower()
:SetMaxPower()
:GetMaxPower()
:SetDisplayId()
:GetDisplayId()
:GetNativeDisplayId()
:SetNativeDisplayId()
Creature Methods
Code:
:IsVehicle()
:RemoveFromWorld(bool)
:HasItems()
:GetProto()
:GetItemIdBySlot()
:GetItemAmountBySlot()
:GetSlotByItemId()
:GetItemAmountByItemId()
:HasQuests()
:HasQuest()
:AddQuest()
:DeleteQuest()
:FindQuest()
:GetQuestRelation()
:NumOfQuests()
:isVendor()
:isTrainer()
:isClass()
:isProf()
:isQuestGiver()
:isGossip()
:isTaxi()
:isCharterGiver()
:isGuildBank()
:isBattleMaster()
:isBanker()
:isInnkeeper()
:isSpiritHealer()
:isTabardDesigner()
:isAuctioner()
:isStableMaster()
:isArmorer()
:CanSee()
:GetSQL_id()
:GetTotemSlot()
:GetGroup()
:IsPickPocketed()
:GetCreatureInfo()
:SetCreatureProto()
:IsTotem()
:IsExotic()
:GetScript()
:IsCritter()
:IsTrainingDummy()
:Despawn()
:RegisterEvent()
:RemoveEvents()
:GetRandomEnemy()
:GetRandomFriend()
:GetRandomPlayer()
:GetClosestFriend()
:GetClosestEnemy()
:GetClosestPlayer()
Creature AI Interface
Code:
:GetPetOwner()
:SetPetOwner()
:SetUnitToFollow(Unit*)
:getUnitToFollow()
:SetFollowDistance()
:SetUnitToFollowAngle()
:getUnitToFear()
:SetUnitToFear(Unit*)
:getSoullinkedWith()
:GetIsSoulLinked()
:SetSoulLinkedWith()
:getAIState()
:SetAIState()
:addSpellToList()
:SetNextSpell()
:MoveTo()
:StopMovement()
:hasWaypoints()
:getNextTarget()
:setNextTarget(Unit*)
:AttackReaction()
:HealReaction()
:ClearHateList()
:WipeHateList()
:WipeTargetList()
:RemoveThreatByPtr()
:modThreatByPtr()
:getThreatByPtr()
:GetMostHated()
:GetSecondHated()
:taunt()
:getTauntedBy()
:GetIsTaunted()
:getSoullinkedWith()
:SetSoulLinkedWith()
:GetIsSoulLinked()
:getOutOfCombatRange()
:setOutOfCombatRange()
:MoveTo()
:getCurrentWaypoint()
:changeWayPointID()
:getWayPoint()
:deleteWayPoint()
:deleteWaypoints()
:setMoveType()
:getMoveType()
:setMoveRunFlag()
:getMoveRunFlag()
:setWaypointToMove()
:IsFlying()
:getCurrentAgent()
:setCurrentAgent()
:SetAllowedToEnterCombat()
:GetAllowedToEnterCombat()
:GetAITargetsCount()
Creature Script
Code:
:RegisterAIUpdateEvent()
:ModifyAIUpdateEvent()
:RemoveAIUpdateEvent()
GameObject Methods
Code:
:GetGUID() - returns the object's GUID.
:GetHighGUID() - returns the object's HighGUID.
:GetLowGUID() - returns the object's LowGUID.
:GetNewGUID() - returns the object's NewGUID.
:GetEntry() - returns the object's Entry.
:GetScale() - returns the object's Scale.
:SetScale()
:GetTypeFromGUID()
:GetEntryFromGUID()
:GetTypeID() - returns the object's Type ID.
:IsUnit()
:IsGameObject()
:IsPlayer()
:IsItem()
:IsCreature()
:IsPet()
:SetPosition(Object)
:GetPositionX() - returns the object's X.
:GetPositionY() - returns the object's Y.
:GetPositionZ() - returns the object's Z.
:GetOrientation() - returns the object's Orientation.
:GetO() - returns the object's O.
:GetSpawnX() - returns the object's SpawnX.
:GetSpawnY() - returns the object's SpawnY.
:GetSpawnZ() - returns the object's SpawnZ.
:CalcDistance2Object(Object)
:CalcDistance2Location(Object)
:CalcDistanceBtwnObjects(Object*,Object*)
:CalcDistanceObject2Location(Object*,float,float,float)
:CalcDistanceLocation2Location(float,float,float,float,float,float)
:GetMapID() - returns the object's MapID.
:GetZoneID() - returns the object's ZoneID.
:SetZoneID()
:SetMapID()
:GetUInt32Value()
:GetUInt64Value()
:SetUInt32Value()
:SetUInt64Value()
:GetFloatValue()
:ModFloatValue()
:ModFloatValueByPCT()
:ModSignedUInt32Value()
:ModUnsignedUInt32Value()
:GetByte()
:SetByte()
:SetByteFlag()
:RemoveByteFlag()
:HasByteFlag()
:EventSetUInt32Value()
:SetFloatValue()
:SetFlag()
:HasFlag()
:IsInRange()
:IsInFront()
:IsBehind()
:IsInArc()
:calcAngle()
:calcRadAngle()
:getEasyAngle()
:GetDistance2Object(Object*)
:GetDistance(float,float,float)
:GetCurrentSpell()
:SetCurrentSpell()
Dynamic Object Methods
Code:
:Create()
:Remove()
Player Methods
Code:
:Gossip_Complete()
:Gossip_SendPOI()
:AdvanceSkillLine()
:AddSkillLine()
:GetSkillLineMax()
:GetSkillLineCurrent()
:RemoveSkillLine()
:UpdateMaxSkillLineCounts()
:ModifySkillBonus()
:ModifySkillBonusByType()
:HasSkillLine()
:RemoveSpellsFromLine()
:RemoveAllSkills()
:RemoveLanguages()
:AddLanguages()
:AdvanceAllSkills()
:ModifySkillMaximum()
:LearnSkillSpells()
:Cooldown_AddStart()
:Cooldown_Add()
:Cooldown_AddItem()
:Cooldown_CanCast(SpellEntry*)
:SendPacket()
:SendMessageToSet()
:GetTaxiPath()
:GetTaxiState()
:TaxiStart()
:SetTaxiPath()
:SetTaxiPos()
:SetTaxiState()
:HasQuests()
:GetOpenQuestSlot()
:GetQuestLogForEntry()
:GetQuestLogInSlot()
:GetQuestSharer()
:SetQuestSharer()
:SetQuestLogSlot()
:HasFinishedDaily()
:AddToFinishedQuests()
:HasFinishedQuest()
:GetQuestRewardStatus()
:HasQuestForItem()
:HasQuestSpell()
:RemoveQuestSpell()
:HasQuest()
:RemoveQuestMob()
:GetTeam()
:GetTeamInitial()
:SetTeam()
:ResetTeam()
:IsTeamHorde()
:IsTeamAlliance()
:IsInFeralForm()
:GetMaxLevel()
:GetSelection()
:GetTarget()
:SetSelection()
:SetTarget()
:HasSpell()
:HasSpell()
:LearnSpell()
:UnlearnSpell()
:AddShapeShiftSpell()
:RemoveShapeShiftSpell()
:ModStanding()
:GetStanding()
:GetBaseStanding()
:SetStanding()
:SetAtWar()
:GetStandingRank()
:GetReputationRankFromStanding()
:SetFactionInactive()
:GetExaltedCount()
:GetPVPRank()
:SetPVPRank()
:GetMaxPersonalRating()
:HasTitle()
:SetKnownTitle()
:InGroup()
:IsGroupLeader()
:HasBeenInvited()
:SetInviter()
:GetInviter()
:GetGroup()
:GetSubGroup()
:IsGroupMember()
:IsBanned()
:SetBanned()
:SetBannedWithReason(string)
:UnSetBanned()
:GetBanReason()
:IsInGuild()
:GetGuildID()
:SetGuildID()
:GetGuildRank()
:SetGuildRank()
:GetGuildInvitersGuid()
:SetGuildInvitersGuid()
:UnSetGuildInvitersGuid()
:RequestDuel()
:EndDuel()
:DuelCountdown()
:SetDuelStatus()
:GetDuelStatus()
:SetDuelState()
:GetDuelState()
:GetDuelTeam()
:SetDuelTeam()
:SetBindPoint()
:KillPlayer()
:ResurrectPlayer()
:GetShapeShift()
:SetShapeShift()
:CanSee()
:IsVisible()
:Reset_Spells()
:Reset_Talents()
:GetSelectedGo()
:IsMounted()
:Dismount()
:Kick()
:SoftDisconnect()
:GetSummonedObject()
:SetSummonedObject()
:ClearCooldownsOnLine()
:ResetAllCooldowns()
:ClearCooldownForSpell()
:Phase()
:ExitInstance()
:GetAreaID()
:SetAreaID()
:EventTeleport()
:EventTeleportTaxi()
:SafeTeleport(uint32,uint32,float,float,float,float)
:GetDungeonDifficulty()
:GetRaidDifficulty()
:GetGold()
:ModGold()
:HasGold()
:SetGold()
:GiveGold()
:TakeGold()
:SetFarsightTarget()
:GetFarsightTarget()
:SetXp()
:GetXp()
:SetNextLevelXp()
:SetTalentPoints()
:ModTalentPoints()
:GetTalentPoints()
:SetHonorCurrency()
:GetHonorCurrency()
:ModHonorCurrency()
:GetArenaCurrency()
:SetArenaCurrency()
:ModArenaCurrency()
:SetGlyph()
:GetGlyph()
:ResetPvPTimer()
:StopPvPTimer()
:PvPToggle()
:LearnTalent()
:AddComboPoints()
:GetTradeTarget()
:Possess()
:UnPossess()
:IsAttacking()
:PlaySound()
:GetItemInterface()
:Resurrect()
:ResurrectPlayer()
:GetName()
Global Methods
Code:
LuaPacket(opcode, size)- Creates a LuaPacket object so that you can use Packet Methods on it.
CreateLuaEvent()
ModifyLuaEventInterval()
ModifyLuaEventTimer()
DestroyLuaEvent()
getregistry()
TO_PLAYER()
TO_CREATURE()
TO_ITEM()
TO_UNIT()
TO_GAMEOBJECT()
GetGameTime()
GetPlayer()
GetEngineName()
GetEngineVersion()
logcolor()
WorldDBQuery()
CharDBQuery()
SendWorldMessage()
ReloadTable()
ReloadLuaEngine()
GetPlayersInWorld()
Rehash()
GetArcemuRevision()
GetPlayersInMap()
GetPlayersInZone()
bit_and()
bit_or()
bit_xor()
bit_not()
bit_shiftleft()
bit_shiftright()
GetPlatform()
SendPacketToZone()
SendPacketToInstance()
SendPacketToWorld()
SendPacketToChannel()
GetInstanceCreature()
GetInstancePlayerCount()
GetPlayersInInstance()
DBC Spell
This is executed on dbcSpell. This is a global variable.
Code:
:LookupEntry()
:GetNumRows()
:LookupEntryForced()
SQL Query
These are executed on WorldDB or CharacterDB. Both of these are global variables.
Code:
:Query()
:Execute()
Map Methods
Code:
:GetMapID()
:GetObject()
:CreateGameObject()
:CreateAndSpawnGameObject()
:GetGameObject()
:GetCreature()
:GetMapInfo()
:CreateCreature()
:CreateDynamicObject()
:GetDynamicObject()
:GetPlayer()
:GetInstanceID()
:GetInterface()
:HasPlayers()
:GetPlayerCount()
:GetSqlIdCreature()
:GetSqlIdGameObject()
Map Script Interface
Code:
:GetGameObjectNearestCoords(GetGameObjectNearestCoords)
:GetCreatureNearestCoords(GetCreatureNearestCoords)
:GetPlayerNearestCoords(GetPlayerNearestCoords)
:SpawnCreature(uint32,float,float,float,float,bool,bool,uint32,uint32,uint32)
:SpawnGameObject(uint32,float,float,float,float,bool,uint32,uint32,uint32)
Taxi Methods
Code:
:GetTaxiNode(GetTaxiNode)
:GetTaxiPath(uint32)
:GetTaxiPathFT(uint32,uint32)
:GetNearestTaxiNode(GetNearestTaxiNode)
:GetID(GetID)
:AddPathNode(AddPathNode)
:GetNodeCount(GetNodeCount)
:GetPrice(GetPrice)
Packet Methods
These are invoked on LuaPacket objects.
pcode()
Code:
:clear()
:WriteInt8()
:WriteUInt8()
:WriteInt16()
:WriteUInt16()
:WriteInt32()
:WriteUInt32()
:WriteWoWGuid()
:size()
Spell Methods
Code:
:gettype()
:getstate()
:cancel()
:cast()
:finish()
:getproto()
:isaspect()
:isseal()
:createprotooverride()
:getduration()
:getradius()
:isstealthspell()
:isinvisibilityspell()
Will update this thread later with more a concrete tutorial on the new engine.