fork download
  1. var status = -1;
  2. var eqs = [
  3. [1302030, [1302064, 1402039]], // Maple Soul Singer -> Maple Glory Sword / Maple Soul Rohen
  4. [1332025, [1332056, 1332055]], // Maple Wagner -> Maple Asura Dagger / Maple Dark Mate
  5. [1382012, [1382039, 1372034]], // Maple Lama Staff -> Maple Wisdom Staff / Maple Shine Wand
  6. [1412011, [1312032, 1412027]], // Maple Dragon Axe -> Maple Steel Axe / Maple Demon Axe
  7. [1422014, [1422029]], // Maple Doom Singer -> Maple Belzet
  8. [1432012, [1432040]], // Maple Impaler -> Maple Soul Spear
  9. [1442024, [1442051]], // Maple Scorpio -> Maple Karstan
  10. [1452022, [1452045]], // Maple Soul Searcher -> Maple Kandiva Bow
  11. [1462019, [1462040]], // Maple Crossbow -> Maple Nishada
  12. [1472032, [1472055]], // Maple Kandayo -> Maple Skanda
  13. [1482021, [1482022]], // Maple Storm Finger -> Maple Golden Claw
  14. [1492021, [1492022]] // Maple Storm Pistol -> Maple Cannon Shooter
  15. ];
  16. var reqs = [
  17. [4001126, 200], // Maple Leaf
  18. [4033440, 50], // Basic White Essence Stones
  19. [4033439, 25], // Basic Pink Essence Stones
  20. [4033433, 25] // Basic Red Essence Stones
  21. ];
  22. var selEq;
  23.  
  24. function start() {
  25. cm.sendNext("Lucky you, #h #! You’ve arrived just in time for an incoming stock of new Maple weapons made by the Resistance. They are quite a mighty upgrade from the old weapons provided by Claudine, would you care to take a look? #v1402039#, #v1302064#, #v1332056#, #v1332055#, #v1382039#, #v1372034#, #v1312032#, #v1412027#, #v1422029#, #v1432040#, #v1442051#, #v1452045#, #v1462040#, #v1472055#, #v1482022#, #v1492022#.");
  26. }
  27.  
  28. function action(mode, type, selection) {
  29. if (mode == 0 && status == 2) {
  30. cm.sendOk("Well it's while stocks last anyway. Come back when you are ready.");
  31. cm.dispose();
  32. return;
  33. } else if (mode < 1) {
  34. cm.dispose();
  35. return;
  36. }
  37. status++;
  38. if (status == 0) {
  39. var text = "We will issue one of these weapons out to you for a price!\r\n";
  40. text += "\r\nThe requirements are:";
  41. text += "\r\nThe level 43 Maple weapon you want to upgrade.";
  42. text += "\r\n\t#v4001126# 200 Maple Leaves from monsters all over Commerci.";
  43. text += "\r\n\t#v4033440# 50 Basic White Essence Stones from mining in Ardentmill.";
  44. text += "\r\n\t#v4033439# 25 Basic Pink Essence Stones from mining in Ardentmill.";
  45. text += "\r\n\t#v4033433# 25 Basic Red Essence Stones from mining in Ardentmill.";
  46. if (haveEq()) {
  47. cm.sendNext(text);
  48. } else {
  49. cm.sendOk(text);
  50. cm.dispose();
  51. }
  52. } else if (status == 1) {
  53. var selText = "Which equip would you like to upgrade? (The equip chosen will be the top one in your inventory).\r\n";
  54. for (var i = 0; i < eqs.length; i++) {
  55. if (cm.haveItem(eqs[i][0])) {
  56. selText += "\r\n#L" + i + "##i" + eqs[i][0] + "##z" + eqs[i][0] + "#";
  57. }
  58. }
  59. cm.sendSimple(selText);
  60. } else if (status == 2) {
  61. selEq = selection;
  62. var selText = "With a #i" + eqs[selEq][0] + "#, you can get ";
  63. if (eqs[selEq][1].length == 1) {
  64. selText += "a #i" + eqls[selEq][1][0] + "#";
  65. } else {
  66. selText += "either a #i" + eqls[selEq][1][0] + "# or a #i" + eqls[selEq][1][0] + "#.";
  67. }
  68. if (haveReq(selEq)) {
  69. selText += "\r\n\r\nWould you like to exchange a #i" + eqs[selEq][0] + "#?";
  70. cm.sendYesNo(selText);
  71. } else {
  72. cm.sendOk(selText);
  73. cm.dispose();
  74. }
  75. } else if (status == 3) {
  76. if (haveReq(selEq)) {
  77. if (cm.canHold(1302007)) {
  78. takeReq(selEq);
  79. cm.gainItem(eqs[selEq][0], 1, true);
  80. } else {
  81. cm.sendOk("Do you even have space to receive the weapon? Come back when you're ready!");
  82. cm.dispose();
  83. }
  84. } else {
  85. cm.dispose();
  86. }
  87. }
  88. }
  89.  
  90. function haveReq(item) {
  91. if (!cm.haveItem(eqs[item][0])) {
  92. return false;
  93. }
  94. for (var i = 0; i < reqs.length; i++) {
  95. if (cm.haveItem(reqs[i][0], reqs[i][1])) {
  96. return false;
  97. }
  98. }
  99. return true;
  100. }
  101.  
  102. function takeReq(item) {
  103. cm.gainItem(eqs[item][0], -1);
  104. for (var i = 0; i < reqs.length; i++) {
  105. cm.gainItem(reqs[i][0], -reqs[i][1])
  106. }
  107. return true;
  108. }
  109.  
  110. function haveEq() {
  111. for (var i = 0; i < eqs.length; i++) {
  112. if (cm.haveItem(eqs[i][0])) {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
Success #stdin #stdout 0.56s 44608KB
stdin
restart:

# Constants
con := {
  r1=2, r2=2, beta1=4, beta2=4, mu1=0.5, mu2=0.5,
  nu1=0.5, nu2=0.5, eta1=1.5, eta2=1.5,
  theta1=2, theta2=2, delta1=4, delta2=4,
  gamma1=4, gamma2=4
}:

# Define u(x)
u := x -> evalf( ((delta1*r1 - delta1*(mu1*x^eta1 + nu1*x^theta1)) / 
                (mu1*x^eta1 + nu1*x^theta1 - r1 - gamma1)) ):
                
# Define f(x)
f := x -> evalf( (r2*delta2 + (gamma2 + r2)*x - (mu2*u(x)^eta2 + nu2*u(x)^theta2)*(delta2 + x)) ):

# Solve f(x) = 0 numerically
sol := fsolve(f(x)=0, x=0..5): 
x1 := sol: 
x2 := u(x1):

# Define g1 and g2
g1 := (x,y) -> evalf( r1 + gamma1*y/(delta1 + y) - mu1*x^eta1 - nu1*x^theta1 ):
g2 := (x,y) -> evalf( r2 + gamma2*x/(delta2 + x) - mu2*y^eta2 - nu2*y^theta2 ):

# Evaluate g1 and g2 at (x1, x2)
g1_val := g1(x1, x2): 
g2_val := g2(x1, x2):

# Partial derivatives needed for characteristic equation
a11 := evalf( r1 + gamma1*x2/(delta1 + x2) - nu1*x1^theta1 - mu1*(eta1+1)*x1^eta1 ):
a22 := evalf( r2 + gamma2*x1/(delta2 + x1) - nu2*x2^theta2 - mu2*(eta2+1)*x2^eta1 ):
b11 := evalf( -nu1*theta1*x1^theta1 ):
b21 := evalf( gamma2*delta2*x2 / (delta2 + x1)^2 ):
c12 := evalf( gamma1*delta1*x1 / (delta1 + x2)^2 ):
c22 := evalf( -nu2*theta2*x2^theta2 ):

# Critical tau1
tau1 := 0.686756:

# Define h1(x), h2(x), h3(x) with tau2 = 0
h1 := x -> -(a11*c22 + (b11*c22 - c12*b21)*cos(x*tau1))^2 - (x*c22 + (b11*c22 - c12*b21)*sin(x*tau1))^2:

h2 := x -> -(a11*c22 + (b11*c22 - c12*b21)*cos(x*tau1)) * 
            (x^2 - a11*a22 + x*b11*sin(x*tau1) - a22*b11*cos(x*tau1)) +
            (c22*x + (b11*c22 - c12*b21)*sin(x*tau1)) * 
            (x*(a11 + a22) + x*b11*cos(x*tau1) + a22*b11*sin(x*tau1)):

h3 := x -> (a11*c22 + (b11*c22 - c12*b21)*cos(x*tau1)) * 
            (x*(a11 + a22) + x*b11*cos(x*tau1) + a22*b11*sin(x*tau1)) +
            (x^2 - a11*a22 + x*b11*sin(x*tau1) - a22*b11*cos(x*tau1)) * 
            (x*c22 + (b11*c22 - c12*b21)*sin(x*tau1)):

# Final combined function
h := x -> h2(x)^2 + h3(x)^2 - h1(x)^2:

# Find critical root
root := fsolve(h(x)=0, x=0..5):
x_crit := root:
h_val := h(x_crit):

# Display tau1 remains valid
printf("Root found at x = %.5f with h(x) = %.5e\n", x_crit, h_val);
stdout
Standard output is empty