Scripts/Commands: Small QoL adjustments

This commit is contained in:
Aokromes committed 2016-05-15 07:13:07 +02:00
1 parent 3ba6ba19a4
commit e4eb3c841c
12 files changed
+912 -65

No files matched your search

+80 -37
View File
@@ -222,14 +222,15 @@ public:
{ "whisper", rbac::RBAC_PERM_COMMAND_NPC_WHISPER, false, &HandleNpcWhisperCommand, "" },
{ "yell", rbac::RBAC_PERM_COMMAND_NPC_YELL, false, &HandleNpcYellCommand, "" },
{ "tame", rbac::RBAC_PERM_COMMAND_NPC_TAME, false, &HandleNpcTameCommand, "" },
{ "add", rbac::RBAC_PERM_COMMAND_NPC_ADD, false, NULL, "", npcAddCommandTable },
{ "delete", rbac::RBAC_PERM_COMMAND_NPC_DELETE, false, NULL, "", npcDeleteCommandTable },
{ "follow", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, false, NULL, "", npcFollowCommandTable },
{ "set", rbac::RBAC_PERM_COMMAND_NPC_SET, false, NULL, "", npcSetCommandTable },
{ "add", rbac::RBAC_PERM_COMMAND_NPC_ADD, false, nullptr, "", npcAddCommandTable },
{ "delete", rbac::RBAC_PERM_COMMAND_NPC_DELETE, false, nullptr, "", npcDeleteCommandTable },
{ "follow", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, false, nullptr, "", npcFollowCommandTable },
{ "set", rbac::RBAC_PERM_COMMAND_NPC_SET, false, nullptr, "", npcSetCommandTable },
{ "evade", rbac::RBAC_PERM_COMMAND_NPC_EVADE, false, &HandleNpcEvadeCommand, "" },
};
static std::vector<ChatCommand> commandTable =
{
{ "npc", rbac::RBAC_PERM_COMMAND_NPC, false, NULL, "", npcCommandTable },
{ "npc", rbac::RBAC_PERM_COMMAND_NPC, false, nullptr, "", npcCommandTable },
};
return commandTable;
}
@@ -326,17 +327,17 @@ public:
uint32 itemId = item_int;
char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0
char* fmaxcount = strtok(nullptr, " "); //add maxcount, default: 0
uint32 maxcount = 0;
if (fmaxcount)
maxcount = atoul(fmaxcount);
char* fincrtime = strtok(NULL, " "); //add incrtime, default: 0
char* fincrtime = strtok(nullptr, " "); //add incrtime, default: 0
uint32 incrtime = 0;
if (fincrtime)
incrtime = atoul(fincrtime);
char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0
char* fextendedcost = strtok(nullptr, " "); //add ExtendedCost, default: 0
uint32 extendedcost = fextendedcost ? atoul(fextendedcost) : 0;
Creature* vendor = handler->getSelectedCreature();
if (!vendor)
@@ -369,7 +370,7 @@ public:
return false;
char* guidStr = strtok((char*)args, " ");
char* waitStr = strtok((char*)NULL, " ");
char* waitStr = strtok((char*)nullptr, " ");
ObjectGuid::LowType lowGuid = atoi((char*)guidStr);
@@ -454,36 +455,24 @@ public:
}
Creature* creature = handler->getSelectedCreature();
if (!creature)
if (!creature || creature->IsPet())
{
handler->SendSysMessage(LANG_SELECT_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
if (creature->IsPet())
{
if (((Pet*)creature)->getPetType() == HUNTER_PET)
{
creature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr->GetXPForLevel(lvl)/4);
creature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
}
((Pet*)creature)->GivePetLevel(lvl);
}
else
{
creature->SetMaxHealth(100 + 30*lvl);
creature->SetHealth(100 + 30*lvl);
creature->SetLevel(lvl);
creature->SaveToDB();
}
creature->SetMaxHealth(100 + 30*lvl);
creature->SetHealth(100 + 30*lvl);
creature->SetLevel(lvl);
creature->SaveToDB();
return true;
}
static bool HandleNpcDeleteCommand(ChatHandler* handler, char const* args)
{
Creature* unit = NULL;
Creature* unit = nullptr;
if (*args)
{
@@ -638,7 +627,7 @@ public:
return false;
char* arg1 = strtok((char*)args, " ");
char* arg2 = strtok((char*)NULL, "");
char* arg2 = strtok((char*)nullptr, "");
if (!arg1 || !arg2)
return false;
@@ -936,8 +925,8 @@ public:
// later switched on/off according to special events (like escort
// quests, etc)
char* guid_str = strtok((char*)args, " ");
char* type_str = strtok((char*)NULL, " ");
char* dontdel_str = strtok((char*)NULL, " ");
char* type_str = strtok((char*)nullptr, " ");
char* dontdel_str = strtok((char*)nullptr, " ");
bool doNotDelete = false;
@@ -945,7 +934,7 @@ public:
return false;
ObjectGuid::LowType lowguid = 0;
Creature* creature = NULL;
Creature* creature = nullptr;
if (dontdel_str)
{
@@ -971,7 +960,7 @@ public:
{
//TC_LOG_ERROR("misc", "DEBUG: type_str, NODEL ");
doNotDelete = true;
type_str = NULL;
type_str = nullptr;
}
}
}
@@ -1011,7 +1000,7 @@ public:
}
// now lowguid is low guid really existed creature
// and creature point (maybe) to this creature or NULL
// and creature point (maybe) to this creature or nullptr
MovementGeneratorType move_type;
@@ -1295,7 +1284,7 @@ public:
}
char* receiver_str = strtok((char*)args, " ");
char* text = strtok(NULL, "");
char* text = strtok(nullptr, "");
if (!receiver_str || !text)
{
@@ -1354,7 +1343,16 @@ public:
if (!*args)
return false;
char* charID = handler->extractKeyFromLink((char*)args, "Hcreature_entry");
bool loot = false;
char const* spawntype_str = strtok((char*)args, " ");
char const* entry_str = strtok(nullptr, "");
if (stricmp(spawntype_str, "LOOT") == 0)
loot = true;
else if (stricmp(spawntype_str, "NOLOOT") == 0)
loot = false;
else
entry_str = args;
char* charID = handler->extractKeyFromLink((char*)entry_str, "Hcreature_entry");
if (!charID)
return false;
@@ -1367,7 +1365,7 @@ public:
if (!sObjectMgr->GetCreatureTemplate(id))
return false;
chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120);
chr->SummonCreature(id, *chr, loot ? TEMPSUMMON_CORPSE_TIMED_DESPAWN : TEMPSUMMON_CORPSE_DESPAWN, 30 * IN_MILLISECONDS);
return true;
}
@@ -1439,6 +1437,51 @@ public:
return true;
}
static bool HandleNpcEvadeCommand(ChatHandler* handler, char const* args)
{
Creature* creatureTarget = handler->getSelectedCreature();
if (!creatureTarget || creatureTarget->IsPet())
{
handler->PSendSysMessage(LANG_SELECT_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
if (!creatureTarget->IsAIEnabled)
{
handler->PSendSysMessage(LANG_CREATURE_NOT_AI_ENABLED);
handler->SetSentErrorMessage(true);
return false;
}
char* type_str = args ? strtok((char*)args, " ") : nullptr;
char* force_str = args ? strtok(nullptr, " ") : nullptr;
CreatureAI::EvadeReason why = CreatureAI::EVADE_REASON_OTHER;
bool force = false;
if (type_str)
{
if (stricmp(type_str, "NO_HOSTILES") == 0 || stricmp(type_str, "EVADE_REASON_NO_HOSTILES") == 0)
why = CreatureAI::EVADE_REASON_NO_HOSTILES;
else if (stricmp(type_str, "BOUNDARY") == 0 || stricmp(type_str, "EVADE_REASON_BOUNDARY") == 0)
why = CreatureAI::EVADE_REASON_BOUNDARY;
else if (stricmp(type_str, "SEQUENCE_BREAK") == 0 || stricmp(type_str, "EVADE_REASON_SEQUENCE_BREAK") == 0)
why = CreatureAI::EVADE_REASON_SEQUENCE_BREAK;
else if (stricmp(type_str, "FORCE") == 0)
force = true;
if (!force && force_str)
if (stricmp(force_str, "FORCE") == 0)
force = true;
}
if (force)
creatureTarget->ClearUnitState(UNIT_STATE_EVADE);
creatureTarget->AI()->EnterEvadeMode(why);
return true;
}
static bool HandleNpcAddFormationCommand(ChatHandler* handler, char const* args)
{
if (!*args)
@@ -1550,7 +1593,7 @@ public:
if (!pSlotID)
return false;
char* pItemID = strtok(NULL, " ");
char* pItemID = strtok(nullptr, " ");
if (!pItemID)
return false;