示例#1
0
文件: house.c 项目: anylonen/omega
/* makes a log npc for houses and hovels */
void make_house_npc(int i, int j)
{
  pml ml = ((pml) checkmalloc(sizeof(mltype)));
  pob ob;
  ml->m = ((pmt) checkmalloc(sizeof(montype)));
  *(ml->m) = Monsters[NPC];
  make_log_npc(ml->m);
  if (ml->m->id == NPC) mprint("You detect signs of life in this house.");
  else mprint("An eerie shiver runs down your spine as you enter....");
  /* if not == NPC, then we got a ghost off the npc list */
  ml->m->x = i;
  ml->m->y = j;
  Level->site[i][j].creature = ml->m;
  ml->m->click = (Tick + 1) % 50;
  ml->next = Level->mlist;
  Level->mlist = ml;
  m_status_set(ml->m,HOSTILE);
  if (nighttime())
    m_status_reset(ml->m,AWAKE);
  else m_status_set(ml->m,AWAKE);
  if (ml->m->startthing > -1) {
    ob = ((pob) checkmalloc(sizeof(objtype)));    
    *ob = Objects[ml->m->startthing];
    m_pickup(ml->m,ob);
  }
}
示例#2
0
/* Makes one of the highscore NPCs */
void make_hiscore_npc(pmt npc, int npcid)
{
    int behavior;
    int level;
    int st = -1;
    pob ob;
    *npc = Monsters[HISCORE_NPC];
    npc->aux2 = npcid;

    /* Each of the highscore NPCs can be created here */
    switch(npcid) {
    case 0:
        level = Hilevel;
        behavior = Hibehavior;
        strcpy(Str2, Hiscorer);

        break;
    case 1:
        level = Priestlevel[1];
        behavior = Priestbehavior[1];
        strcpy(Str2, Priest[1]);

        /* hs of odin */
        st = ARTIFACTID + 14;

        break;
    case 2:
        level = Priestlevel[2];
        behavior = Priestbehavior[2];
        strcpy(Str2, Priest[2]);

        /* hs of set */
        st = ARTIFACTID + 17;

        break;
    case 3:
        level = Priestlevel[3];
        behavior = Priestbehavior[3];
        strcpy(Str2, Priest[3]);

        /* hs of athena */
        st = ARTIFACTID + 16;

        break;
    case 4:
        level = Priestlevel[4];
        behavior = Priestbehavior[4];
        strcpy(Str2, Priest[4]);

        /* hs of hecate */
        st = ARTIFACTID + 15;

        break;
    case 5:
        level = Priestlevel[5];
        behavior = Priestbehavior[5];
        strcpy(Str2, Priest[5]);

        /* hs of druid */
        st = ARTIFACTID + 18;
        npc->talkf = M_TALK_DRUID;

        break;
    case 6:
        level = Priestlevel[6];
        behavior = Priestbehavior[6];
        strcpy(Str2, Priest[6]);

        /* hs of destiny */
        st = ARTIFACTID + 19;

        break;
    case 7:
        level = Shadowlordlevel;
        behavior = Shadowlordbehavior;
        strcpy(Str2, Shadowlord);

        break;
    case 8:
        level = Commandantlevel;
        behavior = Commandantbehavior;
        strcpy(Str2, Commandant);

        break;
    case 9:
        level = Archmagelevel;
        behavior = Archmagebehavior;
        strcpy(Str2, Archmage);

        /* Kolwynia */
        st = ARTIFACTID + 9;
        npc->talkf = M_TALK_ARCHMAGE;

        break;
    case 10:
        level = Primelevel;
        behavior = Primebehavior;
        strcpy(Str2, Prime);
        npc->talkf = M_TALK_PRIME;
        npc->specialf = M_SP_PRIME;

        break;
    case 11:
        level = Championlevel;
        behavior = Championbehavior;
        strcpy(Str2, Champion);

        break;
    case 12:
        level = Dukelevel;
        behavior = Dukebehavior;
        strcpy(Str2, Duke);

        break;
    case 13:
        level = Chaoslordlevel;
        behavior = Chaoslordbehavior;
        strcpy(Str2, Chaoslord);

        break;
    case 14:
        level = Lawlordlevel;
        behavior = Lawlordbehavior;
        strcpy(Str2, Lawlord);

        break;
    default:
        st = THINGID + 16;
        level = Justiciarlevel;
        behavior = Justiciarbehavior;
        strcpy(Str2, Justiciar);
        npc->talkf = M_TALK_GUARD;
        npc->specialf = M_SP_WHISTLEBLOWER;

        break;
    }

    if(st > -1) {
        ob = (pob)malloc(sizeof(objtype));
        *ob = Objects[st];
        m_pickup(npc, ob);
    }

    npc->monstring = salloc(Str2);
    strcpy(Str1, "The body of ");
    strcat(Str1, Str2);
    npc->corpsestr = salloc(Str1);
    determine_npc_behavior(npc, level, behavior);
}
示例#3
0
/* Consider one monster's action */
void m_pulse(struct monster *m)
{
    int range = distance(m->x, m->y, Player.x, Player.y);

    if(Time % 10 == 0) {
        if(m->hp < Monsters[m->id].hp) {
            ++m->hp;
        }
    }

    if(!m_statusp(m, AWAKE) && (range <= m->wakeup)) {
        m_status_set(m, AWAKE);
        resetgamestatus(FAST_MOVE);
    }

    if(m_statusp(m, AWAKE)) {
        if(m_statusp(m, WANDERING)) {
            if(m_statusp(m, MOBILE)) {
                m_random_move(m);
            }

            if(range <= m->sense) {
                m_status_reset(m, WANDERING);
            }
        }
        else {
            /* Not wandering */
            if(m_statusp(m, HOSTILE)) {
                if((range > 2) && (range < m->sense) && (random_range(2) == 1)) {
                    if(los_p(m->x, m->y, Player.x, Player.y)
                       && (Player.status[INVISIBLE] == 0)) {
                        monster_strike(m);
                    }
                }
            }

            if((m_statusp(m, HOSTILE) || m_statusp(m, NEEDY))
               && (range > 1)
               && m_statusp(m, MOBILE)) {
                monster_move(m);

                /* If monster is greedy, picks up treasure it finds */
                if(m_statusp(m, GREEDY)) {
                    while(Level->site[m->x][m->y].things != NULL) {
                        m_pickup(m, Level->site[m->x][m->y].things->thing);
                        Level->site[m->x][m->y].things = Level->site[m->x][m->y].things->next;
                    }
                }
            }

            if(m_statusp(m, HOSTILE) && (range == 1)) {
                resetgamestatus(FAST_MOVE);
                tacmonster(m);
            }
        }

        /* Prevents monsters form casting spells from other side of dungeon */
        if(range < max(5, m->level)) {
            monster_special(m);
        }
    }
}