Corpse auto-pickup

by Kamion

Back to Mechanic's Corner.

Kamion2006-10-14 08:26:29
I tried this with unearthing sand on the Isle of Light after I realised the trigger setting off an alarm for 8 seconds didn't work if it lagged...but it wont work on corpses....I tried this:

#VAR CORPSE 0
#TRIGGER {You have slain a %w (*).} {CORPSE=%1}
#TRIGGER {You have gained equilibrium.} {#IF (CORPSE=NOT 0) {GET @CORPSE}}
#TRIGGER {You pick up the corpse of (*).} {CORPSE=0}

Did the same with sand, like I said before, pretty much the same thing. I think it's the {#IF (CORPSE=NOT 0) {GET @CORPSE}} that's the problem...I wouldn't know. Any help? I'm utterly clueless.
Soll2006-10-14 08:45:21
In general, that's not going to fire very reliably. So I warn you that you may want to recode that. However, here is a fixed code.

#var corpse 0
#trigger {^You have slain a (%w) (*).$} {#var corpse %1}
#trigger {^You have recovered equilibrium.$} {#if (@corpse!=%null) {get @corpse}}
#trigger {^You pick up the corpse of (*).$} {#var corpse ""}
Kamion2006-10-14 08:49:19
ZOMG! Two-second-reply, thanks loads, thanks even more for the fast reply. Can you explain, though, exactly what I didn't do correctly?

EDIT: After testing, it turns out it fires even if CORPSE=0. Any way to FIX that? Shouldn't it be:
#trigger {^You have recovered equilibrium.$} {#if (!@corpse=%null) {get @corpse}}
?
Soll2006-10-14 09:11:40
Sorry, the %null value means there is -nothing- inside the variable. A '0' still counts as data in the variable, so it will fire.

I should have said, at the beginning:


#var corpse ""

followed by

#trigger {^You have slain a (%w) (*).$} {#var corpse %1}
#trigger {^You have recovered equilibrium.$} {#if (@corpse!=%null) {get @corpse}}
#trigger {^You pick up the corpse of (*).$} {#var corpse ""}
Shorlen2006-10-14 10:34:28
So, you have a variable corpse.

There are two ways to set that variable:
CODE
corpse=something
#var corpse something

These do the same thing, essentially.

When using the variable, you need to put the @ sign in front of it.
@var means "get the contents of the variable named "var"

One command to show stuff to the screen is #echo
CODE
#echo corpse

outputs the word "corpse"
CODE
#echo @corpse

outputs the contents of the corpse variable

! means not
The syntax of #if is #if (expression) {what to do if expression is true} {what to do if expression is false}
Any expression that evaluates to 0 is false. Any expression that does not evaluate to 0 is true. ! inverts the value of the expression it proceeds.

Thus, #if (@corpse!=%null) checks to see if @corpse contains anything at all. If it does, it's true. #if (!@corpse!=%null) is a silly thing to say. That inverts the value of corpse (so, if it was 0, makes it 1, if it was 1, makes it 0) and then checks to see if it is anything at all. There is no reason for the ! there.
Vix2006-10-14 15:59:36
Wouldn't it be easier to just get an Acquisitio enchant? tongue.gif
Unknown2006-10-14 18:01:47
Acquisitio is annoying. Even if I'm playing a character who gets it for free I don't normally have it up in a lot of circumstances.

1.it picks up things you don't want it to pick up.

2.no number one pretty much covered it, it's annoying when you end up with twenty or so things you don't want, and some decaying corpses your friend killed and he should have instead.
Unknown2006-10-14 23:38:13
It'd be a lot simpler if they'd just code it in game where the players automatically picked up corpses as long as they're not adventurer corpses. Problem solved.
Voror2006-10-14 23:56:31
I believe there is a reason why they have coded that way... I am just not sure what it is tongue.gif

On the scripting side of it I will explain the idea of how I plan to do it. I don't use Zmud, so I cannot write the actual code for you but here goes:

First you make a trigger, that matches the equillibrium line, and does 2 things:
a. sends to the MUD the line "get @target", where @target is the variable that you use to attack something.
b. disables itself.
You start with this trigger disabled.

Second make a second trigger that matches the "You have slain" line, and just enables the first trigger.

I don't know if any of this actually made sense or if you can do it in Zmud but hopefuly it will work. The advantage over acquisitio is that you pickup only the corpses you kill, and that it is guaranteed not to fail if the thing you attack and its name in the slain line are different.
Gandal2006-10-15 00:14:12
Switch to Nexus and I'll show you tongue.gif .

Hm, can you make in-game alias in zMUD? Like in Nexus, SETALIAS PS POINT STAFF &TAR or SETALIAS GI GET &TAR? If you can, then make an alias in the coding screen, GETIT as GI, then a trigger for "you have slain {*}," and a trigger for "you have recovered equilibrium". Also variable for death.