Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.55 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////
  2. //Darkpoole - 17/01/2019 (the right way)
  3. //Redesigned Paladin to have a talent system and get rid of
  4. //god awful Jihad implementation. My code is cute and you're
  5. //the one who is wrong.
  6. //////////////////////////////////////////////////////////////////////////////////
  7.  
  8.  
  9. #include <damage_types.h>
  10. #include <daemons.h>
  11. #include <ansi.h>
  12. #define skill_exist(skill) (SKILL_H->get_tot_base_level(skill,sh_ob) >= 1 ||SKILL_H->get_tot_base_level(skill,sh_ob) == -1)
  13. #define BGUARD BLK+BOLD
  14. #define DIV    BLU+BOLD
  15. #define BULW   MAG+BOLD
  16. #define AVGE   GRN+BOLD
  17. object sh_ob;
  18. string mygod;
  19. int can_select;
  20. int _available();
  21.  
  22. int    * talent_reqs = ({ 7,14,21,28 });
  23. string * tier_1      = ({"fervor","religion","shield","avenger"      });
  24. string * tier_2      = ({"lay hands","might","divine shield","wrack" });
  25. string * tier_3      = ({"executioner","martyr","holy-word","harm"   });
  26. string * tier_4      = ({"bloodlust","resurrect","last stand","bless"});
  27.  
  28. mapping all_tal = ([ "fervor", "might", "executioner", "bloodlust", "religion", "lay hands",
  29.     "martyr", "resurrect", "shield", "divine shield", "holy-word","last stand","avenger","harm",
  30. "wrack","bless"]);
  31.  
  32. string * all_talents = ({
  33.     "fervor","might","executioner","bloodlust","religion","lay hands","martyr","resurrect", "shield",
  34. "divine shield","holy-word","last stand","avenger","bless","harm","wrack"});
  35. int query_talent_slots()
  36. {
  37.     int my_lev, slots,i,size;
  38.     size = sizeof(all_talents);
  39.     //my_lev = QUESTD->query_quest_points_earned(this_player())/200;
  40.     my_lev = 30;
  41.     if(my_lev > 30)
  42.     {
  43.         my_lev = 30;
  44.     }
  45.     slots = (my_lev / 5);
  46.    
  47.     for (i = 0; i < size; i ++)
  48.     {
  49.         if(skill_exist(all_talents[i]))
  50.         {
  51.             slots--;
  52.         }
  53.     }
  54.     if(this_player()->query("paladin/talents/harm")) slots--;
  55.     if(this_player()->query("paladin/talents/wrack")) slots--;
  56.     if(this_player()->query("paladin/talents/bless")) slots--;
  57.     if(this_player()->query("paladin/talents/shield")) slots--;
  58.     if(slots < 0) slots = 0;
  59.     return slots;
  60. }
  61.  
  62. void start_shadow (object who) {
  63.     int x;
  64.    
  65.     if (who->query_paladinshadow() || who->query_subclass_shadow()) {
  66.         destruct(this_object());
  67.         return;
  68.     }
  69.     shadow(who,1);
  70.     sh_ob = who;
  71.    
  72.     sh_ob->add_hook("pre_death", "class_pre_death");
  73.     add_action("_available","talents");
  74.     add_action("_available","palist");
  75.     add_action("_selecttalent","palearn");
  76.     add_action("_selecttalent","tselect");
  77.    
  78. }
  79.  
  80. int _available(string str)
  81. {
  82.     object last;
  83.     string avail1,avail2,avail3,avail4;
  84.     int index, size, size2, size3, size4, i,j,k,l,m,totlevel;
  85.     string msg;
  86.    
  87.     if (!this_player()->query_is_player())
  88.     return 0;
  89.     if (query_is_war() || this_player()->query_war_player())
  90.     return 0;
  91.    
  92.     size = sizeof(tier_1);
  93.     size2 = sizeof(tier_2);
  94.     size3 = sizeof(tier_3);
  95.     size4 = sizeof(tier_4);
  96.    
  97.     avail1 = "";
  98.     avail2 = "";
  99.     avail3 = "";
  100.     avail4 = "";
  101.     totlevel = this_player()->query_total_level();
  102.    
  103.     if(str == "all")
  104.     {
  105.         tell_object(sh_ob,format(RED+BOLD+sprintf("%|80'='s"," Talents "+RED+BOLD)));
  106.         tell_object(sh_ob,sprintf("%@-16s",({"               ","Tier1","Tier2","Tier3","Tier4\n"})));
  107.         tell_object(sh_ob,sprintf(
  108.         "%@-16s",({BGUARD+"\nBlackguard   :","[fervor]","[might]","[executioner]","[bloodlust]\n"})));
  109.         tell_object(sh_ob,sprintf(
  110.         "%@-16s",({DIV+"\nHallowed     :","[religion]","[lay hands]","[martyr]","[full restore]\n"})));
  111.         tell_object(sh_ob,sprintf(
  112.         "%@-16s",({BULW+"\nBulwark      :","[shield]","[divine shield]","[holy-word]","[last stand]\n"})));
  113.         tell_object(sh_ob,sprintf(
  114.         "%@-16s",({AVGE+"\nAvenger      :","[Avenger]","[wrack]","[harm]","[bless]\n"})));
  115.         tell_object(sh_ob,format(RED+sprintf(
  116.         "%|80'='s"," Slots Available: "+query_talent_slots()+" "))+NOR);
  117.         return 1;
  118.     }
  119.    
  120.     for (i = 0; i < size; i ++)
  121.     {
  122.         if (totlevel >= talent_reqs[i]  )
  123.         {
  124.             if(skill_exist(tier_1[i])||
  125.             sh_ob->query("paladin/talents/"+tier_1[i]))
  126.             {
  127.                 avail1 += "["+tier_1[i]+"*]\n";
  128.                
  129.             }
  130.             else {
  131.                 avail1 += "["+tier_1[i]+"]\n";
  132.             }
  133.         }
  134.     }
  135.     for (i = 0; i < size; i ++)
  136.     {
  137.         if (totlevel >= talent_reqs[i]  )
  138.         {
  139.             if(skill_exist(tier_2[i])||
  140.             sh_ob->query("paladin/talents/"+tier_2[i]))
  141.             {
  142.                 avail1 += "["+tier_2[i]+"*]\n";
  143.                
  144.             }
  145.             else {
  146.                 avail1 += "["+tier_2[i]+"]\n";
  147.             }
  148.         }
  149.     }
  150.     for (i = 0; i < size3; i ++)
  151.     {
  152.         if (totlevel >= talent_reqs[i]  )
  153.         {
  154.             if(skill_exist(tier_3[i]) ||
  155.             sh_ob->query("paladin/talents/"+tier_3[i]))
  156.             {
  157.                 avail3 += "["+tier_3[i]+"*]\n";
  158.             }
  159.             else
  160.             {
  161.                 avail3 += "["+tier_3[i]+"]\n";
  162.             }
  163.         }
  164.     }
  165.     for (i = 0; i < size4; i ++)
  166.     {
  167.         if (totlevel >= talent_reqs[i]  )
  168.         {
  169.             if(skill_exist(tier_4[i])||
  170.             sh_ob->query("paladin/talents/"+tier_4[i]))
  171.             {
  172.                 avail4 += "["+tier_4[i]+"*]\n";
  173.             }
  174.             else
  175.             {
  176.                 avail4 += "["+tier_4[i]+"]\n";
  177.             }
  178.         }
  179.     }
  180.     tell_object(sh_ob,format(RED+BOLD+sprintf(
  181.     "%|84'='s"," Talents "+RED+BOLD)));
  182.     tell_object(sh_ob,format(RED+sprintf(
  183.     "\n%|75'='s","Slots Available: "+query_talent_slots()+" "))+NOR+"\n");
  184.     tell_object(sh_ob,sprintf(
  185.     "%#-85.5s",CYN+BOLD+"Specilization:    \nTier1\nTier2\nTier3\nTier4")+"\n");
  186.     tell_object(sh_ob,sprintf(
  187.     "%#-80.5s",""+BGUARD+"Blackguard   : \n"
  188.     +DIV+"Hallowed     : \n"+BULW+"Bulwark     : \n"+AVGE+"Avenger      : \n"+avail1+avail2+avail3+avail4));
  189.     tell_object(sh_ob,format(RED+sprintf(
  190.     "\n%|75'='s","")));
  191.     return 1;
  192. }
  193.  
  194. int _selecttalent(string str)
  195. {
  196.     int i, size,size2,can_have,totlevel;
  197.     size = sizeof(talent_reqs);
  198.     totlevel = sh_ob->query_total_level(); 
  199.    
  200.     if(wildmatch(str,"^(fervor|shield|avenger|religion)$"))
  201.     {
  202.         can_select = 7;
  203.     }
  204.     if(wildmatch(str,"^(might|lay hands|divine shield)$"))
  205.     {
  206.         can_select = 14;
  207.     }
  208.     if(wildmatch(str,"^(executioner|martyr|holy-word)$"))
  209.     {
  210.         can_select = 21;
  211.     }
  212.     if(wildmatch(str,"^(bloodlust|resurrect|last stand)$"))
  213.     {
  214.         can_select = 24;
  215.     }  
  216.    
  217.     if(!str)
  218.     {
  219.         tell_object(sh_ob,"Select Which Talent?\n");
  220.         return 1;
  221.     }
  222.    
  223.     if(query_talent_slots() == 0)
  224.     {
  225.         tell_object(sh_ob,"No slots left.\n");
  226.         return 1;
  227.     }
  228.    
  229.     if(str)
  230.     {
  231.         sscanf( str, "%s", str );
  232.         if( !member( all_tal, str ))
  233.         {
  234.             return notify_fail("Not a valid Talent, try again.\n");
  235.         }
  236.         if(skill_exist(str))
  237.         {
  238.             return notify_fail(str+" already exists, please select again.\n");
  239.         }
  240.         if(str == "shield" && totlevel >= can_select)
  241.         {
  242.             this_player()->set("paladin/talents/"+str,1);
  243.             tell_object(sh_ob,str+" selected, "+query_talent_slots()+" slots left.\n");
  244.             return 1;
  245.         }
  246.         if(str == "avenger"&& totlevel >= can_select)
  247.         {
  248.             this_player()->set("paladin/talents/"+str,1);  
  249.             SKILL_H->add_skill(str,1,sh_ob,0);
  250.             tell_object(sh_ob,str+" selected, "+query_talent_slots()+" slots left.\n");
  251.             return 1;
  252.         }
  253.         if(str == "harm" && totlevel < 16)
  254.         {
  255.             return notify_fail("Not a valid Talent, try again.\n");
  256.         }
  257.         else
  258.         {
  259.             this_player()->set("paladin/talents/"+str,1);
  260.             tell_object(sh_ob,str+" selected, "+query_talent_slots()+" slots left.\n");
  261.             return 1;
  262.         }
  263.         if(str == "wrack" && totlevel < 23)
  264.         {
  265.             return notify_fail("Not a valid Talent, try again.\n");
  266.         }
  267.         else
  268.         {
  269.             this_player()->set("paladin/talents/"+str,1);
  270.             tell_object(sh_ob,str+" selected, "+query_talent_slots()+" slots left.\n");
  271.             return 1;
  272.         }
  273.         if(str == "bless" && totlevel < 27)
  274.         {
  275.             return notify_fail("Not a valid Talent, try again.\n");
  276.         }
  277.         else
  278.         {
  279.             this_player()->set("paladin/talents/"+str,1);
  280.             tell_object(sh_ob,str+" selected, "+query_talent_slots()+" slots left.\n");
  281.             return 1;
  282.         }
  283.         if(totlevel >= can_select)
  284.         {
  285.             SKILL_H->add_skill(str,1,sh_ob,0);
  286.             tell_object(sh_ob,str+" selected, "+query_talent_slots()+" slots left.\n");    
  287.             return 1;
  288.         }
  289.         else
  290.         {
  291.             tell_object(sh_ob,"Not a valid Talent, try again.\n");
  292.             return 1;
  293.         }
  294.     }
  295. }
  296.  
  297. void advance_player_level(int level, int hlevel)
  298. {
  299.     int mylevel;
  300.     mylevel = level + hlevel;
  301.     return sh_ob->advance_player_level(level,hlevel);
  302. }
  303.  
  304. int query_sub_skill_adj(string str)
  305. {
  306.     return sh_ob->query_sub_skill_adj(str);
  307. }
  308.  
  309. void end_subclass_shadow()
  310. {
  311.     destruct(this_object());
  312. }
  313.  
  314. string set_no_move( string why, int time )
  315. {
  316.     return sh_ob->set_no_move(why,time);
  317. }
  318.  
  319.  
  320. object query_paladinshadow () { return this_object(); }
  321.  
  322. detection_types() { return ({ "good", "evil", "magic" }); }
  323.  
  324.  
  325. int valid_wear(string str){  
  326.     return str == "shield" || str=="armour" || str=="helmet" || str=="gloves" ||
  327.     str=="boots" || str=="cloak" || str=="amulet" || str == "ring" || str=="ring2" ||
  328.     str=="eyewear" || str== "other";
  329. }
  330.  
  331.  
  332. int wear(object ob){
  333.     string type;
  334.     int level;
  335.     if(!ob->query("paladin/talents/shield") && ob->query_type()=="shield")
  336.     {
  337.         tell_object(sh_ob,"You have not selected 'Shield' talent, You cannot wear shields.\n");
  338.         return 1;
  339.     }
  340.     else
  341.     {
  342.         return sh_ob->wear(ob,1);
  343.     }
  344. }
  345.  
  346. int
  347. class_pre_death(string tag, object who, int dam, int type,object killer)
  348. {
  349.     int count,invuln;
  350.     count = who->query_current_toughness()/10;
  351.    
  352.     if (type == VORPAL) return 0;
  353.     if(sh_ob->query("paladin/talents/last stand"))
  354.     {
  355.         if(count > random(10))
  356.         {
  357.             tell_object(sh_ob,"Last Stand Message.\n");
  358.             invuln++;
  359.             count--;
  360.             if(count < 0) count = 0;
  361.             sh_ob->heal_self(random(55));
  362.             sh_ob->add_temp("invuln_count", invuln);
  363.             if(sh_ob->query("invuln_count") > count+sh_ob->query_total_level())
  364.             {
  365.                 tell_object(sh_ob,"With one last swing, your body gives out in exhaustion.\n");
  366.                 tell_object(sh_ob,"You withstood death "+sh_ob->query("invuln_count")+" times.\n");
  367.                 return 0;
  368.             }
  369.             return 1;
  370.            
  371.         }
  372.     }
  373. }
  374.  
  375.  
  376. query_weapondam_skill(str)
  377. {
  378.     return sh_ob->query_weapondam_skill(str);
  379. }
  380.  
  381. int query_current_weapondam()
  382. {
  383.     if(sh_ob->query("mighty"))
  384.     {
  385.         return sh_ob->query_current_weapondam() * 11 / 10;
  386.         } else {
  387.         return sh_ob->query_current_weapondam();
  388.     }
  389. }
  390. int valid_harm(string arg)
  391. {
  392.     if(arg == "mindspin" && mygod == "Mother of All" && (random(5) > 0)) return 0;
  393.     return sh_ob->valid_harm(arg);
  394.    
  395. }
  396.  
  397. object query_subclass_shadow() {return this_object();}
  398.  
  399. int query_current_toughness()
  400. {
  401.     return sh_ob->query_current_toughness();
  402. }
  403.  
  404. int query_night_sight()
  405. {
  406.     return sh_ob->query_night_sight();
  407. }
  408.  
  409. query_terrain_mod(string arg) { return sh_ob->query_terrain_mod(arg); }
  410.  
  411. string query_mygod() { return mygod; }
  412. string *query_pose_messages(object who) {
  413.     return ({
  414.         "Holy light cascades from the heavens, blessing the gods' chosen "
  415.         "warrior WHO.",
  416.         "The power of light and good covers the land as WHO prays 'STR'."
  417.     });
  418. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement