Skip to content

Commit 6aa13f0

Browse files
authored
Add GossipMenuAddItemData method for Mangos (#506)
1 parent f654490 commit 6aa13f0

File tree

4 files changed

+77
-55
lines changed

4 files changed

+77
-55
lines changed

methods/CMangos/PlayerMethods.h

+18-17
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace LuaPlayer
143143
return 1;
144144
}
145145
#endif
146-
146+
147147
/**
148148
* Returns 'true' if the [Player] has the given amount of item entry specified, 'false' otherwise.
149149
*
@@ -160,7 +160,7 @@ namespace LuaPlayer
160160
E->Push(player->HasItemCount(itemId, count, check_bank));
161161
return 1;
162162
}
163-
163+
164164
/**
165165
* Returns 'true' if the [Player] has a quest for the item entry specified, 'false' otherwise.
166166
*
@@ -174,7 +174,7 @@ namespace LuaPlayer
174174
E->Push(player->HasQuestForItem(entry));
175175
return 1;
176176
}
177-
177+
178178
/**
179179
* Returns 'true' if the [Player] can use the item or item entry specified, 'false' otherwise.
180180
*
@@ -418,7 +418,7 @@ namespace LuaPlayer
418418
return 1;
419419
}
420420
#endif
421-
421+
422422
/**
423423
* Returns 'true' if the [Player] is immune to everything.
424424
*
@@ -1336,7 +1336,7 @@ namespace LuaPlayer
13361336
E->Push(player->GetItemByEntry(entry));
13371337
return 1;
13381338
}
1339-
1339+
13401340
/**
13411341
* Returns the database textID of the [WorldObject]'s gossip header text for the [Player]
13421342
*
@@ -1404,7 +1404,7 @@ namespace LuaPlayer
14041404
E->Push(player->GetTeamId());
14051405
return 1;
14061406
}
1407-
1407+
14081408
/**
14091409
* Returns amount of the specified [Item] the [Player] has.
14101410
*
@@ -1553,7 +1553,7 @@ namespace LuaPlayer
15531553
E->Push(player->GetMailSize());
15541554
return 1;
15551555
}
1556-
1556+
15571557
/**
15581558
* Locks the player controls and disallows all movement and casting.
15591559
*
@@ -2013,7 +2013,7 @@ namespace LuaPlayer
20132013
return 0;
20142014
}
20152015
#endif
2016-
2016+
20172017
/**
20182018
* Shows the mailbox window to the player from specified guid.
20192019
*
@@ -2202,7 +2202,7 @@ namespace LuaPlayer
22022202
player->GetSession()->SendShowBank(obj->GET_GUID());
22032203
return 0;
22042204
}
2205-
2205+
22062206
/**
22072207
* Sends a vendor window to the [Player] from the [WorldObject] specified.
22082208
*
@@ -2965,7 +2965,7 @@ namespace LuaPlayer
29652965
player->AutoUnequipOffhandIfNeed();
29662966
return 1;
29672967
}
2968-
2968+
29692969
/**
29702970
* Returns true if the player can equip the given [Item] or item entry to the given slot, false otherwise.
29712971
*
@@ -3121,7 +3121,7 @@ namespace LuaPlayer
31213121
player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, currentKills + val);
31223122
return 0;
31233123
}
3124-
3124+
31253125
/**
31263126
* Adds the given amount of the specified item entry to the player.
31273127
*
@@ -3137,7 +3137,7 @@ namespace LuaPlayer
31373137
E->Push(player->StoreNewItemInInventorySlot(itemId, itemCount));
31383138
return 1;
31393139
}
3140-
3140+
31413141
/**
31423142
* Removes the given amount of the specified [Item] from the player.
31433143
*
@@ -3395,9 +3395,9 @@ namespace LuaPlayer
33953395
/**
33963396
* Adds a new item to the gossip menu shown to the [Player] on next call to [Player:GossipSendMenu].
33973397
*
3398-
* sender and intid are numbers which are passed directly to the gossip selection handler. Internally they are partly used for the database gossip handling.
3399-
* code specifies whether to show a box to insert text to. The player inserted text is passed to the gossip selection handler.
3400-
* money specifies an amount of money the player needs to have to click the option. An error message is shown if the player doesn't have enough money.
3398+
* sender and intid are numbers which are passed directly to the gossip selection handler. Internally they are partly used for the database gossip handling.
3399+
* code specifies whether to show a box to insert text to. The player inserted text is passed to the gossip selection handler.
3400+
* money specifies an amount of money the player needs to have to click the option. An error message is shown if the player doesn't have enough money.
34013401
* Note that the money amount is only checked client side and is not removed from the player either. You will need to check again in your code before taking action.
34023402
*
34033403
* See also: [Player:GossipSendMenu], [Player:GossipAddQuests], [Player:GossipComplete], [Player:GossipClearMenu]
@@ -3483,7 +3483,7 @@ namespace LuaPlayer
34833483
* Clears the [Player]s current gossip item list.
34843484
*
34853485
* See also: [Player:GossipMenuAddItem], [Player:GossipSendMenu], [Player:GossipAddQuests], [Player:GossipComplete]
3486-
*
3486+
*
34873487
* Note: This is needed when you show a gossip menu without using gossip hello or select hooks which do this automatically.
34883488
* Usually this is needed when using [Player] is the sender of a Gossip Menu.
34893489
*/
@@ -3746,7 +3746,7 @@ namespace LuaPlayer
37463746
ChatHandler(player->GetSession()).ExecuteCommand(command);
37473747
return 0;
37483748
}
3749-
3749+
37503750
ElunaRegister<Player> PlayerMethods[] =
37513751
{
37523752
// Getters
@@ -3943,6 +3943,7 @@ namespace LuaPlayer
39433943

39443944
// Gossip
39453945
{ "GossipMenuAddItem", &LuaPlayer::GossipMenuAddItem },
3946+
{ "GossipMenuAddItemData", METHOD_REG_NONE }, // not implemented
39463947
{ "GossipSendMenu", &LuaPlayer::GossipSendMenu },
39473948
{ "GossipComplete", &LuaPlayer::GossipComplete },
39483949
{ "GossipClearMenu", &LuaPlayer::GossipClearMenu },

methods/Mangos/PlayerMethods.h

+36-17
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ namespace LuaPlayer
145145
return 1;
146146
}
147147
#endif
148-
148+
149149
/**
150150
* Returns 'true' if the [Player] has the given amount of item entry specified, 'false' otherwise.
151151
*
@@ -162,7 +162,7 @@ namespace LuaPlayer
162162
E->Push(player->HasItemCount(itemId, count, check_bank));
163163
return 1;
164164
}
165-
165+
166166
/**
167167
* Returns 'true' if the [Player] has a quest for the item entry specified, 'false' otherwise.
168168
*
@@ -176,7 +176,7 @@ namespace LuaPlayer
176176
E->Push(player->HasQuestForItem(entry));
177177
return 1;
178178
}
179-
179+
180180
/**
181181
* Returns 'true' if the [Player] can use the item or item entry specified, 'false' otherwise.
182182
*
@@ -420,7 +420,7 @@ namespace LuaPlayer
420420
return 1;
421421
}
422422
#endif
423-
423+
424424
/**
425425
* Returns 'true' if the [Player] is immune to everything.
426426
*
@@ -1281,7 +1281,7 @@ namespace LuaPlayer
12811281
E->Push(player->GetItemByEntry(entry));
12821282
return 1;
12831283
}
1284-
1284+
12851285
/**
12861286
* Returns the database textID of the [WorldObject]'s gossip header text for the [Player]
12871287
*
@@ -1349,7 +1349,7 @@ namespace LuaPlayer
13491349
E->Push(player->GetTeamId());
13501350
return 1;
13511351
}
1352-
1352+
13531353
/**
13541354
* Returns amount of the specified [Item] the [Player] has.
13551355
*
@@ -1488,7 +1488,7 @@ namespace LuaPlayer
14881488
E->Push(player->GetSession()->GetSessionDbcLocale());
14891489
return 1;
14901490
}
1491-
1491+
14921492
/**
14931493
* Locks the player controls and disallows all movement and casting.
14941494
*
@@ -1947,7 +1947,7 @@ namespace LuaPlayer
19471947
return 0;
19481948
}
19491949
#endif
1950-
1950+
19511951
/**
19521952
* Shows the mailbox window to the player from specified guid.
19531953
*
@@ -2132,7 +2132,7 @@ namespace LuaPlayer
21322132
player->GetSession()->SendShowBank(obj->GET_GUID());
21332133
return 0;
21342134
}
2135-
2135+
21362136
/**
21372137
* Sends a vendor window to the [Player] from the [WorldObject] specified.
21382138
*
@@ -2891,7 +2891,7 @@ namespace LuaPlayer
28912891
player->AutoUnequipOffhandIfNeed();
28922892
return 1;
28932893
}
2894-
2894+
28952895
/**
28962896
* Returns true if the player can equip the given [Item] or item entry to the given slot, false otherwise.
28972897
*
@@ -3041,7 +3041,7 @@ namespace LuaPlayer
30413041
player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, currentKills + val);
30423042
return 0;
30433043
}
3044-
3044+
30453045
/**
30463046
* Adds the given amount of the specified item entry to the player.
30473047
*
@@ -3057,7 +3057,7 @@ namespace LuaPlayer
30573057
E->Push(player->StoreNewItemInInventorySlot(itemId, itemCount));
30583058
return 1;
30593059
}
3060-
3060+
30613061
/**
30623062
* Removes the given amount of the specified [Item] from the player.
30633063
*
@@ -3319,9 +3319,9 @@ namespace LuaPlayer
33193319
/**
33203320
* Adds a new item to the gossip menu shown to the [Player] on next call to [Player:GossipSendMenu].
33213321
*
3322-
* sender and intid are numbers which are passed directly to the gossip selection handler. Internally they are partly used for the database gossip handling.
3323-
* code specifies whether to show a box to insert text to. The player inserted text is passed to the gossip selection handler.
3324-
* money specifies an amount of money the player needs to have to click the option. An error message is shown if the player doesn't have enough money.
3322+
* sender and intid are numbers which are passed directly to the gossip selection handler. Internally they are partly used for the database gossip handling.
3323+
* code specifies whether to show a box to insert text to. The player inserted text is passed to the gossip selection handler.
3324+
* money specifies an amount of money the player needs to have to click the option. An error message is shown if the player doesn't have enough money.
33253325
* Note that the money amount is only checked client side and is not removed from the player either. You will need to check again in your code before taking action.
33263326
*
33273327
* See also: [Player:GossipSendMenu], [Player:GossipAddQuests], [Player:GossipComplete], [Player:GossipClearMenu]
@@ -3351,6 +3351,24 @@ namespace LuaPlayer
33513351
return 0;
33523352
}
33533353

3354+
/**
3355+
* Adds a new item that acts as a response to which are chosen from a gossip menu shown to the [Player].
3356+
*
3357+
* See also: [Player:GossipMenuAddItem], [Player:GossipSendMenu], [Player:GossipAddQuests], [Player:GossipComplete], [Player:GossipClearMenu]
3358+
*
3359+
* @param int32 action_menu : number that specifies which gossip menu to show next, or negative to close the current one
3360+
* @param uint32 action_poi : number that specifies which point of interest to send players to
3361+
* @param uint32 action_script : number that specifies a script to start
3362+
*/
3363+
int GossipMenuAddItemData(Eluna* E, Player* player)
3364+
{
3365+
int32 action_menu = E->CHECKVAL<int32>(2);
3366+
uint32 action_poi = E->CHECKVAL<uint32>(3);
3367+
uint32 action_script = E->CHECKVAL<uint32>(4);
3368+
player->PlayerTalkClass->GetGossipMenu().AddMenuItemData(action_menu, action_poi, action_script);
3369+
return 0;
3370+
}
3371+
33543372
/**
33553373
* Closes the [Player]s currently open Gossip Menu.
33563374
*
@@ -3394,7 +3412,7 @@ namespace LuaPlayer
33943412
* Clears the [Player]s current gossip item list.
33953413
*
33963414
* See also: [Player:GossipMenuAddItem], [Player:GossipSendMenu], [Player:GossipAddQuests], [Player:GossipComplete]
3397-
*
3415+
*
33983416
* Note: This is needed when you show a gossip menu without using gossip hello or select hooks which do this automatically.
33993417
* Usually this is needed when using [Player] is the sender of a Gossip Menu.
34003418
*/
@@ -3635,7 +3653,7 @@ namespace LuaPlayer
36353653
return 0;
36363654
}
36373655
#endif
3638-
3656+
36393657
ElunaRegister<Player> PlayerMethods[] =
36403658
{
36413659
// Getters
@@ -3843,6 +3861,7 @@ namespace LuaPlayer
38433861

38443862
// Gossip
38453863
{ "GossipMenuAddItem", &LuaPlayer::GossipMenuAddItem },
3864+
{ "GossipMenuAddItemData", &LuaPlayer::GossipMenuAddItemData },
38463865
{ "GossipSendMenu", &LuaPlayer::GossipSendMenu },
38473866
{ "GossipComplete", &LuaPlayer::GossipComplete },
38483867
{ "GossipClearMenu", &LuaPlayer::GossipClearMenu },

methods/TrinityCore/PlayerMethods.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ namespace LuaPlayer
16201620

16211621
/**
16221622
* Returns the closest [GameObject] to the [Player].
1623-
*
1623+
*
16241624
* @return [GameObject] gameobject
16251625
*/
16261626
int GetNearbyGameObject(Eluna* E, Player* player)
@@ -2070,7 +2070,7 @@ namespace LuaPlayer
20702070
* @values [MOVE_UNROOT, 2]
20712071
* @values [MOVE_WATER_WALK, 3]
20722072
* @values [MOVE_LAND_WALK, 4]
2073-
*
2073+
*
20742074
* @param int32 movementType
20752075
*/
20762076
int SetMovement(Eluna* E, Player* player)
@@ -3873,7 +3873,7 @@ namespace LuaPlayer
38733873
*
38743874
* @param int saveMode = -1
38753875
* @param bool returnReagent = false
3876-
*
3876+
*
38773877
*/
38783878
int RemovePet(Eluna* E, Player* player)
38793879
{
@@ -4074,6 +4074,7 @@ namespace LuaPlayer
40744074

40754075
// Gossip
40764076
{ "GossipMenuAddItem", &LuaPlayer::GossipMenuAddItem },
4077+
{ "GossipMenuAddItemData", METHOD_REG_NONE }, // not implemented
40774078
{ "GossipSendMenu", &LuaPlayer::GossipSendMenu },
40784079
{ "GossipComplete", &LuaPlayer::GossipComplete },
40794080
{ "GossipClearMenu", &LuaPlayer::GossipClearMenu },

0 commit comments

Comments
 (0)