PDA

View Full Version : COL Signs Script



TheThirdEye
06-16-2010, 03:15 AM
Well, I am still beating my head against the wall of understanding with writing scripts for PsiNet but suffering can lead to wisdom. With that in mind I have taken one of the scripts I use while hunting and always wished would somehow run in the background and converted it to do so. Any comments from the few of you that are actually scripting for Psinet would be appreciated. I acknowledge there is more that can be done here. I would like it to actually monitor the character's mana, then apply the signs when mana is available. As it stands right now will just hang if there is not enough mana for running the sign after it started the first time. This doesnt' make it very useful for lower level or mana intensive characters who will have to stop and restart the script if the sign runs out while low on mana. At least you won't fry your nerves.




#Utility for main (mana only) CoL signs
#Based on the script written by Lady Eiadh of Solhaven

#This script is designed to avoid frying your nerves.

#This is a looping script intended to run on PsiSage in the background while hunting

#Script will not run unless you have at least 9 mana

#Modified by Fiandel (PC TheThirdEye)

if(%me.mana < 9){
GOTO NoMana2
} else {
PUT Sign of Striking
WAIT
PUT Sign of Smiting
WAIT
PUT Sign of Warding
WAIT
PUT Sign of Defending
WAIT
PUT Sign of Deflection
GOTO Start
}

Start:
MATCH ChkMana1 WARDING is no longer
MATCH ChkMana2 STRIKING is no longer
MATCH ChkMana3 DEFENDING is no longer
MATCH ChkMana4 SMITING is no longer
MATCH ChkMana5 DEFLECTION is no longer
MATCHWAIT

ChkMana1:
if(%me.mana < 1){
GOTO NoMana
} else {
PUT sign of warding
GOTO Start
}

ChkMana2:
if(%me.mana < 1){
GOTO NoMana
} else {
PUT sign of striking
GOTO Start
}

ChkMana3:
if(%me.mana < 2){
GOTO NoMana
} else {
PUT sign of defending
GOTO Start
}

ChkMana4:
if(%me.mana < 2){
GOTO NoMana
} else {
PUT sign of smiting
GOTO Start
}

ChkMana5:
if(%me.mana < 3){
GOTO NoMana
} else {
PUT sign of deflection
GOTO Start
}


NoMana:
ECHO ***********************
ECHO *** NOT ENOUGH MANA ***
ECHO ***********************
GOTO Start

NoMana2:
ECHO ****************************
ECHO ******NOT ENOUGH MANA*******
ECHO **RESTART SCRIPT WHEN YOUR**
ECHO ***MANA IS GREATER THAN 9***
ECHO ****************************
GOTO EXIT

Please no more "Switch to Lich" or "Lich 4 LIFE!" or "You could do that better in LICH!". Yes, I understand that LICH is in every way the most awesomesauce software ever created and 100 to the 10th power better than PsiNet so there is no need to preach. I may even try LICH in the future but please, enough already.

Shaelun
06-23-2010, 12:36 PM
Any comments from the few of you that are actually scripting for Psinet would be appreciated.

Yeah, well, that certainly isn't me... I don't even script in GS for the scripting program I wrote anymore, let alone anybody elses. Still, the parts you have are enough of a "how-to" for me to feel like I'm not throwing bogus code at you, so here's an unnecessarily complicated way of doing it in a single script without having to start up separate ones to have independent timers running while waiting for mana and/or spirit for recasting a sign:



# Nearly forgot to initialize the SaveVar variable to 0 (I have no clue how Sage handles initial values)
SaveVar = 0

WardingBit = 1
DefendingBit = 2
ShieldsBit = 4
StrikingBit = 8
SmitingBit = 16
SwordsBit = 32

WardingCost = 1
DefendingCost = 2
StrikingCost = 1
SmitingCost = 2

MINSPIRIT = 7


Start:
match WardingDown WARDING is no longer
match DefendingDown DEFENDING is no longer
match ShieldsDown SHIELDS is no longer
match StrikingDown STRIKING is no longer
match SmitingDown SMITING is no longer
match SwordsDown SWORDS is no longer
match SignQueuePoller Also here
matchwait

WardingDown:
if (%me.mana < $WardingCost) {
SaveVar = $SaveVar + $WardingBit
} else { put SIGN OF WARDING }
goto Start

DefendingDown:
if (%me.mana < $DefendingCost) {
SaveVar = $SaveVar + $DefendingBit
} else { put SIGN OF DEFENDING }
goto Start

