Changeset 1144

Show
Ignore:
Timestamp:
02/02/2010 10:08:39 PM (5 weeks ago)
Author:
Paroxysm
Message:

ADDED: New commands.
UNIT :

-GetSelectedGO() - gets the current targeted go through .go select.
-IsInGroup?() - used by players.

GAMEOBJECT:

  • Fixed SpawnGameObject/Creature? functions they should properly spawn and return creature userdata.
  • GetByte?(index,index2) - similar to Object::GetByte?(..) function.
  • SetByte?(index,index2,value) - similar to Object::SetByte?(..)
  • ChangeScale?(float newscale, bool updatenow) - changes the gameobject's scale, updatenow boolean makes it respawn the gameobject.
  • CustomAnimate?(0 or 1) - activates the gameobject's custom animation. 0 turns on, 1 turns off.
Location:
Trunk/src/LuaEngine
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • Trunk/src/LuaEngine/FunctionTables.h

    r1142 r1144  
    8080        { "SetMovementType", &luaUnit::SetMovementType }, 
    8181        { "CastSpell", &luaUnit::CastSpell }, 
    82         { "FullCastSpell", &luaUnit::FullCastSpell }, 
    83         { "FullCastSpellOnTarget", &luaUnit::FullCastSpellOnTarget }, 
    8482        { "SpawnCreature", &luaUnit::SpawnCreature }, 
    8583        { "SpawnGameObject", &luaUnit::SpawnGameObject }, 
     
    128126        { "MoveToWaypoint", &luaUnit::MoveToWaypoint }, 
    129127        { "DestroyCustomWaypointMap", &luaUnit::DestroyCustomWaypointMap }, 
    130         { "SetCombatCapable", &luaUnit::SetCombatCapable }, 
    131         { "SetCombatMeleeCapable", &luaUnit::SetCombatMeleeCapable }, 
    132         { "SetCombatRangedCapable", &luaUnit::SetCombatRangedCapable }, 
    133         { "SetCombatSpellCapable", &luaUnit::SetCombatSpellCapable }, 
    134         { "SetCombatTargetingCapable", &luaUnit::SetCombatTargetingCapable }, 
     128        { "SetCombatCapable", &luaUnit::DisableCombat }, 
     129        { "SetCombatMeleeCapable", &luaUnit::DisableMelee }, 
     130        { "SetCombatRangedCapable", &luaUnit::DisableRanged }, 
     131        { "SetCombatSpellCapable", &luaUnit::DisableSpells }, 
     132        { "SetCombatTargetingCapable", &luaUnit::DisableTargeting }, 
    135133        { "SetNPCFlags", &luaUnit::SetNPCFlags }, 
    136134        { "SetModel", &luaUnit::SetModel }, 
     
    313311        { "ResetAllTalents", &luaUnit::ResetAllTalents }, 
    314312        { "GetAccountName", &luaUnit::GetAccountName }, 
    315 //NA:   { "GetGamemasterLevel", &luaUnit::GetGamemasterLevel }, 
    316313        { "SavePlayer", &luaUnit::SavePlayer }, 
    317314        { "HasQuest", &luaUnit::HasQuest }, 
     
    341338    { "GetNativeDisplay", &luaUnit::GetNativeDisplay }, 
    342339        { "IsMounted", &luaUnit::IsMounted }, 
    343                 //hypersniper added commands 
    344                 { "GetGameTime", &luaUnit::GetGameTime }, 
    345                 { "PlaySoundToPlayer", &luaUnit::PlaySoundToPlayer }, 
    346                 { "GetDuelState", &luaUnit::GetDuelState },  
    347                 { "SetPosition", &luaUnit::SetPosition}, 
    348                 { "CastSpellOnTarget", &luaUnit::CastSpellOnTarget}, 
    349                 { "GetLandHeight", &luaUnit::GetLandHeight}, 
    350                 { "QuestAddStarter", &luaUnit::QuestAddStarter}, 
    351                 { "QuestAddFinisher", &luaUnit::QuestAddFinisher}, 
    352                 { "SetPlayerSpeed", &luaUnit::SetPlayerSpeed}, 
    353                 { "GiveHonor", &luaUnit::GiveHonor}, 
    354                 { "SetBindPoint", &luaUnit::SetBindPoint}, 
    355                 { "SoftDisconnect", &luaUnit::SoftDisconnect}, 
    356                 { "SetZoneWeather", &luaUnit::SetZoneWeather}, 
    357                 { "SetPlayerWeather", &luaUnit::SetPlayerWeather}, 
    358                 { "SendPacketToPlayer", &luaUnit::SendPacketToPlayer}, 
    359                 { "SendPacketToZone", &luaUnit::SendPacketToZone}, 
    360                 { "SendPacketToWorld", &luaUnit::SendPacketToWorld}, 
    361                 { "SendPacketToInstance", &luaUnit::SendPacketToInstance}, 
    362                 { "PlayerSendChatMessage", &luaUnit::PlayerSendChatMessage}, 
    363                 { "GetDistanceYards", &luaUnit::GetDistanceYards}, 
    364                 { "VendorAddItem", &luaUnit::VendorAddItem}, 
    365                 { "VendorRemoveItem", &luaUnit::VendorRemoveItem}, 
    366                 { "VendorRemoveAllItems", &luaUnit::VendorRemoveAllItems}, 
    367                 { "CreatureHasQuest", &luaUnit::CreatureHasQuest}, 
    368                 { "SendVendorWindow", &luaUnit::SendVendorWindow}, 
    369                 { "SendTrainerWindow", &luaUnit::SendTrainerWindow}, 
    370                 { "SendInnkeeperWindow", &luaUnit::SendInnkeeperWindow}, 
    371                 { "SendBankWindow", &luaUnit::SendBankWindow}, 
    372                 { "SendAuctionWindow", &luaUnit::SendAuctionWindow}, 
    373                 { "SendBattlegroundWindow", &luaUnit::SendBattlegroundWindow}, 
    374                 { "GetInventoryItem", &luaUnit::GetInventoryItem}, 
    375                 { "GetInventoryItemById", &luaUnit::GetInventoryItemById}, 
    376                 { "PhaseSet", &luaUnit::PhaseSet}, 
    377                 { "PhaseAdd", &luaUnit::PhaseAdd}, 
    378                 { "PhaseDelete", &luaUnit::PhaseDelete}, 
    379                 { "GetPhase", &luaUnit::GetPhase}, 
    380                 { "AggroWithInRangeFriends", &luaUnit::AggroWithInRangeFriends}, 
    381                 { "GetPrimaryCombatTarget", &luaUnit::GetPrimaryCombatTarget}, 
    382                 { "MoveRandomArea", &luaUnit::MoveRandomArea}, 
    383                 { "SendLootWindow", &luaUnit::SendLootWindow}, 
    384                 { "AddLoot", &luaUnit::AddLoot}, 
    385                 { "SetPacified", &luaUnit::SetPacified}, 
    386                 { "SpawnVehicle", &luaUnit::SpawnVehicle}, 
    387                 { "SetVehicle", &luaUnit::SetVehicle}, 
    388                 { "GetVehicle", &luaUnit::GetVehicle}, 
    389                 { "RemoveFromVehicle", &luaUnit::RemoveFromVehicle}, 
    390                 { "GetVehicleSeat", &luaUnit::GetVehicleSeat}, 
    391                 { "IsVehicle", &luaUnit::IsVehicle}, 
    392                 { "GetPassengerCount", &luaUnit::GetPassengerCount}, 
    393                 { "MoveVehicle", &luaUnit::MoveVehicle}, 
    394                 { "SetPlayerLock", &luaUnit::SetPlayerLock}, 
    395                 //3004 ends here 
    396                 { "GetGroupPlayers", &luaUnit::GetGroupPlayers}, 
    397                 { "IsGm", &luaUnit::IsGm}, 
    398                 { "GetDungeonDifficulty", &luaUnit::GetDungeonDifficulty}, 
    399                 { "GetGroupLeader", &luaUnit::GetGroupLeader}, 
    400                 { "SetGroupLeader", &luaUnit::SetGroupLeader}, 
    401                 { "AddGroupMember", &luaUnit::AddGroupMember}, 
    402                 { "SetDungeonDifficulty", &luaUnit::SetDungeonDifficulty}, 
    403                 { "ExpandToRaid", &luaUnit::ExpandToRaid}, 
    404                 { "SendPacketToGroup", &luaUnit::SendPacketToGroup}, 
    405                 { "IsGroupFull", &luaUnit::IsGroupFull}, 
    406                 //next 9 credit: Alvanaar 
    407                 { "IsGroupedWith", &luaUnit::IsGroupedWith}, 
    408                 { "GetTotalHonor", &luaUnit::GetTotalHonor}, 
    409                 { "GetHonorToday", &luaUnit::GetHonorToday}, 
    410                 { "GetHonorYesterday", &luaUnit::GetHonorYesterday}, 
    411                 { "GetArenaPoints", &luaUnit::GetArenaPoints}, 
    412                 { "AddArenaPoints", &luaUnit::AddArenaPoints}, 
    413                 { "AddLifetimeKills", &luaUnit::AddLifetimeKills}, 
    414                 { "GetGender", &luaUnit::GetGender}, //9 
    415                 { "SetGender", &luaUnit::SetGender}, 
    416                 { "GetGroupType", &luaUnit::GetGroupType}, 
    417                 //next 5: cred alvanaar 
    418                 { "SendPacketToGuild", &luaUnit::SendPacketToGuild }, 
    419                 { "GetGuildId", &luaUnit::GetGuildId }, 
    420                 { "GetGuildRank", &luaUnit::GetGuildRank }, 
    421                 { "SetGuildRank", &luaUnit::SetGuildRank }, 
    422                 { "IsInGuild", &luaUnit::IsInGuild }, //5 
    423                 { "SendGuildInvite", &luaUnit::SendGuildInvite }, 
    424                 { "DemoteGuildMember", &luaUnit::DemoteGuildMember }, 
    425                 { "PromoteGuildMember", &luaUnit::PromoteGuildMember }, 
    426                 { "SetGuildMotd", &luaUnit::SetGuildMotd }, 
    427                 { "GetGuildMotd", &luaUnit::GetGuildMotd }, 
    428                 { "SetGuildInformation", &luaUnit::SetGuildInformation }, 
    429                 { "AddGuildMember", &luaUnit::AddGuildMember }, 
    430                 { "RemoveGuildMember", &luaUnit::RemoveGuildMember }, 
    431                 { "SetPublicNote", &luaUnit::SetPublicNote }, 
    432                 { "SetOfficerNote", &luaUnit::SetOfficerNote }, 
    433                 { "DisbandGuild", &luaUnit::DisbandGuild }, 
    434                 { "ChangeGuildMaster", &luaUnit::ChangeGuildMaster }, 
    435                 { "SendGuildChatMessage", &luaUnit::SendGuildChatMessage }, 
    436                 { "SendGuildLog", &luaUnit::SendGuildLog }, 
    437                 { "GuildBankDepositMoney", &luaUnit::GuildBankDepositMoney }, 
    438                 { "GuildBankWithdrawMoney", &luaUnit::GuildBankWithdrawMoney }, 
    439                 { "GetInstanceOwner", &luaUnit::GetInstanceOwner }, 
    440                 { "GetGmRank", &luaUnit::GetGmRank }, 
    441                 { "SetByteValue", &luaUnit::SetByteValue }, 
    442                 { "GetByteValue", &luaUnit::GetByteValue }, 
    443                 { "IsPvPFlagged", &luaUnit::IsPvPFlagged }, 
    444                 { "IsFFAPvPFlagged", &luaUnit::IsFFAPvPFlagged }, 
    445                 { "GetGuildLeader", &luaUnit::GetGuildLeader }, 
    446                 { "GetGuildMemberCount", &luaUnit::GetGuildMemberCount }, 
    447                 { "CanAttack", &luaUnit::CanAttack }, 
    448                 { "GetInRangeUnits", &luaUnit::GetInRangeUnits }, 
    449                 { "GetInRangeEnemies", &luaUnit::GetInRangeEnemies }, 
    450                 { "IsFriendly", &luaUnit::IsFriendly }, 
    451                 { "MovePlayerTo", &luaUnit::MovePlayerTo }, 
    452                 // next 15 - Alvanaar 
    453                 //{ "IsInChannel", &luaUnit::IsInChannel }, 
    454                 //{ "JoinChannel", &luaUnit::JoinChannel }, 
    455                 //{ "LeaveChannel", &luaUnit::LeaveChannel }, 
    456                 //{ "SetChannelOwner", &luaUnit::SetChannelOwner }, 
    457                 //{ "GetChannelOwner", &luaUnit::GetChannelOwner }, 
    458                 //{ "SendPacketToChannel", &luaUnit::SendPacketToChannel }, 
    459                 //{ "SetChannelName", &luaUnit::SetChannelName }, 
    460                 //{ "SetChannelPassword", &luaUnit::SetChannelPassword }, 
    461                 //{ "GetChannelPassword", &luaUnit::GetChannelPassword }, 
    462                 //{ "GetChannelOwner", &luaUnit::GetChannelOwner }, 
    463                 //{ "KickFromChannel", &luaUnit::KickFromChannel }, 
    464                 //{ "BanFromChannel", &luaUnit::BanFromChannel }, 
    465                 //{ "UnbanFromChannel", &luaUnit::UnbanFromChannel }, 
    466                 //{ "GetChannelMemberCount", &luaUnit::GetChannelMemberCount }, 
    467                 //{ "GetChannelMembers", &luaUnit::GetChannelMembers }, 
    468                 { "GetPlayerMovementVector", &luaUnit::GetPlayerMovementVector}, 
    469                 { "UnsetKnownTitle", &luaUnit::UnsetKnownTitle}, 
    470                 { "IsInPhase", &luaUnit::IsInPhase}, 
    471                 { "HasFlag", &luaUnit::HasFlag }, 
    472                 { "Repop", &luaUnit::Repop }, 
    473                 { "SetMovementFlags", &luaUnit::SetMovementFlags }, 
    474                 { "GetSpawnId", &luaUnit::GetSpawnId }, 
    475                 { "ResetTalents", &luaUnit::ResetTalents }, 
    476                 { "SetTalentPoints", &luaUnit::SetTalentPoints }, 
    477                 { "GetTalentPoints", &luaUnit::GetTalentPoints }, 
    478                 { "EventChat", &luaUnit::EventChat }, 
    479                 { "GetEquippedItemBySlot", &luaUnit::GetEquippedItemBySlot }, 
    480                 { "GetGuildMembers", &luaUnit::GetGuildMembers }, 
    481                 { "AddAchievement", &luaUnit::AddAchievement }, 
    482                 { "RemoveAchievement", &luaUnit::RemoveAchievement }, 
    483                 { "HasAchievement", &luaUnit::HasAchievement }, 
    484                 { "RemoveArenaPoints", &luaUnit::RemoveArenaPoints}, 
    485                 { "TakeHonor", &luaUnit::TakeHonor}, 
    486                 { "SetPhase", &luaUnit::PhaseSet}, 
    487                 { "DeletePhase", &luaUnit::PhaseDelete}, 
    488                 { "AddToPhase", &luaUnit::PhaseAdd}, 
    489                 { "GetAreaId", &luaUnit::GetAreaId}, 
    490                 { "ResetPetTalents", &luaUnit::ResetPetTalents}, 
    491                 { "IsDazed", &luaUnit::IsDazed }, 
    492                 { "GetAura", &luaUnit::GetAura }, 
    493                 { "IsRooted", &luaUnit::IsRooted }, 
    494                 { "HasAuraWithMechanic", &luaUnit::HasAuraWithMechanic }, 
    495                 { "HasNegativeAura", &luaUnit::HasNegativeAura }, 
    496                 { "HasPositiveAura", &luaUnit::HasPositiveAura }, 
    497                 { "SetActionBar", &luaUnit::SetActionBar }, 
    498                 { "GetClosestEnemy", &luaUnit::GetClosestEnemy }, 
    499                 { "GetClosestFriend", &luaUnit::GetClosestFriend }, 
    500                 { "IsOnTaxi", &luaUnit::IsOnTaxi }, 
    501                 { "GetTaxi", &luaUnit::GetTaxi }, 
    502                 { "GetObjectType", &luaUnit::GetObjectType }, 
    503                 { "CreateCustomWaypoint", &luaUnit::CreateCustomWaypoint }, 
    504                 { "DeleteWaypoints", &luaUnit::DeleteAllWaypoints }, 
    505                 { "GiveXp", &luaUnit::GiveXp }, 
    506                 { "GetPower", &luaUnit::GetPower }, 
    507                 { "GetPowerPct", &luaUnit::GetPowerPct }, 
    508                 { "GetMaxPower", &luaUnit::GetMaxPower }, 
    509                 { "SetPower", &luaUnit::SetPower }, 
    510                 { "SetPowerPct", &luaUnit::SetPowerPct }, 
    511                 { "SetMaxPower", &luaUnit::SetMaxPower }, 
    512                 { "LearnSpells", &luaUnit::LearnSpells }, 
    513                 { NULL, NULL }, 
     340        //hypersniper added commands 
     341        { "GetGameTime", &luaUnit::GetGameTime }, 
     342        { "PlaySoundToPlayer", &luaUnit::PlaySoundToPlayer }, 
     343        { "GetDuelState", &luaUnit::GetDuelState },  
     344        { "SetPosition", &luaUnit::SetPosition}, 
     345        { "CastSpellOnTarget", &luaUnit::CastSpellOnTarget}, 
     346        { "GetLandHeight", &luaUnit::GetLandHeight}, 
     347        { "QuestAddStarter", &luaUnit::QuestAddStarter}, 
     348        { "QuestAddFinisher", &luaUnit::QuestAddFinisher}, 
     349        { "SetPlayerSpeed", &luaUnit::SetPlayerSpeed}, 
     350        { "GiveHonor", &luaUnit::GiveHonor}, 
     351        { "SetBindPoint", &luaUnit::SetBindPoint}, 
     352        { "SoftDisconnect", &luaUnit::SoftDisconnect}, 
     353        { "SetZoneWeather", &luaUnit::SetZoneWeather}, 
     354        { "SetPlayerWeather", &luaUnit::SetPlayerWeather}, 
     355        { "SendPacketToPlayer", &luaUnit::SendPacketToPlayer}, 
     356        { "SendPacketToZone", &luaUnit::SendPacketToZone}, 
     357        { "SendPacketToWorld", &luaUnit::SendPacketToWorld}, 
     358        { "SendPacketToInstance", &luaUnit::SendPacketToInstance}, 
     359        { "PlayerSendChatMessage", &luaUnit::PlayerSendChatMessage}, 
     360        { "GetDistanceYards", &luaUnit::GetDistanceYards}, 
     361        { "VendorAddItem", &luaUnit::VendorAddItem}, 
     362        { "VendorRemoveItem", &luaUnit::VendorRemoveItem}, 
     363        { "VendorRemoveAllItems", &luaUnit::VendorRemoveAllItems}, 
     364        { "CreatureHasQuest", &luaUnit::CreatureHasQuest}, 
     365        { "SendVendorWindow", &luaUnit::SendVendorWindow}, 
     366        { "SendTrainerWindow", &luaUnit::SendTrainerWindow}, 
     367        { "SendInnkeeperWindow", &luaUnit::SendInnkeeperWindow}, 
     368        { "SendBankWindow", &luaUnit::SendBankWindow}, 
     369        { "SendAuctionWindow", &luaUnit::SendAuctionWindow}, 
     370        { "SendBattlegroundWindow", &luaUnit::SendBattlegroundWindow}, 
     371        { "GetInventoryItem", &luaUnit::GetInventoryItem}, 
     372        { "GetInventoryItemById", &luaUnit::GetInventoryItemById}, 
     373        { "PhaseSet", &luaUnit::PhaseSet}, 
     374        { "PhaseAdd", &luaUnit::PhaseAdd}, 
     375        { "PhaseDelete", &luaUnit::PhaseDelete}, 
     376        { "GetPhase", &luaUnit::GetPhase}, 
     377        { "AggroWithInRangeFriends", &luaUnit::AggroWithInRangeFriends}, 
     378        { "GetPrimaryCombatTarget", &luaUnit::GetPrimaryCombatTarget}, 
     379        { "MoveRandomArea", &luaUnit::MoveRandomArea}, 
     380        { "SendLootWindow", &luaUnit::SendLootWindow}, 
     381        { "AddLoot", &luaUnit::AddLoot}, 
     382        { "SetPacified", &luaUnit::SetPacified}, 
     383        { "SpawnVehicle", &luaUnit::SpawnVehicle}, 
     384        { "SetVehicle", &luaUnit::SetVehicle}, 
     385        { "GetVehicle", &luaUnit::GetVehicle}, 
     386        { "RemoveFromVehicle", &luaUnit::RemoveFromVehicle}, 
     387        { "GetVehicleSeat", &luaUnit::GetVehicleSeat}, 
     388        { "IsVehicle", &luaUnit::IsVehicle}, 
     389        { "GetPassengerCount", &luaUnit::GetPassengerCount}, 
     390        { "MoveVehicle", &luaUnit::MoveVehicle}, 
     391        { "SetPlayerLock", &luaUnit::SetPlayerLock}, 
     392        //3004 ends here 
     393        { "GetGroupPlayers", &luaUnit::GetGroupPlayers}, 
     394        { "IsGm", &luaUnit::IsGm}, 
     395        { "GetDungeonDifficulty", &luaUnit::GetDungeonDifficulty}, 
     396        { "GetGroupLeader", &luaUnit::GetGroupLeader}, 
     397        { "SetGroupLeader", &luaUnit::SetGroupLeader}, 
     398        { "AddGroupMember", &luaUnit::AddGroupMember}, 
     399        { "SetDungeonDifficulty", &luaUnit::SetDungeonDifficulty}, 
     400        { "ExpandToRaid", &luaUnit::ExpandToRaid}, 
     401        { "SendPacketToGroup", &luaUnit::SendPacketToGroup}, 
     402        { "IsGroupFull", &luaUnit::IsGroupFull}, 
     403        //next 9 credit: Alvanaar 
     404        { "IsGroupedWith", &luaUnit::IsGroupedWith}, 
     405        { "GetTotalHonor", &luaUnit::GetTotalHonor}, 
     406        { "GetHonorToday", &luaUnit::GetHonorToday}, 
     407        { "GetHonorYesterday", &luaUnit::GetHonorYesterday}, 
     408        { "GetArenaPoints", &luaUnit::GetArenaPoints}, 
     409        { "AddArenaPoints", &luaUnit::AddArenaPoints}, 
     410        { "AddLifetimeKills", &luaUnit::AddLifetimeKills}, 
     411        { "GetGender", &luaUnit::GetGender}, //9 
     412        { "SetGender", &luaUnit::SetGender}, 
     413        { "GetGroupType", &luaUnit::GetGroupType}, 
     414        //next 5: cred alvanaar 
     415        { "SendPacketToGuild", &luaUnit::SendPacketToGuild }, 
     416        { "GetGuildId", &luaUnit::GetGuildId }, 
     417        { "GetGuildRank", &luaUnit::GetGuildRank }, 
     418        { "SetGuildRank", &luaUnit::SetGuildRank }, 
     419        { "IsInGuild", &luaUnit::IsInGuild }, //5 
     420        { "SendGuildInvite", &luaUnit::SendGuildInvite }, 
     421        { "DemoteGuildMember", &luaUnit::DemoteGuildMember }, 
     422        { "PromoteGuildMember", &luaUnit::PromoteGuildMember }, 
     423        { "SetGuildMotd", &luaUnit::SetGuildMotd }, 
     424        { "GetGuildMotd", &luaUnit::GetGuildMotd }, 
     425        { "SetGuildInformation", &luaUnit::SetGuildInformation }, 
     426        { "AddGuildMember", &luaUnit::AddGuildMember }, 
     427        { "RemoveGuildMember", &luaUnit::RemoveGuildMember }, 
     428        { "SetPublicNote", &luaUnit::SetPublicNote }, 
     429        { "SetOfficerNote", &luaUnit::SetOfficerNote }, 
     430        { "DisbandGuild", &luaUnit::DisbandGuild }, 
     431        { "ChangeGuildMaster", &luaUnit::ChangeGuildMaster }, 
     432        { "SendGuildChatMessage", &luaUnit::SendGuildChatMessage }, 
     433        { "SendGuildLog", &luaUnit::SendGuildLog }, 
     434        { "GuildBankDepositMoney", &luaUnit::GuildBankDepositMoney }, 
     435        { "GuildBankWithdrawMoney", &luaUnit::GuildBankWithdrawMoney }, 
     436        { "GetInstanceOwner", &luaUnit::GetInstanceOwner }, 
     437        { "GetGmRank", &luaUnit::GetGmRank }, 
     438        { "SetByteValue", &luaUnit::SetByteValue }, 
     439        { "GetByteValue", &luaUnit::GetByteValue }, 
     440        { "IsPvPFlagged", &luaUnit::IsPvPFlagged }, 
     441        { "IsFFAPvPFlagged", &luaUnit::IsFFAPvPFlagged }, 
     442        { "GetGuildLeader", &luaUnit::GetGuildLeader }, 
     443        { "GetGuildMemberCount", &luaUnit::GetGuildMemberCount }, 
     444        { "CanAttack", &luaUnit::CanAttack }, 
     445        { "GetInRangeUnits", &luaUnit::GetInRangeUnits }, 
     446        { "GetInRangeEnemies", &luaUnit::GetInRangeEnemies }, 
     447        { "IsFriendly", &luaUnit::IsFriendly }, 
     448        { "MovePlayerTo", &luaUnit::MovePlayerTo }, 
     449        // next 15 - Alvanaar 
     450        //{ "IsInChannel", &luaUnit::IsInChannel }, 
     451        //{ "JoinChannel", &luaUnit::JoinChannel }, 
     452        //{ "LeaveChannel", &luaUnit::LeaveChannel }, 
     453        //{ "SetChannelOwner", &luaUnit::SetChannelOwner }, 
     454        //{ "GetChannelOwner", &luaUnit::GetChannelOwner }, 
     455        //{ "SendPacketToChannel", &luaUnit::SendPacketToChannel }, 
     456        //{ "SetChannelName", &luaUnit::SetChannelName }, 
     457        //{ "SetChannelPassword", &luaUnit::SetChannelPassword }, 
     458        //{ "GetChannelPassword", &luaUnit::GetChannelPassword }, 
     459        //{ "GetChannelOwner", &luaUnit::GetChannelOwner }, 
     460        //{ "KickFromChannel", &luaUnit::KickFromChannel }, 
     461        //{ "BanFromChannel", &luaUnit::BanFromChannel }, 
     462        //{ "UnbanFromChannel", &luaUnit::UnbanFromChannel }, 
     463        //{ "GetChannelMemberCount", &luaUnit::GetChannelMemberCount }, 
     464        //{ "GetChannelMembers", &luaUnit::GetChannelMembers }, 
     465        { "GetPlayerMovementVector", &luaUnit::GetPlayerMovementVector}, 
     466        { "UnsetKnownTitle", &luaUnit::UnsetKnownTitle}, 
     467        { "IsInPhase", &luaUnit::IsInPhase}, 
     468        { "HasFlag", &luaUnit::HasFlag }, 
     469        { "Repop", &luaUnit::Repop }, 
     470        { "SetMovementFlags", &luaUnit::SetMovementFlags }, 
     471        { "GetSpawnId", &luaUnit::GetSpawnId }, 
     472        { "ResetTalents", &luaUnit::ResetTalents }, 
     473        { "SetTalentPoints", &luaUnit::SetTalentPoints }, 
     474        { "GetTalentPoints", &luaUnit::GetTalentPoints }, 
     475        { "EventChat", &luaUnit::EventChat }, 
     476        { "GetEquippedItemBySlot", &luaUnit::GetEquippedItemBySlot }, 
     477        { "GetGuildMembers", &luaUnit::GetGuildMembers }, 
     478        //{ "AddAchievement", &luaUnit::AddAchievement }, 
     479        //{ "RemoveAchievement", &luaUnit::RemoveAchievement }, 
     480        //{ "HasAchievement", &luaUnit::HasAchievement }, 
     481        { "RemoveArenaPoints", &luaUnit::RemoveArenaPoints}, 
     482        { "TakeHonor", &luaUnit::TakeHonor}, 
     483        { "SetPhase", &luaUnit::PhaseSet}, 
     484        { "DeletePhase", &luaUnit::PhaseDelete}, 
     485        { "AddToPhase", &luaUnit::PhaseAdd}, 
     486        { "GetAreaId", &luaUnit::GetAreaId}, 
     487        { "ResetPetTalents", &luaUnit::ResetPetTalents}, 
     488        { "IsDazed", &luaUnit::IsDazed }, 
     489        { "GetAura", &luaUnit::GetAura }, 
     490        { "IsRooted", &luaUnit::IsRooted }, 
     491        { "HasAuraWithMechanic", &luaUnit::HasAuraWithMechanic }, 
     492        { "HasNegativeAura", &luaUnit::HasNegativeAura }, 
     493        { "HasPositiveAura", &luaUnit::HasPositiveAura }, 
     494        { "SetActionBar", &luaUnit::SetActionBar }, 
     495        { "GetClosestEnemy", &luaUnit::GetClosestEnemy }, 
     496        { "GetClosestFriend", &luaUnit::GetClosestFriend }, 
     497        { "IsOnTaxi", &luaUnit::IsOnTaxi }, 
     498        { "GetTaxi", &luaUnit::GetTaxi }, 
     499        { "GetObjectType", &luaUnit::GetObjectType }, 
     500        { "CreateCustomWaypoint", &luaUnit::CreateCustomWaypoint }, 
     501        { "DeleteWaypoints", &luaUnit::DeleteAllWaypoints }, 
     502        { "GiveXp", &luaUnit::GiveXp }, 
     503        { "GetPower", &luaUnit::GetPower }, 
     504        { "GetPowerPct", &luaUnit::GetPowerPct }, 
     505        { "GetMaxPower", &luaUnit::GetMaxPower }, 
     506        { "SetPower", &luaUnit::SetPower }, 
     507        { "SetPowerPct", &luaUnit::SetPowerPct }, 
     508        { "SetMaxPower", &luaUnit::SetMaxPower }, 
     509        { "LearnSpells", &luaUnit::LearnSpells }, 
     510        { "GetCurrentWaypoint", &luaUnit::GetCurrentWaypoint }, 
     511        { "GetSelectedGO", &luaUnit::GetSelectedGO }, 
     512        { "FullCastSpell", &luaUnit::FullCastSpell }, 
     513        { "FullCastSpellOnTarget", &luaUnit::FullCastSpellOnTarget }, 
     514        { "DisableMelee", &luaUnit::DisableMelee }, 
     515        { "DisableRanged", &luaUnit::DisableRanged }, 
     516        { "DisableSpells", &luaUnit::DisableSpells }, 
     517        { "DisableCombat", &luaUnit::DisableCombat }, 
     518        { "DisableTargeting", &luaUnit::DisableTargeting }, 
     519        { "IsInGroup", &luaUnit::IsInGroup }, 
     520        { NULL, NULL }, 
    514521}; 
    515  
    516  
    517  
    518522 
    519523RegType<GameObject> GOMethods[] = { 
     
    556560        { "ModUInt32Value", &luaGameObject::ModUInt32Value }, 
    557561        { "CastSpell", &luaGameObject::CastSpell }, 
    558         { "FullCastSpell", &luaGameObject::FullCastSpell }, 
    559562        { "CastSpellOnTarget", &luaGameObject::CastSpellOnTarget }, 
    560         { "FullCastSpellOnTarget", &luaGameObject::FullCastSpellOnTarget }, 
    561563        { "GossipObjectCreateMenu", &luaGameObject::GossipCreateMenu }, 
    562564        { "GossipObjectMenuAddItem", &luaGameObject::GossipMenuAddItem },  
     
    564566        { "GossipObjectComplete", &luaGameObject::GossipComplete }, 
    565567        { "GossipObjectSendPOI", &luaGameObject::GossipSendPOI }, 
    566         //{ "EventCastSpell", &luaGameObject::EventCastSpell }, 
    567568        { "RegisterAIUpdateEvent", &luaGameObject::RegisterAIUpdate }, 
    568569        { "ModifyAIUpdateEvent", &luaGameObject::ModAIUpdate }, 
     
    577578        { "DespawnObject", &luaGameObject::DespawnObject }, 
    578579        //hypersniper's 
    579                 { "GetGameTime", &luaGameObject::GetGameTime }, 
    580                 { "GetLandHeight", &luaGameObject::GetLandHeight}, 
    581                 { "SetZoneWeather", &luaGameObject::SetZoneWeather}, 
    582                 { "PhaseSet", &luaGameObject::PhaseSet}, 
    583                 { "PhaseAdd", &luaGameObject::PhaseAdd}, 
    584                 { "PhaseDelete", &luaGameObject::PhaseDelete}, 
    585                 { "GetPhase", &luaGameObject::GetPhase}, 
     580        { "GetGameTime", &luaGameObject::GetGameTime }, 
     581        { "GetLandHeight", &luaGameObject::GetLandHeight}, 
     582        { "SetZoneWeather", &luaGameObject::SetZoneWeather}, 
     583        { "PhaseSet", &luaGameObject::PhaseSet}, 
     584        { "PhaseAdd", &luaGameObject::PhaseAdd}, 
     585        { "PhaseDelete", &luaGameObject::PhaseDelete}, 
     586        { "GetPhase", &luaGameObject::GetPhase}, 
    586587        { "SendPacket", luaGameObject::SendPacket }, 
    587                 { "SendPacketToZone", &luaGameObject::SendPacketToZone}, 
    588                 { "SendPacketToWorld", &luaGameObject::SendPacketToWorld}, 
    589                 { "SendPacketToInstance", &luaGameObject::SendPacketToInstance}, 
    590                 { "AddLoot", &luaGameObject::AddLoot}, 
    591                 //3004 ends here 
    592                 { "Update", &luaGameObject::Update}, //sadikum 
    593                 { "GetInstanceOwner", &luaGameObject::GetInstanceOwner }, 
    594                 { "GetDungeonDifficulty", &luaGameObject::GetDungeonDifficulty }, 
    595                 { "SetDungeonDifficulty", &luaGameObject::SetDungeonDifficulty }, 
    596                 { "SetByteValue", &luaGameObject::SetByteValue }, 
    597                 { "GetByteValue", &luaGameObject::GetByteValue }, 
    598                 { "HasFlag", &luaGameObject::HasFlag }, 
    599                 { "IsInPhase", &luaGameObject::IsInPhase}, 
    600                 { "SetPhase", &luaGameObject::PhaseSet}, 
    601                 { "DeletePhase", &luaGameObject::PhaseDelete}, 
    602                 { "AddToPhase", &luaGameObject::PhaseAdd}, 
     588        { "SendPacketToZone", &luaGameObject::SendPacketToZone}, 
     589        { "SendPacketToWorld", &luaGameObject::SendPacketToWorld}, 
     590        { "SendPacketToInstance", &luaGameObject::SendPacketToInstance}, 
     591        { "AddLoot", &luaGameObject::AddLoot}, 
     592        //3004 ends here 
     593        { "Update", &luaGameObject::Update}, //sadikum 
     594        { "GetInstanceOwner", &luaGameObject::GetInstanceOwner }, 
     595        { "GetDungeonDifficulty", &luaGameObject::GetDungeonDifficulty }, 
     596        { "SetDungeonDifficulty", &luaGameObject::SetDungeonDifficulty }, 
     597        { "HasFlag", &luaGameObject::HasFlag }, 
     598        { "IsInPhase", &luaGameObject::IsInPhase}, 
     599        { "SetPhase", &luaGameObject::PhaseSet}, 
     600        { "DeletePhase", &luaGameObject::PhaseDelete}, 
     601        { "AddToPhase", &luaGameObject::PhaseAdd}, 
    603602        { "GetAreaId", &luaGameObject::GetAreaId}, 
    604603        { "SetPosition", &luaGameObject::SetPosition}, 
     
    608607        { "GetDistanceYards", &luaGameObject::GetDistanceYards }, 
    609608        { "GetSpawnId", &luaGameObject::GetSpawnId }, 
     609        { "ChangeScale", &luaGameObject::ChangeScale }, 
     610        { "GetByte", &luaGameObject::GetByte }, 
     611        { "GetByteValue", &luaGameObject::GetByte }, 
     612        { "SetByte", &luaGameObject::SetByte }, 
     613        { "SetByteValue", &luaGameObject::SetByte }, 
     614        { "FullCastSpell", &luaGameObject::FullCastSpell }, 
     615        { "FullCastSpellOnTarget", &luaGameObject::FullCastSpellOnTarget }, 
     616        { "CustomAnimate", &luaGameObject::CustomAnimate }, 
    610617        { NULL, NULL }, 
    611618}; 
  • Trunk/src/LuaEngine/GameobjectFunctions.h

    r1136 r1144  
    261261        int SpawnCreature(lua_State * L, GameObject * ptr) 
    262262        { 
    263                 if (ptr == NULL) return 0; 
    264                 uint32 entry_id = luaL_checkint(L, 1); 
    265                 float x = CHECK_FLOAT(L, 2); 
    266                 float y = CHECK_FLOAT(L, 3); 
    267                 float z = CHECK_FLOAT(L, 4); 
    268                 float o = CHECK_FLOAT(L, 5); 
    269                 uint32 faction = luaL_checkint(L, 6); 
    270                 uint32 duration = luaL_checkint(L, 7); 
    271  
    272                 if (!entry_id || !faction) //Shady: is it really required? 
    273                 { 
    274                         lua_pushnil(L); 
    275                         return 1; 
    276                 } 
    277                 CreatureProto *p = CreatureProtoStorage.LookupEntry(entry_id); 
    278              
    279                 if (p == NULL) 
    280                   return 0; 
    281  
    282                 Creature *pCreature = ptr->GetMapMgr()->CreateCreature(entry_id); 
    283                 if(pCreature == NULL) 
    284                 { 
    285                         lua_pushnil(L); 
    286                         return 1; 
    287                 } 
    288                 pCreature->spawnid = 0; 
    289                 pCreature->m_spawn = 0; 
    290                 pCreature->Load(p,x,y,z); 
    291                 if (faction) 
    292                         pCreature->SetFaction(faction); 
    293                 pCreature->_setFaction(); 
    294                 pCreature->SetMapId(ptr->GetMapId()); 
    295                 pCreature->SetOrientation(o); 
    296                 pCreature->Despawn(duration, 0); 
    297                 pCreature->SetInstanceID(ptr->GetInstanceID()); 
    298                 pCreature->PushToWorld(ptr->GetMapMgr()); 
    299                 if (duration) 
    300                 { 
    301                         pCreature->Despawn(duration,0); 
    302                 } 
    303                 PUSH_UNIT(L,pCreature); 
    304                 return 1; 
    305         } 
    306  
    307         int SpawnGameObject(lua_State * L, GameObject * ptr) 
    308         { 
    309                 if (ptr == NULL) return 0; 
     263                CHECK_TYPEID_RETNIL(TYPEID_GAMEOBJECT); 
    310264                uint32 entry_id = CHECK_ULONG(L,1); 
    311265                float x = CHECK_FLOAT(L, 2); 
     
    313267                float z = CHECK_FLOAT(L, 4); 
    314268                float o = CHECK_FLOAT(L, 5); 
    315                 uint32 duration = luaL_checkint(L, 6); 
    316                 float scale = (float)luaL_optnumber(L,7,1.0f); 
    317                 if (!entry_id || !duration) 
     269                uint32 faction = CHECK_ULONG(L,6); 
     270                uint32 duration = CHECK_ULONG(L,7); 
     271                uint32 equip1 = luaL_optint(L, 8, 1); 
     272                uint32 equip2 = luaL_optint(L, 9, 1); 
     273                uint32 equip3 = luaL_optint(L, 10, 1); 
     274                uint32 phase = luaL_optint(L, 11, ptr->m_phase);  
     275                bool save = luaL_optint(L, 12, 0) ? true : false;  
     276 
     277                if(!entry_id) 
    318278                { 
    319279                        lua_pushnil(L); 
    320280                        return 1; 
    321281                } 
    322  
    323                 GameObjectInfo *goi = GameObjectNameStorage.LookupEntry(entry_id); 
    324                 if (goi == NULL) 
    325                 { 
    326                         dropWarning("Invalid GameObject ID specified: %u", entry_id); 
    327                         lua_error(L); 
    328                         return 0; 
    329                 } 
    330                 GameObject *pC = ptr->GetMapMgr()->CreateGameObject(entry_id); 
    331                 if(pC == NULL) 
     282                CreatureProto *p = CreatureProtoStorage.LookupEntry(entry_id); 
     283             
     284                if(p == NULL)  
    332285                { 
    333286                        lua_pushnil(L); 
    334287                        return 1; 
    335288                } 
    336                 pC->m_spawn=0; 
    337                 pC->CreateFromProto(entry_id, ptr->GetMapId(), (float)x, (float)y, (float)z, (float)o); 
    338                 pC->SetMapId(ptr->GetMapId()); 
    339                 pC->SetInstanceID(ptr->GetInstanceID()); 
    340                 pC->SetFloatValue(OBJECT_FIELD_SCALE_X, scale); 
    341                 pC->Spawn(ptr->GetMapMgr()); 
    342                 if(duration) 
    343                 { 
    344                         sEventMgr.AddEvent(pC, &GameObject::ExpireAndDelete, EVENT_GAMEOBJECT_UPDATE, duration, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); 
    345                 } 
    346                 PUSH_GO(L,pC); 
     289                Creature * pCreature = ptr->GetMapMgr()->GetInterface()->SpawnCreature(entry_id,x,y,z,o,true,true,0,0,phase); 
     290                if(pCreature == NULL) 
     291                { 
     292                        lua_pushnil(L); 
     293                        return 1; 
     294                } 
     295                if(faction) 
     296                { 
     297                        pCreature->SetFaction(faction); 
     298                        pCreature->_setFaction(); 
     299                } 
     300                pCreature->SetInstanceID(ptr->GetInstanceID()); 
     301                pCreature->SetMapId(ptr->GetMapId()); 
     302                pCreature->SetEquippedItem(MELEE,equip1); 
     303                pCreature->SetEquippedItem(OFFHAND,equip2); 
     304                pCreature->SetEquippedItem(RANGED,equip3); 
     305                if (duration) 
     306                        pCreature->Despawn(duration,0); 
     307                if (save) 
     308                        pCreature->SaveToDB(); 
     309                PUSH_UNIT(L,pCreature); 
     310                return 1; 
     311        } 
     312 
     313        int SpawnGameObject(lua_State * L, GameObject * ptr) 
     314        { 
     315                CHECK_TYPEID_RETNIL(TYPEID_GAMEOBJECT); 
     316                uint32 entry_id = CHECK_ULONG(L,1); 
     317                float x = CHECK_FLOAT(L, 2); 
     318                float y = CHECK_FLOAT(L, 3); 
     319                float z = CHECK_FLOAT(L, 4); 
     320                float o = CHECK_FLOAT(L, 5); 
     321                uint32 duration = CHECK_ULONG(L, 6); 
     322                float scale = (float)(luaL_optint(L, 7, 100)/100);  
     323                uint32 phase = luaL_optint(L, 8, ptr->m_phase); 
     324                bool save = luaL_optint(L, 9, 0) ? true : false;  
     325                if (entry_id) 
     326                { 
     327                        GameObject* pC = ptr->GetMapMgr()->GetInterface()->SpawnGameObject(entry_id,x,y,z,o,false,0,0,phase); 
     328                        if(pC == NULL) 
     329                        { 
     330                                lua_pushnil(L); 
     331                                return 1; 
     332                        } 
     333                        pC->SetInstanceID(ptr->GetInstanceID()); 
     334                        pC->SetMapId(ptr->GetMapId()); 
     335                        pC->SetFloatValue(OBJECT_FIELD_SCALE_X, scale);   
     336                        pC->Spawn(ptr->GetMapMgr()); 
     337                        if (duration) 
     338                                sEventMgr.AddEvent(pC,&GameObject::ExpireAndDelete,EVENT_GAMEOBJECT_UPDATE,duration,1,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); 
     339                        if (save) 
     340                                pC->SaveToDB(); 
     341                        PUSH_GO(L,pC); 
     342                } 
     343                else 
     344                        lua_pushnil(L); 
    347345                return 1; 
    348346        } 
     
    350348        int GetSpawnX(lua_State * L, GameObject * ptr) 
    351349        { 
    352                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     350                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    353351                lua_pushnumber(L,ptr->GetSpawnX()); 
    354352                return 1; 
     
    357355        int GetSpawnY(lua_State * L, GameObject * ptr) 
    358356        { 
    359                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     357                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    360358                lua_pushnumber(L,ptr->GetSpawnY()); 
    361359                return 1; 
     
    364362        int GetSpawnZ(lua_State * L, GameObject * ptr) 
    365363        { 
    366                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     364                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    367365                lua_pushnumber(L,ptr->GetSpawnZ()); 
    368366                return 1; 
     
    371369        int GetSpawnO(lua_State * L, GameObject * ptr) 
    372370        { 
    373                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     371                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    374372                lua_pushnumber(L,ptr->GetSpawnO()); 
    375373                return 1; 
     
    378376        int GetX(lua_State * L, GameObject * ptr) 
    379377        { 
    380                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     378                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    381379                lua_pushnumber(L,ptr->GetPositionX()); 
    382380                return 1; 
     
    385383        int GetY(lua_State * L, GameObject * ptr) 
    386384        { 
    387                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     385                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    388386                lua_pushnumber(L,ptr->GetPositionY()); 
    389387                return 1; 
     
    392390        int GetZ(lua_State * L, GameObject * ptr) 
    393391        { 
    394                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);if(ptr) 
     392                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);if(ptr) 
    395393                lua_pushnumber(L,ptr->GetPositionZ()); 
    396394                return 1; 
     
    399397        int GetO(lua_State * L, GameObject * ptr) 
    400398        { 
    401                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     399                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    402400                lua_pushnumber(L,ptr->GetOrientation()); 
    403401                return 1; 
     
    406404        int GetInRangePlayersCount(lua_State * L, GameObject * ptr) 
    407405        { 
    408                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     406                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    409407                lua_pushnumber(L,ptr->GetInRangePlayersCount()); 
    410408                return 1; 
     
    413411        int GetEntry(lua_State * L, GameObject * ptr) 
    414412        { 
    415                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     413                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    416414                lua_pushnumber(L,ptr->GetEntry()); 
    417415                return 1; 
     
    600598                CHECK_TYPEID(TYPEID_GAMEOBJECT); 
    601599                uint32 sp = CHECK_ULONG(L,1); 
    602                 if (!sp) return 0; 
    603                 Spell * spp = new Spell(ptr,dbcSpell.LookupEntry(sp),true,NULL); 
    604                 SpellCastTargets tar(ptr->GetGUID()); 
    605                 spp->prepare(&tar); 
    606                 return 0; 
    607         } 
    608  
    609         int FullCastSpell(lua_State * L, GameObject * ptr) 
    610         { 
    611                 CHECK_TYPEID(TYPEID_GAMEOBJECT); 
    612                 uint32 sp = CHECK_ULONG(L,1); 
    613                 if (!sp) return 0; 
    614                 Spell * spp = new Spell(ptr,dbcSpell.LookupEntry(sp),false,NULL); 
    615                 SpellCastTargets tar(ptr->GetGUID()); 
    616                 spp->prepare(&tar); 
    617                 return 0; 
    618         } 
    619  
     600                if(sp) 
     601                { 
     602                        Spell * tSpell = new Spell(ptr,dbcSpell.LookupEntry(sp),true,NULL); 
     603                        SpellCastTargets tar(ptr->GetGUID()); 
     604                        tSpell->prepare(&tar); 
     605                } 
     606                return 0; 
     607        } 
    620608        int CastSpellOnTarget(lua_State * L, GameObject * ptr) 
    621609        { 
     
    623611                uint32 sp = CHECK_ULONG(L,1); 
    624612                Unit * target = CHECK_UNIT(L,2); 
    625                 if (!sp || target==NULL) return 0; 
    626                 Spell * spp = new Spell(ptr,dbcSpell.LookupEntry(sp),true,NULL); 
    627                 spp->m_targets.m_unitTarget = target->GetGUID(); 
    628                 //prepare digest 
    629                 SpellCastTargets tar(target->GetGUID()); 
    630                 spp->m_targets = tar; 
    631                 spp->SendSpellStart(); 
    632                 spp->cast(false); 
     613                if(sp && target != NULL) 
     614                { 
     615                        Spell * tSpell = new Spell(ptr,dbcSpell.LookupEntry(sp),true,NULL); 
     616                        SpellCastTargets sp(target->GetGUID()); 
     617                        tSpell->prepare(&sp); 
     618                } 
    633619                return 0; 
    634620        } 
     
    827813                return 0; 
    828814        } 
    829  
    830         int FullCastSpellOnTarget(lua_State * L, GameObject * ptr) 
    831         { 
    832                 CHECK_TYPEID(TYPEID_GAMEOBJECT); 
    833                 uint32 sp = CHECK_ULONG(L,1); 
    834                 Unit * target = CHECK_UNIT(L,2); 
    835                 if (!sp) return 0; 
    836                 Spell * spp = new Spell(ptr,dbcSpell.LookupEntry(sp),false,NULL); 
    837                 SpellCastTargets tar(target->GetGUID()); 
    838                 spp->prepare(&tar); 
    839                 return 0; 
    840         } 
    841  
    842815        int GetGUID(lua_State * L, GameObject* ptr) 
    843816        { 
     
    862835        { 
    863836                CHECK_TYPEID_RET(TYPEID_GAMEOBJECT); 
    864                 lua_pushboolean(L, (ptr->IsActive() ? 1 : 0)); 
    865                 return 1; 
     837                if(ptr->GetByte(GAMEOBJECT_BYTES_1,0)) 
     838                        RET_BOOL(true); 
     839                RET_BOOL(false); 
    866840        } 
    867841 
     
    869843        { 
    870844                CHECK_TYPEID_RET(TYPEID_GAMEOBJECT); 
    871                 if (ptr->GetUInt32Value(GAMEOBJECT_DYNAMIC) == 1) 
    872                 { 
    873                         ptr->SetUInt32Value(GAMEOBJECT_DYNAMIC, 0); 
    874                 }  
    875                 else 
    876                 { 
    877                         ptr->SetUInt32Value(GAMEOBJECT_DYNAMIC, 1); 
    878                 } 
    879                 return 1; 
     845                if(ptr->GetByte(GAMEOBJECT_BYTES_1, 0) == 1) 
     846                        ptr->SetByte(GAMEOBJECT_BYTES_1, 0, 0); 
     847                else  
     848                        ptr->SetByte(GAMEOBJECT_BYTES_1, 0, 1); 
     849                ptr->SetUInt32Value(GAMEOBJECT_FLAGS, (ptr->GetUInt32Value(GAMEOBJECT_FLAGS) & ~1)); 
     850                RET_BOOL(true); 
    880851        } 
    881852         
     
    960931                return 1; 
    961932        } 
    962  
    963         int SetByteValue(lua_State * L, GameObject * ptr) 
    964         { 
    965                 if (!ptr) return 0; 
    966                 uint32 index = luaL_checkint(L,1); 
    967                 uint32 index1 = luaL_checkint(L,2); 
    968                 uint8 value = luaL_checkint(L,3); 
    969                 ptr->SetByte(index,index1,value); 
    970                 return 0; 
    971         } 
    972  
    973         int GetByteValue(lua_State * L, GameObject * ptr) 
    974         { 
    975                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
    976                 uint32 index = luaL_checkint(L,1); 
    977                 uint32 index1 = luaL_checkint(L,2); 
    978                 lua_pushinteger(L,ptr->GetByte(index,index1)); 
    979                 return 1; 
    980         } 
    981  
    982933        int HasFlag(lua_State * L, GameObject * ptr) 
    983934        { 
     
    999950        int GetSpawnId(lua_State * L, GameObject * ptr) 
    1000951        { 
    1001                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     952                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    1002953                lua_pushnumber(L, ptr->m_spawn != NULL ? ptr->m_spawn->id : 0); 
    1003954                return 1; 
     
    1006957        int GetAreaId(lua_State * L, GameObject * ptr) 
    1007958        { 
    1008                 CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT); 
     959                CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT); 
    1009960                lua_pushnumber(L, ( ptr->GetMapMgr()->GetAreaID(ptr->GetPositionX(), ptr->GetPositionY()) ) ); 
    1010961                return 1; 
     
    1013964        int SetPosition(lua_State * L, GameObject * ptr) 
    1014965        { 
    1015                 if (!ptr) return 0; 
     966                CHECK_TYPEID_RET(TYPEID_GAMEOBJECT) 
    1016967                uint32 NewGuid = ptr->GetMapMgr()->GenerateGameobjectGuid(); 
    1017968        ptr->RemoveFromWorld(true); 
     
    1023974                ptr->SetPosition(x, y, z, o); 
    1024975                ptr->AddToWorld(); 
    1025                 return 0; 
     976                RET_BOOL(true); 
    1026977        } 
    1027978 
    1028979        int GetObjectType(lua_State * L, GameObject * ptr) 
    1029980        { 
    1030                 if (!ptr)  
    1031                 {  
    1032                         lua_pushnil(L);  
    1033                         return 1;  
    1034                 } 
    1035                 lua_pushstring(L, "GameObject"); 
    1036                 return 1; 
     981                CHECK_TYPEID_RETNIL(TYPEID_GAMEOBJECT); 
     982                RET_STRING("GameObject"); 
     983        } 
     984        int ChangeScale(lua_State * L, GameObject * ptr) 
     985        { 
     986                CHECK_TYPEID_RET(TYPEID_GAMEOBJECT) 
     987                float nScale = CHECK_FLOAT(L,1); 
     988                bool updateNow = CHECK_BOOL(L,2); 
     989                nScale = (nScale <= 0) ? 1 : nScale; 
     990                ptr->SetScale(nScale); 
     991                if(updateNow) 
     992                { 
     993                        uint32 nguid = ptr->GetMapMgr()->GenerateGameobjectGuid(); 
     994                        ptr->RemoveFromWorld(true); 
     995                        ptr->SetNewGuid(nguid); 
     996                        ptr->AddToWorld(); 
     997                } 
     998                RET_BOOL(true); 
     999        } 
     1000        int GetByte(lua_State * L, GameObject * ptr) 
     1001        { 
     1002                CHECK_TYPEID_RETNIL(TYPEID_GAMEOBJECT); 
     1003                uint32 index = luaL_checkint(L,1); 
     1004                uint32 index2 = luaL_checkint(L,2); 
     1005                uint8 value = ptr->GetByte(index,index2); 
     1006                RET_INT(value); 
     1007        } 
     1008        int SetByte(lua_State * L, GameObject * ptr) 
     1009        { 
     1010                CHECK_TYPEID_RET(TYPEID_GAMEOBJECT); 
     1011                int index = luaL_checkint(L,1); 
     1012                int index2 = luaL_checkint(L,2); 
     1013                uint8 value = luaL_checkint(L,3); 
     1014                ptr->SetByte(index,index2,value); 
     1015                RET_BOOL(true); 
     1016        } 
     1017        int FullCastSpellOnTarget(lua_State * L, GameObject * ptr) 
     1018        { 
     1019                CHECK_TYPEID(TYPEID_GAMEOBJECT); 
     1020                uint32 sp = CHECK_ULONG(L,1); 
     1021                Unit * target = CHECK_UNIT(L,2); 
     1022                if(sp && target != NULL) 
     1023                { 
     1024                        Spell * tSpell = new Spell(ptr,dbcSpell.LookupEntry(sp),false,NULL); 
     1025                        SpellCastTargets sct(target->GetGUID()); 
     1026                        tSpell->prepare(&sct); 
     1027                } 
     1028                return 0; 
     1029        } 
     1030        int FullCastSpell(lua_State * L, GameObject * ptr) 
     1031        { 
     1032                CHECK_TYPEID(TYPEID_GAMEOBJECT); 
     1033                uint32 sp = CHECK_ULONG(L,1); 
     1034                if(sp) 
     1035                { 
     1036                        Spell * tSpell = new Spell(ptr,dbcSpell.LookupEntry(sp),false,NULL); 
     1037                        SpellCastTargets sct(ptr->GetGUID()); 
     1038                        tSpell->prepare(&sct); 
     1039                } 
     1040                return 0; 
     1041        } 
     1042        int CustomAnimate(lua_State * L, GameObject * ptr) 
     1043        { 
     1044                uint32 aindex = CHECK_ULONG(L,1); 
     1045                if(aindex < 2 && ptr != NULL) 
     1046                { 
     1047                        WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM,12); 
     1048                        data << ptr->GetGUID(); 
     1049                        data << aindex; 
     1050                        ptr->SendMessageToSet(&data,false); 
     1051                        RET_BOOL(true); 
     1052                } 
     1053                RET_BOOL(false); 
    10371054        } 
    10381055} 
  • Trunk/src/LuaEngine/LUAEngine.cpp

    r1135 r1144  
    949949        if(ref == LUA_REFNIL || ref == LUA_NOREF) 
    950950                return luaL_error(L,"Error in SuspendLuaThread! Failed to create a valid reference."); 
    951         TimedEvent * evt = TimedEvent::Allocate(thread,new CallbackP2<LuaEngine,lua_State*,int>(&g_luaMgr,&LuaEngine::ResumeLuaThread,thread,ref),0,waitime,1); 
     951        TimedEvent * evt = TimedEvent::Allocate(thread,new CallbackP1<LuaEngine,int>(&g_luaMgr,&LuaEngine::ResumeLuaThread,ref),0,waitime,1); 
    952952        sWorld.event_AddEvent(evt); 
    953953        lua_remove(L,1); // remove thread object 
     
    955955        //All that remains now are the extra arguments passed to this function. 
    956956        lua_xmove(L,thread,lua_gettop(L)); 
    957         g_luaMgr.getPendingThreadSet().insert(thread); 
     957        g_luaMgr.getThreadRefs().insert(ref); 
    958958        return lua_yield(thread,lua_gettop(L)); 
    959959} 
     
    15411541public: 
    15421542        LuaCreature(Creature* creature) : CreatureAIScript(creature) {}; 
    1543         ~LuaCreature() {}; 
     1543        ~LuaCreature() 
     1544        { 
     1545                typedef std::multimap<uint32,LuaCreature*> CMAP; 
     1546                CMAP & cMap = sLuaMgr.getLuCreatureMap(); 
     1547                CMAP::iterator itr = cMap.find(_unit->GetEntry()); 
     1548                CMAP::iterator itend = cMap.upper_bound(_unit->GetEntry()); 
     1549                CMAP::iterator it; 
     1550                for(;itr != cMap.end() && itr != itend;) 
     1551                { 
     1552                        it = itr++; 
     1553                        if(it->second != NULL && it->second == this) 
     1554                                cMap.erase(it); 
     1555                } 
     1556        } 
    15441557        ARCEMU_INLINE void SetUnit(Creature * ncrc) { _unit = ncrc; } 
    15451558        void OnCombatStart(Unit* mTarget) 
     
    19331946                sLuaMgr.ExecuteCall(args); 
    19341947                RELEASE_LOCK 
    1935         } 
    1936  
    1937         void Destroy() 
    1938         { 
    1939                 typedef std::multimap<uint32,LuaCreature*> CMAP; 
    1940                 CMAP & cMap = sLuaMgr.getLuCreatureMap(); 
    1941                 CMAP::iterator itr = cMap.find(_unit->GetEntry()); 
    1942                 CMAP::iterator itend = cMap.upper_bound(_unit->GetEntry()); 
    1943                 CMAP::iterator it; 
    1944                 for(;itr != cMap.end() && itr != itend;) 
    1945                 { 
    1946                         it = itr++; 
    1947                         if(it->second != NULL && it->second == this) 
    1948                                 cMap.erase(it); 
    1949                 } 
    1950                 delete this; 
    19511948        } 
    19521949        LuaUnitBinding * m_binding; 
     
    23882385                        CRCMAP::iterator itr = cMap.find(id); 
    23892386                        CRCMAP::iterator itend = cMap.upper_bound(id); 
    2390                         for(; itr != itend; ++itr) 
     2387                        for(; itr != cMap.end() && itr != itend; ++itr) 
    23912388                        { 
    23922389                                //grab the 1st and initalize 
     
    24252422                        GMAP::iterator itr = gMap.find(id); 
    24262423                        GMAP::iterator itend = gMap.upper_bound(id); 
    2427                         for(; itr != itend; ++itr) 
     2424                        for(; itr != gMap.end() && itr != itend; ++itr) 
    24282425                        { 
    24292426                                if(itr->second != NULL && itr->second->getGO() != NULL && itr->second->getGO()->GetGUID() == guid) 
     
    27982795void LuaEngine::Unload() 
    27992796{ 
    2800         lua_close(lu); // clean up the engine of any existing defined variables 
     2797        // clean up the engine of any existing defined variables 
    28012798        { 
    28022799                UnitBindingMap::iterator itr = this->m_unitBinding.begin(); 
     
    28862883                } 
    28872884        } 
    2888  
    2889         m_pendingThreads.clear(); 
     2885        set<int>::iterator itr = m_pendingThreads.begin(); 
     2886        for(; itr != m_pendingThreads.end(); ++itr) 
     2887        { 
     2888                lua_unref(lu,(*itr)); 
     2889        } 
     2890        m_pendingThreads.erase(m_pendingThreads.begin(),m_pendingThreads.end()); 
     2891 
     2892        lua_close(lu); 
    28902893} 
    28912894void LuaEngine::Restart() 
     
    30653068} 
    30663069 
    3067 void LuaEngine::ResumeLuaThread(lua_State * thread,int ref) { 
     3070void LuaEngine::ResumeLuaThread(int ref) { 
    30683071        getcoLock().Acquire(); 
    30693072        lua_State * expectedThread = NULL; 
    3070         lua_State * foundthread = NULL; 
    30713073        lua_rawgeti(lu,LUA_REGISTRYINDEX,ref); 
    30723074        if(lua_isthread(lu,-1) ) 
    30733075                expectedThread = lua_tothread(lu,-1); 
    3074         foundthread = getPendingThread(thread); 
    3075         if(expectedThread != NULL && foundthread != NULL)  
     3076        if(expectedThread != NULL)  
    30763077        { 
    30773078                //push ourself on the stack 
    3078                 lua_pushthread(foundthread); 
     3079                lua_pushthread(expectedThread); 
    30793080                //move the thread to the main lu state(and pop it off) 
    3080                 lua_xmove(foundthread,lu,1); 
     3081                lua_xmove(expectedThread,lu,1); 
    30813082                if(lua_rawequal(lu,-1,-2) ) 
    30823083                { 
     
    30993100#define CHECK_TYPEID(expected_type) if(!ptr || !ptr->IsInWorld() || ptr->GetTypeId() != expected_type) { return 0; } 
    31003101#define CHECK_TYPEID_RET(expected_type) if(!ptr || !ptr->IsInWorld() || ptr->GetTypeId() != expected_type) { lua_pushboolean(L,0); return 1; } 
    3101 #define CHECK_TYPEID_RET_INT(expected_type) if(!ptr || !ptr->IsInWorld() || ptr->GetTypeId() != expected_type) { lua_pushinteger(L,0); return 1; } 
    3102 #define CHECK_TYPEID_RET_NIL(expected_type) if(!ptr || !ptr->isInWorld() || ptr->GetTypeId() != expected_type) { lua_pushnil(L); return 1; } 
     3102#define CHECK_TYPEID_RETINT(expected_type) if(!ptr || !ptr->IsInWorld() || ptr->GetTypeId() != expected_type) { lua_pushinteger(L,0); return 1; } 
     3103#define CHECK_TYPEID_RETNIL(expected_type) if(!ptr || !ptr->IsInWorld() || ptr->GetTypeId() != expected_type) { lua_pushnil(L); return 1; } (void*)0 
     3104#define RET_NIL { lua_pushnil(L); return 1; } (void*)0 
     3105#define RET_BOOL(exp) { (exp) ? lua_pushboolean(L,1) : lua_pushboolean(L,0); return 1; } (void*)0 
     3106#define RET_STRING(str) { lua_pushstring(L,(str)); return 1; } (void*)0 
     3107#define RET_NUMBER(number) { lua_pushnumber(L,(number)); return 1; } (void*)0 
     3108#define RET_INT(integer) { lua_pushinteger(L,(integer)); return 1; } (void*)0 
    31033109 
    31043110// Simplicity macros. 
  • Trunk/src/LuaEngine/LUAEngine.h

    r1122 r1144  
    221221        typedef HM_NAMESPACE::hash_map<uint32, LuaItemGossipBinding> GossipItemScriptsBindingMap; 
    222222        typedef HM_NAMESPACE::hash_map<uint32, LuaGOGossipBinding> GossipGOScriptsBindingMap; 
    223         std::set<lua_State * > m_pendingThreads; 
     223        std::set<int> m_pendingThreads; 
    224224 
    225225        //maps to creature, & go script interfaces 
     
    253253 
    254254        void RegisterEvent(uint8 regtype, uint32 id, uint32 evt, const char * func); 
    255         void ResumeLuaThread(lua_State *, int); 
     255        void ResumeLuaThread(int); 
    256256        bool BeginCall(const char * func); 
    257257        void HyperCallFunction(const char * FuncName, int ref); 
     
    375375                return (itr == m_qAIScripts.end()) ? NULL: itr->second; 
    376376        } 
    377         lua_State* getPendingThread(lua_State * threadtosearch) { 
     377        /*int getPendingThread(lua_State * threadtosearch) { 
    378378                set<lua_State*>::iterator itr = m_pendingThreads.find(threadtosearch); 
    379379                return (itr == m_pendingThreads.end() )? NULL : (*itr); 
    380         } 
     380        }*/ 
    381381        LuaGossip * getUnitGossipInterface(uint32 id)  
    382382        { 
     
    400400        ARCEMU_INLINE HM_NAMESPACE::hash_map<uint32, LuaGossip*> & getItemGossipInterfaceMap() { return m_itemgAIScripts; } 
    401401        ARCEMU_INLINE HM_NAMESPACE::hash_map<uint32, LuaGossip*> & getGameObjectGossipInterfaceMap() { return m_gogAIScripts; } 
    402         ARCEMU_INLINE set<lua_State * > & getPendingThreadSet() { return m_pendingThreads; } 
     402        ARCEMU_INLINE set<int> & getThreadRefs() { return m_pendingThreads; } 
    403403 
    404404        struct _ENGINEHOOKINFO {  
  • Trunk/src/LuaEngine/UnitFunctions.h

    r1142 r1144  
    445445        int CastSpell(lua_State * L, Unit * ptr) 
    446446        { 
    447                 //CHECK_TYPEID(TYPEID_UNIT || TYPEID_PLAYER); 
    448447                uint32 sp = CHECK_ULONG(L,1); 
    449448                if (sp && ptr) 
     
    454453        int FullCastSpell(lua_State * L, Unit * ptr) 
    455454        { 
    456                 //CHECK_TYPEID(TYPEID_UNIT || TYPEID_PLAYER); 
    457455                uint32 sp = CHECK_ULONG(L,1); 
    458456                if (sp && ptr) 
     
    460458                return 0; 
    461459        } 
     460        int FullCastSpellOnTarget(lua_State * L, Unit * ptr) 
     461        { 
     462                if(ptr != NULL) 
     463                { 
     464                        uint32 sp = CHECK_ULONG(L,1); 
     465                        Unit * target = CHECK_UNIT(L,2); 
     466                        if(sp && target != NULL) 
     467                                ptr->CastSpell(target->GetGUID(),sp,false); 
     468                } 
     469                return 0; 
     470        } 
    462471        int CastSpellOnTarget(lua_State * L, Unit * ptr) 
    463472        { 
     
    465474                Unit * target = CHECK_UNIT(L,2); 
    466475                if(ptr != NULL && sp && target != NULL) 
    467                 { 
    468                         Spell * spp = new Spell(ptr,dbcSpell.LookupEntry(sp),true,NULL); 
    469                         spp->m_targets.m_unitTarget = target->GetGUID(); 
    470                         //prepare digest 
    471                         SpellCastTargets tar(target->GetGUID()); 
    472                         spp->m_targets = tar; 
    473                         spp->SendSpellStart(); 
    474                         spp->cast(false); 
    475                 } 
    476                 return 0; 
    477         } 
    478  
    479         int FullCastSpellOnTarget(lua_State * L, Unit * ptr) 
    480         { 
    481                 //CHECK_TYPEID(TYPEID_UNIT || TYPEID_PLAYER); 
    482                 uint32 sp = CHECK_ULONG(L,1); 
    483                 Unit * target = CHECK_UNIT(L, 2); 
    484  
    485                 if (!sp || !target || !ptr) 
    486                         return 0; 
    487                 ptr->CastSpell(target,dbcSpell.LookupEntry(sp),false); 
     476                        ptr->CastSpell(target,sp,true); 
    488477                return 0; 
    489478        } 
     
    504493                bool save = luaL_optint(L, 12, 0) ? true : false;  
    505494 
    506                 if(!entry_id || !faction) 
     495                if(!entry_id) 
    507496                { 
    508497                        lua_pushnil(L); 
     
    521510                        return 1; 
    522511                } 
    523                 pCreature->SetFaction(faction); 
    524                 pCreature->_setFaction(); 
     512                if(faction) 
     513                { 
     514                        pCreature->SetFaction(faction); 
     515                        pCreature->_setFaction(); 
     516                } 
    525517                pCreature->SetInstanceID(ptr->GetInstanceID()); 
    526518                pCreature->SetMapId(ptr->GetMapId()); 
     
    528520                pCreature->SetEquippedItem(OFFHAND,equip2); 
    529521                pCreature->SetEquippedItem(RANGED,equip3); 
     522                pCreature->m_noRespawn = true; 
    530523                if (duration) 
    531524                        pCreature->Despawn(duration,0); 
     
    568561                        lua_pushnil(L); 
    569562                return 1; 
    570  
    571  
    572563        } 
    573564 
     
    622613        int IsInCombat(lua_State * L, Unit * ptr) 
    623614        { 
    624                 if (!ptr) 
    625                         return 0; 
     615                if(ptr == NULL || !ptr->IsInWorld() ) 
     616                        RET_NIL; 
    626617                if(ptr->CombatStatus.IsInCombat()) 
    627618                        lua_pushboolean(L, 1); 
     
    633624        int SetScale(lua_State * L, Unit * ptr) 
    634625        { 
    635                 //CHECK_TYPEID(TYPEID_UNIT); 
    636626                float scale = CHECK_FLOAT(L,1); 
    637627                if (scale && ptr) 
    638628                        ptr->SetFloatValue(OBJECT_FIELD_SCALE_X,(float)scale); 
    639                 return 0; 
     629                else 
     630                        RET_BOOL(false); 
     631                RET_BOOL(true); 
    640632        } 
    641633 
    642634        int SetModel(lua_State * L, Unit * ptr) 
    643635        { 
    644                 int modelid = luaL_checkint(L,1); 
    645                 if(ptr != NULL)  
    646                 { 
    647                         ptr->SetDisplayId(modelid); 
    648                 } 
    649                 return 0; 
     636                uint32 model = CHECK_ULONG(L,1); 
     637                if(ptr != NULL) 
     638                        ptr->SetDisplayId(model); 
     639                else 
     640                        RET_BOOL(false); 
     641                RET_BOOL(true); 
    650642        } 
    651643 
     
    658650                return 0; 
    659651        } 
    660  
    661         int SetCombatCapable(lua_State * L, Unit * ptr) 
    662         { 
    663                 CHECK_TYPEID(TYPEID_UNIT); 
    664                 bool enabled = CHECK_BOOL(L,1); 
    665                 ptr->GetAIInterface()->disable_combat = enabled; 
    666                 return 0; 
    667         } 
    668  
    669         int SetCombatMeleeCapable(lua_State * L, Unit * ptr) 
    670         { 
    671                 CHECK_TYPEID(TYPEID_UNIT); 
    672                 bool enabled = CHECK_BOOL(L,1); 
    673                 ptr->GetAIInterface()->disable_melee = enabled; 
    674                 return 0; 
    675         } 
    676  
    677         int SetCombatRangedCapable(lua_State * L, Unit * ptr) 
    678         { 
    679                 CHECK_TYPEID(TYPEID_UNIT); 
    680                 bool enabled = CHECK_BOOL(L,1); 
    681                 ptr->GetAIInterface()->disable_ranged = enabled; 
    682                 return 0; 
    683         } 
    684  
    685         int SetCombatSpellCapable(lua_State * L, Unit * ptr) 
    686         { 
    687                 CHECK_TYPEID(TYPEID_UNIT); 
    688                 bool enabled = CHECK_BOOL(L,1); 
    689                 ptr->GetAIInterface()->disable_spell = enabled; 
    690                 return 0; 
    691         } 
    692  
    693         int SetCombatTargetingCapable(lua_State * L, Unit * ptr) 
    694         { 
    695                 CHECK_TYPEID(TYPEID_UNIT); 
    696                 bool enabled = CHECK_BOOL(L,1); 
    697                 ptr->GetAIInterface()->disable_targeting = enabled; 
    698                 return 0; 
    699         } 
    700  
    701652        int SetMount(lua_State * L, Unit * ptr) 
    702653        { 
     
    10881039                                uint32 count = 0; 
    10891040                                Unit* mt = ptr->GetAIInterface()->GetMostHated(); 
    1090                                 if (!mt->IsPlayer()) 
     1041                                if (mt == NULL || !mt->IsPlayer()) 
    10911042                                        return 0; 
    10921043 
     
    14981449        int GetItemCount(lua_State * L, Unit * ptr) 
    14991450        { 
    1500                 CHECK_TYPEID_RET_INT(TYPEID_PLAYER); 
     1451                CHECK_TYPEID_RETINT(TYPEID_PLAYER); 
    15011452                int itemid = luaL_checkint(L,1); 
    15021453                lua_pushinteger(L, TO_PLAYER(ptr)->GetItemInterface()->GetItemCount(itemid,false)); 
     
    15191470        int GetMainTank(lua_State * L, Unit * ptr) 
    15201471        { 
    1521                 CHECK_TYPEID_RET_INT(TYPEID_UNIT); 
     1472                CHECK_TYPEID_RETINT(TYPEID_UNIT); 
    15221473                Unit* ret = ptr->GetAIInterface()->GetMostHated(); 
    15231474                if (!ret) 
     
    15301481        int GetAddTank(lua_State * L, Unit * ptr) 
    15311482        { 
    1532                 CHECK_TYPEID_RET_INT(TYPEID_UNIT); 
     1483                CHECK_TYPEID_RETINT(TYPEID_UNIT); 
    15331484                Unit* ret = ptr->GetAIInterface()->GetSecondHated(); 
    15341485                if(ret==NULL) 
     
    15411492        int ClearThreatList(lua_State * L, Unit * ptr) 
    15421493        { 
    1543                 CHECK_TYPEID_RET_INT(TYPEID_UNIT); 
     1494                CHECK_TYPEID_RETINT(TYPEID_UNIT); 
    15441495                ptr->ClearHateList(); 
    15451496                return 0; 
     
    18951846        int WipeHateList(lua_State * L, Unit * ptr) 
    18961847        { 
    1897                 CHECK_TYPEID_RET_INT(TYPEID_UNIT); 
     1848                CHECK_TYPEID_RETINT(TYPEID_UNIT); 
    18981849                ptr->WipeHateList(); 
    18991850                return 0; 
     
    19021853        int WipeTargetList(lua_State * L, Unit * ptr) 
    19031854        { 
    1904                 CHECK_TYPEID_RET_INT(TYPEID_UNIT); 
     1855                CHECK_TYPEID_RETINT(TYPEID_UNIT); 
    19051856                ptr->GetAIInterface()->WipeTargetList(); 
    19061857                return 0; 
     
    19091860        int WipeCurrentTarget(lua_State * L, Unit * ptr) 
    19101861        { 
    1911                 CHECK_TYPEID_RET_INT(TYPEID_UNIT); 
     1862                CHECK_TYPEID_RETINT(TYPEID_UNIT); 
    19121863                ptr->GetAIInterface()->WipeCurrentTarget(); 
    19131864                return 0; 
     
    19671918        int ClearHateList(lua_State * L, Unit * ptr) 
    19681919        { 
    1969                 CHECK_TYPEID_RET_INT(TYPEID_UNIT); 
     1920                CHECK_TYPEID_RETINT(TYPEID_UNIT); 
    19701921                ptr->ClearHateList(); 
    19711922                return 0; 
     
    40834034        int GetSelection(lua_State * L, Unit * ptr) 
    40844035        { 
    4085                 CHECK_TYPEID(TYPEID_PLAYER); 
     4036                CHECK_TYPEID_RETNIL(TYPEID_PLAYER); 
    40864037                Player * plr = TO_PLAYER(ptr); 
    40874038                Unit * selection = plr->GetMapMgr()->GetUnit(plr->GetSelection()); 
     
    40924043                return 1; 
    40934044        } 
     4045        int GetSelectedGO(lua_State * L, Unit * ptr) 
     4046        { 
     4047                CHECK_TYPEID_RETNIL(TYPEID_PLAYER); 
     4048                Player * plr = TO_PLAYER(ptr); 
     4049                PUSH_GO(L,plr->GetSelectedGo()); 
     4050                return 1; 
     4051        } 
    40944052 
    40954053        int RepairAllPlayerItems(lua_State * L, Unit * ptr) 
    40964054        { 
    4097                 CHECK_TYPEID(TYPEID_PLAYER); 
     4055                CHECK_TYPEID_RET(TYPEID_PLAYER); 
    40984056                Player * plr = TO_PLAYER(ptr); 
    40994057                Item * pItem = NULL; 
     
    59075865                return 1; 
    59085866        } 
     5867        int GetCurrentWaypoint(lua_State * L, Unit * ptr) 
     5868        { 
     5869                CHECK_TYPEID_RETNIL(TYPEID_UNIT); 
     5870                RET_NUMBER(ptr->GetAIInterface()->getCurrentWaypoint()); 
     5871        } 
     5872        int DisableMelee(lua_State * L, Unit * ptr) 
     5873        { 
     5874                CHECK_TYPEID_RET(TYPEID_UNIT) 
     5875                bool disable = CHECK_BOOL(L,1); 
     5876                TO_CREATURE(ptr)->GetAIInterface()->disable_melee = disable; 
     5877                RET_BOOL(true); 
     5878        } 
     5879        int DisableSpells(lua_State * L, Unit * ptr) 
     5880        { 
     5881                CHECK_TYPEID_RET(TYPEID_UNIT) 
     5882                bool disable = CHECK_BOOL(L,1); 
     5883                TO_CREATURE(ptr)->GetAIInterface()->disable_spell = disable; 
     5884                RET_BOOL(true); 
     5885        } 
     5886        int DisableRanged(lua_State * L, Unit * ptr) 
     5887        { 
     5888                CHECK_TYPEID_RET(TYPEID_UNIT) 
     5889                bool disable = CHECK_BOOL(L,1); 
     5890                TO_CREATURE(ptr)->GetAIInterface()->disable_ranged = disable; 
     5891                RET_BOOL(true); 
     5892        } 
     5893        int DisableCombat(lua_State * L, Unit * ptr) 
     5894        { 
     5895                CHECK_TYPEID_RET(TYPEID_UNIT) 
     5896                bool disable = CHECK_BOOL(L,1); 
     5897                TO_CREATURE(ptr)->GetAIInterface()->disable_combat = disable; 
     5898                RET_BOOL(true); 
     5899        } 
     5900        int DisableTargeting(lua_State * L, Unit * ptr) 
     5901        { 
     5902                CHECK_TYPEID_RET(TYPEID_UNIT) 
     5903                bool disable = CHECK_BOOL(L,1); 
     5904                TO_CREATURE(ptr)->GetAIInterface()->disable_targeting = disable; 
     5905                RET_BOOL(true); 
     5906        } 
     5907        int IsInGroup(lua_State * L, Unit * ptr) 
     5908        { 
     5909                CHECK_TYPEID_RET(TYPEID_PLAYER) 
     5910                if(TO_PLAYER(ptr)->InGroup() ) 
     5911                        RET_BOOL(true); 
     5912                RET_BOOL(false); 
     5913        } 
    59095914} 
    59105915#endif