Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "utils.h"
- #include "char.h"
- #include "char_manager.h"
- #include "motion.h"
- #include "packet.h"
- #include "buffer_manager.h"
- #include "unique_item.h"
- #include "wedding.h"
- #define NEED_TARGET (1 << 0)
- #define NEED_PC (1 << 1)
- #define WOMAN_ONLY (1 << 2)
- #define OTHER_SEX_ONLY (1 << 3)
- #define SELF_DISARM (1 << 4)
- #define TARGET_DISARM (1 << 5)
- #define BOTH_DISARM (SELF_DISARM | TARGET_DISARM)
- struct emotion_type_s
- {
- const char * command;
- const char * command_to_client;
- long flag;
- float extra_delay;
- } emotion_types[] = {
- { "Ĺ°˝ş", "french_kiss", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, 2.0f },
- { "ȂȂ", "kiss", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, 1.5f },
- { "µű±Í", "slap", NEED_PC | SELF_DISARM, 1.5f },
- { "ąÚĽö", "clap", 0, 1.0f },
- { "żÍ", "cheer1", 0, 1.0f },
- { "¸¸ĽĽ", "cheer2", 0, 1.0f },
- // DANCE
- { "´í˝ş1", "dance1", 0, 1.0f },
- { "´í˝ş2", "dance2", 0, 1.0f },
- { "´í˝ş3", "dance3", 0, 1.0f },
- { "´í˝ş4", "dance4", 0, 1.0f },
- { "´í˝ş5", "dance5", 0, 1.0f },
- { "´í˝ş6", "dance6", 0, 1.0f },
- // END_OF_DANCE
- { "ĂŕÇĎ", "congratulation", 0, 1.0f },
- { "żëĽ", "forgive", 0, 1.0f },
- { "Čł˛", "angry", 0, 1.0f },
- { "ŔŻČ¤", "attractive", 0, 1.0f },
- { "˝˝ÇÄ", "sad", 0, 1.0f },
- { "şę˛ô", "shy", 0, 1.0f },
- { "ŔŔżř", "cheerup", 0, 1.0f },
- { "ÁúĹő", "banter", 0, 1.0f },
- { "±â»Ý", "joy", 0, 1.0f },
- { "\n", "\n", 0, 0.0f },
- /*
- //{ "Ĺ°˝ş", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, MOTION_ACTION_FRENCH_KISS, 1.0f },
- { "ȂȂ", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, MOTION_ACTION_KISS, 1.0f },
- { "˛¸ľČ±â", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, MOTION_ACTION_SHORT_HUG, 1.0f },
- { "Ć÷żË", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, MOTION_ACTION_LONG_HUG, 1.0f },
- { "ľî±úµżą«", NEED_PC | SELF_DISARM, MOTION_ACTION_PUT_ARMS_SHOULDER, 0.0f },
- { "ĆČÂŻ", NEED_PC | WOMAN_ONLY | SELF_DISARM, MOTION_ACTION_FOLD_ARM, 0.0f },
- { "µű±Í", NEED_PC | SELF_DISARM, MOTION_ACTION_SLAP, 1.5f },
- { "ČÖĆĶ÷", 0, MOTION_ACTION_CHEER_01, 0.0f },
- { "¸¸ĽĽ", 0, MOTION_ACTION_CHEER_02, 0.0f },
- { "ąÚĽö", 0, MOTION_ACTION_CHEER_03, 0.0f },
- { "ČŁČŁ", 0, MOTION_ACTION_LAUGH_01, 0.0f },
- { "űű", 0, MOTION_ACTION_LAUGH_02, 0.0f },
- { "żěÇĎÇĎ", 0, MOTION_ACTION_LAUGH_03, 0.0f },
- { "ľűľű", 0, MOTION_ACTION_CRY_01, 0.0f },
- { "ČćČć", 0, MOTION_ACTION_CRY_02, 0.0f },
- { "Ŕλç", 0, MOTION_ACTION_GREETING_01, 0.0f },
- { "ąŮŔĚ", 0, MOTION_ACTION_GREETING_02, 0.0f },
- { "Á¤ÁßŔλç", 0, MOTION_ACTION_GREETING_03, 0.0f },
- { "şńł", 0, MOTION_ACTION_INSULT_01, 0.0f },
- { "¸đżĺ", SELF_DISARM, MOTION_ACTION_INSULT_02, 0.0f },
- { "żěŔˇ", 0, MOTION_ACTION_INSULT_03, 0.0f },
- { "°Ľżě¶×", 0, MOTION_ACTION_ETC_01, 0.0f },
- { "˛ô´ö˛ô´ö", 0, MOTION_ACTION_ETC_02, 0.0f },
- { "µµ¸®µµ¸®", 0, MOTION_ACTION_ETC_03, 0.0f },
- { "±ÜŔű±ÜŔű", 0, MOTION_ACTION_ETC_04, 0.0f },
- { "ơ", 0, MOTION_ACTION_ETC_05, 0.0f },
- { "»×", 0, MOTION_ACTION_ETC_06, 0.0f },
- */
- };
- std::set<std::pair<DWORD, DWORD> > s_emotion_set;
- ACMD(do_emotion_allow)
- {
- if ( ch->GetArena() )
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("´ë·ĂŔ忡Ľ »çżëÇĎ˝Ç Ľö ľř˝Ŕ´Ď´Ů."));
- return;
- }
- char arg1[256];
- one_argument(argument, arg1, sizeof(arg1));
- if (!*arg1)
- return;
- DWORD val = 0; str_to_number(val, arg1);
- s_emotion_set.insert(std::make_pair(ch->GetVID(), val));
- }
- bool CHARACTER_CanEmotion(CHARACTER& rch)
- {
- // °áČĄ˝Ä ¸ĘżˇĽ´Â »çżëÇŇ Ľö ŔÖ´Ů.
- if (marriage::WeddingManager::instance().IsWeddingMap(rch.GetMapIndex()))
- return true;
- // żÁ¤ŔÇ °ˇ¸é Âřżë˝Ă »çżëÇŇ Ľö ŔÖ´Ů.
- if (rch.IsEquipUniqueItem(UNIQUE_ITEM_EMOTION_MASK))
- return true;
- if (rch.IsEquipUniqueItem(UNIQUE_ITEM_EMOTION_MASK2))
- return true;
- return false;
- }
- ACMD(do_emotion)
- {
- int i;
- {
- if (ch->IsRiding())
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¸»Ŕ» Ĺş »óĹÂżˇĽ °¨Á¤ÇĄÇöŔ» ÇŇ Ľö ľř˝Ŕ´Ď´Ů."));
- return;
- }
- }
- for (i = 0; *emotion_types[i].command != '\n'; ++i)
- {
- if (!strcmp(cmd_info[cmd].command, emotion_types[i].command))
- break;
- if (!strcmp(cmd_info[cmd].command, emotion_types[i].command_to_client))
- break;
- }
- if (*emotion_types[i].command == '\n')
- {
- sys_err("cannot find emotion");
- return;
- }
- if (!CHARACTER_CanEmotion(*ch))
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("żÁ¤ŔÇ °ˇ¸éŔ» Âřżë˝Ăżˇ¸¸ ÇŇ Ľö ŔÖ˝Ŕ´Ď´Ů."));
- return;
- }
- if (IS_SET(emotion_types[i].flag, WOMAN_ONLY) && SEX_MALE==GET_SEX(ch))
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ż©ŔÚ¸¸ ÇŇ Ľö ŔÖ˝Ŕ´Ď´Ů."));
- return;
- }
- char arg1[256];
- one_argument(argument, arg1, sizeof(arg1));
- LPCHARACTER victim = NULL;
- if (*arg1)
- victim = ch->FindCharacterInView(arg1, IS_SET(emotion_types[i].flag, NEED_PC));
- if (IS_SET(emotion_types[i].flag, NEED_TARGET | NEED_PC))
- {
- if (!victim)
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("±×·± »ç¶÷ŔĚ ľř˝Ŕ´Ď´Ů."));
- return;
- }
- }
- if (victim)
- {
- if (!victim->IsPC() || victim == ch)
- return;
- if (victim->IsRiding())
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¸»Ŕ» Ĺş »ó´ëżÍ °¨Á¤ÇĄÇöŔ» ÇŇ Ľö ľř˝Ŕ´Ď´Ů."));
- return;
- }
- long distance = DISTANCE_APPROX(ch->GetX() - victim->GetX(), ch->GetY() - victim->GetY());
- if (distance < 10)
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("łĘą« °ˇ±îŔĚ ŔÖ˝Ŕ´Ď´Ů."));
- return;
- }
- if (distance > 500)
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("łĘą« ¸Ö¸® ŔÖ˝Ŕ´Ď´Ů"));
- return;
- }
- if (IS_SET(emotion_types[i].flag, OTHER_SEX_ONLY))
- {
- if (GET_SEX(ch)==GET_SEX(victim))
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ŔĚĽş°Łżˇ¸¸ ÇŇ Ľö ŔÖ˝Ŕ´Ď´Ů."));
- return;
- }
- }
- if (IS_SET(emotion_types[i].flag, NEED_PC))
- {
- if (s_emotion_set.find(std::make_pair(victim->GetVID(), ch->GetVID())) == s_emotion_set.end())
- {
- if (true == marriage::CManager::instance().IsMarried( ch->GetPlayerID() ))
- {
- const marriage::TMarriage* marriageInfo = marriage::CManager::instance().Get( ch->GetPlayerID() );
- const DWORD other = marriageInfo->GetOther( ch->GetPlayerID() );
- if (0 == other || other != victim->GetPlayerID())
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ŔĚ ÇൿŔş »óČŁµżŔÇ ÇĎżˇ °ˇ´É ÇŐ´Ď´Ů."));
- return;
- }
- }
- else
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ŔĚ ÇൿŔş »óČŁµżŔÇ ÇĎżˇ °ˇ´É ÇŐ´Ď´Ů."));
- return;
- }
- }
- s_emotion_set.insert(std::make_pair(ch->GetVID(), victim->GetVID()));
- }
- }
- char chatbuf[256+1];
- int len = snprintf(chatbuf, sizeof(chatbuf), "%s %u %u",
- emotion_types[i].command_to_client,
- (DWORD) ch->GetVID(), victim ? (DWORD) victim->GetVID() : 0);
- if (len < 0 || len >= (int) sizeof(chatbuf))
- len = sizeof(chatbuf) - 1;
- ++len; // \0 ą®ŔÚ Ć÷ÇÔ
- TPacketGCChat pack_chat;
- pack_chat.header = HEADER_GC_CHAT;
- pack_chat.size = sizeof(TPacketGCChat) + len;
- pack_chat.type = CHAT_TYPE_COMMAND;
- pack_chat.id = 0;
- TEMP_BUFFER buf;
- buf.write(&pack_chat, sizeof(TPacketGCChat));
- buf.write(chatbuf, len);
- ch->PacketAround(buf.read_peek(), buf.size());
- if (victim)
- sys_log(1, "ACTION: %s TO %s", emotion_types[i].command, victim->GetName());
- else
- sys_log(1, "ACTION: %s", emotion_types[i].command);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement