Page 2 of 9 FirstFirst 123456 ... LastLast
Results 11 to 20 of 86

Thread: Choosing star sign?

  1. #11
    Join Date
    Mar 2008
    Posts
    721

    Default

    Raven is very nice too because that way you really don't need the speed talent line.

    I mostly play raven-borns. Just love being able to outrun anything. Essential for archers.
    Of course it's unfair - that's the whole point.

    The Adom wiki: everything you don't want to know about Adom.
    http://ancardia.wikia.com/

  2. #12

    Default

    Edit: please use this fixed version instead: http://www.adom.de/forums/showpost.p...0&postcount=67

    Code:
    /* Pulled from the ADOM server sources, likely not going to get a Biskup seal of approval */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <signal.h>
    #include <syscall.h>
    #include <sys/ptrace.h>
    #include <sys/types.h>
    #include <sys/wait.h>
    #include <unistd.h>
    #include <errno.h>
    #include <string.h>
    #include <sys/user.h>
    #include <sys/reg.h>
    
    //#define BIRTHSIGN_ADDR 0x0813EE03 // 1.1.1
    #define BIRTHSIGN_ADDR 0x0813AC63 // 1.0.0
    
    const int long_size = sizeof(long);
    
    typedef union {
      char bytes[4];
      long w;
    } word;
    
    void getdata(pid_t child, long addr, char *buf, int words)
    { 
      int i;
      word w;
    
      for(i=0; i<words; i++) {
        w.w = ptrace(PTRACE_PEEKDATA, child, addr + i*4, NULL);
        memcpy(buf + i*4, w.bytes, long_size);
      }
    }
    
    void putdata(pid_t child, long addr, char *buf, int words)
    {
      int i;
      word w;
    
      for(i=0; i<words; i++) {
        memcpy(w.bytes, buf + i*4, long_size);
        ptrace(PTRACE_POKEDATA, child, addr + i*4, w.w);
      }
    }
    
    void handle_sig(int pid, int status) {
      if(WIFEXITED(status)) {
        exit(0);
      }
    
      else if(WIFSIGNALED(status)) {
        kill(pid, 9);
        exit(1);
      }
    }
    
    int select_month(void) {
      int month;
      char buf[8];
    
      do {
        system("clear");
    
        printf("Select the month of your birth:\r\n"
    	   "\r\n"
    	   "  ? - random\r\n"
    	   "\r\n"
    	   "  A - Raven\r\n"
    	   "  B - Book\r\n"
    	   "  C - Wand\r\n"
    	   "  D - Unicorn\r\n"
    	   "  E - Salamander\r\n"
    	   "  F - Dragon\r\n"
    	   "  G - Sword\r\n"
    	   "  H - Falcon\r\n"
    	   "  I - Cup\r\n"
    	   "  J - Candle\r\n"
    	   "  K - Wolf\r\n"
    	   "  L - Tree\r\n"
    	   "\r\n"
    	   "> ");
    
        month = toupper(fgetc(stdin));
      } while(month != '?' && (month < 'A' || month > 'L'));
    
      system("clear");
      return month == '?' ? 0 : month-'A'+1;
    }
    
    int main(int argc, char **argv)
    {
      pid_t pid;
      int waitv;
      unsigned long breakpoint;
      struct user_regs_struct regs, newregs;
      int month;
      char sage=0;
      long orig_eax;
    
      sigset_t mask;
    
      char code[] = {0xcd, 0x80, 0xcc, 0};
      char backup[4];
    
      if(argc > 1 && !strcmp(argv[1], "--enable-sage"))
         sage = 1;
    
      sigemptyset(&mask);
      sigaddset(&mask, SIGINT);
      sigaddset(&mask, SIGTSTP);
      sigaddset(&mask, SIGQUIT);
      sigprocmask(SIG_BLOCK, &mask, NULL);
    
      srand(time(NULL));
      breakpoint = BIRTHSIGN_ADDR;
    
      switch(pid = fork()) {
        
      case -1:
        perror("fork");
        break;
        
      case 0: /*  child process */
        ptrace(PTRACE_TRACEME, 0, 0, 0);
    
        if(!sage)
          //execl("/usr/games/adom-111-bin", "/usr/games/adom-111-bin", NULL);
          execl("/usr/games/adom-100-bin", "/usr/games/adom-100-bin", NULL);
    
        else
          //execl("/var/lib/adom/server/adom-sage", "/var/lib/adom/server/adom-sage", "-a", "/usr/games/adom-111-bin", "-s", "/var/lib/adom/server/adom-sage.so", NULL);
          execl("/var/lib/adom/server/adom-sage", "/var/lib/adom/server/adom-sage", "-a", "/usr/games/adom-100-bin", "-s", "/var/lib/adom/server/adom-sage.so", NULL);
        break;
        
      default: /* parent process */
        wait(&waitv);
        handle_sig(pid, waitv);
    
        do {
          ptrace(PTRACE_SYSCALL, pid, 0, 0);
          wait(&waitv);
    
          handle_sig(pid, waitv);
          orig_eax = ptrace(PTRACE_PEEKUSER, pid, 4*ORIG_EAX, NULL);
        } while(orig_eax != SYS_time);
    
        getdata(pid, breakpoint, backup, 1);
        putdata(pid, breakpoint, code, 1);
    
        ptrace(PTRACE_CONT, pid, NULL, NULL);
        wait(&waitv);
        handle_sig(pid, waitv);
    
        ptrace(PTRACE_GETREGS, pid, NULL, &regs);
    
        month = select_month();
        if(!month) month = rand() % 12;
        else month--;
    
        regs.eip = breakpoint;
        regs.eax &= 0xFFFF0000;
        regs.eax |= (unsigned int)(30*month + (rand()%30));
      
        ptrace(PTRACE_SETREGS, pid, NULL, &regs);
        putdata(pid, breakpoint, backup, 1);
    
        ptrace(PTRACE_CONT, pid, NULL, NULL);
    
        if(wait(&waitv) > 0) {
          handle_sig(pid, waitv);
          kill(pid, 9);
          return 1;
        }
      }
      
      return 0;
    }
    Last edited by jaakkos; 10-10-2009 at 01:26 PM.

  3. #13
    Join Date
    Mar 2008
    Posts
    721

    Default

    Quote Originally Posted by jaakkos View Post
    Code:
    /* Pulled from the ADOM server sources, likely not going to get a Biskup seal of approval */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <signal.h>
    #include <syscall.h>
    #include <sys/ptrace.h>
    #include <sys/types.h>
    #include <sys/wait.h>
    #include <unistd.h>
    #include <errno.h>
    #include <string.h>
    #include <sys/user.h>
    #include <sys/reg.h>
    
    //#define BIRTHSIGN_ADDR 0x0813EE03 // 1.1.1
    #define BIRTHSIGN_ADDR 0x0813AC63 // 1.0.0
    
    const int long_size = sizeof(long);
    
    typedef union {
      char bytes[4];
      long w;
    } word;
    
    void getdata(pid_t child, long addr, char *buf, int words)
    { 
      int i;
      word w;
    
      for(i=0; i<words; i++) {
        w.w = ptrace(PTRACE_PEEKDATA, child, addr + i*4, NULL);
        memcpy(buf + i*4, w.bytes, long_size);
      }
    }
    
    void putdata(pid_t child, long addr, char *buf, int words)
    {
      int i;
      word w;
    
      for(i=0; i<words; i++) {
        memcpy(w.bytes, buf + i*4, long_size);
        ptrace(PTRACE_POKEDATA, child, addr + i*4, w.w);
      }
    }
    
    void handle_sig(int pid, int status) {
      if(WIFEXITED(status)) {
        exit(0);
      }
    
      else if(WIFSIGNALED(status)) {
        kill(pid, 9);
        exit(1);
      }
    }
    
    int select_month(void) {
      int month;
      char buf[8];
    
      do {
        system("clear");
    
        printf("Select the month of your birth:\r\n"
    	   "\r\n"
    	   "  ? - random\r\n"
    	   "\r\n"
    	   "  A - Raven\r\n"
    	   "  B - Book\r\n"
    	   "  C - Wand\r\n"
    	   "  D - Unicorn\r\n"
    	   "  E - Salamander\r\n"
    	   "  F - Dragon\r\n"
    	   "  G - Sword\r\n"
    	   "  H - Falcon\r\n"
    	   "  I - Cup\r\n"
    	   "  J - Candle\r\n"
    	   "  K - Wolf\r\n"
    	   "  L - Tree\r\n"
    	   "\r\n"
    	   "> ");
    
        month = toupper(fgetc(stdin));
      } while(month != '?' && (month < 'A' || month > 'L'));
    
      system("clear");
      return month == '?' ? 0 : month-'A'+1;
    }
    
    int main(int argc, char **argv)
    {
      pid_t pid;
      int waitv;
      unsigned long breakpoint;
      struct user_regs_struct regs, newregs;
      int month;
      char sage=0;
      long orig_eax;
    
      sigset_t mask;
    
      char code[] = {0xcd, 0x80, 0xcc, 0};
      char backup[4];
    
      if(argc > 1 && !strcmp(argv[1], "--enable-sage"))
         sage = 1;
    
      sigemptyset(&mask);
      sigaddset(&mask, SIGINT);
      sigaddset(&mask, SIGTSTP);
      sigaddset(&mask, SIGQUIT);
      sigprocmask(SIG_BLOCK, &mask, NULL);
    
      srand(time(NULL));
      breakpoint = BIRTHSIGN_ADDR;
    
      switch(pid = fork()) {
        
      case -1:
        perror("fork");
        break;
        
      case 0: /*  child process */
        ptrace(PTRACE_TRACEME, 0, 0, 0);
    
        if(!sage)
          //execl("/usr/games/adom-111-bin", "/usr/games/adom-111-bin", NULL);
          execl("/usr/games/adom-100-bin", "/usr/games/adom-100-bin", NULL);
    
        else
          //execl("/var/lib/adom/server/adom-sage", "/var/lib/adom/server/adom-sage", "-a", "/usr/games/adom-111-bin", "-s", "/var/lib/adom/server/adom-sage.so", NULL);
          execl("/var/lib/adom/server/adom-sage", "/var/lib/adom/server/adom-sage", "-a", "/usr/games/adom-100-bin", "-s", "/var/lib/adom/server/adom-sage.so", NULL);
        break;
        
      default: /* parent process */
        wait(&waitv);
        handle_sig(pid, waitv);
    
        do {
          ptrace(PTRACE_SYSCALL, pid, 0, 0);
          wait(&waitv);
    
          handle_sig(pid, waitv);
          orig_eax = ptrace(PTRACE_PEEKUSER, pid, 4*ORIG_EAX, NULL);
        } while(orig_eax != SYS_time);
    
        getdata(pid, breakpoint, backup, 1);
        putdata(pid, breakpoint, code, 1);
    
        ptrace(PTRACE_CONT, pid, NULL, NULL);
        wait(&waitv);
        handle_sig(pid, waitv);
    
        ptrace(PTRACE_GETREGS, pid, NULL, &regs);
    
        month = select_month();
        if(!month) month = rand() % 12;
        else month--;
    
        regs.eip = breakpoint;
        regs.eax &= 0xFFFF0000;
        regs.eax |= (unsigned int)(30*month + (rand()%30));
      
        ptrace(PTRACE_SETREGS, pid, NULL, &regs);
        putdata(pid, breakpoint, backup, 1);
    
        ptrace(PTRACE_CONT, pid, NULL, NULL);
    
        if(wait(&waitv) > 0) {
          handle_sig(pid, waitv);
          kill(pid, 9);
          return 1;
        }
      }
      
      return 0;
    }
    Woohoo, that's kinda interesting. Thanks for posting.
    [Although I couldn't yet get it to work; the starsign selection menu just doesnt show up. No time to debug it right now. :/ But still, instructive, I've never done memory-hacking before.]

    [I wonder if you might, someday, release the full thing?]
    Of course it's unfair - that's the whole point.

    The Adom wiki: everything you don't want to know about Adom.
    http://ancardia.wikia.com/

  4. #14

    Default

    Interesting, will play with that later. Thanks.

    Edit: Works! Sweet!

    Epythic, make sure to change comments and paths around to fit your version of ADOM.
    Last edited by Alucard; 05-02-2009 at 06:37 PM.
    ADOM, where the most commonly used letter in the alphabet is the explosive rune. - starfries

  5. #15
    Join Date
    Mar 2008
    Posts
    721

    Default

    Quote Originally Posted by Alucard View Post
    Interesting, will play with that later. Thanks.

    Edit: Works! Sweet!

    Epythic, make sure to change comments and paths around to fit your version of ADOM.
    I did, of course, and ADOM starts fine.
    I just don't get the starsign selection menu.

    Execution never gets past line 154, this one:
    Code:
        handle_sig(pid, waitv);
    Heres the function:
    Code:
    void handle_sig(int pid, int status) {
      if(WIFEXITED(status)) {
        exit(0); // <---- this gets exectued
    /*
      status == 0
      pid > 0
    */
      }
    
      else if(WIFSIGNALED(status)) {
        kill(pid, 9);
        exit(1);
      }
    }
    Now, how do I fix this? I have no idea :/
    Commenting out the exit(0); line gives me the menu, but only after ADOM exits. Doh.
    Last edited by Epythic; 05-02-2009 at 07:16 PM.
    Of course it's unfair - that's the whole point.

    The Adom wiki: everything you don't want to know about Adom.
    http://ancardia.wikia.com/

  6. #16
    Join Date
    Mar 2008
    Posts
    721

    Default

    Turns out, I uncommented the wrong starsign. No idea how that could happen.
    Jaakkos helped me fix it, thanks

    Somehow I feel stupid
    Of course it's unfair - that's the whole point.

    The Adom wiki: everything you don't want to know about Adom.
    http://ancardia.wikia.com/

  7. #17
    Join Date
    May 2009
    Location
    UK
    Posts
    19

    Default

    Would it be possible for somebody to explain how to add choosing star signs for novice users?

  8. #18
    Join Date
    Mar 2008
    Location
    Kentucky
    Posts
    5,067

    Default

    Use AdomBot. It's basically the same thing to
    my way of thinking.
    "Whip me!" pleads the adom player. The rng replies... "No."

  9. #19
    Join Date
    May 2009
    Location
    UK
    Posts
    19

    Default

    Sorry for the noob questions, but could you explain why?

  10. #20
    Join Date
    Dec 2008
    Location
    Moscow, Russia
    Posts
    1,729

    Default

    Quote Originally Posted by Siuol View Post
    Sorry for the noob questions, but could you explain why?
    Well, what jaakkos posted replaces data in ADoM memory - that means it hacks it =) AdomBot does the same - replaces in memory what you need.

    And concerning adding birth-month choosing: you take this fragment of code and change it:
    1) if you use ADoM 1.1.1, make it in this way:
    #define BIRTHSIGN_ADDR 0x0813EE03 // 1.1.1
    //#define BIRTHSIGN_ADDR 0x0813AC63 // 1.0.0
    otherwise don't change that part
    2) in part
    Code:
      if(!sage)
          //execl("/usr/games/adom-111-bin", "/usr/games/adom-111-bin", NULL);
          execl("/usr/games/adom-100-bin", "/usr/games/adom-100-bin", NULL);
    
        else
          //execl("/var/lib/adom/server/adom-sage", "/var/lib/adom/server/adom-sage", "-a", "/usr/games/adom-111-bin", "-s", "/var/lib/adom/server/adom-sage.so", NULL);
          execl("/var/lib/adom/server/adom-sage", "/var/lib/adom/server/adom-sage", "-a", "/usr/games/adom-100-bin", "-s", "/var/lib/adom/server/adom-sage.so", NULL);
    delete commented execl's and change paths in left ones to where your ADoM executable file is and where your AdomSage files are.
    3) compile this program to get executable and run it whenever you want to play
    4) if you want to use AdomSage, add --enable-sage flag when you execute what you got
    Hope this helps (of course, if you're not a Windows-user and can understand my instructions ) if I haven't missed anything..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •