$corpse command

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

honduras
orc pawn
orc pawn
Posts: 14
Joined: Sat Aug 30, 2003 5:22 pm

$corpse command

Post by honduras » Tue Oct 14, 2003 4:14 am

Is it possilble to check if the corpse have any item in it at all?

Im trying to do something like

Code: Select all

/if $corpse(item)=="false" /goto :doneloot     |if there is nothing else to loot in corpse /return
thx


to incoporate to the following codes. In the hope to loot faster

Code: Select all

sub LootMob 
   /loot 
:waitloot
   /delay 4
  /if $corpse=="False" /goto :waitloot
:lootloop 
   /if n @LootSlot>=6 /goto :doneloot 
   /click left corpse @LootSlot 
   /delay 7
   /if "$cursor()"!="TRUE" /goto :doneloot
:lootChecker 
   /if "$cursor(name)"~~"@MainArray(1,@CheckLoot)" { 
  
      /autoinv
    :wait1
     /delay 1
     /if "$cursor()"!="TRUE" /goto :wait1
      /varadd LootSlot 1 
      /goto :lootloop 
   } 

   /if "$cursor()"=="TRUE" { 
       /click left destroy 
    :wait2
     /delay 1
     /if "$cursor()"!="TRUE" /goto :wait2
   } 
   /varadd LootSlot 1
    /goto :lootloop 
   :doneloot
    /press esc
   /varset LootSlot 0 
   /call GetTarget
/return 


User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Tue Oct 14, 2003 8:32 am

From a quick look at the source code I noticed you can do $corpse(has,"item") which will return true or false depening on if the corpse has an item that matches the string. However the match it doesn't support any kind of pattern matching but it looks like that could be added pretty easily.

Take a look in EQLIB_MacroParser.cpp, this function:
DWORD parmCorpse(PCHAR szVar, PCHAR szOutput, PSPAWNINFO pChar)

MacroFiend
a grimling bloodguard
a grimling bloodguard
Posts: 662
Joined: Mon Jul 28, 2003 2:47 am

Post by MacroFiend » Tue Oct 14, 2003 9:23 am

Looked at the $corpse function and unfortunately found some bugs that could cause it to work incorrectly. Below is the corrected $corpse with a new $corpse(empty) option that will return TRUE when there are no more items on the corpse.

Code: Select all

[color=red]DWORD parmCorpse(PCHAR szVar, PCHAR szOutput, PSPAWNINFO pChar)
{
	DWORD i=0;[/color]
	DWORD iSlotCnt=0;

[color=red]	// $corpse(xxx)
	if (!EQADDR_LOOTWND) return PMP_ERROR_BADPARM;
	PEQWINDOW pLootWindow = NULL;
	pLootWindow = (PEQWINDOW)*EQADDR_LOOTWND;
	CHAR szTemp[MAX_STRING] = {0};[/color]
	if (!strncmp("corpse()",szVar,8)) {
		i += 7;[color=red]
		if (pLootWindow->Open == 1) {
			strcat(szOutput,"TRUE");
		} else {
			strcat(szOutput,"FALSE");
		}
	// $corpse(has,xxx)[/color]
	} else if (!strncmp("corpse(has,",szVar,11)) {[color=red]
		if (!strstr(szVar,")")) {
			DebugSpew("PMP - Bad $merchant() '%s'",szVar);
			return PMP_ERROR_BADPARM;
		} else {
			i += (strstr(szVar,")")-szVar);
			if (pLootWindow->Open == 1) {[/color]
				PCHAR szArg = szVar+11;[color=red]
				if (szArg[0]=='"') szArg++;
				CHAR szTemp[MAX_STRING] = {0};
				DebugSpew("$corpse(has) -- looking for '%s'", szArg);
				BOOL Found = FALSE;[/color]
				for (iSlotCnt=0;iSlotCnt<79;iSlotCnt++) {
					if (pLootWindow->ItemDesc[iSlotCnt]) {
						if (!strnicmp(szArg,pLootWindow->ItemDesc[iSlotCnt]->Item->Name,strlen(pLootWindow->ItemDesc[iSlotCnt]->Item->Name))) {
								Found=TRUE;
								DebugSpew("Corpse does have: %s",pLootWindow->ItemDesc[iSlotCnt]->Item->Name);[color=red]
								break;
						}
					}
				}
				if (Found) {
					strcat(szOutput,"TRUE");
				} else {
					strcat(szOutput,"FALSE");
				}
			} else {
				strcat(szOutput,"FALSE");
			}
		}[/color]
	// $corpse(empty)
	} else if (!strncmp("corpse(empty)",szVar,13)) {
		i += 12;
		if (pLootWindow->Open == 1) {
			DebugSpew("$corpse(empty)");
			BOOL Found = FALSE;
			for (iSlotCnt=0;iSlotCnt<79;iSlotCnt++) {
				if (pLootWindow->ItemDesc[iSlotCnt]) {
					Found=TRUE;
					break;
				}
			}
			if (Found) {
				DebugSpew("Corpse is not empty");
				strcat(szOutput,"FALSE");
			} else {
				strcat(szOutput,"TRUE");
			}
		} else {
			strcat(szOutput,"TRUE");
		}
	// $corpse(Unknown)[color=red]
	} else {
		DebugSpew("PMP - Bad $corpse() '%s'",szVar);
		return PMP_ERROR_BADPARM;
	}
	return i;
}[/color]
*Damn those smilies
*Added color to make it pretty.
Last edited by MacroFiend on Tue Oct 14, 2003 7:10 pm, edited 3 times in total.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Oct 14, 2003 11:09 am

See my post in Development::General MacroFiend. Got some questions about this code before I CVS it in.
MQ2: Think of it as Evolution in action.

honduras
orc pawn
orc pawn
Posts: 14
Joined: Sat Aug 30, 2003 5:22 pm

Post by honduras » Wed Oct 15, 2003 12:57 pm

thx dudes for help.

I find looting and combining a big problem now.

My connection are pretty bad where i come from. so it will take a while before corpse is open, when item looted, when combining is done.

it would take me between 1/2 seconds to 3 seconds to loot an item..

This will help me alot .
thanks

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Wed Oct 15, 2003 1:06 pm

CVS'd that in this morning MacroFiend, thanks.
MQ2: Think of it as Evolution in action.

honduras
orc pawn
orc pawn
Posts: 14
Joined: Sat Aug 30, 2003 5:22 pm

Post by honduras » Sat Oct 18, 2003 7:27 am

doesnt seem to recognize if corpse do have items in it.

i replaced grimjack's hunter mac loot part with the following.

Code: Select all

sub LootMob 
   /loot 
:waitloot
   /delay 1s
   /if "$corpse"!="TRUE" /goto :waitloot  [b]|To see if targeted corpse loot is open? is this correct?[/b]
:lootloop 
   /if "$corpse(empty)"=="TRUE" /goto :doneloot  [b]| is this correct?[/b]
:wait1
   /click left corpse @LootSlot 
   /delay 2s
   /if "$corpse(empty)"=="TRUE" /goto :doneloot 
     /if "$cursor()"=="NULL" /goto :doneloot
:lootChecker 
   /if "$cursor(name)"~~"@MainArray(1,@CheckLoot)" { 
      /autoinv
      /varadd LootSlot 1 
      /goto :lootloop 
   } 

   /if "$cursor()"=="TRUE" { 
       /click left destroy 
       /delay 5
      /varadd LootSlot 1
     /goto :lootloop 

   }
   :doneloot
     /delay 5
    /press esc
   /varset LootSlot 0
   /click left corpse done
/return 

Thx million[/b]

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Sat Oct 18, 2003 9:16 am

Syntax errors. Should be

/if $corpse()!=TRUE /goto :waitloop

/if $corpse(empty)==TRUE /goto :doneloot


Need to get rid of those quotes. Same for $cursor, and use FALSE instead of NULL:

/if $cursor()==FALSE /goto :doneloot
MQ2: Think of it as Evolution in action.