int pop_create_char(int n, int drop) { int cn, tmp, m, flag = 0, hasitems = 0, chance; for (cn = 1; cn<MAXCHARS; cn++) { if (ch[cn].used==USE_EMPTY) { break; } } if (cn==MAXCHARS) { xlog("MAXCHARS reached!\n"); return( 0); } ch[cn] = ch_temp[n]; ch[cn].pass1 = RANDOM(0x3fffffff); ch[cn].pass2 = RANDOM(0x3fffffff); ch[cn].temp = n; for (m = 0; m<40; m++) { if ((tmp = ch[cn].item[m])!=0) { tmp = god_create_item(tmp); if (!tmp) { flag = 1; ch[cn].item[m] = 0; } else { it[tmp].carried = cn; ch[cn].item[m] = tmp; hasitems = 1; } } } for (m = 0; m<20; m++) { if ((tmp = ch[cn].worn[m])!=0) { tmp = pop_create_item(tmp, cn); if (!tmp) { flag = 1; ch[cn].worn[m] = 0; } else { it[tmp].carried = cn; ch[cn].worn[m] = tmp; hasitems = 1; } } } for (m = 0; m<20; m++) { if (ch[cn].spell[m]!=0) { ch[cn].spell[m] = 0; } } if ((tmp = ch[cn].citem)!=0) { tmp = god_create_item(tmp); if (!tmp) { flag = 1; ch[cn].citem = 0; } else { it[tmp].carried = cn; ch[cn].citem = tmp; } } if (flag) { god_destroy_items(cn); ch[cn].used = USE_EMPTY; return(0); } ch[cn].a_end = 1000000; ch[cn].a_hp = 1000000; if (ch[cn].skill[SK_MEDIT][0]) { ch[cn].a_mana = 1000000; } else { ch[cn].a_mana = RANDOM(8) * RANDOM(8) * RANDOM(8) * RANDOM(8) * 100; } ch[cn].dir = DX_DOWN; ch[cn].data[92] = TICKS * 60; chance = 25; if (!ch[cn].skill[SK_MEDIT][0] && ch[cn].a_mana>15 * 100) { chance -= 6; } if (!ch[cn].skill[SK_MEDIT][0] && ch[cn].a_mana>30 * 100) { chance -= 6; } if (!ch[cn].skill[SK_MEDIT][0] && ch[cn].a_mana>65 * 100) { chance -= 6; } if (ch[cn].alignment<0) { for (m = 0; m<40; m++) { if (ch[cn].item[m]==0 && hasitems) { // this check placed here for speed reasons // they are the same as in pop_create_bonus_belt() if (RANDOM(chance) == 0) { tmp = pop_create_bonus(cn, chance); if (tmp) { it[tmp].carried = cn; ch[cn].item[m] = tmp; } } break; } } /* Added by SoulHunter 04.04.2000 */ // creating rainbow belts for (m = 0; m<40; m++) { if (ch[cn].item[m]==0 && hasitems) { // item will be created with chance 1 from 10000 // this check placed here for speed reasons if (RANDOM(10000) == 0) { tmp = pop_create_bonus_belt(cn); if (tmp) { it[tmp].carried = cn; ch[cn].item[m] = tmp; } } break; } } /* --end */ } if (drop) { if (!god_drop_char(cn, ch[cn].x, ch[cn].y)) { printf("Could not drop char %d\n", n); god_destroy_items(cn); ch[cn].used = USE_EMPTY; return(0); } } do_update_char(cn); globs->npcs_created++; return(cn); }
void effect_tick(void) { int n,cnt=0,in,m,co,fn,cn,in2,flag,z; for (n=1; n<MAXEFFECT; n++) { if (fx[n].used==USE_EMPTY) continue; cnt++; if (fx[n].used!=USE_ACTIVE) continue; if (fx[n].type==1) { // remove injury flag from map fx[n].duration--; if (fx[n].duration==0) { fx[n].used=USE_EMPTY; map[fx[n].data[0]+fx[n].data[1]*MAPX].flags&=~(MF_GFX_INJURED|MF_GFX_INJURED1|MF_GFX_INJURED2); } } if (fx[n].type==2) { // timer for character respawn if (fx[n].duration) fx[n].duration--; if (fx[n].duration==0 && plr_check_target(fx[n].data[0]+fx[n].data[1]*MAPX)) { m=fx[n].data[0]+fx[n].data[1]*MAPX; map[m].flags|=MF_MOVEBLOCK; fx[n].type=8; } } if (fx[n].type==3) { // death mist fx[n].duration++; if (fx[n].duration==19) { fx[n].used=0; m=fx[n].data[0]+fx[n].data[1]*MAPX; map[m].flags&=~MF_GFX_DEATH; } else { m=fx[n].data[0]+fx[n].data[1]*MAPX; map[m].flags&=~MF_GFX_DEATH; map[m].flags|=((unsigned long long)fx[n].duration)<<40; if (fx[n].duration==9) { plr_map_remove(fx[n].data[2]); if (can_drop(m)) ; else if (can_drop(m+1)) m+=1; else if (can_drop(m-1)) m+=-1; else if (can_drop(m+MAPX)) m+=MAPX; else if (can_drop(m-MAPX)) m+=-MAPX; else if (can_drop(m+1+MAPX)) m+=1+MAPX; else if (can_drop(m+1-MAPX)) m+=1-MAPX; else if (can_drop(m-1+MAPX)) m+=-1+MAPX; else if (can_drop(m-1-MAPX)) m+=-1-MAPX; else if (can_drop(m+2)) m+=2; else if (can_drop(m-2)) m+=-2; else if (can_drop(m+2*MAPX)) m+=2*MAPX; else if (can_drop(m-2*MAPX)) m+=-2*MAPX; else if (can_drop(m+2+MAPX)) m+=2+MAPX; else if (can_drop(m+2-MAPX)) m+=2-MAPX; else if (can_drop(m-2+MAPX)) m+=-2+MAPX; else if (can_drop(m-2-MAPX)) m+=-2-MAPX; else if (can_drop(m+1+2*MAPX)) m+=1+2*MAPX; else if (can_drop(m+1-2*MAPX)) m+=1-2*MAPX; else if (can_drop(m-1+2*MAPX)) m+=-1+2*MAPX; else if (can_drop(m-1-2*MAPX)) m+=-1-2*MAPX; else if (can_drop(m+2+2*MAPX)) m+=2+2*MAPX; else if (can_drop(m+2-2*MAPX)) m+=2-2*MAPX; else if (can_drop(m-2+2*MAPX)) m+=-2+2*MAPX; else if (can_drop(m-2-2*MAPX)) m+=-2-2*MAPX; else { int temp; co=fx[n].data[2]; temp=ch[co].temp; chlog(co,"could not drop grave"); god_destroy_items(co); ch[co].used=USE_EMPTY; if (ch[co].flags&CF_RESPAWN) fx_add_effect(2,TICKS*60*5+RANDOM(TICKS*60*10),ch_temp[temp].x,ch_temp[temp].y,temp); m=0; } if (m) { co=fx[n].data[2]; flag=0; for (z=0; z<40 && !flag; z++) { if (ch[co].item[z]) { flag=1; break; } } for (z=0; z<20 && !flag; z++) { if (ch[co].worn[z]) { flag=1; break; } } if (ch[co].citem) flag=1; if (ch[co].gold) flag=1; if (flag) { map[m].flags|=MF_MOVEBLOCK; fn=fx_add_effect(4,0,m%MAPX,m/MAPX,fx[n].data[2]); fx[fn].data[3]=fx[n].data[3]; } else { int temp; temp=ch[co].temp; god_destroy_items(co); ch[co].used=USE_EMPTY; if (temp && (ch[co].flags&CF_RESPAWN)) { if (temp==189 || temp==561) { fx_add_effect(2,TICKS*60*20+RANDOM(TICKS*60*5),ch_temp[temp].x,ch_temp[temp].y,temp); } else { fx_add_effect(2,TICKS*60*4+RANDOM(TICKS*60*1),ch_temp[temp].x,ch_temp[temp].y,temp); } xlog("respawn %d (%s): YES",co,ch[co].name); } else xlog("respawn %d (%s): NO",co,ch[co].name); } } } } } if (fx[n].type==4) { // tomb stone fx[n].duration++; if (fx[n].duration==29) { fx[n].used=USE_EMPTY; co=fx[n].data[2]; m=fx[n].data[0]+fx[n].data[1]*MAPX; map[m].flags&=~MF_GFX_TOMB; map[m].flags&=~MF_MOVEBLOCK; in=god_create_item(170); it[in].data[0]=co; if (ch[co].data[99]) it[in].max_age[0]*=4; sprintf(it[in].description,"Here rests %s, killed by %s on the %d%s%s%s%s day of the Year %d.", ch[co].reference, fx[n].data[3] ? ch[fx[n].data[3]].reference : "unknown causes", globs->mdday, (globs->mdday==1 ? "st" : ""), (globs->mdday==2 ? "nd" : ""), (globs->mdday==3 ? "rd" : ""), (globs->mdday>3 ? "th" : ""), globs->mdyear); god_drop_item(in,fx[n].data[0],fx[n].data[1]); ch[co].x=it[in].x; ch[co].y=it[in].y; chlog(co,"grave done"); } else { m=fx[n].data[0]+fx[n].data[1]*MAPX; map[m].flags&=~MF_GFX_TOMB; map[m].flags|=((unsigned long long)fx[n].duration)<<35; } } if (fx[n].type==5) { // evil magic fx[n].duration++; m=fx[n].data[0]+fx[n].data[1]*MAPX; if (fx[n].duration==8) { fx[n].used=USE_EMPTY; map[m].flags&=~MF_GFX_EMAGIC; } else { map[m].flags&=~MF_GFX_EMAGIC; map[m].flags|=((unsigned long long)fx[n].duration)<<45; } } if (fx[n].type==6) { // good magic fx[n].duration++; m=fx[n].data[0]+fx[n].data[1]*MAPX; if (fx[n].duration==8) { fx[n].used=USE_EMPTY; map[m].flags&=~MF_GFX_GMAGIC; } else { map[m].flags&=~MF_GFX_GMAGIC; map[m].flags|=((unsigned long long)fx[n].duration)<<48; } } if (fx[n].type==7) { // caster magic fx[n].duration++; m=fx[n].data[0]+fx[n].data[1]*MAPX; if (fx[n].duration==8) { fx[n].used=USE_EMPTY; map[m].flags&=~MF_GFX_CMAGIC; } else { map[m].flags&=~MF_GFX_CMAGIC; map[m].flags|=((unsigned long long)fx[n].duration)<<51; } } if (fx[n].type==8) { // repawn mist fx[n].duration++; if (fx[n].duration==19) { fx[n].used=0; m=fx[n].data[0]+fx[n].data[1]*MAPX; map[m].flags&=~MF_GFX_DEATH; } else { m=fx[n].data[0]+fx[n].data[1]*MAPX; map[m].flags&=~MF_GFX_DEATH; map[m].flags|=((unsigned long long)fx[n].duration)<<40; if (fx[n].duration==9) { m=fx[n].data[0]+fx[n].data[1]*MAPX; map[m].flags&=~MF_MOVEBLOCK; if (!pop_create_char(fx[n].data[2],1) && (ch_temp[fx[n].data[2]].flags&CF_RESPAWN)) { fx[n].type=2; fx[n].duration=TICKS*60*5; // try again every 5 minutes map[m].flags&=~MF_GFX_DEATH; } } } } if (fx[n].type==9) { // controlled item animation with optional monster creation fx[n].duration--; in=fx[n].data[0]; if (!(fx[n].duration&1)) it[in].status[1]++; if (fx[n].duration==0) { map[it[in].x+it[in].y*MAPX].it=0; if (fx[n].data[1]) { cn=pop_create_char(fx[n].data[1],0); god_drop_char(cn,it[in].x,it[in].y); ch[cn].dir=DX_RIGHTUP; plr_reset_status(cn); } fx[n].used=USE_EMPTY; it[in].used=USE_EMPTY; } } if (fx[n].type==10) { // respawn object if (fx[n].duration) fx[n].duration--; else { m=fx[n].data[0]+fx[n].data[1]*MAPX; // check if object isnt allowed to respawn (supporting beams for mine) if (is_beam(map[m].it) || is_beam(map[m-1].it) || is_beam(map[m+1].it) || is_beam(map[m-MAPX].it) || is_beam(map[m+MAPX].it) || is_beam(map[m-2].it) || is_beam(map[m+2].it) || is_beam(map[m-2*MAPX].it) || is_beam(map[m+2*MAPX].it) || is_beam(map[m-1+1*MAPX].it) || is_beam(map[m+1+1*MAPX].it) || is_beam(map[m-1-1*MAPX].it) || is_beam(map[m+1-1*MAPX].it) || is_beam(map[m-2+1*MAPX].it) || is_beam(map[m+2+1*MAPX].it) || is_beam(map[m-2-1*MAPX].it) || is_beam(map[m+2-1*MAPX].it) || is_beam(map[m-1+2*MAPX].it) || is_beam(map[m+1+2*MAPX].it) || is_beam(map[m-1-2*MAPX].it) || is_beam(map[m+1-2*MAPX].it) || is_beam(map[m-2+2*MAPX].it) || is_beam(map[m+2+2*MAPX].it) || is_beam(map[m-2-2*MAPX].it) || is_beam(map[m+2-2*MAPX].it)) { fx[n].duration=TICKS*60*15; continue; } in2=map[m].it; map[m].it=0; in=god_create_item(fx[n].data[2]); if (!god_drop_item(in,fx[n].data[0],fx[n].data[1])) { fx[n].duration=TICKS*60; it[in].used=USE_EMPTY; map[m].it=in2; } else { fx[n].used=USE_EMPTY; if (in2) it[in2].used=USE_EMPTY; reset_go(fx[n].data[0],fx[n].data[1]); } } } if (fx[n].type==11) { // remove queued spell flags fx[n].duration--; if (fx[n].duration<1) { fx[n].used=USE_EMPTY; ch[fx[n].data[0]].data[96]&=~fx[n].data[1]; } } if (fx[n].type==12) { // death mist fx[n].duration++; if (fx[n].duration==19) { fx[n].used=0; m=fx[n].data[0]+fx[n].data[1]*MAPX; map[m].flags&=~MF_GFX_DEATH; } else { m=fx[n].data[0]+fx[n].data[1]*MAPX; map[m].flags&=~MF_GFX_DEATH; map[m].flags|=((unsigned long long)fx[n].duration)<<40; } } } globs->effect_cnt=cnt; }
int use_labtransfer(int cn,int nr,int exp) { int x,y,co; for (y=159; y<179; y++) { for (x=164; x<=184; x++) { if ((co=map[x+y*MAPX].ch) && (ch[co].flags&(CF_PLAYER|CF_LABKEEPER))) { do_char_log(cn,0,"Sorry, the area is still busy. %s is there.\n",ch[co].name); chlog(cn,"Sorry, the area is still busy. %s is there",ch[co].name); return 0; } } } switch(nr) { case 1: co=pop_create_char(137,0); break; // grolms case 2: co=pop_create_char(156,0); break; // lizard case 3: co=pop_create_char(278,0); break; // spellcaster case 4: co=pop_create_char(315,0); break; // knight case 5: co=pop_create_char(328,0); break; // undead case 6: co=pop_create_char(458,0); break; // light&dark case 7: co=pop_create_char(462,0); break; // underwater case 8: co=pop_create_char(845,0); break; // forest / golem case 9: co=pop_create_char(919,0); break; // riddle default: do_char_log(cn,0,"Sorry, could not determine which enemy to send you.\n"); chlog(cn,"Sorry, could not determine which enemy to send you"); return 0; } if (!co) { do_char_log(cn,0,"Sorry, could not create your enemy.\n"); chlog(cn,"Sorry, could not create your enemy"); return 0; } if (!god_drop_char(co,174,172)) { do_char_log(cn,0,"Sorry, could not place your enemy.\n"); chlog(cn,"Sorry, could not place your enemy"); god_destroy_items(co); ch[co].used=USE_EMPTY; return 0; } ch[co].data[64]=globs->ticker+5*60*TICKS; // die in two minutes if not otherwise ch[co].data[24]=0; // do not interfere in fights ch[co].data[36]=0; // no walking around ch[co].data[43]=0; // don't attack anyone ch[co].data[80]=0; // no enemies ch[co].data[0]=cn; // person to make solve ch[co].data[1]=nr; // labnr ch[co].data[2]=exp; // exp plr is supposed to get ch[co].flags|=CF_LABKEEPER|CF_NOSLEEP; ch[co].flags&=~CF_RESPAWN; npc_add_enemy(co,cn,1); // make him attack the solver if (!god_transfer_char(cn,174,166)) { do_char_log(cn,0,"Sorry, could not transfer you to your enemy.\n"); chlog(cn,"Sorry, could not transfer you to your enemy"); god_destroy_items(co); ch[co].used=USE_EMPTY; return 0; } chlog(cn,"Entered Labkeeper room"); return 1; }