void lab5_daemon_driver(int cn, int ret, int lastact) { struct msg *msg,*next; int in,co,imm=-1; struct lab5_daemon_data *dat; dat=set_data(cn,DRD_LAB5_DAEMON,sizeof(struct lab5_daemon_data)); if (!dat) return; // loop through our messages for (msg=ch[cn].msg; msg; msg=next) { next=msg->next; if (msg->type==NT_CREATE) { lab5_daemon_driver_parse(cn,dat); } if (msg->type==NT_TEXT) { co=msg->dat3; tabunga(cn,co,(char*)msg->dat2); } if (msg->type==NT_CHAR) { co=msg->dat1; if (dat->type==1) { // master if (ch[co].flags&CF_PLAYER && char_see_char(cn,co)) { if ((in=ch[co].item[WN_RHAND])==0 || it[in].ID!=IID_LAB5_WEAPON) imm=1; else if (imm==-1) imm=0; } } else imm=0; if (dat->type==2) { // gunned if (ch[co].flags&CF_PLAYER && ch[co].y<namecoordy[0]+25 && char_see_char(cn,co)) fight_driver_add_enemy(cn,co,1,1); // dat->aggressive=1; } } standard_message_driver(cn,msg,dat->aggressive,1); remove_message(cn,msg); } // switch to attack if (dat->aggressive==0 && ticker>dat->attackstart) dat->aggressive=1; // immortal switch if (imm==1) ch[cn].flags|=CF_IMMORTAL; else if (imm==0) ch[cn].flags&=~CF_IMMORTAL; // fighting fight_driver_update(cn); if (fight_driver_attack_visible(cn,0)) return; if (fight_driver_follow_invisible(cn)) return; // rest of standard action if (regenerate_driver(cn)) return; if (spell_self_driver(cn)) return; if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,dat->dir,ret,lastact)) return; // nothing left to do do_idle(cn,TICKS/2); }
void keyhold_fight_driver(int cn,int ret,int lastact) { struct gate_fight_driver_data *dat; struct msg *msg,*next; dat=set_data(cn,DRD_GATE_FIGHT,sizeof(struct gate_fight_driver_data)); if (!dat) return; // oops... // loop through our messages for (msg=ch[cn].msg; msg; msg=next) { next=msg->next; if (msg->type==NT_CREATE) { dat->creation_time=ticker; fight_driver_set_dist(cn,10,0,20); } standard_message_driver(cn,msg,1,0); remove_message(cn,msg); } // do something. whenever possible, call do_idle with as high a tick count // as reasonable when doing nothing. // self destruct eventually if (ticker-dat->creation_time>TICKS*60*5) { say(cn,"Thats all folks!"); remove_destroy_char(cn); return; } fight_driver_update(cn); if (fight_driver_attack_visible(cn,0)) return; if (fight_driver_follow_invisible(cn)) return; if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_DOWN,ret,lastact)) return; if (regenerate_driver(cn)) return; if (spell_self_driver(cn)) return; do_idle(cn,TICKS); }
void lab4_gnalb_driver(int cn, int ret, int lastact) { struct lab4_gnalb_driver_data *dat; struct msg *msg,*next; int co,cc,in; char *str; // get data dat=set_data(cn,DRD_LAB4_GNALB,sizeof(struct lab4_gnalb_driver_data)); if (!dat) return; // oops... // loop through our messages for (msg=ch[cn].msg; msg; msg=next) { next=msg->next; if (msg->type==NT_CREATE) { lab4_gnalb_driver_parse(cn,dat); lab4_gnalb_driver_init(cn,dat); } if (msg->type==NT_GIVE) { co=msg->dat1; if (!(in=ch[cn].citem)) { remove_message(cn,msg); continue; } // ??? i saw something like this at DBs source // destroy everything we get destroy_item(ch[cn].citem); ch[cn].citem=0; } if (msg->type==NT_TEXT) { co=msg->dat3; str=(char *)msg->dat2; tabunga(cn,co,str); if (co==cn) { remove_message(cn,msg); continue; } } if (msg->type==NT_SEEHIT && dat->type==2) { cc=msg->dat1; co=msg->dat2; if (!cc || !co) { remove_message(cn,msg); continue; } // is the victim our friend? then help if (co!=cn && ch[co].group==ch[cn].group) { if (!is_valid_enemy(cn,cc,-1)) { remove_message(cn,msg); continue; } if (char_dist(cn,cc)>10) { remove_message(cn,msg); continue; } fight_driver_add_enemy(cn,cc,1,1); remove_message(cn,msg); continue; } // is the attacker our friend? then help if (cc!=cn && ch[cc].group==ch[cn].group) { if (!is_valid_enemy(cn,co,-1)) { remove_message(cn,msg); continue; } if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; } fight_driver_add_enemy(cn,co,0,1); remove_message(cn,msg); continue; } remove_message(cn,msg); continue; } standard_message_driver(cn,msg,dat->aggressive,dat->helper); remove_message(cn,msg); } // fighting fight_driver_update(cn); if (fight_driver_attack_visible(cn,0)) return; if (fight_driver_follow_invisible(cn)) return; // rest of standard action if (regenerate_driver(cn)) return; if (spell_self_driver(cn)) return; // gnalb guards patroling if (dat->type==1 && dat->path) { fight_driver_set_home(cn,ch[cn].x,ch[cn].y); if (swap_move_driver(cn,gnalb_path[dat->path].x,gnalb_path[dat->path].y,1)) return; if (map_dist(ch[cn].x,ch[cn].y,gnalb_path[dat->path].x,gnalb_path[dat->path].y)<4) { int p; do p=RANDOM(4); while(gnalb_path[dat->path].next[p]==0 || (gnalb_path[dat->path].next[1]!=0 && gnalb_path[dat->path].next[p]==dat->lastpath)); dat->lastpath=dat->path; dat->path=gnalb_path[dat->path].next[p]; } else do_idle(cn,TICKS/2); return; } // crazy gnalb talking if (dat->type==3) { switch (RANDOM(50)) { case 0: whisper(cn,"Me saw right in Fire."); break; case 1: whisper(cn,"Me not crazy. In me house me saw in fire."); break; case 2: whisper(cn,"Me will get it out."); break; case 3: whisper(cn,"Fire hot, but me not crazy."); break; case 4: whisper(cn,"Tell mage me saw in fire, me not crazy."); break; case 10: case 11: case 12: case 13: case 14: if (do_use(cn,DX_RIGHT,0)) return; } if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,ret,lastact)) return; // nothing left to do do_idle(cn,TICKS/2); return; } if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_DOWN,ret,lastact)) return; // nothing left to do do_idle(cn,TICKS/2); }
void ruby_driver(int cn,int retval,int lastact) { struct ruby_driver_data *dat; struct sidestory_ppd *ppd; struct msg *msg,*next; int co,ret,in; char *ptr; dat=set_data(cn,DRD_RUBYDRIVER,sizeof(struct ruby_driver_data)); if (!dat) return; // oops... // loop through our messages for (msg=ch[cn].msg; msg; msg=next) { next=msg->next; if (msg->type==NT_CREATE) { ; } if (msg->type==NT_CHAR) { co=msg->dat1; if ((ch[co].flags&CF_PLAYER) && ch[co].driver!=CDR_LOSTCON && char_dist(cn,co)<16 && char_see_char(cn,co) && (ticker-dat->last_time>TICKS*30 || dat->last_char==co) && (ppd=set_data(co,DRD_SIDESTORY_PPD,sizeof(struct sidestory_ppd)))) { switch(areaID) { case 2: ret=do_story(cn,co,ppd,&ppd->ruby2,ruby2_story); break; case 3: ret=ruby_aston_char(cn,co,ppd); break; case 5: ret=do_story(cn,co,ppd,&ppd->ruby5,ruby5_story); break; case 6: ret=do_story(cn,co,ppd,&ppd->ruby6,ruby6_story); break; case 8: ret=do_story(cn,co,ppd,&ppd->ruby8,ruby8_story); break; case 10: ret=do_story(cn,co,ppd,&ppd->ruby10,ruby10_story); break; case 11: ret=do_story(cn,co,ppd,&ppd->ruby11,ruby11_story); break; case 12: ret=do_story(cn,co,ppd,&ppd->ruby12,ruby12_story); break; case 15: ret=do_story(cn,co,ppd,&ppd->ruby15,ruby15_story); break; case 16: ret=do_story(cn,co,ppd,&ppd->ruby16,ruby16_story); break; case 17: ret=do_story(cn,co,ppd,&ppd->ruby17,ruby17_story); break; default: ret=0; break; } if (ret==1) { dat->last_char=co; dat->last_time=ticker; } else if (ret==2) { dat->last_char=dat->last_time=0; } } } if (msg->type==NT_TEXT) { ptr=(char*)msg->dat2; co=msg->dat3; if ((ch[co].flags&CF_PLAYER) && ch[co].driver!=CDR_LOSTCON && char_dist(cn,co)<16 && char_see_char(cn,co) && (ppd=set_data(co,DRD_SIDESTORY_PPD,sizeof(struct sidestory_ppd)))) { switch(areaID) { case 2: hear_story(cn,co,ppd,&ppd->ruby2,ruby2_story,ptr); break; case 3: ruby_aston_text(cn,co,ppd,ptr); break; case 5: hear_story(cn,co,ppd,&ppd->ruby5,ruby5_story,ptr); break; case 6: hear_story(cn,co,ppd,&ppd->ruby6,ruby6_story,ptr); break; case 8: hear_story(cn,co,ppd,&ppd->ruby8,ruby8_story,ptr); break; case 10: hear_story(cn,co,ppd,&ppd->ruby10,ruby10_story,ptr); break; case 11: hear_story(cn,co,ppd,&ppd->ruby11,ruby11_story,ptr); break; case 12: hear_story(cn,co,ppd,&ppd->ruby12,ruby12_story,ptr); break; case 15: hear_story(cn,co,ppd,&ppd->ruby15,ruby15_story,ptr); break; case 16: hear_story(cn,co,ppd,&ppd->ruby16,ruby16_story,ptr); break; case 17: hear_story(cn,co,ppd,&ppd->ruby17,ruby17_story,ptr); break; } } } if (msg->type==NT_GIVE) { co=msg->dat1; if ((in=ch[cn].citem)) { if ((ch[co].flags&CF_PLAYER) && (ppd=set_data(co,DRD_SIDESTORY_PPD,sizeof(struct sidestory_ppd)))) { switch(areaID) { case 2: ret=give_story(cn,co,ppd,&ppd->ruby2,ruby2_story,in); break; case 5: ret=give_story(cn,co,ppd,&ppd->ruby5,ruby5_story,in); break; case 6: ret=give_story(cn,co,ppd,&ppd->ruby6,ruby6_story,in); break; case 8: ret=give_story(cn,co,ppd,&ppd->ruby8,ruby8_story,in); break; case 10: ret=give_story(cn,co,ppd,&ppd->ruby10,ruby10_story,in); break; case 11: ret=give_story(cn,co,ppd,&ppd->ruby11,ruby11_story,in); break; case 12: ret=give_story(cn,co,ppd,&ppd->ruby12,ruby12_story,in); break; case 15: ret=give_story(cn,co,ppd,&ppd->ruby15,ruby15_story,in); break; case 16: ret=give_story(cn,co,ppd,&ppd->ruby16,ruby16_story,in); break; case 17: ret=give_story(cn,co,ppd,&ppd->ruby17,ruby17_story,in); break; default: ret=0; break; } } else ret=0; ch[cn].citem=0; if (ret || !give_char_item(co,in)) { destroy_item(in); } } } standard_message_driver(cn,msg,0,0); remove_message(cn,msg); } // do something. whenever possible, call do_idle with as high a tick count // as reasonable when doing nothing. fight_driver_update(cn); if (fight_driver_attack_visible(cn,0)) return; if (fight_driver_follow_invisible(cn)) return; if (spell_self_driver(cn)) return; if (regenerate_driver(cn)) return; if (dat->last_time && map_dist(ch[cn].x,ch[cn].y,ch[cn].tmpx,ch[cn].tmpy)>16) dat->last_time=0; if (dat->last_char && !char_see_char(cn,dat->last_char)) dat->last_char=dat->last_time=0; if (ticker-dat->last_time<TICKS*60) { int dir; co=dat->last_char; dir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y); if (tile_char_dist(cn,co)>2 && move_driver(cn,ch[co].x,ch[co].y,2)) return; turn(cn,dir); } else if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,retval,lastact)) return; do_idle(cn,TICKS/2); }
void warpfighter(int cn,int ret,int lastact) { struct warpfighter_data *dat; struct msg *msg,*next; int co,in,fre; dat=set_data(cn,DRD_WARPFIGHTER,sizeof(struct warpfighter_data)); if (!dat) return; // oops... // loop through our messages for (msg=ch[cn].msg; msg; msg=next) { next=msg->next; switch(msg->type) { case NT_CREATE: fight_driver_set_dist(cn,40,0,40); dat->creation_time=ticker; break; case NT_TEXT: co=msg->dat3; tabunga(cn,co,(char*)msg->dat2); break; } standard_message_driver(cn,msg,1,0); remove_message(cn,msg); } // do something. whenever possible, call do_idle with as high a tick count // as reasonable when doing nothing. co=dat->co; if (!ch[co].flags || ch[co].serial!=dat->cser || ch[co].x<dat->xs || ch[co].y<dat->ys || ch[co].x>dat->xe || ch[co].y>dat->ye) { remove_char(cn); destroy_char(cn); //xlog("self-destruct %d %d %d %d %d %d (%d)",!ch[co].flags,ch[co].serial!=dat->cser,ch[co].x<dat->xs,ch[co].y<dat->ys,ch[co].x>dat->xe,ch[co].y>dat->ye,dat->co); return; } if (dat->pot_done<1 && ticker>dat->creation_time+TICKS*2) { dat->pot_done++; if (ch[cn].level>60 && !RANDOM(6)) { if (RANDOM(2)) { emote(cn,"drinks a potion of freeze"); ch[cn].value[1][V_FREEZE]=ch[cn].value[1][V_ATTACK]+ch[cn].value[1][V_ATTACK]/4; ch[cn].value[1][V_MANA]=10; update_char(cn); ch[cn].mana=POWERSCALE*10; } else { if ((fre=may_add_spell(cn,IDR_FREEZE)) && (in=create_item("freeze_spell"))) { emote(cn,"drinks a spoiled potion of freeze"); it[in].mod_value[0]=-ch[cn].value[0][V_SPEED]-100; it[in].driver=IDR_FREEZE; it[in].carried=cn; ch[cn].item[fre]=in; *(signed long*)(it[in].drdata)=ticker+TICKS*60; *(signed long*)(it[in].drdata+4)=ticker; create_spell_timer(cn,in,fre); update_char(cn); } } } } if (ch[cn].lifeshield<POWERSCALE*5 && ch[cn].endurance<ch[cn].value[0][V_WARCRY]*POWERSCALE/3 && dat->pot_done<3) { dat->pot_done++; if (ch[cn].level>50 && !RANDOM(4)) { emote(cn,"drinks an endurance potion"); ch[cn].endurance=min(ch[cn].value[0][V_ENDURANCE]*POWERSCALE,ch[cn].endurance+32*POWERSCALE); } } if (ch[cn].hp<ch[cn].value[0][V_ENDURANCE]*POWERSCALE/2 && dat->pot_done<5) { dat->pot_done++; if (ch[cn].level>40 && !RANDOM(4)) { emote(cn,"drinks a healing potion"); ch[cn].hp=min(ch[cn].value[0][V_HP]*POWERSCALE,ch[cn].hp+32*POWERSCALE); } } fight_driver_update(cn); if (fight_driver_attack_visible(cn,0)) return; if (fight_driver_follow_invisible(cn)) return; if (regenerate_driver(cn)) return; if (spell_self_driver(cn)) return; if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_DOWN,ret,lastact)) return; do_idle(cn,TICKS); }