Open GoogleCodeExporter opened 9 years ago
The problem with making a +job/roll command is that so many different games
have so many different dice systems that it's hard to make a consistent/general
set of dice that works. That said, I have coded this on a (TinyMUX) game and
have a copy of the code. It probably deserves a spot in the HOWTO.
Ultimately, all you need to do is use the Job system's &TRIG_ADD functionality
to add text to jobs. The parameters are customizable depending on what you
wanted to do.
In the game I coded, I added on optional syntax to the +roll command which took
all the other switches, plus an =<target> option, e.g., +roll foo+bar=5 would
roll your foo and bar stats and send the results to the user's +myjob 5. In
order to prevent players spoofing it, the job addition came from an NPC. The
way the command worked:
- The target was stored in the T register:
setq(t,squish(%5))
- I created a lookup function to get the job DBREF from the job number (note
the &VJ attribute contained the dbref of the job database object):
&FUN_ROLL_MYJOB #34=
if(isint(%0),filter(%vj/FIL_MYJOBS,locate(%vj,Job %0,iT)))
- In later code where the job would be emitted, it is instead added to the job
with TRIG_ADD as follows (note %qK contains the contents of the emit, so is
therefore the text of the job. %va is set to the DBREF of the NPC we want the
die rolls posted from):
@break setr(j,u(%vf/FUN_ROLL_MYJOB,%qT))={
@trigger %vj/TRIG_ADD=%qJ,%qK,%va,ADD,1;
@trigger %vj/TRIG_BROADCAST=%qJ,%#,ADD;
@pemit %#=Added to [name(%qJ)]: %qK
};
(The @break prevents the next code, which would have emitted %qk to the room,
etc.)
This should be enough information to incorporate into an existing dice system.
The answer would be the same for a spend system... tack on to your existing
+spend commands using appropriate code to figure out what to send to TRIG_ADD.
Original comment by widdis@gmail.com
on 25 Jun 2014 at 3:54
Original issue reported on code.google.com by
K.Jisa...@gmail.com
on 25 Jun 2014 at 3:31