Script: BotBasic 07/11/05

Moderator: MacroQuest Developers

Red-One
a ghoul
a ghoul
Posts: 143
Joined: Tue Dec 28, 2004 9:14 pm

Script: BotBasic 07/11/05

Post by Red-One » Thu Jul 07, 2005 4:27 pm

07/11/05
-It will run now.
-copy and past code into a text file, name it botbasic.iss, and put it in your innerspace/scripts folder.
Usage:
With isxeq loaded, pull down the console and "RunScript botbasic.iss" then immediately type "EndScript botbasic.iss". Minimize EQ and goto your innerspace DIR and find bot_YourToonName.xml. Edit this file with the master name, and the ChatInChan you wish the bot to listen to, then go back to EQ and RunScript botbasic again, or just copy and paste the skeleton XML below and rename it to bot_YourToonName and place it in your InnerSpace DIR.

Commands:
follow - bot follows you
stay - bot stops following you
sit - bot sits
face - bot faces you
stand - bot stands

TODO:
Add interface to spell_routines.iss by onetimehero
Add interface to wait4rez by RedOneDI (this script is still incomplete too)
Add lots more options and commands
Fix my syntax, because I'm sure most of it is wrong.
Add functionality for multiple masters, multiple channels, multiple levels of bot access.
Finish reload command to be able to adjust and reset settings on the fly without having to restart the bot.


Comments:
If anyone can glance this over and see if I'm even starting down the right path would be appreciative. I was flipping back and forth between comments in the forums and the wiki as I went, so I might not even be consistent with how I'm doing things. I might be mixing up LS stuff versus ISXEQ specific stuff.

Please comment, thanks.

BotBasic.iss

Code: Select all


#include spell_routines.inc
#define INI_FILENAME bot_${Me.CleanName}.ini



function main()
{
	; Name of the configuration file to use
	declare SettingFile string script "bot_${Me.CleanName}.xml"

	echo Starting: Bot Basic with file bot_${Me.CleanName}.xml
	Call bf_VarSetup
	Call bf_LoadIni
	if "${MasterName.Equal["NOT_FOUND"]}"
	{
		echo No Masters found, terminating...		
		call bf_EndScript
	}
	else
	{
		echo Master is ${MasterName}
	}
	call bf_AddTriggers

	do
	{
		ExecuteQueued
		waitframe
	
	}
	while "1"


	return
}

function bf_LoadIni()
{
	SettingXML[${SettingFile}]:Unload
	;check if file exists
	;echo ${SettingXML[${SettingFile}].Sets} 
	if !${SettingXML[${SettingFile}].Sets}
	{
		SettingXML[${SettingFile}].Set[General Options]:Set[MasterName,CHANGEME]
		SettingXML[${SettingFile}].Set[General Options]:Set[ChatInChan,group]
		SettingXML[${SettingFile}].Set[General Options]:Set[ChatOutChan,group]
		SettingXML[${SettingFile}]:Save

	
	}

	MasterName:Set[${SettingXML[${SettingFile}].Set[General Options].GetString[MasterName,NOT_FOUND]}]
	ChatInChan:Set[${SettingXML[${SettingFile}].Set[General Options].GetString[ChatInChan,NOT_FOUND]}]
	ChatOutChan:Set[${SettingXML[${SettingFile}].Set[General Options].GetString[ChatOutChan,NOT_FOUND]}]
	echo Listening in channel ${ChatInChan} for ${MasterName} commands.
	return

}

function bf_VarSetup()
{
	declare MasterName string script
	declare ChatInChan string global
	declare ChatOutChan string script
	declare bv_DoFollow int script 0
	declare ss_Return string script
	declare si_Return int script 0
	declare sb_Return bool script
	return
}

function bf_AddTriggers()
{
	
	AddTrigger bf_Chat_tell "@Player@ tells you, '@LinePart@'"
	AddTrigger bf_Chat_tell "@Player@ told you, '@LinePart@'"
	AddTrigger bf_Chat_channel "@Player@ tells %\${ChatInChan.Lower}%:1, '@LinePart@'"
	AddTrigger bf_Chat_irc "<@Player@> @LinePart@"
	return	
}

function bf_Check_Master()
{
	;TODO: Multimaster check
	if "${Player.Equal[${MasterName}]}"
	{
		si_Return:Set[1]
		return
	}
	sb_Return:Set[0]
	return
}

function bf_Command_follow(string Player)
{
	call bf_Command_stand
	bv_DoFollow:Set[1]
	call bf_Follow ${Player}

}

function bf_Command_stay()
{
	bv_DoFollow:Set[0]

}

function bf_Command_stand()
{
	if ${Me.Sitting}
	{
		EQExecute /stand
	}

}

function bf_Command_sit()
{
	
	bv_DoFollow:Set[0]
	if ${Me.Standing}
	{
		EQExecute /sit
	}

}

function bf_Command_face(string Player)
{
	Spawn[pc,${Player.Lower}]:Assist:Face[fast]
	return

}

function bf_DoCommand(string FullLine, string Player, string Command)
{
	;echo Start of DoCommand with ${Command}
	;Find the command to execute
	;TODO Custom commands from an XML
	if ${Command.Left[${Me.CleanName.Length}].Equal[${Me.CleanName}]}
	{
		echo Command is for me!
		Command:Set[${Command.Right[-${Me.CleanName.Length}]}]
	}	

	if ${Command.Left[1].Equal["/"]}
	{
		EQExecute ${Command}
		return
	}
	
	Switch ${Command}
	{
		case Follow
			echo [COMMAND] follow
			call bf_Command_follow ${Player}
			break
		case sit
			echo [COMMAND] sit
			call bf_Command_sit
			break
		case stay
			echo [COMMAND] stay
			call bf_Command_stay
			break
		case face
			echo [COMMAND] face
			call bf_Command_face ${Player}
			break
		case stand
			echo [COMMAND] stand
			call bf_Command_stand
			break
		Default
			echo Could not parse: ${Command}
			break
			

	}
	EndSwitch

	return


}

