Re: [CODE] Another Form of Portal

From: Alexander van Koppen (alexk@odie.et.fnt.hvu.nl)
Date: 10/23/96


Hi !

> I've been looking over the portal codes on the ftp site, they all seem
> nice. I just need a direction (or a little help, I'm pretty stuck here)
> for something like this :
> 
< cut >
> 
> Hum, seems like I'm trying to make a code that can translate VNUMS into
> some kind of word, maybe even depending wether you're a mage or a
> cleric. (comes later though). Anyone has an idea on how to do this? (or
> has made it already??), I would appreciate every help or suggestions I
> can get on this one (as said from starters, I'm pretty stuck)

Hmm, why not follow the 'example' in magic.c (?? spell_parser.c, spells.c ?)
and just make 5 arrays with each 10 entries, and take each of the numbers
from the vnum as a reference in each array...

(e.g.:)
    0   1   2   3   4   5   6   7   8   9
A1: na  ra  go  ne  to  ni  re  ma  ti  lo
A2: s   g   h   w   r   c   v   m   k   l
A3: ae  ie  ou  oi  an  on  en  ao  eo  eu
A4: v   w   s   v   b   n   m   l   p   r
A5: en  or  in  on  bur dur min kel kol nor

So, if someone casts 'arcane name' in room 3402 (or 03402), he would get

A1[0] + A2[3] + A3[4] + A4[0] + A5[2], or 'nawanvin'.

Similarily, if someone wanted to get to room 19001, he'd have to cast
'portal' Ralaevor. Oh, you might want to add a 6th array, which would
contain a 'checksum substring', so that the smarter players can't simply
'decode' the algorithm.

(  ie: for room 03402: ((0 xor 3 xor 4 xor 0 xor 2) mod 10)   )

The decoding routine would look something like this:
{
  a = (char *) arcane_room_name;
  b = (char *) 0;
  r = (char *) 0; /* room number */

  for (i = 1; i < 6; i++) {
    found = FALSE;
    for (j = 0; j < 10; j++) {
      b = A[i][j];
      if (!strncmp(a, b, strlen(b)) {
        found = TRUE;
        a = a + strlen(b); /* or a = a[strlen(b)] */
        room = room * 10 + j;
      }
      if (!found)
        return -1;
  }
  return room;
}

Hope this helps :)
  Alexander.

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST