|
Lain Novice
Joined: 26 Oct 2001 Posts: 38
|
Posted: Tue May 06, 2003 9:41 am
Only #FORALL the first few strings |
I have modified a flee script - to store upto three opposite directions, pushing the latest direction to the top and deleting the last one (Meaning there are always no more than three directions).
ONINPUT trigger:
Pattern: ^n$
Value:
#IF (%item( @fleedir, 1)="north") {#VAR fleedir %delnitem( @fleedir, 1)} {
#VAR fleedir %push( "south", @fleedir)
#VAR fleedir %delnitem( @fleedir, 4)
}
~n
Flee alias:
#IF ("%1"="on") {
#t+ flee
#SH Auto-flee on.
} {#IF ("%1"="off") {
#t- flee
#SH Auto-flee off.
} {
#FORALL @fleedir {%i}
#VAR fleedir ""
}}
It first checks to see if the direction to be added is the opposite of the first string on the list - if it is the direction won't be added, otherwise you would be fleeing back on yourself and that isn't very helpful if you are attempting to run away.
Doing this though only leaves me with two directions to flee in and then one and none if I come back on myself three times. I'm trying to find a way to store upto 5 or possibly 10 directions, but only ever executing the first three directions, regardless of how many strings there are. That way I can back up a few rooms and still have enough directions stored to flee if I need to.
Is there a command or function like #FORALL that would achieve this?
Lain |
|
|
|
Lain Novice
Joined: 26 Oct 2001 Posts: 38
|
Posted: Tue May 06, 2003 4:16 pm |
Okay, found a solution using %item( @fleedir, 1) not sure if it's the correct way, but at least it works.
I've had to put the autoflee in a class folder and have it disable after it executes otherwise everytime it sees the health it will execute again and again. It can be turned on again with "flee on", I'm thinking about adding a trigger to turn it back on if the NPC you're fleeing from manages to follow you across the three rooms. "flee" sends the three directions on top in @fleedir, "flee off" turns off autoflee, "flee reset" removes the directions stored in @fleedir.
Fleeing back where you came from.
#CLASS {Flee}
#CLASS {Autoflee}
#CLASS 0
#ALIAS flee {#IF ("%1"="on") {#t+ autoflee;#SH Autoflee on.} {#IF ("%1"="off") {#t- autoflee;#SH Autoflee off.} {#IF ("%1"="reset") {#SH Flee path reset.;#VAR fleedir ""} {#IF (@fleedir) {#SH Fleeing.;%item( @fleedir, 1);%item( @fleedir, 2);%item( @fleedir, 3);#VAR fleedir %delnitem( %delnitem( %delnitem( @fleedir, 1), 1), 1)} {#SH You have lost your way.}}}}} "Flee"
#ONINPUT {^n$} {#IF (%item( @fleedir, 1)="north") {#VAR fleedir %delnitem( @fleedir, 1)} {#VAR fleedir %push( "south", @fleedir);#VAR fleedir %delnitem( @fleedir, 13)};~n} "Flee" {notrig}
#ONINPUT {^s$} {#IF (%item( @fleedir, 1)="south") {#VAR fleedir %delnitem( @fleedir, 1)} {#VAR fleedir %push( "north", @fleedir);#VAR fleedir %delnitem( @fleedir, 13)};~s} "Flee" {notrig}
#ONINPUT {^e$} {#IF (%item( @fleedir, 1)="east") {#VAR fleedir %delnitem( @fleedir, 1)} {#VAR fleedir %push( "west", @fleedir);#VAR fleedir %delnitem( @fleedir, 13)};~e} "Flee" {notrig}
#ONINPUT {^w$} {#IF (%item( @fleedir, 1)="west") {#VAR fleedir %delnitem( @fleedir, 1)} {#VAR fleedir %push( "east", @fleedir);#VAR fleedir %delnitem( @fleedir, 13)};~w} "Flee" {notrig}
#ONINPUT {^ne$} {#IF (%item( @fleedir, 1)="northeast") {#VAR fleedir %delnitem( @fleedir, 1)} {#VAR fleedir %push( "southwest", @fleedir);#VAR fleedir %delnitem( @fleedir, 13)};~ne} "Flee" {notrig}
#ONINPUT {^nw$} {#IF (%item( @fleedir, 1)="northwest") {#VAR fleedir %delnitem( @fleedir, 1)} {#VAR fleedir %push( "southeast", @fleedir);#VAR fleedir %delnitem( @fleedir, 13)};~nw} "Flee" {notrig}
#ONINPUT {^se$} {#IF (%item( @fleedir, 1)="southeast") {#VAR fleedir %delnitem( @fleedir, 1)} {#VAR fleedir %push( "northwest", @fleedir);#VAR fleedir %delnitem( @fleedir, 13)};~se} "Flee" {notrig}
#ONINPUT {^sw$} {#IF (%item( @fleedir, 1)="southwest") {#VAR fleedir %delnitem( @fleedir, 1)} {#VAR fleedir %push( "northeast", @fleedir);#VAR fleedir %delnitem( @fleedir, 13)};~sw} "Flee" {notrig}
#ONINPUT {^u$} {#IF (%item( @fleedir, 1)="up") {#VAR fleedir %delnitem( @fleedir, 1)} {#VAR fleedir %push( "down", @fleedir);#VAR fleedir %delnitem( @fleedir, 13)};~u} "Flee" {notrig}
#ONINPUT {^d$} {#IF (%item( @fleedir, 1)="down") {#VAR fleedir %delnitem( @fleedir, 1)} {#VAR fleedir %push( "up", @fleedir);#VAR fleedir %delnitem( @fleedir, 13)};~d} "Flee" {notrig}
#TRIGGER {Hp~: (&hp) ~((&maxhp)~) Gp~: (&gp) ~((&maxgp)~) Xp~: (&xp)} {#IF (%eval( @hp*100/@maxhp) < 60) {#SH Autofleeing.;%item( @fleedir, 1);%item( @fleedir, 2);%item( @fleedir, 3);#VAR fleedir %delnitem( %delnitem( %delnitem( @fleedir, 1), 1), 1);#t- Autoflee} {#NOOP}} "Autoflee"
#TRIGGER {Fleeing.} {#CO yellow} "Flee"
#TRIGGER {Flee path reset.} {#CO yellow} "Flee"
#TRIGGER {Autoflee (*).} {#CO yellow} "Flee"
#TRIGGER {Autofleeing.} {#CO yellow} "Flee"
#TRIGGER {You have lost your way.} {#CO yellow} "Flee"
Lain |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue May 06, 2003 6:07 pm |
If you wanted to have more than three directions in your variable, all you needed to do is change or delete the highlighted command:
Pattern: ^n$
Value:
#IF (%item( @fleedir, 1)="north") {#VAR fleedir %delnitem( @fleedir, 1)} {
#VAR fleedir %push( "south", @fleedir)
#VAR fleedir %delnitem( @fleedir, 4)
}
~n
LightBulb
Advanced Member |
|
|
|
Lain Novice
Joined: 26 Oct 2001 Posts: 38
|
Posted: Tue May 06, 2003 11:23 pm |
I wanted to have more than three directions stored but only three directions executed when I flee. I knew how to change the number of string it kept, but I didn't know a function that would execute only 3 strings from a list of 12 strings, not all 12 like the #FORALL command would do.
#VAR fleedir %delnitem( @fleedir, 4)
to
#VAR fleedir %delnitem( @fleedir, 13)
So I always have upto 12 directions stored and I've added this to the alias and autoflee trigger,
%item( @fleedir, 1)
%item( @fleedir, 2)
%item( @fleedir, 3)
#VAR fleedir %delnitem( %delnitem( %delnitem( @fleedir, 1), 1), 1)
This executes string numbers 1, 2 and 3 and then deletes the top string three times, that way I'm back where I should be for the next three directions.
If I was to move n, n, n, e, e, e, s, s, s, w, w, w it stores the opposite direction backwards e, e, e, n, n, n, w, w, w, s, s, s when I flee it would execute e, e, e, then delete those directions, thus the list becomes n, n, n, w, w, w, s, s, s. And if I flee again n, n, n, w, w, w and so on.
Lain |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|