Need Help with script!

Weizen

Active Member
I'm trying to write a script that will change me from wearing my drum and playing run song and when I attack it will switch to my war song and equip my weapons. I got the script to run but it continuously loops. How can I make it do the loop once. I only want it to change my states when it is needed. Once I have run song going dont keep pushing the key I set my in game macro. If I enter combat I want it to hit the key once to change me back into war song mode and after combat move me back to run song status. Any help is appreciated! I've attached the script Im running. It works but I know it can be done without it hitting the key a million times a sec.

Weize

P.S
The - key and the = key I have in game macros that /playsong and /wear
 

Attachments

ZExit

Active Member
Try this:
Code:
variable bool isRunning = TRUE
variable string sSpeed = "Weizen'\s Bard Song - "\Speed song"\"
variable string sWar = "Weizen'\s Bard Song - "\Fight song"\"
;----------------------------------------------
function main()
{
	echo VG: Bard Mode Enabled...
	do
	{
		while ${Me(exists)}
		{
			if ${Me.ToPawn.CombatState} == 1
				{
				call play_war
				}
			else
				{
				call play_speed
				}
			wait 3
		}
	}
	while ${isRunning}
}

function play_speed()
{
	if !${Me.Effect[${sSpeed}](exists)}
	{
		Press -
		echo VG: Speed song in effect!
	}
}

function play_war()
{
	if !${Me.Effect[${sWar}](exists)}
	{
		Press =
		echo VG: Fight song in effect!
	}
}
You may have to increase the wait 3 a bit to give the client time to activate the song before a play_ function is called again.
 

Weizen

Active Member
ZExit,

I tried using your version as well but it does a continuous loop and constantly presses the button. Im sure there is a better way to do this but I'm not up to speed on my programming yet. The problem is that my loop will continuously run while im alive hence the pressing of the button over and over. Is there a way to just have it toggle once and stay that way until I switch modes?

Weizen
 

spudman

Active Member
Weizen said:
ZExit,

I tried using your version as well but it does a continuous loop and constantly presses the button. Im sure there is a better way to do this but I'm not up to speed on my programming yet. The problem is that my loop will continuously run while im alive hence the pressing of the button over and over. Is there a way to just have it toggle once and stay that way until I switch modes?

Weizen
This function portion...
Code:
	if !${Me.Effect[${sSpeed}](exists)}
	{
		Press -
		echo VG: Speed song in effect!
	}
Is checking if you have the 'speed song effect' already and if you don't it presses the key for the speed song. Put some debugging stuff in there to echo all your effects and compare them. You might have a typo in your song names at the top of the script or bard songs might be shown as each of their individual melodies instead of one big effect.

i.e.
echo ${Me.Effect[1].Name}
echo ${sSpeed}

Change the 1 to anything from 1 to ${Me.Effect} and play with it to see what it's returning and how that compares with your string declaration at the top of your script that has your song names. If it turns out to be melodies as effects then you may have to identify it by what melody is playing.

Info on char type...
http://vg.isxgames.com/wiki/index.php?title=Character_(Data_Type)
 

spudman

Active Member
hmm, got me curious so I did some looking on my bard and it appeared that Effect/Maintained don't seem to be reporting the right info.
 

ststew

Active Member
from working with my bard i think it only recognizes the components of the song, not the song itself

-fist
 

CrazyJosh1

Active Member
try this;

though, one thing to remember, songs show up as debuffs, rather than buffs. So you may need to check for the debuff rather than the buff itself.

Code:
variable string sSpeed = "Weizen'\s Bard Song - "\Speed song"\"
variable string sWar = "Weizen'\s Bard Song - "\Fight song"\"
;----------------------------------------------
function main()
{
	ext -require isxvg
	echo VG: Bard Mode Enabled...
	while 1
	{
		if (${Me.HealthPct} > 0)
		{
			if (${Me.ToPawn.CombatState} == 1) && ${Me.InCombat}
			{
				call play_war
			}
			else
			{
				call play_speed
			}
			wait 3
		}
		echo "You died, you suck, waiting to restart"
		while (${Me.HealthPct} == 0)
		{
			waitframe
		}	
		call main
	}
}

function play_speed()
{
	if (!${Me.Effect[${sSpeed}](exists)})
		Press -
		echo VG: Speed song in effect!
}

function play_war()
{
	if (!${Me.Effect[${sWar}](exists)})
		Press =
		echo VG: Fight song in effect!
}
 

Cr4zyb4rd

Active Member
Code:
variable string sSpeed = "${Me.Name}'\s Bard Song - "\Speed song"\"
variable string sWar = "${Me.Name}'\s Bard Song - "\Fight song"\"
They might have a bit better luck with that, Weizen :p
 

spudman

Active Member
Thought escape sequences were supposed to be before the character you're trying to escape? Also it's ${Me.FName} I think...

