Index / Last update: May 2002
// BOTDEALCC1
// Deals 1 crew counter from location "arg1" to location "arg2".
//--------------------------------------------------------------
// - Field ccloc_XX has the location of crew member #XX.
// - Field ccpos_XX has the position of crew member #XX within the location.
// - Field ncc_LL has the number of crew counters in location #LL.
// - Note that the value of ccpos_XX should be from 0..ncc_{ccloc_XX}.
//--------------------------------------------------------------
// Eg: If "arg1" is 0, and "arg2" is 41,
// Then search the cc fields for XX such that
// ccloc_XX = 0 and ccpos_XX = ncc_0 - 1 (deal off bottom of loc0).
// When you find XX, do this:
// ccloc_XX = 41; ccpos_XX = ncc_41 (add to bottom of loc41).
// Then ncc_0--; ncc_41++.
//--------------------------------------------------------------
@field gamebot = botdealcc1 :
@fieldloop("2117","ccloc_",
@switch( @and(@eq("%v",@g("arg1")),
@eq(@g(@print("ccpos_",@substr("%f","6"))),
@sub(@g(@print("ncc_",@g("arg1"))),"1"))),
"1",
@print(
@s("%f",@g("arg2")),
@s(@print("ccpos_",@substr("%f","6")),
@g(@print("ncc_",@g("arg2"))))
)
)
);
@s(@print("ncc_",@g("arg1")), @sub(@g(@print("ncc_",@g("arg1"))),"1"));
@s(@print("ncc_",@g("arg2")), @add(@g(@print("ncc_",@g("arg2"))),"1"));
@incr() and @decr()@incr(dbref, fldname)
fldname of object dbref.@setfield(dbref, fldname,
@add(@getfield(dbref, fldname), "1"))@decr(dbref, fldname)
fldname of object dbref.@setfield(dbref, fldname,
@sub(@getfield(dbref, fldname), "1"))@setsub()@setsub(var1, val1,
..., varX, valX)
@setsub("x","3","letter","c") would
set the value of %x to "3" and the value
of %{letter} to "c".@setsub() may be used
only within the immediate scope that the @setsub() was itself
within, and only after the call to @setsub().%k%k
@fieldloop(str,prefix,...) call,
such that the value of %k would be equal to
@substr("%f",@strlen(prefix)). That is, the rest of the field
that wasn't matched by the prefix.%k should be defined when %f and %v are.%k
isn't currently a standard subsitution code.@fieldloop() call within a @strloop() call where
the @strloop might define %k.
I suspect this possible breakage is rather unlikely, though.
@field gamebot = botdealcc1 :
@setsub("x",@g("arg1"),"y",@g("arg2"));
@fieldloop("2117","ccloc_",
@switch( @and(@eq("%v","%x"),
@eq(@g("ccpos_%k"), @sub(@g("ncc_%x"),"1"))),
"1",
@print(
@s("%f","%y"),
@s("ccpos_%k", @g("ncc_%y"))
)
)
);
@decr("2117","ncc_%x");
@incr("2117","ncc_%y");
Index / David Welbourn / last update: May 2002.