Jump to content
  • 0

Using @summon with a % after killing each mob.


JulianD

Question


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  12/27/16
  • Last Seen:  

Greetings appreciated development community,

 

I'm trying to create a system that allow players to summon the monster they killed with a variable % chance:

For example:

 

After killing 1 Poring, it will have a 100% chance of using "@summon Poring 60" (60 will mean that the summon will last for 60 minutes)

After killing 1 Eddga, it will have a 5% chance of using "@summon Eddga 60"

 

This is so far what I have written: (I'm a beginner scripter, so I don't certainly know what I'm doing)

-	script	TFRSummoner	-1,{
	end;

OnNPCKillEvent:
	if( killedrid == 1002){
		atcommand "@summon 1002 60";
	}
	end;
}

This code allowed the players to summon a poring after killing it with a 100% chance, but I don't know how to make it work with a different % chance.

Additionally, I don't know how to add multiple entries depending on different mob IDs.

I would also like to know if there is any way to autodetect the monster ID that was killed, to avoid writing +1000 entries of different monsters in the script.

 

Thank you for your assistance, I really appreciate it.

 

Best regards,

 

Julián Díaz

Passionate Human Being

Edited by JulianD
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  477
  • Reputation:   269
  • Joined:  06/13/17
  • Last Seen:  

Quote

I would also like to know if there is any way to autodetect the monster ID that was killed, 

it's already in your script.. `killedrid`
 

-	script	TFRSummoner	-1,{
OnInit:
	setarray .Monster[1],1002,1115;
	setarray .Chance[1],30,5;
end;

OnNPCKillEvent:
	.@id = inarray(.Monster,killedrid);
	if(!.@id) end;
	if( rand(1,100) <= .Chance[.@id])
		atcommand "@summon "+killedrid+" 60";
end;
}

i'll explain it because i see that you want to learn..

at OnInit i put all the Monsters ID on an array called .Monster and after that. i put the percent chance they would be summon at an array called .Chance

at OnNPCKillEvent, i checked if the monster they killed is is on the .Monster array and pass it on a variable call .@id.. if the monster id is not found.. it will end there doing nothing.. however if the monster is on the array .  we will create a random number from 1 to 100 that signifies percentage and then finally match it with a logical operator to check if the random is within the chance.. If the check is true. than it will summon 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   25
  • Joined:  11/28/11
  • Last Seen:  

In this case it would make sense to think about some sort of progression method. What is the spawn-chance based on? Even in @Haruka Mayumi's solution you would have to explicitly define every mobs spawn chance. My solution isn't much better, as it simply uses the mob level to calculate a spawn chance. A better solution would be to create an array that contains mob level ranges and their spawn chances. Something like "all mobs with level 1-10 have a 100% spawn chance". Such a system will always work, even when new mobs get added, but sadly you lose some control over the actual spawn rate of specific mobs. You could also create a tiered system like "normal mobs use algorithm, mini-bosses always have 5% chance and bosses have 1% chance".

 

-	script	TFRSummoner	-1,{
end;

OnNPCKillEvent:
	// only summon the mob if we actually get useful information
	if (getmonsterinfo(killedrid,MOB_LV)) {
		// calculate the chance of the monster spawning based on mob level
		// higher level = lower spawn chance
		if (rand(1,100) >= ((getmonsterinfo(killedrid,MOB_LV) / 160) * 100)) {
			atcommand "@summon "+killedrid+" 60";
		}
	}
	end;
}
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  12/27/16
  • Last Seen:  

@Haruka Mayumi
Thank you, your explanation was very clear to me and I am currently configuring it to work with the IDs that I want.

I am currently thinking about also adding a different summon time. Would it be like this?:

-	script	TFRSummoner	-1,{
OnInit:
	setarray .Monster[1],1002,1115;
	setarray .Chance[1],30,5;
	setarray .Time[1],120,30;
end;

OnNPCKillEvent:
	.@id = inarray(.Monster,killedrid);
	if(!.@id) end;
	if( rand(1,100) <= .Chance[.@id])
		atcommand "@summon "+killedrid+" .Time[.@id]";
end;
}

EDIT: I actually tested the script, and it does not display any error message, and the mobs are still being summoned... The only thing is that the summon is not lasting for the time that I set on the .Time array, but all mobs are lasting just 1 minute (default). I guess I'm not calling the value of the array properly.

EDIT2: I was able to finally make it work: (If someone wants to add the script, it is currently summoning Champion Mobs with 75% chance during 20 minutes, mini-bosses and MVP have different % and duration depending on the amount of monsters that globally and naturally spawn as following: (Still all values can be changed separately.)

# of Mobs    Chance       Time
1                    100             240
2-5                 100             120
6-10                89              107
11-15              79               94
16-20              68               82
21-25              58               69
26-30              47               56
31-35              37               43
36-40              26               31
41-45              16               18
+46                 5                 5

-	script	TFRSummoner	-1,{
OnInit:
	setarray .Monster[0],1089,1090,1091,1092,1093,1096,1120,1198,1203,1204,1205,1259,1262,1283,1289,1295,1302,1307,1320,1388,1582,1626,1640,1641,1642,1643,1644,1645,1681,1700,1701,1702,1703,1704,1705,1706,1707,1709,1710,1711,1712,1720,1754,1755,1765,1783,1829,1830,1831,1833,1839,1870,1873,1894,1916,1918,1919,1920,1921,1929,1956,1958,1959,1960,1961,1990,1991,2174,2175,2176,2177,2178,2179,2180,2181,2182,2183,2184,2185,2187,2188,2189,2190,2191,2192,2193,2194,2198,2208,2228,2229,2230,2231,2232,2233,2234,2242,2243,2244,2317,2320,2321,2322,2332,2470,2471,2472,2473,2474,2475,2476,2530,2542,2562,2563,2564,2650,2665,2675,2684,2685,2686,2721,2726,2736,2742,2743,2744,2788,2828,2861,2921,2923,2942,2988,2997,2998,2999,3001,3002,3003,3004,3005,3008,3098,3099,3105,3106,3108,3109,3191,3192,3193,3194,3195,3196,3208,3209,3210,3211,3212,3213,3214,3215,3216,3217,3218,3219,3220,3221,3222,3223,3224,3225,3226,3227,3228,3229,3230,3231,3232,3233,3234,3235,3236,3237,3238,3239,3240,3241,3242,3243,3244,3245,3246,3253,3474,3475,3484,3741,1038,1039,1046,1059,1086,1087,1112,1115,1147,1150,1157,1159,1190,1251,1252,1272,1312,1373,1389,1418,1492,1511,1583,1623,1630,1646,1647,1648,1649,1650,1651,1658,1685,1688,1708,1719,1734,1751,1768,1779,1785,1832,1871,1885,1917,2022,2068,2087,2131,2156,2165,2202,2235,2236,2237,2238,2239,2240,2241,2249,2251,2253,2255,2319,2362,2441,2442,2483,2529,2532,2533,2534,2535,2996,3000,3029,3073,3074,3091,3092,3096,3097,3124,3181,3254,3450,3473,2603,2604,2605,2606,2607,2608,2609,2610,2611,2612,2613,2614,2615,2616,2617,2618,2619,2620,2621,2622,2623,2624,2625,2626,2627,2628,2629,2630,2631,2632,2633,2634,2635,2636,2637,2638,2639,2640,2641,2642,2643,2644,2645,2646,2647,2648,2649,2651,2652,2653,2654,2655,2656,2657,2658,2659,2660,2661,2662,2663,2664,2666,2667,2668,2669,2670,2671,2672,2673,2674,2676,2677,2678,2679,2680,2681,2682,2683,2687,2688,2689,2690,2691,2693,2694,2695,2696,2697,2698,2699,2700,2701,2702,2703,2704,2705,2706,2707,2708,2709,2710,2711,2712,2713,2714,2715,2716,2717,2718,2719,2720,2722,2723,2724,2725,2727,2728,2729,2730,2731,2732,2733,2734,2735,2737,2738,2739,2740,2741,2745,2746,2747,2748,2749,2750,2751,2752,2753,2754,2755,2756,2757,2758,2759,2760,2761,2762,2763,2764,2765,2766,2767,2768,2769,2770,2771,2772,2773,2774,2775,2776,2777,2778,2779,2780,2781,2784,2785,2786,2787,2789,2790,2791,2792,2793,2794,2795,2796,2797,2798,2799,2800,2801,2802,2803,2804,2805,2806,2807,2808,2809,2810,2811,2812,2813,2814,2815,2816,2817,2818,2819,2820,2821,2822,2823,2824,2825,2826,2827,2829,2830,2831,2832,2833,2834,2835,2836,2837,2838,2839,2840,2841,2842,2843,2844,2845,2846,2847,2848,2849,2850,2851,2852,2853,2854,2855,2856,2857,2858,2859,2860,2862,2863,2864,2865,2866,2867,2868,2869,2870,2871,2872,2873,2874,2875,2876,2877,2878,2879,2880,2881,2882,2883,2884,2885,2886,2887,2888,2889,2890,2891,2892,2893,2894,2895,2896,2897,2898,2899,2900,2901,2902,2903,2904,2905,2906,2907,2908,2909,2910,2911,2912,2913;
	setarray .Chance[0],100,89,89,100,100,100,100,5,47,58,58,58,79,58,89,5,16,68,5,100,100,100,100,100,100,100,100,100,79,5,5,5,5,89,89,89,89,100,100,100,100,58,5,47,79,5,5,5,5,5,89,5,100,47,100,5,5,5,5,100,100,79,100,89,89,100,100,100,89,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,5,100,100,58,100,100,100,100,100,100,100,100,5,5,89,100,100,100,100,100,37,26,58,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,89,100,89,100,100,100,100,100,100,100,100,100,100,100,79,5,5,89,68,89,79,68,89,89,100,100,100,100,100,100,100,100,100,100,100,100,89,89,79,79,79,89,89,100,100,100,100,100,100,100,100,100,100,100,100,100,100,58,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,89,100,100,100,100,100,100,100,89,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75;
	setarray .Time[0],120,107,107,120,120,120,120,5,56,69,69,69,94,69,107,5,18,82,5,120,120,240,120,120,120,120,120,120,94,5,5,5,5,107,107,107,107,120,120,120,120,69,5,56,94,5,5,5,5,5,107,5,120,56,240,5,5,5,5,240,240,94,120,107,107,240,240,120,107,120,120,120,120,120,120,120,120,120,120,240,240,240,240,120,5,120,240,69,240,120,120,120,120,120,120,120,5,5,107,240,240,240,240,120,43,31,69,240,240,240,240,120,240,240,240,240,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,240,240,240,240,240,240,240,107,240,107,240,120,120,240,240,240,240,120,240,240,240,94,5,5,107,82,107,94,82,107,107,240,240,240,240,240,240,240,240,240,240,240,240,107,107,94,94,94,107,107,240,240,240,240,240,240,240,240,240,240,240,240,240,240,69,240,240,240,240,120,120,120,120,120,120,120,120,120,120,120,120,120,240,240,120,120,240,240,120,120,120,240,240,120,120,120,120,120,120,120,120,240,120,240,240,240,120,240,240,107,120,120,240,240,240,240,240,107,240,240,240,120,120,120,120,120,120,120,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20;
end;

OnNPCKillEvent:
	.@id = inarray(.Monster,killedrid);
	if(!.@id) end;
	if( rand(1,100) <= .Chance[.@id])
		atcommand "@summon "+killedrid+" "+.Time[.@id]+"";
end;
}

Thank you once again @Haruka Mayumi  for your excellent support.

@Terces

Thank you as well for taking your time to answer. I think that chances with specific IDs work for me because it will allow me to choose what monsters reward the players by fighting on their side for some time. I will probably add mini-bosses and MVPs for now, and I will try to select some other specific regular mobs to be summoned as well. It was interesting to read your script too, I was able to learn from it too.

Edited by JulianD
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...