Changeset 163
- Timestamp:
- 11/19/08 13:42:06 (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Chat.cpp
r149 r163 103 103 { "standstate", SEC_GAMEMASTER, false, &ChatHandler::HandleStandStateCommand, "", NULL }, 104 104 { "morph", SEC_GAMEMASTER, false, &ChatHandler::HandleMorphCommand, "", NULL }, 105 { "gender", SEC_ADMINISTRATOR, false, &ChatHandler::HandleModifyGenderCommand, "", NULL }, 105 106 { NULL, 0, false, NULL, "", NULL } 106 107 }; … … 284 285 { NULL, 0, false, NULL, "", NULL } 285 286 }; 287 288 static ChatCommand petCommandTable[] = 289 { 290 { "create", SEC_GAMEMASTER, false, &ChatHandler::HandleCreatePetCommand, "", NULL }, 291 { "learn", SEC_GAMEMASTER, false, &ChatHandler::HandlePetLearnCommand, "", NULL }, 292 { "unlearn", SEC_GAMEMASTER, false, &ChatHandler::HandlePetUnlearnCommand, "", NULL }, 293 { "tp", SEC_GAMEMASTER, false, &ChatHandler::HandlePetTpCommand, "", NULL }, 294 { NULL, 0, false, NULL, "", NULL } 295 }; 296 286 297 287 298 static ChatCommand groupCommandTable[] = … … 421 432 { "move", SEC_GAMEMASTER, false, &ChatHandler::HandleMoveObjectCommand, "", NULL }, 422 433 { "near", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNearObjectCommand, "", NULL }, 434 { "activate", SEC_GAMEMASTER, false, &ChatHandler::HandleActivateObjectCommand, "", NULL }, 423 435 { NULL, 0, false, NULL, "", NULL } 424 436 }; … … 476 488 { "instance", SEC_ADMINISTRATOR, true, NULL, "", instanceCommandTable }, 477 489 { "server", SEC_ADMINISTRATOR, true, NULL, "", serverCommandTable }, 490 { "pet", SEC_GAMEMASTER, false, NULL, "", petCommandTable }, 478 491 479 492 { "aura", SEC_ADMINISTRATOR, false, &ChatHandler::HandleAuraCommand, "", NULL }, … … 541 554 { "chardelete", SEC_CONSOLE, true, &ChatHandler::HandleCharacterDeleteCommand, "", NULL }, 542 555 { "sendmessage", SEC_ADMINISTRATOR, true, &ChatHandler::HandleSendMessageCommand, "", NULL }, 556 { "playall", SEC_ADMINISTRATOR, false, &ChatHandler::HandlePlayAllCommand, "", NULL }, 543 557 { "repairitems", SEC_GAMEMASTER, false, &ChatHandler::HandleRepairitemsCommand, "", NULL }, 544 558 { "freeze", SEC_ADMINISTRATOR, false, &ChatHandler::HandleFreezeCommand, "", NULL }, -
trunk/src/game/Chat.h
r149 r163 350 350 bool HandleLinkGraveCommand(const char* args); 351 351 bool HandleNearGraveCommand(const char* args); 352 bool HandleActivateObjectCommand(const char* args); 352 353 bool HandleSpawnTransportCommand(const char* args); 353 354 bool HandleExploreCheatCommand(const char* args); … … 361 362 bool HandleAddItemCommand(const char* args); 362 363 bool HandleAddItemSetCommand(const char* args); 364 bool HandleModifyGenderCommand(const char* args); 365 bool HandlePetTpCommand(const char* args); 366 bool HandlePetUnlearnCommand(const char* args); 367 bool HandlePetLearnCommand(const char* args); 368 bool HandleCreatePetCommand(const char* args); 363 369 364 370 bool HandleGroupLeaderCommand(const char* args); … … 425 431 bool HandleCharDeleteCommand(const char *args); 426 432 bool HandleSendMessageCommand(const char * args); 433 bool HandlePlayAllCommand(const char* args); 427 434 bool HandleRepairitemsCommand(const char* args); 428 435 bool HandleFlushArenaPointsCommand(const char *args); -
trunk/src/game/Language.h
r149 r163 729 729 LANG_INSTANCE_MUST_RAID_GRP = 5007, 730 730 LANG_INSTANCE_NOT_AS_GHOST = 5008, 731 LANG_COMMAND_PLAYED_TO_ALL = 5009, 731 732 // Room for more Trinity strings 5009-9999 732 733 -
trunk/src/game/Level2.cpp
r149 r163 4128 4128 return true; 4129 4129 } 4130 4131 bool ChatHandler::HandleCreatePetCommand(const char* args) 4132 { 4133 Player *player = m_session->GetPlayer(); 4134 Creature *creatureTarget = getSelectedCreature(); 4135 4136 CreatureInfo const* cInfo = objmgr.GetCreatureTemplate(creatureTarget->GetEntry()); 4137 // Creatures with family 0 crashes the server 4138 if(cInfo->family == 0) 4139 { 4140 PSendSysMessage("This creature cannot be tamed. (family id: 0)."); 4141 SetSentErrorMessage(true); 4142 return false; 4143 } 4144 4145 if(player->GetPetGUID()) 4146 { 4147 PSendSysMessage("You already have a pet"); 4148 SetSentErrorMessage(true); 4149 return false; 4150 } 4151 4152 if(!creatureTarget || creatureTarget->isPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER) 4153 { 4154 PSendSysMessage(LANG_SELECT_CREATURE); 4155 SetSentErrorMessage(true); 4156 return false; 4157 } 4158 4159 // Everything looks OK, create new pet 4160 Pet* pet = new Pet(HUNTER_PET); 4161 4162 if(!pet->CreateBaseAtCreature(creatureTarget)) 4163 { 4164 delete pet; 4165 PSendSysMessage("Error 1"); 4166 return false; 4167 } 4168 4169 creatureTarget->setDeathState(JUST_DIED); 4170 creatureTarget->RemoveCorpse(); 4171 creatureTarget->SetHealth(0); // just for nice GM-mode view 4172 4173 pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, player->GetGUID()); 4174 pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID()); 4175 pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction()); 4176 4177 if(!pet->InitStatsForLevel(creatureTarget->getLevel())) 4178 { 4179 sLog.outError("ERROR: InitStatsForLevel() in EffectTameCreature failed! Pet deleted."); 4180 PSendSysMessage("Error 2"); 4181 return false; 4182 } 4183 4184 // prepare visual effect for levelup 4185 pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1); 4186 4187 pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true); 4188 // this enables pet details window (Shift+P) 4189 pet->AIM_Initialize(); 4190 pet->InitPetCreateSpells(); 4191 pet->SetHealth(pet->GetMaxHealth()); 4192 4193 MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet); 4194 4195 // visual effect for levelup 4196 pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()); 4197 4198 player->SetPet(pet); 4199 pet->SavePetToDB(PET_SAVE_AS_CURRENT); 4200 player->PetSpellInitialize(); 4201 4202 return true; 4203 } 4204 4205 bool ChatHandler::HandlePetLearnCommand(const char* args) 4206 { 4207 if(!*args) 4208 return false; 4209 4210 Player *plr = m_session->GetPlayer(); 4211 Pet *pet = plr->GetPet(); 4212 4213 if(!pet) 4214 { 4215 PSendSysMessage("You have no pet"); 4216 SetSentErrorMessage(true); 4217 return false; 4218 } 4219 4220 uint32 spellId = extractSpellIdFromLink((char*)args); 4221 4222 if(!spellId || !sSpellStore.LookupEntry(spellId)) 4223 return false; 4224 4225 // Check if pet already has it 4226 if(pet->HasSpell(spellId)) 4227 { 4228 PSendSysMessage("Pet already has spell: %u", spellId); 4229 SetSentErrorMessage(true); 4230 return false; 4231 } 4232 4233 // Check if spell is valid 4234 SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); 4235 if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo)) 4236 { 4237 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spellId); 4238 SetSentErrorMessage(true); 4239 return false; 4240 } 4241 4242 pet->learnSpell(spellId); 4243 4244 PSendSysMessage("Pet has learned spell %u", spellId); 4245 return true; 4246 } 4247 4248 bool ChatHandler::HandlePetUnlearnCommand(const char *args) 4249 { 4250 if(!*args) 4251 return false; 4252 4253 Player *plr = m_session->GetPlayer(); 4254 Pet *pet = plr->GetPet(); 4255 4256 if(!pet) 4257 { 4258 PSendSysMessage("You have no pet"); 4259 SetSentErrorMessage(true); 4260 return false; 4261 } 4262 4263 uint32 spellId = extractSpellIdFromLink((char*)args); 4264 4265 if(pet->HasSpell(spellId)) 4266 pet->removeSpell(spellId); 4267 else 4268 PSendSysMessage("Pet doesn't have that spell"); 4269 4270 return true; 4271 } 4272 4273 bool ChatHandler::HandlePetTpCommand(const char *args) 4274 { 4275 if(!*args) 4276 return false; 4277 4278 Player *plr = m_session->GetPlayer(); 4279 Pet *pet = plr->GetPet(); 4280 4281 if(!pet) 4282 { 4283 PSendSysMessage("You have no pet"); 4284 SetSentErrorMessage(true); 4285 return false; 4286 } 4287 4288 uint32 tp = atol(args); 4289 4290 pet->SetTP(tp); 4291 4292 PSendSysMessage("Pet's tp changed to %u", tp); 4293 return true; 4294 } 4295 4296 bool ChatHandler::HandleActivateObjectCommand(const char *args) 4297 { 4298 if(!*args) 4299 return false; 4300 4301 char* cId = extractKeyFromLink((char*)args,"Hgameobject"); 4302 if(!cId) 4303 return false; 4304 4305 uint32 lowguid = atoi(cId); 4306 if(!lowguid) 4307 return false; 4308 4309 GameObject* obj = NULL; 4310 4311 // by DB guid 4312 if (GameObjectData const* go_data = objmgr.GetGOData(lowguid)) 4313 obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); 4314 4315 if(!obj) 4316 { 4317 PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); 4318 SetSentErrorMessage(true); 4319 return false; 4320 } 4321 4322 // Activate 4323 obj->SetLootState(GO_READY); 4324 obj->UseDoorOrButton(10000); 4325 4326 PSendSysMessage("Object activated!"); 4327 4328 return true; 4329 } -
trunk/src/game/Level3.cpp
r149 r163 6227 6227 } 6228 6228 6229 bool ChatHandler::HandlePlayAllCommand(const char* args) 6230 { 6231 if(!*args) 6232 return false; 6233 6234 uint32 soundId = atoi((char*)args); 6235 6236 if(!sSoundEntriesStore.LookupEntry(soundId)) 6237 { 6238 PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId); 6239 SetSentErrorMessage(true); 6240 return false; 6241 } 6242 6243 WorldPacket data(SMSG_PLAY_SOUND, 4); 6244 data << uint32(soundId) << m_session->GetPlayer()->GetGUID(); 6245 sWorld.SendGlobalMessage(&data); 6246 6247 PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId); 6248 return true; 6249 } 6250 6251 bool ChatHandler::HandleModifyGenderCommand(const char *args) 6252 { 6253 if(!*args) return false; 6254 Player *player = getSelectedPlayer(); 6255 6256 if(!player) 6257 { 6258 PSendSysMessage(LANG_NO_PLAYER); 6259 SetSentErrorMessage(true); 6260 return false; 6261 } 6262 6263 std::string gender = (char*)args; 6264 uint32 displayId = player->GetNativeDisplayId(); 6265 6266 if(gender == "male") // MALE 6267 { 6268 if(player->getGender() == GENDER_MALE) 6269 { 6270 PSendSysMessage("%s is already male", player->GetName()); 6271 SetSentErrorMessage(true); 6272 return false; 6273 } 6274 6275 // Set gender 6276 player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_MALE); 6277 // Change display ID 6278 player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); 6279 player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); 6280 6281 ChatHandler(player).PSendSysMessage("Gender changed. You are now a man!"); 6282 PSendSysMessage("Gender changed for %s", player->GetName()); 6283 return true; 6284 } 6285 else if(gender == "female") // FEMALE 6286 { 6287 if(player->getGender() == GENDER_FEMALE) 6288 { 6289 PSendSysMessage("%s is already female", player->GetName()); 6290 SetSentErrorMessage(true); 6291 return false; 6292 } 6293 6294 // Set gender 6295 player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_FEMALE); 6296 // Change display ID 6297 player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); 6298 player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); 6299 6300 ChatHandler(player).PSendSysMessage("Gender changed. You are now a woman!"); 6301 PSendSysMessage("Gender changed for %s", player->GetName()); 6302 return true; 6303 } 6304 else 6305 { 6306 PSendSysMessage("You must use male or female as gender."); 6307 SetSentErrorMessage(true); 6308 return false; 6309 } 6310 6311 return true; 6312 } 6313 6229 6314 bool ChatHandler::HandleFreezeCommand(const char *args) 6230 6315 {