ShieldsDown:
if (%me.spirit < $MINSPIRIT) {
SaveVar = $SaveVar + $ShieldsBit
} else { put SIGN OF SHIELDS }
goto Start

StrikingDown:
if (%me.mana < $StrikingCost) {
SaveVar = $SaveVar + $StrikingBit
} else { put SIGN OF STRIKING }
goto Start

SmitingDown:
if (%me.mana < $SmitingCost) {
SaveVar = $SaveVar + $SmitingBit
} else { put SIGN OF SMITING }
goto Start

SwordsDown:
if (%me.spirit < $MINSPIRIT) {
SaveVar = $SaveVar + $SwordsBit
} else { put SIGN OF SWORDS }
goto Start


SignQueuePoller:
if ($SaveVar >= $SwordsBit) {
if (%me.spirit >= $MINSPIRIT) {
put SIGN OF SWORDS
SaveVar = $SaveVar - $SwordsBit
}
}
if ($SaveVar >= $SmitingBit) {
if (%me.mana >= $SMITINGCOST) {
put SIGN OF SMITING
SaveVar = $SaveVar - $SmitingBit
}
}
if ($SaveVar >= $StrikingBit) {
if (%me.mana >= $STRIKINGCOST) {
put SIGN OF STRIKING
SaveVar = $SaveVar - $StrikingBit
}
}

if ($SaveVar >= $ShieldsBit) {
if (%me.spirit >= $MINSPIRIT) {
put SIGN OF SHIELDS
SaveVar = $SaveVar - $ShieldsBit
}
}
if ($SaveVar >= $DefendingBit) {
if (%me.mana >= $DEFENDINGCOST) {
put SIGN OF DEFENDING
SaveVar = $SaveVar - $DefendingBit
}
}
if ($SaveVar >= $WardingBit) {
if (%me.mana >= $WARDINGCOST) {
put SIGN OF WARDING
SaveVar = $SaveVar - $WardingBit
}
}
goto Start

... so wtf is that doign? It's constantly monitoring for signs to melt, so that it doesn't ever miss any & forever-after forget to ever cast that sign again. Instead of waiting for enough mana if mana (or spirit) is lacking, it's simulating setting a bit in the binary representation of the "SaveVar" variable. 1 in binary is "01", 2 is "10", 4 is "100", 8 is "1000", 16 is "10000", and 32 is "100000" -- notice how each sign has its own little bit in that variable. I'm assuming you can't just manipulate bits with this language, though, so we're doing a silly addition/subtraction instead of the usual bitshifting stuff (which is nothing you need to worry about looking up if you don't want to -- just one of the ways you test for bit values in the C-style languages.) Generically, when you "poll" for a condition, what you do is check extremely quickly & repeatedly if it's true or not -- hence the name of the "SignQueuePoller" label, which is jumped to anytime "Also here" is seen. Change that to whatever you want, really.


I think it'll work just fine. Think, mind you. You'll also have to modify my "SaveVar = blah-blah" lines to fit the proper syntax for Sage. FYI, if you don't go in descending order of bit position (32, 16, 8, etc.), then it'll get all screwy (as in whatever else you change, preserve the largest-to-smallest checking.)

Hope that's more use than it is confusion for you. Have fun :)

Shaelun
06-23-2010, 02:13 PM
Damn; it suddenly hit me in the middle of something totally unrelated that what I provided won't work properly unless the mana is consistently available to activate the signs in descending order as well. So much for my fun idea.

Better to just use a devoted variable for every sign, e.g.


NeedSwords = 0
NeedShields = 0

...

match SwordsDown SWORDS is no longer
matchwait

...

SwordsDown:
if (%me.mana < $SwordsCost) {
NeedSwords = 1
} else { put SIGN OF SWORDS }
goto Start

...

SignQueuePoller:
if ($NeedSwords == 1) {
if (%me.spirit >= $MINSPIRIT) {
put SIGN OF SWORDS
NeedSwords = 0
}
}

...


etc.. Either that or just write a script that sits around waiting for mana to be available & reactivates the appropriate sign (as in start that script when your main one sees the sign melt, and leave the activation of it to the new script.) The only problem with that is that unless you properly coordinate all of these scripts that will be running waiting to put signs back up, you'll occasionally have them check for mana, find that there's enough at the time of the check, then attempt to activate a sign & not take into account a different script will also be using mana & may have checked at the same time -- leaving your nerves just barely toasty, etc..