function bf_Chat_tell(string FullLine, string Player, string Command)
{
	
	;Check it if is a master
	call bf_Check_Master ${Player}
	if ${si_Return}
	{
		return
	}
	;echo Received a tell with ${Command}
	call bf_DoCommand "${FullLine}" "${Player}" "${Command}"

	
	
}

function bf_Chat_channel(string FullLine, string Player, string Command)
{
	;Check it if is a master
	call bf_Check_Master ${Player}
	if ${si_Return}
	{
		return
	}
	;echo Received a Channel with ${Command}
	call bf_DoCommand "${FullLine}" "${Player}" "${Command}"
}

function bf_Chat_irc(string FullLine, string Player, string Command)
{
	;Check it if is a master
	call bf_Check_Master ${Player}
	if ${si_Return}
	{
		return
	}
	;echo Received an irc with ${Command}
	call bf_DoCommand "${FullLine}" "${Player}" "${Command}"
}

function bf_Chat(string FullLine, string Player, string Command, string Arg2, string Arg3)
{

	
}

function bf_Follow(string Player)
{
	declare InRange int local 0
	;echo ${Spawn[pc,${Player.Lower}].ID}
	
	if ${Spawn[pc,${Player.Lower}].ID}
	{
		;echo Folling ${Player}
		Spawn[pc,${Player.Lower}]:Target	
		Spawn[pc,${Player.Lower}]:Target:Face[fast]
	

	}
	else
	{
		echo Could not find spawn ${Player} to follow
		return
	}
	
	if ${Target.ID}
	{
	do
	{
		if !${Target.ID}
		{
			bv_DoFollow:Set[0]
		}
		Spawn[pc,${Player.Lower}]:Target:Face[fast]
		;echo In follow function, looking for ${Player}
		ExecuteQueued
		;EQExecute ${Spawn[${PlayerID}]}
		if "${Target.Distance} > 10"
		{
			Keypress forward
			Keypress forward hold
			InRange:Set[1]
		}
		else
		{
			if ${InRange}
			{

				Keypress back
				InRange:Set[0]
			}
		}
	}
	while ${bv_DoFollow}
	Keypress back
	}
	return
}

function bf_RemoveTriggers()
{
	
	RemoveTrigger bf_Chat
	RemoveTrigger bf_Chat_tell
	RemoveTrigger bf_Chat_irc

	return

}

function bf_EndScript()
{
	
	call bf_RemoveTriggers
	EndScript BotBasic

}

-Red

Red-One
a ghoul
a ghoul
Posts: 143
Joined: Tue Dec 28, 2004 9:14 pm

XML

Post by Red-One » Mon Jul 11, 2005 10:50 pm

bot_YourToonName.xml, put it in the root of your InnerSpace folder, not in any subfolder. If you don't copy this it will be auto-generated which you will have to edit anyway. Only 2 things used are mastername and chatinchan.

Code: Select all

<?xml version='1.0'?>
<InnerSpaceSettings NextID="2">
	<Set ID="1" Name="General Options">
		<Setting Name="mastername">MasterNameHere</Setting>
		<Setting Name="chatinchan">ChatChanToListenTo</Setting>
		<Setting Name="chatoutchan">SPACEHOLDER</Setting>
	</Set>
	
</InnerSpaceSettings>


-Red

Red-One
a ghoul
a ghoul
Posts: 143
Joined: Tue Dec 28, 2004 9:14 pm

Post by Red-One » Mon Jul 11, 2005 10:50 pm

Let intentionally blank

-Red

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Fri Jun 23, 2006 8:50 am

I'm messing around with this and looking for ways to add to it.

Right now, the one issue I'd like to deal with is getting the bot to listen to relay'd commands. I am running 2 characters on one system so I can use the relay instead of irc and I sure as hell do not want to use eq chat channels at all.

Code: Select all

function bf_AddTriggers()
{
   
   AddTrigger bf_Chat_tell "@Player@ tells you, '@LinePart@'"
   AddTrigger bf_Chat_tell "@Player@ told you, '@LinePart@'"
   AddTrigger bf_Chat_channel "@Player@ tells %\${ChatInChan.Lower}%:1, '@LinePart@'"
   AddTrigger bf_Chat_irc "<@Player@> @LinePart@"
   return   
}
How do you add a trigger to listen for relays?
How would I list the "Channel" in the ini for relay?

I'll probably need to get IRC going later, if I plan to use my sigother's account to run 3 toons, but for now I'm working on communication via the built in relay system.

Also, I'm working on a simple "assist" command. My character being botted is a pet class, and I want to have it assist on demand and send in pet. Later, I am going to want to add in another assist that takes a "assist 'spell name'" command and then casts that spell on the mob in question. I want it to use a param so that I can use different spells as needed. I might have to go with just gem numbers, but that will be fine as well.

Any thoughts?

My assist sections so far:

Code: Select all

      case assist
         echo [COMMAND] assist
         call bf_Command_assist
         break



;my addition, will it work?
function bf_Command_assist()
{
   if ${Me.Sitting}
   {
      EQExecute /stand
      waitframe
   }
      EQExecute /assist ${MasterName}
      waitframe
      EQExecute /pet assist
}
I have not yet been able to test. I'm very leary of using EQ channels.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 10:46 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 10:47 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 11:24 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 11:25 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 11:26 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 11:28 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 11:29 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 11:30 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 11:31 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 11:32 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Script: BotBasic 07/11/05

Post by xyilla » Fri May 30, 2025 11:33 pm