Code:
variable string sSpeed = "${Me.FName}\'s Bard Song - \"Speed song\""
variable string sWar = "${Me.FName}\'s Bard Song - \"Fight song\""
?? Although if I just echo it to the console, it seems to work both ways, but one way (escapes after the char) echo's with the beginning and ending quotes, the other way it echo's just the string

i.e.
Code:
echo "${Me.FName}\'s Bard Song - \"Test\""
yields
SoandSo's Bard Song - "Test"
whereas...
Code:
echo "${Me.FName}\'s Bard Song - "\Test"\"
yields
"SoandSo's Bard Song - "Test""
 

spudman

Active Member
Seems it works either way with the escape sequences, but I think it's just IS's handling of strings that's compensating?

Anyway, I played around with this on my bard and here's what I ended up with. Added in a distance check, since I usually kite mobs a little before fighting and wouldn't want fight song kicking off in middle of a kite and removed the 2nd call to main and just put a delay in there if you get revived or release since it will just pop back into the while loop after your health goes back up. Added brackets on the announcements so that it didn't spam them to the console and just notified once. Don't even know if the OP is using it, but since crafting is petering out for me lately I've been spending a little more time adventuring. :)

Code:
variable string sSpeed = "${Me.FName}\'s Bard Song - \"Speed Song\""
variable string sWar = "${Me.FName}\'s Bard Song - \"Fight Song\""
;----------------------------------------------
function main()
{
	ext -require isxvg
	echo VG: Bard Mode Enabled...
	while 1
	{
		While (${Me.HealthPct} > 0)
		{
			if (${Me.ToPawn.CombatState} == 1) && ${Me.InCombat}  && (${Me.Target.Distance} < 8)
			{
				call play_war
			}
			else
			{
				call play_speed
			}
			wait 3
		}
		echo "You died, you suck, waiting to restart"
		while (${Me.HealthPct} == 0)
		{
			waitframe
		}
		;wait a few seconds after being revived or releasing
		wait 20
	}
}

function play_speed()
{
	if (!${Me.Effect[${sSpeed}](exists)})
	{
		Press -
		wait 5
		echo VG: Speed song in effect!
	}
}

function play_war()
{
	if (!${Me.Effect[${sWar}](exists)})
	{
		Press =
		wait 5
		echo VG: Fight song in effect!
	}
}
 

Cr4zyb4rd

Active Member
Seems it works either way with the escape sequences, but I think it's just IS's handling of strings that's compensating?
Yeah. Sorry I didn't catch that, as the example is technically "doing it wrong".

Code:
\""This is some string"\"
Will still come out right, because all the quotes are doing is telling the parser to treat it all as a single argument, but the escaped ones really should be inside, since they're technically part of the entire string you're trying to pass on.
 

Weizen

Active Member
Thanks for the replies! I've been busy lately but will try it when I get home from work. I'll post my results. Thanks again!

Weizen
 

Weizen

Active Member
I tried the script last night and it worked nice except for one thing. Everytime I got attacked it would turn off runsong and would play warsong. My hopes with CombatState it would not change my songs unless I attacked. Sometimes I just want to keep running if Im running through aggro mobs. I thought there was a state of CombatState that would recognize if I'm getting hit but not fighting back? I would like for it to be able to recognize if Im fighting back. I guess a trigger would work like if I cast Bellows then switch me to warsong otherwise leave me in runsong. Anyone have an idea on how I can make it work? Thanks for all the help!

Weizen
 

spudman

Active Member
You'll have to play around with...
${Me.ToPawn.CombatState}
and
${Me.InCombat}

and see if a combination works for you. Could also use ${Me.AutoAttackOn} in some fashion, but i thought if you use parry, it turns AA off until you actually parry, which would mean it would swap your instrument back in in the middle of a fight and then you wouldn't be able to do your counter move (not sure on this though).

Or alternatively you could create a very simple UI for your script that was just a toggle button that allowed you to toggle on or off a 'travel' mode. In travel mode, you would not swap to weapons or change songs. For the UI I'd look at the vgsprintui as a template, since it's a toggle and very simple.
 

Cr4zyb4rd

Active Member
In my own bardbot that I fooled around with a bit, I used a toggle much like that to turn "fence mode" off and on. The code (that I'd already PMed to Weizen) is even simpler than the sprint UI...

Code:
	UIElement[main hud]:AddChild[button,bardbotbutton,"<button Name=\"bardbotbutton\"><X>0</X><Y>r40</Y><Width>24</Width><Height>16</Height><OnRightClick>endscript vgbardbot</OnRightClick><OnLeftClick>UseFence:Toggle</OnLeftClick><Text>Bot</Text><Border>1</Border><Texture></Texture><BackgroundColor>ff00ff00</BackgroundColor></button>"]
season to taste, and then in your exit/cleanup you can just
Code:
	UIElement[bardbotbutton@main hud]:Destroy
for a little script it's a bit easier than fooling around with XML files and images.
 
Top Bottom