Advertisement
Guest User

Followers

a guest
Jan 24th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 21.55 KB | None | 0 0
  1. /*
  2. Author: Kubix
  3. Date: 18.11.2015
  4. Version: 2.0.1
  5.  
  6. */
  7.  
  8. /*
  9.     arg(0)          ->  mission_level_req
  10.     arg(1)          ->  special_mission
  11.     arg(2)          ->  companion_id
  12.     arg(3)          ->  mission_id
  13. */
  14.  
  15. function    script  get_Random_RE_Value {
  16.  
  17.     if(!$define_Random_Reward) return 0;
  18.     if(getd("ti_" + getarg(2) + getarg(3)) > gettimetick(2)) {
  19.         if(getd("val_" + getarg(2) + getarg(3)) == 0) setd "val_" + getarg(2) + getarg(3), 2;
  20.         return getd("val_" + getarg(2) + getarg(3));
  21.     }
  22.     if(getarg(1)) {
  23.         switch(getarg(1)) {
  24.             // special mission id
  25.             /*
  26.                 case 1: // 1 = mission ID
  27.                     .@value = 1; // 1 = reward count
  28.                     break;
  29.             */
  30.            
  31.         }
  32.         setd "val_" + getarg(2) + getarg(3), .@value;
  33.         return getd("val_" + getarg(2) + getarg(3));
  34.     }
  35.    
  36.     switch(getarg(0)) {
  37.         case 0: default: return 0;
  38.        
  39.         case 1: case 2: case 3: case 4: case 5: case 6: case 7:
  40.             .@value = rand(getarg(0), (BaseLevel / 10));
  41.             if(.@value <= 0) .@value = 2;
  42.             setd "ti_" + getarg(2) + getarg(3), gettimetick(2) + 86400;
  43.             setd "val_" + getarg(2) + getarg(3), .@value;
  44.             return getd("val_" + getarg(2) + getarg(3));
  45.     }
  46.    
  47. }
  48.  
  49. /*
  50.     arg(0)          ->  mission_id
  51.     arg(1)          ->  companion_id
  52.     arg(2)          ->  mission_level_req
  53.     arg(3)          ->  mission_equip_req
  54.     arg(4)          ->  mission_job_req
  55.     arg(5)          ->  special_mission
  56. */
  57.  
  58. function    script  get_Random_Reward   {
  59.     if(!$define_Random_Reward) return 0;
  60.     if(getd("ti_" + getarg(1) + getarg(0)) > gettimetick(2)) return getd("re_" + getarg(1) + getarg(0));
  61.     switch(getarg(2)) {
  62.         case 0: default: return "Error.";
  63.        
  64.         case 1: case 2: case 3: case 4: case 5: case 6: case 7:
  65.             .@return_Reward = callfunc("reward_DB", getarg(0), getarg(2), getarg(5));
  66.             break;
  67.     }
  68.    
  69.     setd "ti_" + getarg(1) + getarg(0), gettimetick(2) + 86400;
  70.     setd "re_" + getarg(1) + getarg(0), .@return_Reward;
  71.     return getd("re_" + getarg(1) + getarg(0));
  72. }
  73.  
  74. /*
  75.     arg(0)          ->  mission_id
  76.     arg(1)          ->  level_req
  77.     arg(2)          ->  special_mission
  78. */
  79.  
  80. function    script  reward_DB   {
  81.  
  82.     if(!getarg(0) || !getarg(1)) {
  83.         logmes "reward_DB: can't find mission_id or level_req.";
  84.         mes "error.";
  85.         mes "Error code : 1";
  86.         close;
  87.     }
  88.    
  89.     if(getarg(2)) {
  90.         switch(getarg(0)) {
  91.             // mission id for special missions
  92.             /*
  93.                 case 1: // 1 = mission_id
  94.                     .@return_Reward = 909; // reward = 909 (jellopy)
  95.                     break;
  96.                    
  97.                     so, mission with ID 1 = special mission and have reward = 909 (jellopy)
  98.                     and this mission will skip next code.
  99.             */
  100.         }
  101.         setd "re_" + getarg(1) + getarg(0), .@return_Reward;
  102.         return getd("re_" + getarg(1) + getarg(0));
  103.     }
  104.    
  105.     switch(getarg(1)){ // switching Follower level.
  106.         case 0: default: end;
  107.         case 1:
  108.             return $mission_Array_LVO[rand(getarraysize($mission_Array_LVO))];
  109.         case 2:
  110.             return $mission_Array_LVT[rand(getarraysize($mission_Array_LVT))];
  111.         case 3:
  112.             return $mission_Array_LVTH[rand(getarraysize($mission_Array_LVTH))];
  113.         case 4:
  114.             return $mission_Array_LVF[rand(getarraysize($mission_Array_LVF))];
  115.         case 5:
  116.             return $mission_Array_LVFI[rand(getarraysize($mission_Array_LVFI))];
  117.         case 6:
  118.             return $mission_Array_LVS[rand(getarraysize($mission_Array_LVS))];
  119.         case 7:
  120.             return $mission_Array_LVSE[rand(getarraysize($mission_Array_LVSE))];
  121.     }
  122.    
  123. }
  124.  
  125. /*
  126.     arg(0)          ->  uniquie_id
  127. */
  128. function    script  Companion_Create    {
  129.     .@companionName$ = .@companionDesc$ = .@companionCutin$ = .@companionSound$ = "";
  130.     .@companionClassID = .@new_id = 0;
  131.  
  132.     if(!$define_betaver && garrison_map$ == "") end;
  133.     if (!getarg(0)) return 0;
  134.     callfunc("companion_Check_Char", getarg(0), getcharid(0));
  135.     query_sql("SELECT companion_name, companion_class, companion_desc, companion_cutin, companion_sound FROM `companion_list` WHERE `companion_unique_id` = '" + getarg(0) + "'", .@companionName$, .@companionClassID, .@companionDesc$, .@companionCutin$, .@companionSound$);
  136.    
  137.     .@new_id = getarg(0) + rand(11111,99999); // char companion uniquie_id.
  138.    
  139.     if (!$define_betaver && .@companionCutin$ != "Companion") cutin .@companionCutin$,4;
  140.     if (!$define_betaver && .@companionSound$ != "default") soundeffect .@companionSound$ + ".wav",0;
  141.     setd "next_level_exp" + getarg(0), $define_standartExp * 2 / $define_compRatesExp;
  142.     mes "follower added!";
  143.     mes "'" + .@companionDesc$ + "'";
  144.     query_sql("INSERT INTO `garrison_companions` (`char_id`,`map`,`companion_name1`,`companion_job1`, `companion_id1`) VALUES ('" + getcharid(0) + "', '" + garrison_map$ + "', '" + .@companionName$ + "', '" + .@companionClassID + "', '"+getarg(0)+"')");
  145.     if(!$define_betaver) query_sql("UPDATE `garrisons` SET `companion_count`=`companion_count`+'1' WHERE `name` = '" + strcharinfo(0) + "'");
  146.     query_sql("UPDATE `companion_list` SET `companion_count_all`=`companion_count_all` + 1 WHERE `companion_unique_id` = '"+getarg(0)+"'");
  147.     close;
  148. }
  149.  
  150. //  arg(0)      ->  companion_id
  151. //  arg(1)      ->  char_id
  152. function    script  companion_Check_Char    {
  153.     if(!getarg(0) || !getarg(1)) end;
  154.    
  155.     query_sql("SELECT char_id, companion_id1 FROM `garrison_companions` WHERE `char_id` = '"+getarg(1)+"' and `companion_id1` = '"+getarg(0)+"'", .@char_array_id, .@comp_array_id);
  156.     if(getarraysize(.@char_array_id) > 1 || getarraysize(.@comp_array_id) > 1) {
  157.         mes "You already have this follower.";
  158.         close;
  159.     }
  160.    
  161.     return;
  162. }
  163.  
  164.  
  165. -   script  Companion_Manager   -1,{
  166.     function Calculating_Chance; function Get_Reward;
  167.     function Return_JobName;
  168.     mes "- manager -";
  169.     mes "pick a follower";
  170.     next;
  171.  
  172.     @comJob = @comBlvl = @comBexp = @comID = @comMID = @comAvailable = @comEqLev = .@i = 0;
  173.     @comName$ = @comMName$ = "";
  174.     query_sql("SELECT companion_name1, companion_job1, companion_baselevel1, companion_baseexp1, companion_id1, companion_missionid1, companion_missionname1, companion_available, companion_equiplv FROM `garrison_companions` WHERE `char_id` = '" + getcharid(0) + "'", @comName$, @comJob, @comBlvl, @comBexp, @comID, @comMID, @comMName$, @comAvailable, @comEqLev);
  175.     set .@menu$, "";
  176.     for (set .@i, 0; .@i < getarraysize(@comName$); set .@i, .@i + 1){
  177.         if (@comName$[.@i] != "") {
  178.             set .@menu$, .@menu$ + "-> ^FF0000" + @comName$[.@i] + "^000000 - " + Return_JobName(@comJob[.@i]);
  179.             set .@menu$, .@menu$ + ":";
  180.         }
  181.     }
  182.     set .@comSelected, select(.@menu$) - 1;
  183.  
  184.     set .@next_level, getd("next_level_exp" + @comID[.@comSelected]);
  185.     mes " --- Information about Follower --- ";
  186.     mes "Name : ^998888" + @comName$[.@comSelected] + "^000000";
  187.     mes "Class : ^6699DD" + Return_JobName(@comJob[.@comSelected]) + "^000000.";
  188.     mes "Level : ^FF0000" + @comBlvl[.@comSelected] + "^000000.";
  189.     mes "Exp : ^0000FF[" + @comBexp[.@comSelected] + " / "+.@next_level+"]^000000";
  190.     mes "Items level : ^998800" + @comEqLev[.@comSelected] + "^000000";
  191.     next;
  192.     switch (select("pick up a reward:Send on a mission:Other info")) {
  193.     case 1:
  194.         @cm_cid = @mission_id = @mission_state = @mission_job = @gc_cid = @gc_cj = 0;
  195.         query_sql("SELECT companion_missions.companion_id, companion_missions.mission_id, companion_missions.mission_state, companion_missions.mission_jobreq, garrison_companions.companion_id1, garrison_companions.companion_job1 FROM `companion_missions` LEFT JOIN `garrison_companions` ON garrison_companions.companion_id1 = companion_missions.companion_id WHERE companion_missions.`char_id` = '" + getcharid(0) + "' and companion_missions.`companion_id` = '" + @comID[.@comSelected] + "' and `mission_state` = 1", @cm_cid, @mission_id, @mission_state, @mission_job, @gc_cid, @gc_cj);
  196.  
  197.         if (getd("companion_" + @comID[.@comSelected]) - gettimetick(2) <= 0 && @mission_id != 0 && @mission_state != 0) {
  198.  
  199.             if (rand(100) > getd("mission_comp_chance" + @comID[.@comSelected])) {
  200.                 mes "^FF0000Mission failed!^000000";
  201.                 query_sql("DELETE FROM `companion_missions` WHERE `mission_id` = '" + @mission_id + "' and `companion_id` = '" + @cm_cid + "'");
  202.                 query_sql("UPDATE `garrison_companions` SET `companion_missionid1` = 0, `companion_missionname1` = 'mission' WHERE `companion_id1` = '"+@comID[.@comSelected]+"'");
  203.                 setd "companion_" + @comID[.@comSelected], 0;
  204.                 close;
  205.             }
  206.  
  207.             switch (Get_Reward(@mission_id, @comID[.@comSelected])) {
  208.             case 0:
  209.                 mes "- Manager -";
  210.                 mes "Massage test!";
  211.                 close;
  212.             case 1:
  213.                 mes "Mission completed!";
  214.                 close;
  215.             case 2:
  216.                 mes "- Manager -";
  217.                 mes "Wrong 'MissionID' or 'CompanionID'. Contact your administrator";
  218.                 close;
  219.             }
  220.         }
  221.         else {
  222.             set @companion_mission, getd("companion_" + @comID[.@comSelected]);
  223.             if (@companion_mission > 0) {
  224.                 mes "- Manager -";
  225.                 mes "Follower is still on a mission " + callfunc("Time2Str", @companion_mission);
  226.             }
  227.             else {
  228.                 mes "- Manager -";
  229.                 mes "Follower haven't been on a mission.";
  230.             }
  231.             close;
  232.         }
  233.     case 2:
  234.         if (getd("companion_" + @comID[.@comSelected]) - gettimetick(2) > 0) {
  235.             set @companion_mission, getd("companion_" + @comID[.@comSelected]);
  236.             mes "- Manager -";
  237.             mes "Follower is still on a mission " + callfunc("Time2Str", @companion_mission);
  238.             close;
  239.         }
  240.         @MIDs = @mID = @mTime = @mReward1 = @mRewardVal1 = @mReward2 = @mRewardVal2 = @mReward3 = @mRewardVal3 = @mCharExp = @mCharExp2 = @mCompExp = @mCompExp2 = @mZenyReward = @mReqLevel = 0;
  241.         @mName$ = @mType$ = @mDesc$ = "";
  242.         query_sql("SELECT * FROM `garrison_missions` WHERE `mission_reqlevel` = '" + @comBlvl[.@comSelected] + "'", @MIDs, @mID, @mName$, @mType$, @mDesc$, @mTime, @mReward1, @mRewardVal1, @mReward2, @mRewardVal2, @mReward3, @mRewardVal3, @mCharExp, @mCharExp2, @mCompExp, @mCompExp2, @mZenyReward, @mReqLevel, @mJobReq, @mLevReq, @special);
  243.         set .@menu$, "";
  244.         for (set .@a, 0; .@a < getarraysize(@mName$); set .@a, .@a + 1){
  245.             if (@mName$[.@a] != "") {
  246.                 set .@menu$, .@menu$ + " - ^6699DD" + @mName$[.@a] + "^000000 -> " + Return_JobName(@mJobReq[.@a]);
  247.                 set .@menu$, .@menu$ + ":";
  248.             }
  249.         }
  250.         set .@missionSelected, select(.@menu$) - 1;
  251.  
  252.         mes " -- ^6699DDRequiments^000000 -- ";
  253.         if (@comJob[.@comSelected] == @mJobReq[.@missionSelected]) mes "Follower class : ^00FF00" + Return_JobName(@mJobReq[.@missionSelected]) + "^000000";
  254.         else if (@comJob[.@comSelected] != @mJobReq[.@missionSelected]) mes "Follower class  : ^FF0000" + Return_JobName(@mJobReq[.@missionSelected]) + "^000000";
  255.         mes "Name : " + @mName$[.@missionSelected] + ".";
  256.         mes "Time : " + callfunc("Time2Str2", @mTime[.@missionSelected]);
  257.         mes "^669900'" + @mDesc$[.@missionSelected] + "'^000000";
  258.         mes "Item level : ^998800" + @mLevReq[.@missionSelected] + "^000000";
  259.         mes "Chance to perform : " + Calculating_Chance(@mID[.@missionSelected], @comID[.@comSelected], @mJobReq[.@missionSelected], @comJob[.@comSelected], @mLevReq[.@missionSelected], @comEqLev[.@comSelected]) + "%";
  260.         mes "-----------------------------------";
  261.         mes " -- ^FF0000Rewards^000000 -- ";
  262.         if(!$define_Random_Reward) {
  263.             if (@mReward1[.@missionSelected] && @mRewardVal1[.@missionSelected]) mes "->" + getitemname(@mReward1[.@missionSelected]) + ", " + @mRewardVal1[.@missionSelected] + "oo<-";
  264.             if (@mReward2[.@missionSelected] && @mRewardVal2[.@missionSelected]) mes "->" + getitemname(@mReward2[.@missionSelected]) + ", " + @mRewardVal2[.@missionSelected] + "oo<-";
  265.             if (@mReward3[.@missionSelected] && @mRewardVal3[.@missionSelected]) mes "->" + getitemname(@mReward3[.@missionSelected]) + ", " + @mRewardVal3[.@missionSelected] + "oo<-";
  266.         } else {
  267.             mes "Reward : " + getitemname(callfunc("get_Random_Reward", @mID[.@missionSelected], @comID[.@comSelected], @comBlvl[.@comSelected], @mLevReq[.@missionSelected], @mJobReq[.@missionSelected], @special[.@missionSelected]));
  268.             mes "Amount : " + callfunc("get_Random_RE_Value", @comBlvl[.@comSelected], @special[.@missionSelected], @comID[.@comSelected], @mID[.@missionSelected]);
  269.         }
  270.         mes "Follower exp +^FF0000" + (@mCompExp[.@missionSelected]) + "^000000.";
  271.         mes "-----------------------------------";
  272.         next;
  273.         if (select("Continue:Cancel") == 2) close;
  274.         if (@comJob[.@comSelected] != @mJobReq[.@missionSelected]) {
  275.             mes "- Manager -";
  276.             mes "^FF0000Follower class not suitable for this quest!";
  277.             mes "Want to continue?^000000";
  278.             next;
  279.             if (select("Yes:No") == 2) close;
  280.         }
  281.         setd("companion_" + @comID[.@comSelected], gettimetick(2) + @mTime[.@missionSelected]);
  282.         query_sql("INSERT INTO `companion_missions` (`char_id`,`companion_id`,`mission_id`,`mission_state`, `mission_time`, `mission_jobreq`) VALUES ('" + getcharid(0) + "', '" + @comID[.@comSelected] + "', '" + @mID[.@missionSelected] + "', '1', '" + @mTime[.@missionSelected] + "', '" + @mJobReq[.@missionSelected] + "')");
  283.         query_sql("UPDATE `garrison_companions` SET `companion_missionid1` = '"+@mID[.@missionSelected]+"', `companion_missionname1` = '"+@mName$[.@missionSelected]+"' WHERE `companion_id1` = '"+@comID[.@comSelected]+"'");
  284.         mes "- Manager -";
  285.         mes "Follower has been sent on a mission ^FF0000" + @mName$[.@missionSelected] + "^000000";
  286.         logmes "> " + strcharinfo(0) + " companion started quest. ID " + @mName$[.@missionSelected];
  287.         close;
  288.  
  289.     case 3:
  290.         @com_Wlvl = @com_Alvl = @com_Wid = @com_Aid = 0;
  291.         query_sql("SELECT companion_weaponid, companion_weaponlv, companion_armorid, companion_armorlv FROM `garrison_companions` WHERE `companion_id1` = '" + @comID[.@comSelected] + "'", @com_Wid, @com_Wlvl, @com_Aid, @com_Alvl);
  292.         mes "- Manager -";
  293.         mes "Weapon ^6699DD" + getitemname(@com_Wid) + "^000000. ^0000FF[" + @com_Wlvl + "]^000000.";
  294.         mes "Armour ^6699DD" + getitemname(@com_Aid) + "^000000. ^0000FF[" + @com_Alvl + "]^000000.";
  295.         mes "Item level : ^998800" + @comEqLev[.@comSelected] + "^000000";
  296.         next;
  297.         switch (select("Upgrade the weapon:Upgrade the armour")) {
  298.         case 1:
  299.             set .@menu$, "";
  300.             for (set .@c, 0; .@c < getarraysize(.weaponID); set .@c, .@c + 1){
  301.                 if (.weaponID[.@c] != 0) {
  302.                     set .@menu$, .@menu$ + "-> ^9888DD" + getitemname(.weaponID[.@c]) + "^000000.";
  303.                     set .@menu$, .@menu$ + ":";
  304.                 }
  305.             }
  306.             set .@weaponSelected, select(.@menu$) - 1;
  307.  
  308.             if (countitem(.weaponID[.@weaponSelected]) < 1) {
  309.                 mes "- Manager -";
  310.                 mes "You don't have this item.";
  311.                 close;
  312.             }
  313.             delitem .weaponID[.@weaponSelected], 1;
  314.             query_sql("UPDATE `garrison_companions` SET `companion_weaponid` = '"+.weaponID[.@weaponSelected]+"', `companion_weaponlv` = '"+.weaponLVL[.@weaponSelected]+"', `companion_equiplv`=`companion_equiplv` + '"+.weaponLVL[.@weaponSelected]+"' WHERE `companion_id1` = '"+@comID[.@comSelected]+"'");
  315.             mes "Done.";
  316.             close;
  317.  
  318.         case 2:
  319.             set .@menu$, "";
  320.             for (set .@c, 0; .@c < getarraysize(.armorID); set .@c, .@c + 1){
  321.                 if (.armorID[.@c] != 0) {
  322.                     set .@menu$, .@menu$ + "-> ^9888DD" + getitemname(.armorID[.@c]) + "^000000.";
  323.                     set .@menu$, .@menu$ + ":";
  324.                 }
  325.             }
  326.             set .@armorSelected, select(.@menu$) - 1;
  327.  
  328.             if (countitem(.armorID[.@armorSelected]) < 1) {
  329.                 mes "- Manager -";
  330.                 mes "You don't have this item.";
  331.                 close;
  332.             }      
  333.             delitem .armorID[.@armorSelected], 1;
  334.             query_sql("UPDATE `garrison_companions` SET `companion_armorid` = '"+.armorID[.@armorSelected]+"', `companion_armorlv` = '"+.armorLVL[.@armorSelected]+"', `companion_equiplv`=`companion_equiplv` + '"+.armorLVL[.@armorSelected]+"' WHERE `companion_id1` = '"+@comID[.@comSelected]+"'");
  335.             mes "Done.";
  336.             close;
  337.         }
  338.     }
  339.  
  340.     //  arg(0)          ->  mission_id
  341.     //  arg(1)          ->  companion_id
  342.     function    Get_Reward  {
  343.         if (!getarg(0) || !getarg(1)) return 2;
  344.         @reward1 = @reward2 = @reward3 = @rewardval1 = @rewardval2 = @rewardval3 = @zeny_reward = @com_select_job = @com_base_lev = @com_base_exp = @char_bexp = @char_jexp = @comp_bexp = @levelreq = 0;
  345.        
  346.         query_sql("SELECT mission_reward1, mission_rewardval1, mission_reward2, mission_rewardval2, mission_reward3, mission_rewardval3, mission_charbaseexp, mission_charjobexp, mission_compbaseexp, zeny_reward, mission_reqlevel, special_mission FROM `garrison_missions` WHERE `mission_id` = '" + getarg(0) + "'", @reward1, @rewardval1, @reward2, @rewardval2, @reward3, @rewardval3, @char_bexp, @char_jexp, @comp_bexp, @zeny_reward, @levelreq, @special_mission);
  347.         query_sql("UPDATE `garrison_companions` SET `companion_missionid1` = 0, `companion_missionname1` = 'mission' WHERE `companion_id1` = '"+@comID[.@comSelected]+"'");
  348.         setd "companion_" + getarg(1), 0;
  349.         if($define_Random_Reward) {
  350.             getitem getd("re_" + getarg(1) + getarg(0)), getd("val_" + getarg(1) + getarg(0));
  351.         }
  352.         else {
  353.             for (.h = 0; .h < getarraysize(@reward1); .h++) {
  354.                 if (@reward1[.h] != 0) {
  355.                     if (@reward1 != 0 && @rewardval1 != 0) getitem @reward1, @rewardval1;
  356.                     if (@reward2 != 0 && @rewardval2 != 0) getitem @reward2, @rewardval2;
  357.                     if (@reward3 != 0 && @rewardval3 != 0) getitem @reward3, @rewardval3;
  358.                 }
  359.             }
  360.         }
  361.                 if (@zeny_reward != 0) {
  362.                     garrison_resources += @zeny_reward;
  363.                     query_sql("UPDATE `garrisons` SET `garrison_resources`= '"+garrison_resources+"' WHERE `name` = '"+strcharinfo(0)+"'");
  364.                     dispbottom "Resources + " + @zeny_reward + ". Total - " + garrison_resources;
  365.                 }
  366.                 if(@char_bexp) getexp @char_bexp, 0;
  367.                 if(@char_jexp) getexp 0, @char_jexp;
  368.                 query_sql("DELETE FROM `companion_missions` WHERE `mission_id` = '" + getarg(0) + "' and `companion_id` = '" + getarg(1) + "'");
  369.                 query_sql("SELECT companion_job1, companion_baselevel1, companion_baseexp1 FROM `garrison_companions` WHERE `companion_id1` = '" + getarg(1) + "'", @com_select_job, @com_base_lev, @com_base_exp);
  370.                 if ((@com_base_exp + @comp_bexp) >= getd("next_level_exp" + getarg(1))) {
  371.                     setd "next_level_exp" + getarg(1), $define_standartExp * (@com_base_lev * 8) / $define_compRatesExp;
  372.                     set .@next_level, getd("next_level_exp" + getarg(1));
  373.                     set .@now_exp, @com_base_exp + @comp_bexp;
  374.                     mes "- Manager -";
  375.                     mes "^FF0000Mission completed! New level!^000000";
  376.                     mes "Current exp ^0000FF[" + .@now_exp + " / " + .@next_level + "]^000000!";
  377.                     query_sql("UPDATE `garrison_companions` SET `companion_baselevel1` = `companion_baselevel1` + '1', `companion_baseexp1` = `companion_baseexp1` + '" + @comp_bexp + "' WHERE `companion_id1` = '"+getarg(1)+"'");
  378.                     return 1;
  379.                 }
  380.                 else {
  381.                     set .@next_level, getd("next_level_exp" + getarg(1));
  382.                     set .@now_exp, @com_base_exp + @comp_bexp;
  383.                     mes "- Manager -";
  384.                     mes "^6699DDMission completed, exp: ^669900" + @comp_bexp + "^000000 ^6699DDCongratulations!^000000";
  385.                     mes "Current exp ^0000FF[" + .@now_exp + " / " + .@next_level + "]^000000!";
  386.                     query_sql("UPDATE `garrison_companions` SET `companion_baseexp1` = `companion_baseexp1` + '" + @comp_bexp + "' WHERE `companion_id1` = '" + getarg(1) + "'");
  387.                     return 1;
  388.                 }
  389.     }
  390.  
  391.     //  arg(0)                  ->  mission_id
  392.     //  arg(1)                  ->  companion_id
  393.     //  arg(2)                  ->  mission_jobreq
  394.     //  arg(3)                  ->  companion_job
  395.     //  arg(4)                  ->  equip_level_sum_needed
  396.     //  arg(5)                  ->  equip_level_sum_companion
  397.     function    Calculating_Chance  {
  398.         if (getarg(0) < 0 || getarg(1) < 0 || getarg(2) < 0 || getarg(3) < 0) return 0;
  399.         setd "mission_comp_chance" + getarg(1), 0;
  400.        
  401.         if (getarg(4) > getarg(5)) {
  402.             if($define_DebugMode) debugmes "getarg(4) > getarg(5)";
  403.             .@set_chance = getarg(4) - getarg(5);
  404.             .@set_chance2 += $define_baseChance + (getarg(5) / .@set_chance);
  405.         }
  406.         else if (getarg(5) > getarg(4)) {
  407.             if($define_DebugMode) debugmes "getarg(5) > getarg(4)";
  408.             .@set_chance = getarg(5) - getarg(4);
  409.             .@set_chance2 = (5 + $define_baseChance) + (3 * (.@set_chance / 2));
  410.         }
  411.         else {
  412.             if($define_DebugMode) debugmes "ELSE";
  413.             .@set_chance2 = $define_baseChance + 5;
  414.         }
  415.        
  416.         if(getarg(2) == getarg(3)) .@set_chance2 += 15;
  417.         else .@set_chance2 -= 15;
  418.        
  419.         setd "mission_comp_chance" + getarg(1), .@set_chance2;
  420.  
  421.         if (getd("mission_comp_chance" + getarg(1)) > 100) setd "mission_comp_chance" + getarg(1), 100;
  422.         else if (getd("mission_comp_chance" + getarg(1)) < 0) setd "mission_comp_chance" + getarg(1), 0;
  423.  
  424.         return getd("mission_comp_chance" + getarg(1));
  425.     }
  426.  
  427.     //  arg(0)      ->  job_id
  428.     function    Return_JobName  {
  429.         switch (getarg(0)) {
  430.             case 0: return "Warrior";
  431.             case 1: return "Mage";
  432.             case 2: return "Healer";
  433.             case 3: return "Assassin";
  434.             default: return "Error";
  435.         }
  436.     }
  437.    
  438.    
  439.    
  440.     OnInit:
  441.     $define_betaver = 1; // beta version? need for some functions:) turn it off if you want
  442.     $define_standartExp = 1500000; // start exp
  443.     $define_compRatesExp = 100; // base rates, 100 = x1
  444.     $define_compRatesOther = 100; // other rates
  445.     $define_baseChance = 25; // Base chance for complete quest
  446.     $define_Random_Reward = 1; // random rewards: 1 - ON / 0 - OFF
  447.     $define_DebugMode = 1; // show debugs for test?
  448.     $instance_count_id = 10; // not needed now
  449.    
  450.     setarray .weaponID[0], 1208, 1225, 1599; // weapon ids for followers
  451.     setarray .armorID[0], 2357, 2358, 2359; // armor ids for followers
  452.    
  453.     setarray .weaponLVL[0], 5, 10, 20; // item level for each weapon (1208 = 5 item level and etc.)
  454.     setarray .armorLVL[0], 5, 10, 20; // item level for each armor
  455.    
  456.     setarray $mission_Array_LVO[0], 909, 970, 971, 7033, 921, 931, 993; // array with rewards if $define_Random_Reward = 1 (FOR LEVEL 1)
  457.     setarray $mission_Array_LVT[0], 909, 970, 971, 7033, 921, 931, 993; // array with rewards if $define_Random_Reward = 1 (FOR LEVEL 2)
  458.     setarray $mission_Array_LVTH[0], 909, 970, 971, 7033, 921, 931, 993; // array with rewards if $define_Random_Reward = 1 (FOR LEVEL 3)
  459.     setarray $mission_Array_LVF[0], 909, 970, 971, 7033, 921, 931, 993; // array with rewards if $define_Random_Reward = 1 (FOR LEVEL 4)
  460.     setarray $mission_Array_LVFI[0], 909, 970, 971, 7033, 921, 931, 993; // array with rewards if $define_Random_Reward = 1 (FOR LEVEL 5)
  461.     setarray $mission_Array_LVS[0], 909, 970, 971, 7033, 921, 931, 993; // // array with rewards if $define_Random_Reward = 1 (FOR LEVEL 6)
  462.     setarray $mission_Array_LVSE[0], 909, 970, 971, 7033, 921, 931, 993; // // array with rewards if $define_Random_Reward = 1 (FOR LEVEL 7)
  463.     end;
  464. }
  465. prontera, 151, 181, 6   duplicate(Companion_Manager)    Manager#08  100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement