class npc_manager name npc_manager_1 class alias name alias ai_activity no_change ai_movement wander class npc_zone name npc_zone_2 class alias name alias bot_equipment CBODY : 1 2 3 4 5 6 bot_sheet_client clapclap class npc_group count 0 name grp_clapclaps class npc_group_parameters name parameters class alias name alias class npc_group_event_handler event timer_t1_triggered class alias name alias action multi_actions class npc_event_handler_action action code class npc_event_handler_action parameters ()import("script_BotClass"); computeBotDest(){ xp = x; yp = y; s = x2 - x1; r = y2 - y1; y = (r * s * (x2 - xp) + s * s * yp + r * r * y2)/(r * r + s * s); x = x2 + r * (y2 - y)/s; // $x = "x=" + x + " y=" + y; // ()phraseEndSystemMsg(0, "shout", $x); } computePlayerPos(){ $name = $prefix + "_fw"; (distance)npc_distance_helper.getBotIndexByName($name); (distance)npc_distance_helper.getPlayerDistance(distance, $playerEid); // ref x0 = 9240.785156; y0 = -10883.958984; // fw x1 = 9245.047852; y1 = -10886.433594; // nw x2 = 9234.597656; y2 = -10886.433594; r = distance * distance - x1 * x1 + x0 * x0 - y1 * y1 + y0 * y0; $name = $prefix + "_nw"; (distance)npc_distance_helper.getBotIndexByName($name); (distance)npc_distance_helper.getPlayerDistance(distance, $playerEid); s = distance * distance - x2 * x2 + x0 * x0 - y2 * y2 + y0 * y0; $name = $prefix + "_ref"; (distance)npc_distance_helper.getBotIndexByName($name); (distance)npc_distance_helper.getPlayerDistance(distance, $playerEid); distance *= distance; r = (r - distance)/2; s = (s - distance)/2; y = (s*(x0 - x1) - (x0 - x2)*r)/((y0 - y2)*(x0 - x1) - (y0 - y1)*(x0 - x2)); x = (r - (y0 - y1)*y)/(x0 - x1); } checkIfInZone(){ // return 0 if in zone - we reuse the distance variable to preserve the stack range = 50; // allow the max range from the fish playerInRange(); if(playerInRange_ret == 0){ ()phraseEndSystemMsg(0, "shout", "pas_glop_pas_glop"); BCP = 1; ()import("script_BotClassDelete"); deletePlayer(); } } doInitFishAnim(){ ()emote($playerEid, "firework_01"); ()setTimer(12, 1); } doLoopFishAnim(){ ()emote($playerEid, "firework_02"); ()setTimer(18, 1); } despawnPhase(){ ()wander(); ()import("script_BotClassDelete"); deleteBot(); ()setTimer(30, 1); ()despawn(1); v3 = 0; } doEndFishAnim(){ ()emote($playerEid, "firework_03"); ()setTimer(12, 1); } endOfFishing(){ if(tmp > 0.98){ // fish escape and vanish ()phraseEndSystemMsg(0, "shout", "the_fish_escapes_and_vanishes"); doEndFishAnim(); v1 = 1110; // end of fish } else { ()phraseEndSystemMsg(0, "shout", "the_fish_escapes"); v3 = 0; ()wander(); v1 = 1001; // restart to the fishing loop doInitFishAnim(); } } fishIsCatchable(){ // 1102 if(playerInRange_ret < 5 && tmp > 0.5){ ()setTimer(10, 1); v1 = 1103; } else { endOfFishing(); } } fishUnderCapture(){ // 1100/1101 - the fish is under capture if(tmp > 0.95){ endOfFishing(); } else { doLoopFishAnim(); if(playerInRange_ret < 5){ // the fish is near enough v1 = 1101; } else { v1 = 1100; } } } fishingloop(){ if(v3 == 0){ // if the fish is not biting at all (tmp)rndm(0, 1); // check if the fish is biting //$tmp = tmp; if(tmp > 0.75){ ()phraseEndSystemMsg(0, "shout", "the_fish_is_under_capture"); v1 = 1100; // set the catching phase v3 = 1; // the player 1 is catching the fish (will be 2 for player 2) computePlayerPos(); computeBotDest(); ()startMoving(x, y, 0); } else if(tmp > 0.68){ // change anim => initFish v1 = 1000; } } else if(tmp > 0.90){ // change anim => initFish v1 = 1000; } doLoopFishAnim(); } if(v0 != 0){ ($botEid)getBotEid(0); $currVar = $botEid + "_P11"; ($playerEid)getNamedEntityProp($currVar, "state"); // get current playerEid if(v1 < 1000){ // still checking initial requirements v1 = 1001; // start fishing doInitFishAnim(); } else { checkIfInZone(); if(playerInRange_ret > 0){ (tmp)rndm(0, 1); switch(v1){ case 1000:{ // initfish doInitFishAnim(); v1++; } case 1001: fishingloop(); case 1100: // fish is under capture and approaching fishUnderCapture(); case 1101: // fish is under capture and is near fishUnderCapture(); case 1102: // fish is catchable fishIsCatchable(); case 1103: // fish catched despawnPhase(); case 1110: // fish escapes despawnPhase(); } } else { if(v3 == 1){ v3 = 0; } } } } else { ()spawn(); } action condition_if class npc_event_handler_action name condition_if_fish_caught parameters v1 = 1103 action multi_actions class npc_event_handler_action action send_message class npc_event_handler_action name send_message_fish_caught parameters EGS mission_fish2 STOP_FISH_MISSION class npc_group_event_handler event player_target_npc class alias name alias action multi_actions class npc_event_handler_action action code class npc_event_handler_action parameters $botFamily = "CLAP1"; // bot family used for requirements $prefixActivity = "FISH"; // prefix for activity ()import("script_BotClassInit"); //$RCnReq = "1"; // $botFamily, $RCnReq => $RCisRequired, $RCsFamily, $RCminElement (returns "" when not found) //RCgetBotFamilyRequirement(); //()phraseEndSystemMsg(0, "shout", $RCsFamily); //()phraseEndSystemMsg(0, "shout", "1234"); //(@groupToNotify)context(); //()@groupToNotify.talkTo("mission_fish", @groupToNotify); class npc_group_event_handler event all_pets_arrived_from_stable class alias name alias action code class npc_event_handler_action parameters (@groupToNotify)context(); if(v0 != 0){ ($botEid)@groupToNotify.getBotEid(0); $currVar = $botEid + "_P11"; ($playerEid)@groupToNotify.getNamedEntityProp($currVar, "state"); // get current playerEid if(v1 < 1000){ // still checking initial requirements ()@groupToNotify.phraseEndSystemMsg(0, "shout", "check_initial_requirements"); v1 = 1001; // start fishing ()@groupToNotify.setTimer(15, 2); ()@groupToNotify.emote($playerEid, "firework_01"); ()@groupToNotify.phraseEndSystemMsg(0, "shout", "you_start_fishing"); } else { ()@groupToNotify.phraseEndSystemMsg(0, "shout", "ca_continue"); switch(v1){ case 1000:{ // initfish ()emote($playerEid, "firework_01"); ()@groupToNotify.setTimer(10, 2); v1++; } case 1001:{ // loopfish ()emote($playerEid, "firework_02"); ()@groupToNotify.setTimer(18, 2); if(v3 == 0){ // if the fish is not biting at all (v3)rndm(0, 1); // check if the fish is biting if(v3 > 0.75){ v1 = 1100; // set the catching phase } else { // the fish is not biting (v3)rndm(0, 1); if(v3 > 0.90){ // change anim => initFish v1 = 1000; } v3 = 0; } } else { // the fish is already biting (tmp)rndm(0, 1); if(tmp > 0.90){ // change anim => initFish v1 = 1000; } } } case 1100:{ // in catching phase (tmp)rndm(0, 1); if(tmp > 0.85){ // fish catched or escape if(tmp > 0.90){ // fish escape and vanish ()phraseEndSystemMsg(0, "shout", "we_catch_the_fish"); } else { ()phraseEndSystemMsg(0, "shout", "the_fish_escapes"); } ()import("script_BotClassDelete"); //deleteBot(); ()@groupToNotify.setTimer(30, 2); ()despawn(1); } else { ()emote($playerEid, "firework_02"); ()@groupToNotify.setTimer(18, 2); } } } } } else { ()spawn(); } class npc_bot name npc_bot_6 sheet_client clapclap class alias name alias auto_remove_from_journal true automatic true class mission_tree mono_instance true name mission_fish2 need_validation false phrase_auto_menu catch_the_fish3 replayable true run_only_once false class variables name variables class var_sbrick var_name sbrickMandatory class var_item item_sheet icrtfi var_name itemRod class var_item item_sheet mbait01 var_name itemBait class var_sbrick sbrick_sheet bfpafi01 var_name mission_owner_brick class pre_requisite name pre_requisite require_brick_knowledge $sbrickMandatory$ require_wearing_item $itemRod$;$itemBait$ class alias name alias class step name step_4 class actions name pre_actions class set_constrains timer 30 bricks $mission_owner_brick$ class learn_brick class ai_event event_number 5;$mission_owner_brick$ group_name grp_clapclaps class mission_objectives name objectives class wait_ai_msg msg_content STOP_FISH_MISSION_$mission_owner_brick$ name wait_ai_msg_STOP_FISH_MISSION overload_objective OVL_WAIT_MSG roleplay_objective RP_WAIT_MSG class actions name post_actions class destroy_item item/quantity/quality mbait01 chat_type tell class bot_chat phrase you_caught_the_fish class recv_item item/quantity/quality mpois02 1 200 bricks $mission_owner_brick$ class unlearn_brick class mission name mission_fish2 script # script generated from 'fisherman.primitive' #mission tags and pre-requisites replayable solo auto_remove auto : catch_the_fish3 #Variables declaration decl : bot : giver decl : bot : player decl : sbrick : decl : item : icrtfi decl : item : mbait01 #pre-requisites req_wear : icrtfi;mbait01 #script mission_title : mission_desc : # step_4 timer : 30 learn_brick : bfpafi01 ai_event : grp_clapclaps; 5 set_obj : OVL_WAIT_MSG set_obj_rp : RP_WAIT_MSG wait_msg : STOP_FISH_MISSION destroy_item : mbait01 bot_chat : tell : giver : you_caught_the_fish recv_item : mpois02 1 200 unlearn_brick : bfpafi01 class alias name alias class npc_group_event_handler event user_event_5 class alias name alias action multi_actions class npc_event_handler_action action code class npc_event_handler_action parameters ($msgName)getEventParam(0); // the msg name $msgName = "msgname=" + $msgName; ()phraseEndSystemMsg(0, "shout", $msgName); if(v3 != 0){ // fish under capture if(v1 == 1101){ // try to catch the fish v1 = 1102; } } class npc_event_handler event start_of_state name start_of_state_init_all class alias name alias action multi_actions class npc_event_handler_action action code class npc_event_handler_action name code_initAIRequirements parameters $prefixActivity = "FISH"; ()import("script_RequirementClassInit"); // $prefixActivity // add BRICK Family $RCsFamily = "BR1"; $RCsFamilyType = "B"; $RCsFamilyParam1 = ""; $RCsFamilyParam2 = ""; RCaddFamily(); // add ITEM 1 Family $RCsFamily = "IT1"; $RCsFamilyType = "I"; $RCsFamilyParam1 = ""; $RCsFamilyParam2 = ""; RCaddFamily(); // add ITEM 1 RCn = 1; $RCsElement = "icrtfi.sitem"; $RCsParam1 = "10"; // quality $RCsParam2 = ""; // extra RCaddElement(); // add other items from ITEM 1 Family // // add ITEM 2 Family $RCsFamily = "IT2"; $RCsFamilyType = "C"; // consumable $RCsFamilyParam1 = ""; $RCsFamilyParam2 = ""; RCaddFamily(); // add ITEM 2 RCn = "1"; $RCsElement = "mbait01.sitem"; $RCsParam1 = "10"; // quality $RCsParam2 = "200"; // duration RCaddElement(); // add other items from ITEM 1 Family // action code class npc_event_handler_action name code_initClapclapRequirements parameters $prefixActivity = "FISH"; $botFamily = "CLAP1"; ()import("script_RequirementClassInit"); // add requirement 1 for CLAPCLAP 1 (CLAP1) RCnReq = 1; // requirement 1 $RCsFamily = "IT1"; // Familly Item 1 $RCisRequired = "1"; // item equiped required $RCminElement = "1"; // min item level required in family RCaddBotFamilyRequirement(); // add requirement 2 for CLAPCLAP 1 (CLAP1) RCnReq = 2; // requirement 2 $RCsFamily = "IT2"; // Familly Item 2 $RCisRequired = "1"; // item equiped required $RCminElement = "1"; // min item level required in family RCaddBotFamilyRequirement(); // add other requirements for CLAPCLAP 1 (CLAP1) // ai_activity no_change ai_movement idle class npc_zone name npc_zone_4 class alias name alias class npc_group name npc_distance_helper class npc_group_parameters name parameters class alias name alias class npc_bot is_stuck true name npc_zone_2_nw sheet_client object_fisherman_fish_place class alias name alias class npc_bot is_stuck true name npc_zone_2_ref sheet_client object_fisherman_fish_place class alias name alias class npc_bot is_stuck true name npc_zone_2_fw sheet_client object_fisherman_fish_place class alias name alias class script_rep name script_others class script code initBot(){ $botNELVar = $botNELPrefix + "P1"; ()setNelVar($botNELVar, ""); $botNELVar = $botNELPrefix + "P2"; ()setNelVar($botNELVar, ""); $botNELVar = $botNELPrefix + "BR"; ()setNelVar($botNELVar, $requiredBrick); $botNELVar = $botNELPrefix + "I1"; ()setNelVar($botNELVar, $requiredItem1); $botNELVar = $botNELPrefix + "I2"; ()setNelVar($botNELVar, $requiredItem2); } closeFish(){ ()delNelVar("BotCount", 0); ()delNelVar("BotCount", 0); v0 = 0; v1 = 0; v2 = 0; v3 = 0; } initAll(){ $botNELVar = "FISHBRN"; // init brick family count ()setNelVar($botNELVar, 0); $botNELVar = "FISHIT1N"; // init item1 family count ()setNelVar($botNELVar, 0); $botNELVar = "FISHIT2N"; // init item2 family count ()setNelVar($botNELVar, 0); } addFamily(){ $botNELVar = "FISH" + $type_family + "F"; // family count (n)getNelVar($botNELVar); n = n + 1; ()setNelVar($botNELVar, n); // incr family count $botNELVar = "FISH" + $type_family + "F" + n; // init element count in family ()setNelVar($botNELVar, 0); } addBRFamily(){ $type_family = "BR"; addFamily(); } addIT1Family(){ $type_family = "IT1"; addFamily(); } addIT2Family(){ $type_family = "IT2"; addFamily(); } addElement(){ $botNELVar = "FISH" + $type_family + "F" + nFamily; // get element count in family (n)getNelVar($botNELVar); n = n + 1; ()setNelVar($botNELVar, n); // incr family count $botNELVar = $botNELVar + "_" + n; ()setNelVar($botNELVar, $element); // set element } // param: nFamily $element addBRElement(){ $type_family = "BR"; addElement(); } // param: nFamily $element addIT1Element(){ $type_family = "IT1"; addElement(); } // param: nFamily $element addIT2Element(){ $type_family = "IT2"; addElement(); } (@groupToNotify)context(); ($botEid)getBotEid(0); $botNELPrefix = "FISH" + $botEid; name script_initFish class alias name alias class script code ()import("script_fishCommon"); addPlayerToFishList(){ $botNELVar = $botNELPrefix + "P1"; ($playerEid1)getNelVar($botNELVar); $botNELVar = $botNELPrefix + "P2"; ($playerEid2)getNelVar($botNELVar); if($playerEid1 != $playerEid){ if($playerEid2 != $playerEid){ // the player we are trying to add is not already in fish list $playerInRange_Eid = $playerEid; playerInRange(); if(playerInRange_ret == 1){ // if the player we are trying to add is in range if($playerEid1 == ""){ // add the player in the first slot if empty $botNELVar = $botNELPrefix + "P1"; ()setNelVar($botNELVar, $playerEid); v1 = 0; // current Anim - not playing at the moment v0 = 0; // fish is not under capture nextFishUserEvent(); // fire fish userevent 4 ()@groupToNotify.phraseEndSystemMsg(0, "shout", "et_je_peche"); } else if($playerEid2 == ""){ // add the player in the second slot if empty $botNELVar = $botNELPrefix + "P2"; ()setNelVar($botNELVar, $playerEid); v2 = 0; // current Anim - not playing at the moment v3 = 0; // fish is not under capture nextFishUserEvent(); // fire fish userevent 4 } else { ()@groupToNotify.phraseEndSystemMsg(0, "shout", "p1_p2"); } } } else { ()@groupToNotify.phraseEndSystemMsg(0, "shout", "p2"); } } else { ()@groupToNotify.phraseEndSystemMsg(0, "shout", "p1"); } } (@groupToNotify)context(); ($botEid)getBotEid(0); $botNELPrefix = "FISH" + $botEid; ($playerEid)getCurrentPlayerEid(); addPlayerToFishList(); name script_playerStartFishing class alias name alias class script code playerInRange(){ playerInRange_ret = 0; (distance)getPlayerDistance(0, $playerInRange_Eid); if(distance >= 0){ if(distance <= 50){ playerInRange_ret = 1; } } } getPlayerIndex(){ getPlayerIndex_ret = 0; $botNELVar = $botNELPrefix + "P1"; ($botNELVar)getNelVar($botNELVar); if($botNELVar == $playerEid){ getPlayerIndex_ret = 1; } else { $botNELVar = $botNELPrefix + "P2"; ($botNELVar)getNelVar($botNELVar); if($botNELVar == $playerEid){ getPlayerIndex_ret = 2; } } } nextFishUserEvent(){ nextFishUserEvent_ret = 0; if($msgName == ""){ $botNELVar = $botNELPrefix + "BR"; ($required)getNelVar($botNELVar); if($required == ""){ // no item1 to check $msgName = "0"; // prepare to check the next one } else { // check brick ()queryEgs("IsInInventory", $playerEid, $required, @groupToNotify, 4, "0"); } } if($msgName == "0"){ $botNELVar = $botNELPrefix + "I1"; ($required)getNelVar($botNELVar); if($required == ""){ // no item1 to check $msgName = "1"; // prepare to check the next one } else { // check item 1 ()queryEgs("IsInInventory", $playerEid, $required, @groupToNotify, 4, "1"); } } if($msgName == "1"){ $botNELVar = $botNELPrefix + "I2"; ($required)getNelVar($botNELVar); if($required == ""){ // no item2 to check $msgName = "2"; // prepare to check the next one } else { // check item 2 ()queryEgs("IsInInventory", $playerEid, $required, @groupToNotify, 4, "2"); } } if($msgName == "2"){ ()queryEgs("Target", $playerEid, $botEid, @groupToNotify, 4, "3"); } if($msgName == "3"){ // the check is complete nextFishUserEvent_ret = 1; } } name script_fishCommon class alias name alias class script code ()import("script_fishCommon"); isCheckSuccessfull(){ checkSuccessfull_ret = 0; if($msgName == "0"){ // brick if($ret == "1"){ // brick ok checkSuccessfull_ret = 1; } } else if($msgName == "1"){ // item1 if($ret == "1"){ // equiped checkSuccessfull_ret = 1; } } else if($msgName == "2"){ // item2 if($ret == "1"){ // equiped checkSuccessfull_ret = 1; } } else if($msgName == "3"){ // target if($ret == "1"){ // player is targeting the mob $playerInRange_Eid = $playerEid; playerInRange(); if(playerInRange_ret == 1){ // player is in range checkSuccessfull_ret = 1; } } } } // fish info (@groupToNotify)context(); ($botEid)getBotEid(0); $botNELPrefix = "FISH" + $botEid; // the message ($msgName)getEventParam(0); // the msg name ($ret)getEventParam(1); // the return ($funName)getEventParam(2); // the name of the function ($playerEid)getEventParam(3); // the id of the player ($param1)getEventParam(4); // empty ot item, or sbrick or botEid if($botEid != ""){ ()@groupToNotify.phraseEndSystemMsg(0, "shout", "11"); // do the checks getPlayerIndex(); if(getPlayerIndex_ret > 0){ // deal with message for player of interest isCheckSuccessfull(); if(checkSuccessfull_ret > 0){ ()@groupToNotify.phraseEndSystemMsg(0, "shout", "13"); nextFishUserEvent(); if(nextFishUserEvent_ret > 0){ // everything was checked successfully ()@groupToNotify.phraseEndSystemMsg(0, "shout", "14"); if(getPlayerIndex_ret == 1){ ()@groupToNotify.phraseEndSystemMsg(0, "shout", "15"); if(v1 == 0){ // let's start the animation v1 = 1; ()emote($playerEid, "firework_01"); ()setTimer(20, 1); } } else if(getPlayerIndex_ret == 2){ if(v2 == 0){ // let's start the animation v2 = 1; ()emote($playerEid, "firework_01"); ()setTimer(20, 2); } } } } else { // to do : else try other compatible items/bricks if(getPlayerIndex_ret == 2){ v3 = 0; // ensure the fish escapes } else { v0 = 0; // ensure the fish escapes } $botNELVar = $botNELPrefix + "P" + getPlayerIndex_ret; ()setNelVar($botNELVar, ""); } } } name script_fishCheck class alias name alias class script code // $prefixActivity // param: $RCsFamily, $RCsFamilyType {B, I, C} $RCsFamilyParam1, $RCsFamilyParam2 RCaddFamily(){ $RCName = $prefixActivity + "_" + $RCsFamily; ()setNamedEntityProp($RCName, "state", $RCsFamilyType); // set family type (B = brick, I = item, C = Consumable) ()setNamedEntityProp($RCName, "param1", $RCsFamilyParam1); // set family param1 ()setNamedEntityProp($RCName, "param2", $RCsFamilyParam2); // set family param2 } // param: $RCsFamily RCn $RCsElement $RCsParam1 $RCsParam2 RCaddElement(){ $RCName = $prefixActivity + "_" + $RCsFamily + "_" + RCn; ()setNamedEntityProp($RCName, "state", $RCsElement); // set element ()setNamedEntityProp($RCName, "param1", $RCsParam1); // set param1 ()setNamedEntityProp($RCName, "param2", $RCsParam2); // set param2 } // $botFamily, $RCisRequired, $RCsFamily, $RCminElement, RCnReq RCaddBotFamilyRequirement(){ $RCName = $prefixActivity + "_" + $botFamily + "_" + RCnReq; ()setNamedEntityProp($RCName, "state", $RCsFamily); // set family ()setNamedEntityProp($RCName, "param1", $RCminElement); // set min element ()setNamedEntityProp($RCName, "param2", $RCisRequired); // set is required } name script_RequirementClassInit class alias name alias class script code // $prefixActivity //Param: RCnElement (first element = 1), $RCsFamily (Family name) => $RCsElement, $RCsParam1, $RCsParam2, $RCsFamilyType, $RCsFamilyParam1, $RCsFamilyParam2 RCgetElement(){ $RCName = $prefixActivity + "_" + $RCsFamily; ($RCsFamilyType)getNamedEntityProp($RCName, "state"); ($RCsFamilyParam1)getNamedEntityProp($RCName, "param1"); ($RCsFamilyParam2)getNamedEntityProp($RCName, "param2"); $RCName = $RCName + "_" + RCnElement; ($RCsElement)getNamedEntityProp($RCName, "state"); ($RCsParam1)getNamedEntityProp($RCName, "param1"); ($RCsParam2)getNamedEntityProp($RCName, "param2"); } // $botFamily, $RCnReq => $RCisRequired, $RCsFamily, $RCminElement (returns "" when not found) RCgetBotFamilyRequirement(){ $RCName = $prefixActivity + "_" + $botFamily + "_" + $RCnReq; ($RCsFamily)getNamedEntityProp($RCName, "state"); // get family ($RCminElement)getNamedEntityProp($RCName, "param1"); // get min element ($RCisRequired)getNamedEntityProp($RCName, "param2"); // get required } name script_RequirementClassGet class alias name alias class script code ()import("script_BotClass"); // $prefixActivity, $botEid, $botFamily // $botEid, $playerEid BuildPlayerSlot(){ $BCVarPrefix = $botEid + "_P" + BCP; $BCVar = $BCVarPrefix + "1"; ()setNamedEntityProp($BCVar, "state", $playerEid); ()setNamedEntityProp($BCVar, "param1", "1"); // current requirement ()setNamedEntityProp($BCVar, "param2", "1"); // current step in family $BCVar = $BCVarPrefix + "2"; ()setNamedEntityProp($BCVar, "state", ""); // built check ()setNamedEntityProp($BCVar, "param1", ""); // consumable ()setNamedEntityProp($BCVar, "param2", ""); // current consumable $BCVar = $BCVarPrefix + "3"; ()setNamedEntityProp($BCVar, "state", ""); // ()setNamedEntityProp($BCVar, "param1", ""); // ()setNamedEntityProp($BCVar, "param2", ""); // } // $botEid, $playerEid BCaddPlayer(){ BCP = 0; $tttt = "v0 = " + v0; ()phraseEndSystemMsg(0, "shout", $tttt); switch(v0){ case 0:{ // No one is fishing v0 = 1; // P1 is now fishing v1 = 0; // etat initial < 1000, fishing >= 1000 ()setNamedEntityProp($botEid, "state", $botFamily); // botFamily requirement BCP = 1; ()phraseEndSystemMsg(0, "shout", "0 => 1 => avant"); BuildPlayerSlot(); ()phraseEndSystemMsg(0, "shout", "0 => 1 => apres"); } case 1:{ // P1 is fishing $BCVar = $botEid + "_P11"; ($BCP)getNamedEntityProp($BCVar, "state"); if($BCP != $playerEid){ v0 = 3; // P1 and P2 are now fishing BCP = 2; v2 = 0; // etat initial < 1000, fishing >= 1000 ()phraseEndSystemMsg(0, "shout", "1 => 2 => avant"); BuildPlayerSlot(); ()phraseEndSystemMsg(0, "shout", "1 => 2 => apres"); } } case 2:{ // P2 is fishing $BCVar = $botEid + "_P21"; ($BCP)getNamedEntityProp($BCVar, "state"); if($BCP != $playerEid){ v0 = 3; // P1 and P2 are now fishing BCP = 1; v1 = 0; // etat initial < 1000, fishing >= 1000 ()phraseEndSystemMsg(0, "shout", "2 => 1 => avant"); BuildPlayerSlot(); ()phraseEndSystemMsg(0, "shout", "2 => 1 => apres"); } } case 3: // P1 and P2 are already fishing ()phraseEndSystemMsg(0, "shout", "TOO_MANY_PLAYERS_ARE_FISHING"); } } ($playerEid)getCurrentPlayerEid(); range = 200; // allow the max range from the fish playerInRange(); if(playerInRange_ret > 0){ // only work if necessay ($botEid)getBotEid(0); BCaddPlayer(); if(BCP != 0){ ()phraseEndSystemMsg(0, "shout", "YOU_ARE_PREPARING_TO_FISH"); ()setTimer(10, BCP); } } name script_BotClassInit class alias name alias class script code // $botEid BCP removeBot(){ ()destroyNamedEntity($botEid); } removePlayer(){ $BCVarPrefix = $botEid + "_P" + BCP; $BCVar = $BCVarPrefix + "1"; ()destroyNamedEntity($BCVar); $BCVar = $BCVarPrefix + "2"; ()destroyNamedEntity($BCVar); $BCVar = $BCVarPrefix + "3"; ()destroyNamedEntity($BCVar); v0 -= BCP; if(v0 == 0){ ()destroyNamedEntity($BCVar); } //()timerDisable(BCP); } // BCP slot to delete deletePlayer(){ if(BCP == 2){ if(v0 > 1){ removePlayer(); } } else { if(v0 == 1 || v0 == 3){ removePlayer(); } } } deleteBot(){ BCP = 2; deletePlayer(); BCP = 1; deletePlayer(); } name script_BotClassDelete class alias name alias class script code // $prefixActivity, $botEid, $playerEid ()import("script_RequirementClassGet"); playerInRange(){ (playerInRange_ret)isPlayerAlived($playerEid); if(playerInRange_ret == 1) { playerInRange_ret = 0; // check if player is in the good zone for the fishing occupation ($prefix)getStateName(); $name = $prefix + "_fw"; (distance)npc_distance_helper.getBotIndexByName($name); (distance)npc_distance_helper.getPlayerDistance(distance, $playerEid); if(distance < 10){ $name = $prefix + "_nw"; ()phraseEndSystemMsg(0, "shout", $name); (distance)npc_distance_helper.getBotIndexByName($name); (distance)npc_distance_helper.getPlayerDistance(distance, $playerEid); if(distance < 10){ // the player is in the good zone (distance)getPlayerDistance(0, $playerEid); if(distance >= 0 && distance < range){ playerInRange_ret = distance + 0.0001; } } } } } //initTriggerRequirement(){ // triggerRequirement_ret = 0; // $currVar = $botEid + "_P11"; // ($RCnReq)getNamedEntityProp($currVar, "param1"); // get current requirement // RCgetBotFamilyRequirement(); // if($RCminElement == ""){ // no more requirement // $RCnReq = "1"; // ()getNamedEntityProp($currVar, "param1", $RCnReq); // set current requirement to 1 // triggerRequirement_ret = 1; //(RCnReq)strtof($RCnReq); // RCnReq // ($RCnStepReq)getNamedEntityProp($currVar, "param2"); // get current step in family // (RCnStepReq)strtof($RCnStepReq); // (RCminElement)strtof($RCminElement); // if(RCnStepReq < RCminElement){ // ($RCnStepReq)getNamedEntityProp($BCVar, "param1"); // set current step in family // } // $botFamily, RCnReq => $RCisRequired, $RCsFamily, $RCminElement (returns "" when not found) //RCgetBotFamilyRequirement(); //} name script_BotClass class alias name alias class script code // $prefixActivity, $BotEid // => $PlayerEid1 BCgetP1(){ $BCNELVar = $prefixActivity + "_" + $BotEid + "_P1"; ($BCPlayerEid1)getNelVar($BCNELVar); } // => $PlayerEid2 BCgetP2(){ $BCNELVar = $prefixActivity + "_" + $BotEid + "_P2"; ($BCPlayerEid2)getNelVar($BCNELVar); } // BCnBrick => BCnCount, $BCsBrick BCgetBrick(){ $BCNELVar = $prefixActivity + "_" + $BotEid + "_BR"; $BCsBrick = ""; (BCnCount)getNelVar($BCNELVar); if(BCnCount > 0){ } } BCinit(){ $BCPrefix = $prefixActivity + "_" + $BotEid + "_"; $BCNELVar = $BCPrefix + "P1"; // init PlayerEid1 ()setNelVar($BCNELVar, ""); $BCNELVar = $BCPrefix + "P2"; // init PlayerEid2 ()setNelVar($BCNELVar, ""); $BCNELVar = $BCPrefix + "BR"; // init Brick Family ()setNelVar($BCNELVar, 0); $BCNELVar = $BCPrefix + "I1"; // init Item 1 Family ()setNelVar($BCNELVar, 0); $BCNELVar = $BCPrefix + "I2"; // init Item 2 Family ()setNelVar($BCNELVar, 0); } // nBCFamily: A valid RequirementFamily (> 0) BCsetBrickFamily(){ $BCPrefix = $prefixActivity + "_" + $BotEid + "_" + "BR"; ()setNelVar($BCNELVar, nBCFamily); } // nBCFamily: A valid RequirementFamily (> 0) BCsetItem1Family(){ $BCPrefix = $prefixActivity + "_" + $BotEid + "_" + "I1"; ()setNelVar($BCNELVar, nBCFamily); } // nBCFamily: A valid RequirementFamily (> 0) BCsetItem2Family(){ $BCPrefix = $prefixActivity + "_" + $BotEid + "_" + "I2"; ()setNelVar($BCNELVar, nBCFamily); } name script_BotClassGet_old class alias name alias