Demesne targetting

by Silvanus

Back to Mechanic's Corner.

Silvanus2005-02-16 04:36:55
How would I go about coding an, if my target enters my demesne, to enemy them?
Drago2005-02-16 04:44:55
for zmud
#trigger {@target enters your demesne.} {enemy @target}
Or whatever the message is.
Gregori2005-02-16 07:10:12
CODE
#CLASS Demesne
#TRIGGER {(%w) enters your demesne.$} {#if (%ismember(%1,@enemylist) {enemy %1}
#TRIGGER {(%w) leaves your demesne.$} {#if (%ismember(%1,@enemylist) {unenemy %1}
#var enemylist
#alias en {#additem enemylist %1}
#alias uen {#delitem enemylist %1}
#CLASS 0


What this does is allow you to create a stringlist of enemies. I use Commune enemies, then if they enter your demesne and you have watch on, they are enemied, the minute they leave they are unenemied. Keeps your 20 enemies limit free.

This is case senstive by the way. So when you enter an enemy it has to be Capitalised.
Unknown2005-02-16 08:46:33
QUOTE(Gregori @ Feb 16 2005, 08:10 PM)
CODE
#CLASS Demesne
#TRIGGER {(%w) enters your demesne.$} {#if (%ismember(%1,@enemylist) {enemy %1}
#TRIGGER {(%w) leaves your demesne.$} {#if (%ismember(%1,@enemylist) {unenemy %1}
#var enemylist
#alias en {#additem enemylist %1}
#alias uen {#delitem enemylist %1}
#CLASS 0


What this does is allow you to create a stringlist of enemies. I use Commune enemies, then if they enter your demesne and you have watch on, they are enemied, the minute they leave they are unenemied. Keeps your 20 enemies limit free.

This is case senstive by the way. So when you enter an enemy it has to be Capitalised.
51979


A way to fix it, so it doesn't have to be capitalized when you "en" it:

CODE
#CLASS Demesne
#TRIGGER {^(%w) enters your demesne.$} {#IF (%ismember( %1, @EnemyList)) {enemy %1}
#TRIGGER {^(%w) leaves your demesne.$} {#IF (%ismember( %1, @EnemyList)) {unenemy %1}
#VARIABLE EnemyList {}
#ALIAS en {#ADDITEM EnemyList %proper( %1)}
#ALIAS uen {#DELITEM EnemyList %proper( %1)}
#CLASS 0

(I also added a few missing brackets.)

Gregori2005-02-16 08:54:17
heh thanks for catching the brackets. That's what happens when you throw up code with your eyes half open. Good catch on the %proper too. I totally forgot about that.
Gwylifar2005-02-16 17:02:52
Or you could %lower() them in the list as you add, and then %lower() them in the comparison, too. That's even more sure-fire but a titch slower.
Silvanus2005-02-17 00:00:19
I mean like an If trigger, like, "If my target is Zaltan, and Zaltan enters my demesne, to enemy Zaltan."
Daganev2005-02-17 00:45:52
The first suggestion does that. i.e what Drago says.
Richter2005-02-17 00:51:27
Or heck, you could enemy/target at the same time.

Drago's works best in your situation.
Silvanus2005-02-17 00:55:28
Didn't see that tongue.gif
Unknown2005-02-17 05:42:51
QUOTE(Silvanus @ Feb 17 2005, 01:00 PM)
I mean like an If trigger, like, "If my target is Zaltan, and Zaltan enters my demesne, to enemy Zaltan."
52445


You just had to use my name, didn't you? tongue.gif