|
edb6377 Magician
Joined: 29 Nov 2005 Posts: 482
|
Posted: Wed Nov 30, 2005 5:56 pm
Herbalism Mixing Script Need Help With Alias Functions |
I have been working on a script for herbalism mixing
I began to write one but i am running into a few issues.
The way the mud is setup there is no "Specific Combination of Herbs" only the total value of herbs determines what will be. As long as the power of the herbs (Up to a max of 7) falls in a certain range it will be that spell.
What i am trying to do is create a mix alias. I have variables set for my herb values. And a trigger to populate variables as to how many i have of each. I cant figure out however the next steps to take. I have tried about 10 different ways i can think off all without any success. I am looking for something along the lines of the following
COMMAND: Mix curelight
SETS min sprig value - 41
Sets max sprig value - 50
goes through the sprig values and finds all the combinations of herbs i could use to achieve something in that range
goes through my HERB VARIABLES and mixes the option that takes the least number of herbs.
#VAR mixsprival {usicur99urtica92serpentina88virga72salvia64rosa50provinca41verbena33milisopholos32mepeta25queri23lingua18lillium14jusquianus10eliotropia8centaures4celidonia1sedum-1}
#TRIGGER {~( (%n)~) a sprig of (*)} {#var %2 %1 "" {scripts|herbalism}}
Values
Code: |
Sprigs
Sprig Power
usicur 99
urtica 92
serpentina 88
virga pastoris 72
salvia 64
rosa 50
provinca 41
verbena 33
milisopholos 32
mepeta 25
queri 23
lingua canis 18
lillium 14
jusquianus 10
eliotropia 8
centaures 4
celidonia 1
sedum rosea -1
|
Ranges
Code: |
Available Mixtures
Spell Effect Appearance Range Example Mixture
Awaken silvery 1-10 centaures + celidonia
Cause Light reddish 11-20 celidonia + jusquianus
Detect Invisibility light blue 21-30 lillium + eliotropia
Reveal dark purple 31-40 queri + eliotropia
Cure Light glimmering white 41-50 verbena + eliotropia
Refresh warm brown 51-60 rosa + celidonia
Levitation pale blue 61-70 rosa + lillium
Sense Life dark red 71-85 rosa + queri
Calm faint yellow 86-105 rosa + provinca
Cure Poison bright green 106-115 usicur + eliotropia
Blindness shimmering copper 116-135 usicur + lingua canis
Death Grip sticky magenta 136-145 usicur + provinca
Fatigue sparkling gold 146-155 usicur + rosa
Cure Disease bright yellow 156-170 usicur + salvia
Charm warm blue 171-185 usicur + virga pastoris
Flame Wind malevolent magenta 186-200 usicur + serpentina
High Explosive glittering black 201-220 usicur + usicur + centaures
Magic Bomb pulsating orange 221-230 usicur + usicur + queri
|
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Dec 01, 2005 12:59 am |
First you need to build a record variable with the ranges for all the mixtures. Next we will need an example of how you store your current stock of herbs. A single record with counts would be great, but multiple distinct variables will also work. Finally, my quick math says that 1 herb could meet the numbers for most mixes; but all examples show 2...are 2 herbs required?
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
edb6377 Magician
Joined: 29 Nov 2005 Posts: 482
|
Posted: Thu Dec 01, 2005 11:55 am |
yeah there must be a minimum of two herbs up to a maximum of 7 herbs.
Mixing a single herb wont work.
My current stock is stored in my inventory
( 3) a sprig of centaures
a sprig of lillium
( 4) a sprig of mepeta
( 2) a sprig of queri
( 5) a sprig of celidonia
( 2) a sprig of sedum rosea
( 3) a sprig of lingua canis
a sprig of milisophol |
|
|
|
edb6377 Magician
Joined: 29 Nov 2005 Posts: 482
|
Posted: Sat Dec 03, 2005 7:00 pm |
i got a record variable to hold values for min max
herbtable.$herbname Minimum maximum
I have a problem taking that and cycling through my inventory
In creating mixtures you have no more than 2 of the same kind and a minimum of 2 herbs max of 7 in a mixture |
|
|
|
edb6377 Magician
Joined: 29 Nov 2005 Posts: 482
|
Posted: Tue Dec 06, 2005 3:23 am |
hmm no replies.. must be rather difficult.. i cant seem to get anything i try to work
|
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Tue Dec 06, 2005 4:55 am |
Thinking step 1
High Explosive glittering black 201-220 usicur + usicur + centaures
usicur 99
centaures 4
The simplest way you are going to do this is by finding the number of the highest power sprig needed to the range then incrementally add the other sprigs in lesser quantity.
1: 99*1 = 099< 201
2: 99*2 = 198 < 201
3: 99*3 = 297 > 220 Bust and thats good as it would have put us over the maximum of 2 per kind
So we take 2 usicur.
New min 201-198 = 3
New max 220-198 = 22
1: 4*1 = 4 > 3 and < 22
2: 4*2 = 8 > 3 and < 22
3: 4*3 = 12 > 3 and < 22 Not a valid choice as over 2 of a herb type
Do we take 1 or 2 centaures. Do we want to get as close to the max as possible? Brew it.
That kind of recursion will be needed to find the answer.
99*A + 4*B = In range of 201 to 220
Find A and B |
|
Last edited by TonDiening on Tue Dec 06, 2005 6:09 am; edited 1 time in total |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Tue Dec 06, 2005 6:03 am |
Superceded
|
|
Last edited by TonDiening on Tue Dec 06, 2005 7:27 pm; edited 1 time in total |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Tue Dec 06, 2005 3:32 pm |
Ah Interesting, I had missed the fact that its the sum of the herb that counts. :)
|
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Tue Dec 06, 2005 7:37 pm |
This is not something that is optimized and is problably overly complicated but for a 45 min hack it works.
Run the blue aliases to make the variables. You'll have to edit alias HerbMixtureSetup to set up all the spells, I did 3 of them as examples.
Change the green trigger My current stock is stored in my inventory to reflect a line denoting you are checking your stock. It is used to set variables to nothing.
Run alias doCanIMix detect invisibility to see if you can or not.
The example about would output with the settings in the script below:
----------------------
Can I mix Detect_Invisibility with my current inventory... hint lillium|eliotropia
----------------------
Mixing: Detect_Invisibility Min 21 - Max 30
----------------------
Qty Power Herb
1/4 (25) of sprig mepeta
1/3 (4) of sprig centaures
1/5 (1) of sprig celidonia
For total power 30.
----------------------
Script:
#CLASS {Test|zuggsoft22610}
#ALIAS SprigPowerSetup {#VAR SprigPower %null _nodef {test|zuggsoft22610};#ADDKey SprigPower usicur 99;#ADDKey SprigPower urtica 92;#ADDKey SprigPower serpentina 88;#ADDKey SprigPower virga_pastoris 72;#ADDKey SprigPower salvia 64;#ADDKey SprigPower rosa 5;#ADDKey SprigPower provinca 41;#ADDKey SprigPower verbena 33;#ADDKey SprigPower milisophol 32;#ADDKey SprigPower mepeta 25;#ADDKey SprigPower queri 23;#ADDKey SprigPower lingua_canis 18;#ADDKey SprigPower lillium 14;#ADDKey SprigPower jusquianus 1;#ADDKey SprigPower eliotropia 8;#ADDKey SprigPower centaures 4;#ADDKey SprigPower celidonia 1;#ADDKey SprigPower sedum_rosea -1}
#ALIAS HerbMixtureSetup {//Awaken silvery 1-10 centaures + celidonia ;//Cause Light reddish 11-20 celidonia + jusquianus ;#NOOP;#VAR HerbMixtures %null _nodef {test|zuggsoft22610};#VAR HerbMixturesColors %null _nodef {test|zuggsoft22610};#ADDITEM HerbMixtures Detect_Invisibility;#ADDITEM HerbMixturesColors {light blue};#ADDKEY Detect_Invisibility Max 30;#ADDKEY Detect_Invisibility Min 21;#ADDKEY Detect_Invisibility Color {light blue};#ADDKEY Detect_Invisibility Types {lillium|eliotropia};//Reveal dark purple 31-40 queri + eliotropia ;//Cure Light glimmering white 41-50 verbena + eliotropia ;//Refresh warm brown 51-60 rosa + celidonia ;//Levitation pale blue 61-70 rosa + lillium ;#Noop;#ADDITEM HerbMixtures Sense_Life;
#ADDITEM HerbMixturesColors {dark red};#ADDKEY Sense_Life Color {dark red};#ADDKEY Sense_Life Min 71;#ADDKEY Sense_Life Max 85;#ADDKEY Sense_Life Types {rosa|queri};//Calm faint yellow 86-105 rosa + provinca ;//Cure Poison bright green 106-115 usicur + eliotropia ;//Blindness shimmering copper 116-135 usicur + lingua canis ;//Death Grip sticky magenta 136-145 usicur + provinca ;//Fatigue sparkling gold 146-155 usicur + rosa ;//Cure Disease bright yellow 156-170 usicur + salvia ;//Charm warm blue 171-185 usicur + virga pastoris ;//Flame Wind malevolent magenta 186-200 usicur + serpentina ;//High Explosive glittering black 201-220 usicur + usicur + centaures ;#Noop;#ADDITEM HerbMixtures High_Explosive;#ADDITEM HerbMixturesColors {glittering black};#ADDKEY High_Explosive Color {glittering black};#ADDKEY High_Explosive Min 201;#ADDKEY High_Explosive Max 220;#ADDKEY High_Explosive Types {usicur|usicur|centaures};//Magic Bomb pulsating orange 221-230 usicur + usicur + queri}
#ALIAS InvSetup {#echo "My current stock is stored in my inventory ";#ECHO " ";#ECHO "( 3) a sprig of centaures ";#ECHO "a sprig of lillium ";#ECHO "( 4) a sprig of mepeta ";#ECHO "( 2) a sprig of queri ";#ECHO "( 5) a sprig of celidonia ";#ECHO "( 2) a sprig of sedum rosea ";#ECHO "( 3) a sprig of lingua canis ";#ECHO "a sprig of milisophol";#ECHO "( 1) a sprig of eliotropia"}
#TRIGGER {My current stock is stored in my inventory} {#VAR HerbInv.List %null _nodef {test|zuggsoft22610};#CO 31}
#TRIGGER {^a sprig of (*)} {#addkey HerbInv %replace( %trim( %1), " ", "_") 1;#additem HerbInv.List %1;#PCOL 31 %x1}
#TRIGGER {^~( (%n)~) a sprig of (*)} {#addkey HerbInv %replace( %trim( %2), " ", "_") %1;#additem HerbInv.List %2;#PCOL 31 %x2}
#TRIGGER {({@HerbMixturesColors}) potion} {#SUB {%item(@HerbMixtures,%ismember(%1,@HerbMixturesColors)) potion}}
#ALIAS CanIMix {#IF ( %numparam( ) != 1) {#ECHO Syntax: CanIMix Spell_Name_Here} {#IF (%ismember( %upper( %-1), %upper( @HerbMixtures))>0) {#SH ----------------------;#SH Can I mix %1 with my current inventory... hint %db( @{%1}, Types);#SH ----------------------;#NOOP Spell Check;#VAR CanIMix %null _nodef {Test|zuggsoft22610};#VAR CanIMix.Name %1;#VAR CanIMix.Min @%1.Min;#VAR CanIMix.Max @%1.Max;#VAR CanIMix.Fail 0;#NOOP Get all Herbs from Inventory Check;#FORALL @HerbInv.List {#IF (@HerbInv.%i != %null) {#ADDITEM CanIMix.HerbPowerList %concat( %repeat( "0", 5-%len( %db( @SprigPower, %i))), %db( @SprigPower, %i), %repeat( "0", 5-%len( %db( @HerbInv, %i))), %db( @HerbInv, %i), %i)}};#VAR CanIMix_HerbPowerList %sort( @CanIMix.HerbPowerList, 1);#NOOP Viability check;#IF (%numitems( @CanIMix_HerbPowerList) < 2) {#ECHO Fail. Need 2+ herbs.;#VAR CanIMix.Fail 1};#FORALL @CanIMix_HerbPowerList {#add CanIMix.TotalHerbInv %eval( %int( %copy( %i, 1, 5))*%min( 2, %int( %copy( %i, 1, 5))))};#IF (@CanIMix.TotalHerbInv < @CanIMix.Min) {#sh Fail. Do not have enough herbs to make minimum.;#VAR CanIMix.Fail 1};#NOOP Strip out the herbs with too much power;#FORALL @CanIMix_HerbPowerList {#IF (%int( %copy( %i, 1, 5))>@CanIMix.Max) {#NOOP %pop( CanIMix_HerbPowerList)}};#NOOP Probably should re-sort to use up the low value, probably cheap herbs;#NOOP VAR CanIMix_HerbPowerList %sort( @CanIMix.HerbPowerList);#NOOP;#VAR CanIMix.PowerCountDown @CanIMix.Max;#WHILE (!%null( @CanIMix_HerbPowerList)) {#VAR CanIMix.CurrentHerb %pop( CanIMix_HerbPowerList);#IF (@CanIMix.PowerCountDown >= %int( %copy( @CanIMix.CurrentHerb, 1, 5))) {#IF ((@CanIMix.PowerCountDown/%eval( %int( %copy( @CanIMix.CurrentHerb, 1, 5))*%min( 2, %int( %copy( @CanIMix.CurrentHerb, 6, 5))))) >= 2) {#Add CanIMix.PowerCountdown -%min( 2, %int( %copy( @CanIMix.CurrentHerb, 6, 5)))*%int( %copy( @CanIMix.CurrentHerb, 1, 5));#ADDITEM CanIMix.Solution %min( 2, %int( %copy( @CanIMix.CurrentHerb, 6, 5)))%copy( @CanIMix.CurrentHerb, 11, %len( @CanIMix.CurrentHerb)-10+1)} {#add CanIMix.PowerCountdown -%int( %copy( @CanIMix.CurrentHerb, 1, 5));#ADDITEM CanIMix.Solution 1%copy( @CanIMix.CurrentHerb, 11, %len( @CanIMix.CurrentHerb)-10+1)}}};#IF (@CanIMix.Max-@CanIMix.PowerCountdown < @CanIMix.Min) {#VAR CanIMix.Fail 1};#IF (%numitems( @CanIMix.Solution) > 7) {#VAR CanIMix.Fail 1};#SH Mixing: @CanIMix.Name Min @CanIMix.Min - Max @CanIMix.Max %if( @CanIMix.Fail=1, FAILED, "");#SH ----------------------;#SH Qty%tab Power%tab Herb;#FORALL %db( @CanIMix, Solution) {#SH %copy( %i, 1, 1)/%db( @HerbInv, %copy( %i, 2, %len( %i)-1))%tab (%db( @SprigPower, %copy( %i, 2, %len( %i)-1)))%tab of sprig %replace( %copy( %i, 2, %len( %i)-1), "_", " ")};#SH For total power %eval( @CanIMix.Max-@CanIMix.PowerCountdown).;#SH ----------------------} {#SH Mixture not recognized from %replace( @HerbMixtures, "|", ", ")}}}
#ALIAS doCanIMix {canIMix %replace( %-1, " ", "_")}
#CLASS 0 |
|
Last edited by TonDiening on Wed Dec 07, 2005 5:31 pm; edited 1 time in total |
|
|
|
edb6377 Magician
Joined: 29 Nov 2005 Posts: 482
|
Posted: Wed Dec 07, 2005 2:56 am |
ill check this and see how it goes..
I appreciate the reply. |
|
|
|
Slaem Apprentice
Joined: 20 Sep 2005 Posts: 135
|
Posted: Wed Dec 07, 2005 9:10 am |
Btw, what mud is this?
|
|
|
|
kyros Novice
Joined: 26 Jan 2005 Posts: 33
|
Posted: Sun Jul 30, 2006 12:26 am |
Materia Magica!
|
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|