Making a new ifcheck; "fighting"?

Posted by Zeno on Tue 14 Mar 2006 05:27 AM — 5 posts, 12,638 views.

USA #0
I'm looking to add an ifcheck that has this prog syntax:
if fighting($n) == $t

Checks if $n is fighting $t.

Is there a way to code this in without changing the entire mprog_do_ifcheck header and body? Since it seems to only have two CHAR_DATA vars.
USA #1
I must be confused -- why do you have to change the entire header and body, and not just add a normal if-check block as for any other if-check?

Can't you just make an ifcheck for fighting that takes its argument as a string, gets the character, then compares ch->fighting->name to the right-hand side, and then you're done?
USA #2
Maybe I'm the one confused?

Here's what I think. The header only passes in two CHAR_DATA's (besides random), and I need a third one. One is used for the prog initiator (in this case, it's the supermob since this is an obj), another is used for the victim checked in the line. This is what I have currently:
if fighting($n)

That checks if the initiator is fighting $n. That's two variables used. I need a third one for the victim since the supermob has already taken one variable.

As for a string, it wouldn't work. We are using $n, $t etc here. Not strings like "Zeno". Doing this would be pointless:
if fighting($n) == Zeno
Amended on Tue 14 Mar 2006 05:42 AM by Zeno
USA #3
As a side note, isn't $n the initiator already? Wouldn't "if fighting($n)" be a non-question, since $n is never fighting $n?


Anyhow --

I think you are right, the problem is that the right-hand side of if-checks do not seem to take anything but strings and numbers. One thing you could try doing is for the fighting ifcheck, before comparing fighting($n) to the rhs, you would pass rhs through mprog_translate. That should get $t converted to a string. Then, the fighting($n) ifcheck can compare $n->fighting->name to the string that $t was converted from.

I'm saying all this on the fly, I have not actually tested it... it's just from my memory of how the horror-that-is-MUDprog (may it forever burn in hell) works. :-)
USA #4
Quote:
As a side note, isn't $n the initiator already? Wouldn't "if fighting($n)" be a non-question, since $n is never fighting $n?

In this case, the prog was on a speech trigger. So the one who said the trigger is $n. The mob who has the prog is the one it's checking against. So no.

I'll check into some more tomorrow.