Skip to content

Commit 890332a

Browse files
committed
Added new function from #457
Also rearranged expansion specific functions to make sure the nullptrs are at the end of the list.
1 parent 4e6c7b0 commit 890332a

File tree

1 file changed

+71
-26
lines changed

1 file changed

+71
-26
lines changed

CMangos/UnitMethods.h

Lines changed: 71 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,60 @@
1212
*/
1313
namespace LuaUnit
1414
{
15+
/**
16+
* Sets a mechanic immunity for the [Unit].
17+
*
18+
* <pre>
19+
* MECHANIC_NONE = 0,
20+
* MECHANIC_CHARM = 1,
21+
* MECHANIC_DISORIENTED = 2,
22+
* MECHANIC_DISARM = 3,
23+
* MECHANIC_DISTRACT = 4,
24+
* MECHANIC_FEAR = 5,
25+
* MECHANIC_GRIP = 6, // Called MECHANIC_FUMBLE in Classic/TBC
26+
* MECHANIC_ROOT = 7,
27+
* MECHANIC_PACIFY = 8,
28+
* MECHANIC_SILENCE = 9,
29+
* MECHANIC_SLEEP = 10,
30+
* MECHANIC_SNARE = 11,
31+
* MECHANIC_STUN = 12,
32+
* MECHANIC_FREEZE = 13,
33+
* MECHANIC_KNOCKOUT = 14,
34+
* MECHANIC_BLEED = 15,
35+
* MECHANIC_BANDAGE = 16,
36+
* MECHANIC_POLYMORPH = 17,
37+
* MECHANIC_BANISH = 18,
38+
* MECHANIC_SHIELD = 19,
39+
* MECHANIC_SHACKLE = 20,
40+
* MECHANIC_MOUNT = 21,
41+
* MECHANIC_INFECTED = 22, // Called MECHANIC_PERSUADE in Classic/TBC
42+
* MECHANIC_TURN = 23,
43+
* MECHANIC_HORROR = 24,
44+
* MECHANIC_INVULNERABILITY = 25,
45+
* MECHANIC_INTERRUPT = 26,
46+
* MECHANIC_DAZE = 27,
47+
* MECHANIC_DISCOVERY = 28,
48+
* MECHANIC_IMMUNE_SHIELD = 29, // Divine (Blessing) Shield/Protection and Ice Block
49+
* MECHANIC_SAPPED = 30,
50+
* MECHANIC_ENRAGED = 31 // Not used in Classic/TBC
51+
* </pre>
52+
*
53+
* @param int32 immunity : new value for the immunity mask
54+
* @param bool apply = true : if true, the immunity is applied, otherwise it is removed
55+
*/
56+
int SetImmuneTo(Eluna* E, Unit* unit)
57+
{
58+
int32 immunity = Eluna::CHECKVAL<int32>(E->L, 2);
59+
bool apply = Eluna::CHECKVAL<bool>(E->L, 3, true);
60+
61+
#ifndef CATA
62+
unit->ApplySpellImmune(nullptr, 5, immunity, apply);
63+
#else
64+
unit->ApplySpellImmune(0, 5, immunity, apply);
65+
#endif
66+
return 0;
67+
}
68+
1569
/**
1670
* The [Unit] tries to attack a given target
1771
*
@@ -2490,13 +2544,6 @@ namespace LuaUnit
24902544
{ "GetStat", &LuaUnit::GetStat },
24912545
{ "GetBaseSpellPower", &LuaUnit::GetBaseSpellPower },
24922546
{ "GetMovementType", &LuaUnit::GetMovementType },
2493-
#if defined(WOTLK)
2494-
{ "GetCritterGUID", &LuaUnit::GetCritterGUID },
2495-
{ "GetVehicleKit", &LuaUnit::GetVehicleKit },
2496-
#else
2497-
{ "GetCritterGUID", nullptr, METHOD_REG_NONE },
2498-
{ "GetVehicleKit", nullptr, METHOD_REG_NONE },
2499-
#endif
25002547

25012548
// Setters
25022549
{ "SetFaction", &LuaUnit::SetFaction },
@@ -2525,15 +2572,7 @@ namespace LuaUnit
25252572
{ "SetStandState", &LuaUnit::SetStandState },
25262573
{ "SetInCombatWith", &LuaUnit::SetInCombatWith },
25272574
{ "ModifyPower", &LuaUnit::ModifyPower },
2528-
#if defined(WOTLK)
2529-
{ "SetFFA", &LuaUnit::SetFFA },
2530-
{ "SetSanctuary", &LuaUnit::SetSanctuary },
2531-
{ "SetCritterGUID", &LuaUnit::SetCritterGUID },
2532-
#else
2533-
{ "SetFFA", nullptr, METHOD_REG_NONE },
2534-
{ "SetSanctuary", nullptr, METHOD_REG_NONE },
2535-
{ "SetCritterGUID", nullptr, METHOD_REG_NONE },
2536-
#endif
2575+
{ "SetImmuneTo", &LuaUnit::SetImmuneTo },
25372576

25382577
// Boolean
25392578
{ "IsAlive", &LuaUnit::IsAlive },
@@ -2574,11 +2613,6 @@ namespace LuaUnit
25742613
{ "HasAura", &LuaUnit::HasAura },
25752614
{ "IsCasting", &LuaUnit::IsCasting },
25762615
{ "IsStandState", &LuaUnit::IsStandState },
2577-
#if defined(TBC) || defined(WOTLK)
2578-
{ "IsOnVehicle", &LuaUnit::IsOnVehicle },
2579-
#else
2580-
{ "IsOnVehicle", nullptr, METHOD_REG_NONE },
2581-
#endif
25822616

25832617
// Other
25842618
{ "AddAura", &LuaUnit::AddAura },
@@ -2619,14 +2653,26 @@ namespace LuaUnit
26192653
{ "MoveClear", &LuaUnit::MoveClear },
26202654
{ "DealDamage", &LuaUnit::DealDamage },
26212655
{ "DealHeal", &LuaUnit::DealHeal },
2656+
2657+
// Expansion specific methods
26222658
#if defined(TBC) || defined(WOTLK)
2659+
{ "IsOnVehicle", &LuaUnit::IsOnVehicle },
26232660
{ "RemoveArenaAuras", &LuaUnit::RemoveArenaAuras },
2624-
#else
2625-
{ "RemoveArenaAuras", nullptr, METHOD_REG_NONE },
2626-
#endif
2627-
#if defined(WOTLK)
2661+
#elif defined(WOTLK)
2662+
{ "GetCritterGUID", &LuaUnit::GetCritterGUID },
2663+
{ "GetVehicleKit", &LuaUnit::GetVehicleKit },
2664+
{ "SetFFA", &LuaUnit::SetFFA },
2665+
{ "SetSanctuary", &LuaUnit::SetSanctuary },
2666+
{ "SetCritterGUID", &LuaUnit::SetCritterGUID },
26282667
{ "MoveJump", &LuaUnit::MoveJump },
26292668
#else
2669+
{ "GetCritterGUID", nullptr, METHOD_REG_NONE },
2670+
{ "GetVehicleKit", nullptr, METHOD_REG_NONE },
2671+
{ "SetFFA", nullptr, METHOD_REG_NONE },
2672+
{ "SetSanctuary", nullptr, METHOD_REG_NONE },
2673+
{ "SetCritterGUID", nullptr, METHOD_REG_NONE },
2674+
{ "IsOnVehicle", nullptr, METHOD_REG_NONE },
2675+
{ "RemoveArenaAuras", nullptr, METHOD_REG_NONE },
26302676
{ "MoveJump", nullptr, METHOD_REG_NONE },
26312677
#endif
26322678

@@ -2644,7 +2690,6 @@ namespace LuaUnit
26442690
{ "RemoveCharmAuras", nullptr, METHOD_REG_NONE }, // not implemented
26452691
{ "DisableMelee", nullptr, METHOD_REG_NONE }, // not implemented
26462692
{ "SummonGuardian", nullptr, METHOD_REG_NONE }, // not implemented
2647-
{ "SetImmuneTo", nullptr }, // not implemented
26482693

26492694
{ NULL, NULL, METHOD_REG_NONE }
26502695
};

0 commit comments

Comments
 (0)