示例#1
0
void warpteleport_driver(int in,int cn)
{
    int in2,target,n,flag=0;

    if (!cn) return;

    if (!it[in].drdata[0]) {
        switch(it[in].drdata[1]) {
        case 1:
            flag=teleport_char_driver(cn,242,252);
            break;
        case 2:
            flag=teleport_char_driver(cn,247,66);
            break;
        case 3:
            flag=teleport_char_driver(cn,251,16);
            break;
        case 4:
            flag=teleport_char_driver(cn,152,7);
            break;
        case 5:
            flag=teleport_char_driver(cn,183,250);
            break;

        default:
            log_char(cn,LOG_SYSTEM,0,"You found BUG #31as5.");
        }
        if (!flag) log_char(cn,LOG_SYSTEM,0,"Target is busy, please try again soon.");
        return;
    }

    if (!(in2=ch[cn].citem) || it[in2].ID!=IID_AREA25_TELEKEY) {
        log_char(cn,LOG_SYSTEM,0,"Nothing happened.");
        return;
    }

    target=(it[in].drdata[0]-1)*5+(it[in2].drdata[0]-1);

    //log_char(cn,LOG_SYSTEM,0,"target=%d",target);
    if (teleport_char_driver(cn,tl[target].x,tl[target].y)) {
        ch[cn].citem=0;
        ch[cn].flags|=CF_ITEMS;
        destroy_item(in2);
        flag++;

        for (n=0; n<INVENTORYSIZE; n++) {
            if ((in2=ch[cn].item[n]) && it[in2].ID==IID_AREA25_TELEKEY) {
                remove_item_char(in2);
                destroy_item(in2);
                flag++;
            }
        }
        if (flag) log_char(cn,LOG_SYSTEM,0,"Your sphere%s vanished.",flag>0 ? "s" : "");
    }
}
示例#2
0
void meltingkey(int in,int cn)
{
	int sprite;

        if (cn) return;
	if (!it[in].carried) return;	// can only use if item is carried
	
	it[in].drdata[1]++;
	if (it[in].drdata[1]>=it[in].drdata[0]) {
		if (it[in].carried) log_char(it[in].carried,LOG_SYSTEM,0,"Your %s melted away.",it[in].name);
		if (ch[cn].flags&CF_PLAYER) dlog(cn,in,"dropped because it melted");
		remove_item(in);
		destroy_item(in);
		return;
	}
	sprite=50494+it[in].drdata[1]*5/it[in].drdata[0];

	if (it[in].sprite!=sprite) {
		it[in].sprite=sprite;
		if (it[in].carried) {
			ch[it[in].carried].flags|=CF_ITEMS;
			if (sprite==50495) {
				log_char(it[in].carried,LOG_SYSTEM,0,"Your %s starts to melt.",it[in].name);
			}
		}
	}
			
	call_item(it[in].driver,in,0,ticker+TICKS*10);
}
示例#3
0
文件: player.c 项目: Df458/Growgue
void add_item(item* it)
{
    if(it == 0)
        return;
    int index = -1;
    for(int i = 0; i < item_count; ++i) {
        if(index == -1 && inventory[i] == 0) {
            index = i;
            inventory[index] = it;
            break;
        } else if(inventory[i] && !strcmp(it->orig_path, inventory[i]->orig_path)) {
            inventory[i]->count += it->count;
            destroy_item(it);
            return;
        }
    }

    if(index == -1) {
        inventory = realloc(inventory, (item_count + 5) * sizeof(item*));
        for(int i = item_count + 1; i < item_count + 5; ++i)
            inventory[i] = 0;
        inventory[item_count] = it;
        item_count += 5;
        it->on_ground = false;
    }
}
示例#4
0
bool hook_remove_extl(WHook *hk, ExtlFn efn)
{
    WHookItem *item=hook_find_extl(hk, efn);
    if(item!=NULL)
        destroy_item(hk, item);
    return (item!=NULL);
}
示例#5
0
bool hook_remove(WHook *hk, WHookDummy *fn)
{
    WHookItem *item=hook_find(hk, fn);
    if(item!=NULL)
        destroy_item(hk, item);
    return (item!=NULL);
}
示例#6
0
STDMETHODIMP loEnum<BASE,ITEM,IFACE>::Next(ULONG celt, ITEM *rgelt, ULONG *fetched)
{
 HRESULT hr;
 ULONG ii, cmax, cbase;
// UL_WARNING((LOGID, "IEnum::Next -> %u %p", celt, rgelt));

 if (fetched) *fetched = 0;
 else if (celt > 1) return E_INVALIDARG;
 if (!rgelt && celt) return E_INVALIDARG;
 cmax = total - (cbase = curpos);
 if (total < cbase) cmax = 0;
 if (cmax > celt) cmax = celt;
#if 0
 memset(rgelt, 0, celt * sizeof(*rgelt));
#endif
 for(ii = 0; ii < cmax; ii++)
   if (S_OK != (hr = clone_item(&rgelt[ii],
                                &list[cbase + ii])))
     {
      while(ii--) destroy_item(&rgelt[ii]);
      return hr;
     }
 if (fetched) *fetched = cmax;
 curpos = cbase + cmax;

 return celt == cmax? S_OK: S_FALSE;
}
示例#7
0
void decay_worldzone( unsigned wx, unsigned wy, Realms::Realm* realm )
{
    Zone& zone = realm->zone[wx][wy];
    gameclock_t now = read_gameclock();
    bool statistics = Plib::systemstate.config.thread_decay_statistics;

    for ( ZoneItems::size_type idx = 0; idx < zone.items.size(); ++idx )
    {
        Items::Item* item = zone.items[idx];
        if (statistics)
        {
            if (item->can_decay())
            {
                const Items::ItemDesc& descriptor = item->itemdesc();
                if (!descriptor.decays_on_multis)
                {
                    Multi::UMulti* multi = realm->find_supporting_multi( item->x, item->y, item->z );
                    if (multi == NULL)
                        stateManager.decay_statistics.temp_count_active++;
                }
                else
                    stateManager.decay_statistics.temp_count_active++;
            }

        }
        if ( item->should_decay( now ) )
        {
            // check the CanDecay syshook first if it returns 1 go over to other checks
            if ( gamestate.system_hooks.can_decay )
            {
                if ( !gamestate.system_hooks.can_decay->call( new Module::EItemRefObjImp( item ) ) )
                    continue;
            }

            const Items::ItemDesc& descriptor = item->itemdesc();
            Multi::UMulti* multi = realm->find_supporting_multi( item->x, item->y, item->z );

            // some things don't decay on multis:
            if ( multi != NULL && !descriptor.decays_on_multis )
                continue;

            if (statistics)
                stateManager.decay_statistics.temp_count_decayed++;

            if ( !descriptor.destroy_script.empty() && !item->inuse() )
            {
                bool decayok = call_script( descriptor.destroy_script, item->make_ref() );
                if ( !decayok )
                    continue;
            }

            item->spill_contents( multi );
            destroy_item( item );
            --idx;
        }
    }
}
示例#8
0
void itemspawn(int in,int cn)
{
        int in2;

	if (!cn) return;	// always make sure its not an automatic call if you don't handle it

	if (ch[cn].citem) {
		log_char(cn,LOG_SYSTEM,0,"Please empty your 'hand' (mouse cursor) first.");
		return;
	}

        // get item to spawn
        switch(it[in].drdata[0]) {
		case 0:		in2=create_item("melting_key"); break;
		case 1:		in2=create_item("ice_boots1"); break;
		case 2:		in2=create_item("ice_cape1"); break;
		case 3:		in2=create_item("ice_belt1"); break;
		case 4:		in2=create_item("ice_ring1"); break;
		case 5:		in2=create_item("ice_amulet1"); break;
		case 6:		in2=create_item("melting_key2"); break;

		case 7:		in2=create_item("ice_boots2"); break;
		case 8:		in2=create_item("ice_cape2"); break;
		case 9:		in2=create_item("ice_belt2"); break;
		case 10:	in2=create_item("ice_ring2"); break;
		case 11:	in2=create_item("ice_amulet2"); break;

		case 12:	in2=create_item("ice_boots3"); break;
		case 13:	in2=create_item("ice_cape3"); break;
		case 14:	in2=create_item("ice_belt3"); break;
		case 15:	in2=create_item("ice_ring3"); break;
		case 16:	in2=create_item("ice_amulet3"); break;
		case 17:	in2=create_item("palace_bomb"); break;
		case 18:	in2=create_item("palace_cap"); break;

		default:	
				log_char(cn,LOG_SYSTEM,0,"Congratulations, %s, you have just discovered bug #4244B-%d-%d, please report it to the authorities!",ch[cn].name,it[in].x,it[in].y);
				return;
	}

        if (!in2) {
		log_char(cn,LOG_SYSTEM,0,"Congratulations, %s, you have just discovered bug #4244C-%d-%d, please report it to the authorities!",ch[cn].name,it[in].x,it[in].y);
		return;			
	}

	if (!can_carry(cn,in2,0)) {
		destroy_item(in2);
		return;
	}

	if (ch[cn].flags&CF_PLAYER) dlog(cn,in2,"took from ice itemspawn");
	ch[cn].citem=in2;
	ch[cn].flags|=CF_ITEMS;
	it[in2].carried=cn;

        log_char(cn,LOG_SYSTEM,0,"You got a %s.",it[in2].name);
}
示例#9
0
void edemonloader_driver(int in,int cn)
{
	int nr,pwr,sprite,in2,ani,m,gsprite;

        nr=it[in].drdata[0];	// section number
	pwr=it[in].drdata[1];	// power status
	ani=it[in].drdata[2];

	if (cn) {	// player using item
		if (pwr) {
			if (ch[cn].citem) log_char(cn,LOG_SYSTEM,0,"There is already a crystal, you cannot add another item.");				
			else log_char(cn,LOG_SYSTEM,0,"The crystal is stuck.");
			return;
		}
		if (!(in2=ch[cn].citem)) {
			log_char(cn,LOG_SYSTEM,0,"Nothing happens.");
			return;
		}
		if (it[in2].ID!=IID_AREA6_YELLOWCRYSTAL) {
			log_char(cn,LOG_SYSTEM,0,"That doesn't fit.");
			return;
		}
		pwr=it[in2].drdata[0];
		ani=7;
		if (ch[cn].flags&CF_PLAYER) dlog(cn,in2,"dropped into edemonloader");
		ch[cn].citem=0;
		ch[cn].flags|=CF_ITEMS;
		destroy_item(in2);
		sound_area(it[in].x,it[in].y,41);
	} else {	// timer call
		if (pwr) pwr--;
		if (ani) ani--;

		call_item(it[in].driver,in,0,ticker+TICKS);
	}
	
	it[in].drdata[2]=ani;
	it[in].drdata[1]=pwr;

	m=it[in].x+it[in].y*MAXMAP;
	gsprite=map[m].gsprite&0x0000ffff;
	
	if (ani) gsprite|=(14247-ani)<<16;
	else if (pwr) gsprite|=14248<<16;
	else gsprite|=14240<<16;

	if (pwr) { sprite=14257+5-(pwr/43); sect[nr]=pwr; }	//50467
	else { sprite=14234; sect[nr]=0; } // 50466;

	if (it[in].sprite!=sprite || map[m].gsprite!=gsprite) {
		it[in].sprite=sprite;
		map[m].gsprite=gsprite;
		set_sector(it[in].x,it[in].y);
		if (sprite==14234) sound_area(it[in].x,it[in].y,43);	// power off
	}
}
示例#10
0
void oxy_potion(int in,int cn)
{
	if (!cn) return;
	if (!it[in].carried) return;
	
	add_spell(cn,IDR_OXYGEN,TICKS*60,"nonomagic_spell");
	remove_item(in);
	destroy_item(in);
	ch[cn].flags|=CF_ITEMS;
}
示例#11
0
void loEnum<BASE,ITEM,IFACE>::destroy_list(void)
{
 if (count)
   {
    ULONG xx = total;
    total = curpos = 0;
    while(xx--)
      destroy_item(&list[xx]);
   }
}
示例#12
0
void underwater_berry(int in,int cn)
{
	if (!cn) return;

	if (!(ch[cn].flags&CF_PLAYER)) return;

	if (!add_spell(cn,IDR_OXYGEN,TICKS*30,"nonomagic_spell")) return;

	remove_item(in);
	destroy_item(in);
}
示例#13
0
/** Destroy a list
 **/
void list_destroy(GLLIST *list) /**< a pointer to the LIST structure to destroy */
{
	LISTITEM *item = list->first;
	while ( item!=NULL )
	{
		LISTITEM *target = item;
		item = item->next;
		list->size--;
		destroy_item(target);
	}
	/* list size should be zero here */
}
示例#14
0
void backtofire(int in,int cn)
{
	if (!cn) return;
	if (!it[in].carried) return;	// can only use if item is carried
	
	if (teleport_char_driver(cn,it[in].drdata[0],it[in].drdata[1])) {
		if (ch[cn].flags&CF_PLAYER) dlog(cn,in,"dropped because it was used");
		remove_item_char(in);
		destroy_item(in);
		log_char(cn,LOG_SYSTEM,0,"The scroll vanished.");
	}
}
示例#15
0
void destroy_item_byID(int cn,int ID)
{
	struct depot_ppd *ppd;
	int n,in;

	ppd=set_data(cn,DRD_DEPOT_PPD,sizeof(struct depot_ppd));

	for (n=0; n<INVENTORYSIZE; n++) {
		if (n>=12 && n<30) continue;
		
		if ((in=ch[cn].item[n])) {
			if (it[in].ID==ID) {
				destroy_item(ch[cn].item[n]);
				ch[cn].item[n]=0;
				ch[cn].flags|=CF_ITEMS;
			}
		}
	}

	if ((in=ch[cn].citem)) {
		if (it[in].ID==ID) {
			destroy_item(ch[cn].citem);
			ch[cn].citem=0;
			ch[cn].flags|=CF_ITEMS;
		}
	}

	if (ppd) {
		for (n=0; n<MAXDEPOT; n++) {
			if (ppd->itm[n].flags) {
                                if (ppd->itm[n].ID==ID) {
					ppd->itm[n].flags=0;
				}
			}
		}
	}

	destroy_item_from_body(cn,ID);
}
示例#16
0
void keyholder_door(int in,int cn)
{
	int x,y,n,in2,flag,co,nr;
	char buf[80];

	if (!cn) return;

	nr=it[in].drdata[0];

	for (n=0; n<9; n++) {
		flag=0;
		for (x=2+(n%3)*8; x<9+(n%3)*8; x++) {
			for (y=231+(n/3)*8; y<238+(n/3)*8; y++) {
				if ((in2=map[x+y*MAXMAP].it) && (it[in2].flags&IF_TAKE)) { flag=1; break; }
				if (map[x+y*MAXMAP].ch) { flag=1; break; }
			}
		}
		if (!flag) break;
	}	
	if (flag) {
		log_char(cn,LOG_SYSTEM,0,"You hear fighting noises from behind the door. It won't open while the fight lasts.");
		return;
	}
        if (!(in2=ch[cn].citem) || it[in2].driver!=IDR_ENHANCE || it[in2].drdata[0]!=2 || *(unsigned int*)(it[in2].drdata+1)!=2000) {
		log_char(cn,LOG_SYSTEM,0,"You'll need to use 2000 gold units as a key to open the door.");
		return;
	}
	if (!teleport_char_driver(cn,2+(n%3)*8+1,231+(n/3)*8+3)) {
		log_char(cn,LOG_SYSTEM,0,"You hear fighting noises from behind the door. It won't open while the fight lasts.");
		return;
	}
	destroy_item(in2);
	ch[cn].citem=0;
	ch[cn].flags|=CF_ITEMS;

	sprintf(buf,"keyholder_golem%d",nr);
	co=create_char(buf,0);
	if (co) {
		update_char(co);
		ch[co].hp=ch[co].value[0][V_HP]*POWERSCALE;
		ch[co].endurance=ch[co].value[0][V_ENDURANCE]*POWERSCALE;
		ch[co].mana=ch[co].value[0][V_MANA]*POWERSCALE;
		ch[co].dir=DX_LEFTUP;
		ch[co].tmpx=2+(n%3)*8+5;
		ch[co].tmpy=231+(n/3)*8+3;

		drop_char(co,2+(n%3)*8+5,231+(n/3)*8+3,1);
	}
}
示例#17
0
文件: player.c 项目: Df458/Growgue
void remove_item(item* item, int quantity)
{
    if(item == 0)
        return;
    for(int i = 0; i < item_count; ++i) {
        if(inventory[i] == item) {
            if(item->count <= quantity || quantity == -1) {
                destroy_item(item);
                inventory[i] = 0;
            } else
                item->count -= quantity;
            break;
        }
    }
}
示例#18
0
int warpkeydoor_driver(int in,int cn)
{
    int in2,dx,dy;

    if (!cn) return 1;

    dx=it[in].x-ch[cn].x;
    dy=it[in].y-ch[cn].y;
    if (!dx && !dy) {
        log_char(cn,LOG_SYSTEM,0,"Bug #329i, sorry.");
        return 2;
    }

    in2=has_item(cn,IID_AREA25_DOORKEY);

    if (!in2) {
        log_char(cn,LOG_SYSTEM,0,"The door is locked and you do not have the right key.");
        return 2;
    }

    if (teleport_char_driver(cn,it[in].x+dx,it[in].y+dy)) {
        log_char(cn,LOG_SYSTEM,0,"A %s vanished.",it[in2].name);
        remove_item_char(in2);
        destroy_item(in2);
        switch(ch[cn].dir) {
        case DX_RIGHT:
            ch[cn].dir=DX_LEFT;
            break;
        case DX_LEFT:
            ch[cn].dir=DX_RIGHT;
            break;
        case DX_UP:
            ch[cn].dir=DX_DOWN;
            break;
        case DX_DOWN:
            ch[cn].dir=DX_UP;
            break;
        }
        return 1;
    } else {
        log_char(cn,LOG_SYSTEM,0,"Oops. Please try again.");
        return 2;
    }
}
示例#19
0
void warmfire(int in,int cn)
{
	int in2,fn,n;

	if (!cn) return;

	if (ch[cn].citem) {
		log_char(cn,LOG_SYSTEM,0,"Please empty your 'hand' (mouse cursor) first.");
		return;
	}
	if (!it[in].drdata[0]) {
		in2=create_item("ice_scroll");
		if (in2) {
			if (ch[cn].flags&CF_PLAYER) dlog(cn,in2,"took from warmfire");
			ch[cn].citem=in2;
			it[in2].carried=cn;
			ch[cn].flags|=CF_ITEMS;
			it[in2].drdata[0]=ch[cn].x;
			it[in2].drdata[1]=ch[cn].y;
	
			log_char(cn,LOG_SYSTEM,0,"Next to the fire, you find an ancient scroll. It seems to be a scroll of teleport which will take you back here.");
		}
	}

	for (n=12; n<30; n++) {
		if ((in2=ch[cn].item[n]) && it[in2].driver==IDR_CURSE) {
			destroy_item(in2);
			ch[cn].item[n]=0;
			break;
		}
	}
	if (n==30) {
		log_char(cn,LOG_SYSTEM,0,"You warm your hands on the fire.");
		return;
	}
	for (n=0; n<4; n++) {
		if ((fn=ch[cn].ef[n]) && ef[fn].type==EF_CURSE) {
			remove_effect_char(fn);
			free_effect(fn);
		}
	}
	update_char(cn);
	log_char(cn,LOG_SYSTEM,0,"You move close to the heat of the fire, and you feel the demon's cold leave you.");
}
示例#20
0
void flower_mixer(int in,int cn)
{
	int bit1,bit2,in2;

	if (!cn) return;

	if (!(in2=ch[cn].citem)) {
		log_char(cn,LOG_SYSTEM,0,"No, eating this berry isn't a good idea.");
		return;
	}

	if (it[in2].driver!=IDR_LIZARDFLOWER) {
		log_char(cn,LOG_SYSTEM,0,"This cannot be used together. Try something else.");
		return;
	}

	bit1=it[in].drdata[0];
	bit2=it[in2].drdata[0];

	if (it[in].sprite!=11189 && it[in2].sprite!=11189) {
		log_char(cn,LOG_SYSTEM,0,"A bottle pops out of thin air as you try to combine the flowers. You're stunned for a moment, but then you mix the flowers in the bottle.");
	}
	
        it[in].drdata[0]|=bit2;
	ch[cn].flags|=CF_ITEMS;

	if (it[in].drdata[0]==7) {
		it[in].sprite=11188;
		it[in].driver=128;
		strcpy(it[in].name,"Scuba Potion");
		strcpy(it[in].description,"A bubbly fluid in a nice bottle.");
		log_char(cn,LOG_SYSTEM,0,"The potion seems finished.");
	} else {
		strcpy(it[in].description,"A partially finished scuba potion.");
		it[in].sprite=11189;
	}

	ch[cn].citem=0;
	destroy_item(in2);	
}
示例#21
0
int remove_item_from_body_bg(int cnID,int IID)
{
	int n,cnt=0,m,in;

	for (n=1; n<MAXCONTAINER; n++) {
		if (!con[n].in) continue;			// empty or not item container (grave)
		if (con[n].owner!=charID_ID(cnID)) continue;	// not owned by cn

		for (m=0; m<CONTAINERSIZE; m++) {
			if ((in=con[n].item[m]) && it[in].ID==IID) {
				dlog(0,in,"destroying quest item in grave (questlog)");
				destroy_item(in);
				con[n].item[m]=0;
				cnt++;
			}
		}
		

	}
	//if (cnt) tell_chat(0,cnID,1,"Area %d: Removed %d items from corpses you cheat.",areaID,cnt);

	return cnt;
}
示例#22
0
文件: protocol.c 项目: djjsindy/dawn
static intptr_t process_delete(connection_t *conn){
  read_context_t *rc=conn->rc;
  if(rc->read_process!=READ_COMMAND_END){
    intptr_t result=parse_delete_header(conn);
    if(result==AGAIN){
      return AGAIN;
    }
  }
  char *key=rc->key->data;
  queue_t *q=(queue_t *)get(key,hash);
  if(q!=NULL){
    while(1){
      item_t *i=(item_t *)pop(q);
      if(i==NULL){
        break;
      }
      add_get_sync_data(key,i->size);
      destroy_item(i);    
    }
  } 
  write_delete_response(conn);
  event_operation.register_event(conn->fd,WRITE,conn->ec,conn);
  return OK;
}
示例#23
0
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);
}
示例#24
0
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);
}
示例#25
0
void lab4_seyan_driver(int cn, int ret, int lastact)
{
	struct lab4_player_data *pd;
        static struct lab4_seyan_data datbuf;   // we only have one, so there is no need to use the memory system (?)
        struct lab4_seyan_data *dat=&datbuf;
        struct msg *msg,*next;
        int co;
        int talkdir=0,didsay=0;
        char *str;


        // loop through our messages
	for (msg=ch[cn].msg; msg; msg=next) {
		next=msg->next;

                if (msg->type==NT_GIVE) {
                        if (!ch[cn].citem) { remove_message(cn,msg); continue; } // ??? i saw something like this at DBs source
                        co=msg->dat1;

                        // players only
                        if (ch[co].flags&CF_PLAYER) {

                                // get lab ppd
                                pd=set_data(co,DRD_LAB4_PLAYER,sizeof(struct lab4_player_data));
                                if (!pd) { remove_message(cn,msg); continue; }

                                // check item
                                if (it[ch[cn].citem].ID==IID_LAB4_CROWN) {
                                        pd->seyan4got|=(1<<0);
                                        set_seyan_state(pd);
                                        if (dat->cv_co && (dat->cv_co!=co || ch[dat->cv_co].serial!=dat->cv_serial)) { say(cn,"%s, please be patient while i'm talking to others.",ch[co].name); }
                                }
                                if (it[ch[cn].citem].ID==IID_LAB4_SZEPTER) {
                                        pd->seyan4got|=(1<<1);
                                        set_seyan_state(pd);
                                        if (dat->cv_co && (dat->cv_co!=co || ch[dat->cv_co].serial!=dat->cv_serial)) { say(cn,"%s, please be patient while i'm talking to others.",ch[co].name); }
                                }
                        }

                        // destroy everything we get
                        destroy_item(ch[cn].citem);
                        ch[cn].citem=0;
                }

                if (msg->type==NT_CHAR) {

                        co=msg->dat1;

                        // dont talk
			if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; }            // dont talk to other NPCs
			if (ch[co].driver==CDR_LOSTCON) { remove_message(cn,msg); continue; }           // dont talk to players without connection
			if (ticker<dat->lasttalk+5*TICKS) { remove_message(cn,msg); continue; }              // only talk when the old sentence is read
			if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; }      // dont talk to someone we cant see, and dont talk to ourself
			if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; }                  // dont talk to someone far away

                        // remove cv
                        if (dat->cv_co) {
                                if (!ch[dat->cv_co].flags || ch[dat->cv_co].serial!=dat->cv_serial || char_dist(cn,dat->cv_co)>10 || !char_see_char(cn,dat->cv_co)) {
                                        dat->cv_co=0;
                                }
                        }

                        // only talk to cv
                        if (dat->cv_co && dat->cv_co!=co) { remove_message(cn,msg); continue; }

                        // set new cv
                        if (!dat->cv_co) {
                                dat->cv_co=co;
                                dat->cv_serial=ch[co].serial;
                        }

                        // get lab ppd
                        pd=set_data(co,DRD_LAB4_PLAYER,sizeof(struct lab4_player_data));
                        if (!pd) { remove_message(cn,msg); continue; }

			switch(pd->seyan4state) {
                                // INTRO
                                case 0: say(cn,"Hello %s. This is thy first mission in the Labyrinth.",ch[co].name); didsay=1; pd->seyan4state++; break;
                                case 1: say(cn,"Listen, %s. To the east is an entrance to the Gnalbs winter residence.",ch[co].name); didsay=1; pd->seyan4state++; break;
                                case 2: say(cn,"The Gnalbs are peaceful creatures, but their King and their Mage and the Guards are not."); didsay=1; pd->seyan4state++; break;
                                case 3: say(cn,"Bring me the King's Crown, and the Mage's Szepter to prove thou art worthy to enter the next Gate."); didsay=1; pd->seyan4state++; break;
                                case 4: say(cn,"Go ahead now, %s, and fulfil thine destiny.",ch[co].name); didsay=1; pd->seyan4state++; break;
                                case 5: dat->cv_co=0; break;

                                // received crown (szepter missing)
                                case 10: say(cn,"Thou broughtst me the Kings Crown. Now, %s, seek for the Mage's Szepter.",ch[co].name); didsay=1; pd->seyan4state++; break;
                                case 11: dat->cv_co=0; break;
			
                                // received szepter (corwn missing)
                                case 20: say(cn,"Thou broughtst me the Mages Szepter. Now, %s, seek for the King's Crown.",ch[co].name); didsay=1; pd->seyan4state++; break;
                                case 21: dat->cv_co=0; break;

                                // received both, opening gate
                                case 30: say(cn,"%s, thou broughtst me the King's Crown and the Mage's Szepter.",ch[co].name); didsay=1; pd->seyan4state++; break;
                                case 31: say(cn,"Now I will open a magic gate for thee. Use it, and thou wilt be able to travel to the next part of the Labyrinth."); didsay=1; pd->seyan4state++; break;
                                case 32: create_lab_exit(co,10); say(cn,"Mayest Thou Past The Last Gate, %s",ch[co].name); didsay=1; pd->seyan4state++; break;
                                case 33: dat->cv_co=0; break;
                        }

                        if (didsay) {
                                dat->lasttalk=ticker;
                                talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
                        }

		}

                if (msg->type==NT_TEXT) {

                        co=msg->dat3;
                        str=(char *)msg->dat2;

                        tabunga(cn,co,(char*)msg->dat2);

                        if (co==cn) { remove_message(cn,msg); continue; }
			if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; }
			if (!char_see_char(cn,co)) { remove_message(cn,msg); continue; }

                        // get lab ppd
                        pd=set_data(co,DRD_LAB4_PLAYER,sizeof(struct lab4_player_data));
                        if (!pd) { remove_message(cn,msg); continue; }

                        if (strcasestr(str,"REPEAT")) { say(cn,"I will repeat, %s",ch[co].name); set_seyan_state(pd); }
                }

                standard_message_driver(cn,msg,0,0);
                remove_message(cn,msg);
	}

        if (talkdir) turn(cn,talkdir);

        if (dat->lasttalk+TICKS*30<ticker) {
                if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHTDOWN,ret,lastact)) return;		
        }

        do_idle(cn,TICKS);
}
示例#26
0
void cmd_steal(int cn)
{
	int co,x,y,n,cnt,in=0,chance,dice,diff,m;

	if (!ch[cn].prof[P_THIEF]) {
		log_char(cn,LOG_SYSTEM,0,"You are not a thief, you cannot steal.");
		return;
	}
	if (ch[cn].action!=AC_IDLE) {
		log_char(cn,LOG_SYSTEM,0,"You can only steal when standing still.");
		return;
	}

	if (ch[cn].citem) {
		log_char(cn,LOG_SYSTEM,0,"Please free your hand (mouse cursor) first.");
		return;
	}

	dx2offset(ch[cn].dir,&x,&y,NULL);
	
	x+=ch[cn].x;
	y+=ch[cn].y;

	if (x<1 || x>=MAXMAP-1 || y<1 || y>=MAXMAP-1) {
		log_char(cn,LOG_SYSTEM,0,"Out of map.");
		return;
	}
	
	m=x+y*MAXMAP;
	co=map[m].ch;
	if (!co) {
		log_char(cn,LOG_SYSTEM,0,"There's no one to steal from.");
		return;
	}

	if (!can_attack(cn,co)) {
		log_char(cn,LOG_SYSTEM,0,"You cannot steal from someone you are not allowed to attack.");
		return;
	}
	if (map[m].flags&(MF_ARENA|MF_CLAN)) {
		log_char(cn,LOG_SYSTEM,0,"You cannot steal inside an arena.");
		return;
	}
	if (!(ch[co].flags&CF_PLAYER)) {
		log_char(cn,LOG_SYSTEM,0,"You can only steal from players.");
		return;
	}
	if (ch[co].driver==CDR_LOSTCON) {
		log_char(cn,LOG_SYSTEM,0,"You cannot steal from lagging players.");
		return;
	}
	if (areaID==20) {
		log_char(cn,LOG_SYSTEM,0,"You cannot steal in Live Quests.");
		return;
	}

	if (ch[co].action!=AC_IDLE || ticker-ch[co].regen_ticker<TICKS) {
		log_char(cn,LOG_SYSTEM,0,"You cannot steal from someone if your victim is not standing still.");
		return;
	}
	
	for (n=cnt=0; n<INVENTORYSIZE; n++) {
		if (n>=12 && n<30) continue;
		if ((in=ch[co].item[n]) && !(it[in].flags&IF_QUEST) && can_carry(cn,in,1)) cnt++;
	}
	if (!cnt) {
		log_char(cn,LOG_SYSTEM,0,"You could not find anything to steal.");
		return;
	}
	cnt=RANDOM(cnt);

	for (n=cnt=0; n<INVENTORYSIZE; n++) {
		if (n>=12 && n<30) continue;
		if ((in=ch[co].item[n]) && !(it[in].flags&IF_QUEST) && can_carry(cn,in,1)) {
			if (cnt<1) break;
			cnt--;
		}		
	}
	if (n==INVENTORYSIZE) {
		log_char(cn,LOG_SYSTEM,0,"You could not find anything to steal (2).");
		return;
	}

	diff=(ch[cn].value[0][V_STEALTH]-ch[co].value[0][V_PERCEPT])/2;
	chance=40+diff;
	if (chance<10) {
		log_char(cn,LOG_SYSTEM,0,"You'd get caught for sure. You decide not to try.");
		return;
	}
	chance=min(chance,ch[cn].prof[P_THIEF]*3);

        dice=RANDOM(100);
	diff=chance-dice;

        if (diff<-20) {
		log_char(cn,LOG_SYSTEM,0,"%s noticed your attempt and stopped you from stealing.",ch[co].name);
		ch[cn].endurance=1;
		if (ch[co].flags&CF_PLAYER) {
			log_char(co,LOG_SYSTEM,0,"°c3%s tried to steal from you!",ch[cn].name);
		} else notify_char(co,NT_GOTHIT,cn,0,0);
		return;
	}

	dlog(co,in,"dropped because %s stole it",ch[cn].name);
	remove_item_char(in);
	if (!give_char_item(cn,in)) {
		destroy_item(in);
		elog("had to destroy item in cmd_steal()!");
		return;
	}

	add_pk_steal(cn);

	if (diff<0) {
		log_char(cn,LOG_SYSTEM,0,"%s noticed your theft, but you managed to steal a %s anyway.",ch[co].name,it[in].name);
		ch[cn].endurance=1;
		if (ch[co].flags&CF_PLAYER) {
			log_char(co,LOG_SYSTEM,0,"°c3%s stole your %s!",ch[cn].name,it[in].name);
		} else notify_char(co,NT_GOTHIT,cn,0,0);
	} else log_char(cn,LOG_SYSTEM,0,"You stole a %s without %s noticing.",it[in].name,ch[co].name);
}
示例#27
0
void dwarfchief_driver(int cn,int ret,int lastact)
{
	struct dwarfchief_data *dat;
	struct staffer_ppd *ppd;
        int co,in,didsay=0,talkdir=0;
	struct msg *msg,*next;

        dat=set_data(cn,DRD_DWARFCHIEFDRIVER,sizeof(struct dwarfchief_data));
	if (!dat) return;	// oops...

        // loop through our messages
	for (msg=ch[cn].msg; msg; msg=next) {
		next=msg->next;

                // did we see someone?
		if (msg->type==NT_CHAR) {
			
                        co=msg->dat1;

			// dont talk to other NPCs
			if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; }

			// dont talk to players without connection
			if (ch[co].driver==CDR_LOSTCON) { remove_message(cn,msg); continue; }
			
			// only talk every ten seconds
			if (ticker<dat->last_talk+TICKS*4) { remove_message(cn,msg); continue; }

			if (ticker<dat->last_talk+TICKS*10 && dat->current_victim!=co) { remove_message(cn,msg); continue; }

                        // dont talk to someone we cant see, and dont talk to ourself
			if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; }

			// dont talk to someone far away
			if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; }

                        // get current status with player
                        ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));

                        if (ppd) {
                                switch(ppd->dwarfchief_state) {
					case 0:         quiet_say(cn,"Welcome, stranger, to Grimroot, home of the dwarves. I would introduce you to our town further, but I have urgent matters to attend to.");
							questlog_open(co,47);
							ppd->dwarfchief_state++; didsay=1;
                                                        break;
					case 1:		quiet_say(cn,"Four of our miners have gone missing, one each in one of the 4 mine areas, and we can only think it's because of those bothersome golems...");
                                                        ppd->dwarfchief_state++; didsay=1;
							break;
                                        case 2:         quiet_say(cn,"If you wish, here's a scroll so you can help one of them. Give this one to the miner in the first section, then come back for another scroll for the next miner.");
                                                        ppd->dwarfchief_state++; didsay=1;
							if (!has_item(co,IID_DWARFRECALL1)) {
								in=create_item("dwarf_recall90");
								if (in) give_char_item(co,in);
							}
                                                        break;
					case 3:		break; // waiting for player to save first miner
					
					case 4:		questlog_done(co,47);
                                                        ppd->dwarfchief_state++;
							// fall-through intended
					case 5:		if (questlog_isdone(co,48)) { ppd->dwarfchief_state=8; break; }
							quiet_say(cn,"Not too bad for a human, you people are sturdier than I thought... Don't cheer up though, the miner in the next section is surrounded by stronger golems. Don't let them hurt your precious nails!");
							questlog_open(co,48);
                                                        ppd->dwarfchief_state++; didsay=1;
                                                        if (!has_item(co,IID_DWARFRECALL2)) {
								in=create_item("dwarf_recall100");
								if (in) give_char_item(co,in);
							}
                                                        break;
					case 6:		break; // waiting for player to save second miner
					
					case 7:		questlog_done(co,48);
                                                        ppd->dwarfchief_state++;
							// fall-through intended
					case 8:		if (questlog_isdone(co,49)) { ppd->dwarfchief_state=11; break; }
							quiet_say(cn,"A job well done! It's that we have enough hands already, otherwise I'd ask you to go out there and mine for us. Anyway, back to business. Go and find the next miner, and you will be rewarded again.");
							questlog_open(co,49);
                                                        ppd->dwarfchief_state++; didsay=1;
                                                        if (!has_item(co,IID_DWARFRECALL2)) {
								in=create_item("dwarf_recall110");
								if (in) give_char_item(co,in);
							}
                                                        break;
					case 9:		break; // waiting for player to save third miner
					
					case 10:	questlog_done(co,49);
                                                        ppd->dwarfchief_state++;
							// fall-through intended
					case 11:	if (questlog_isdone(co,50)) { ppd->dwarfchief_state=14; break; }
							quiet_say(cn,"Just in time! If you had been any later, he wouldn't have had his dinner, and trust me, you don't want to see a dwarf hungry, it's not a pretty sight. The fourth miner should be ok, he always packs more than the others, but do hurry and find him.");
							questlog_open(co,50);
                                                        ppd->dwarfchief_state++; didsay=1;
                                                        if (!has_item(co,IID_DWARFRECALL2)) {
								in=create_item("dwarf_recall120");
								if (in) give_char_item(co,in);
							}
                                                        break;
					case 12:	break; // waiting for player to save fourth miner

					case 13:	questlog_done(co,50);
                                                        ppd->dwarfchief_state++;
							// fall-through intended
					case 14:	quiet_say(cn,"Thank you for saving the last one! You have been of great help to us. Now let's hope they can stay out of the hands of those golems once and for all. Those recall scrolls aren't cheap you know!");
                                                        ppd->dwarfchief_state++; didsay=1;
                                                        break;
					case 15:	break; // all done

				}
				if (didsay) {
					dat->last_talk=ticker;
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

                // talk back
		if (msg->type==NT_TEXT) {
			co=msg->dat3;

			if (ch[co].flags&CF_PLAYER) {
				ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));
                                switch((didsay=analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,co))) {
					case 2:         if (ppd && ppd->dwarfchief_state<=3) { dat->last_talk=0; ppd->dwarfchief_state=0; }
                                                        if (ppd && ppd->dwarfchief_state>=5 && ppd->dwarfchief_state<=6) { dat->last_talk=0; ppd->dwarfchief_state=5; }
							if (ppd && ppd->dwarfchief_state>=8 && ppd->dwarfchief_state<=9) { dat->last_talk=0; ppd->dwarfchief_state=8; }
							if (ppd && ppd->dwarfchief_state>=11 && ppd->dwarfchief_state<=12) { dat->last_talk=0; ppd->dwarfchief_state=11; }
							if (ppd && ppd->dwarfchief_state>=14 && ppd->dwarfchief_state<=15) { dat->last_talk=0; ppd->dwarfchief_state=14; }
                                                        break;
					case 3:		if (ch[co].flags&CF_GOD) { say(cn,"reset done"); ppd->dwarfchief_state=0; }
							break;
				}
                                if (didsay) {
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

		// got an item?
		if (msg->type==NT_GIVE) {
			co=msg->dat1;

                        if ((in=ch[cn].citem)) {	// we still have it
				quiet_say(cn,"Thou hast better use for this than I do. Well, if there is use for it at all.");
				if (!give_char_item(co,ch[cn].citem)) destroy_item(ch[cn].citem);
				ch[cn].citem=0;				
			}
		}

		remove_message(cn,msg);
	}

        // do something. whenever possible, call do_idle with as high a tick count
	// as reasonable when doing nothing.

	if (talkdir) turn(cn,talkdir);

	if (dat->last_talk+TICKS*30<ticker) {
		if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,ret,lastact)) return;
	}

        do_idle(cn,TICKS);
}
示例#28
0
void dwarfshaman_driver(int cn,int ret,int lastact)
{
	struct dwarfshaman_data *dat;
	struct staffer_ppd *ppd;
        int co,in,didsay=0,talkdir=0;
	struct msg *msg,*next;

        dat=set_data(cn,DRD_DWARFSHAMANDRIVER,sizeof(struct dwarfshaman_data));
	if (!dat) return;	// oops...

        // loop through our messages
	for (msg=ch[cn].msg; msg; msg=next) {
		next=msg->next;

                // did we see someone?
		if (msg->type==NT_CHAR) {
			
                        co=msg->dat1;

			// dont talk to other NPCs
			if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; }

			// dont talk to players without connection
			if (ch[co].driver==CDR_LOSTCON) { remove_message(cn,msg); continue; }
			
			// only talk every ten seconds
			if (ticker<dat->last_talk+TICKS*4) { remove_message(cn,msg); continue; }

			if (ticker<dat->last_talk+TICKS*10 && dat->current_victim!=co) { remove_message(cn,msg); continue; }

                        // dont talk to someone we cant see, and dont talk to ourself
			if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; }

			// dont talk to someone far away
			if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; }

                        // get current status with player
                        ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));

                        if (ppd) {
                                switch(ppd->dwarfshaman_state) {
					case 0:         quiet_say(cn,"Welcome to Grimroot stranger. To make it here you must have battled some strong foes, though they're nothing compared to what you're about to face, should you accept the quest I am about to give you.");
							questlog_open(co,51);
							ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 1:		quiet_say(cn,"But before I give you the quest, I want to see if you can fight the lizards you will be facing. Bring me back 9 lizard's teeth, and I will see that as proof of your strength.");
                                                        ppd->dwarfshaman_state++; didsay=1;
							break;
                                        case 2:         break;	// waiting for teeth
					
					case 3:		if (questlog_isdone(co,52)) { ppd->dwarfshaman_state=6; break; }
							quiet_say(cn,"Ah! I see you've come back with all your teeth, and those of the lizards. I guess you are strong enough after all to do the quest I am about to give you. You see, I've seen the lizards come out with brown berries out of the water.");
							questlog_open(co,52);
                                                        ppd->dwarfshaman_state++; didsay=1;
                                                        break;
                                        case 4:		quiet_say(cn,"Since I hate water, I need others like you to grab them for me. If you want to breath underwater, you will have to combine 3 flowers. I'll leave it up to you to figure out which ones. Now go get me 9 brown berries!");
                                                        ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 5:		break; // waiting for berries
					
					case 6:		if (questlog_isdone(co,53)) { ppd->dwarfshaman_state=10; break; }
							quiet_say(cn,"It's good that you can swim, you have no idea how much I hate water. Thanks for the berries. As I suspected, they seem to have magic properties, which I may be able to use.");
							questlog_open(co,53);
							ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 7:		quiet_say(cn,"Also, I managed to learn some of the lizard's tongue, and overheard them talking in fear of an 'elite lizard'... If you can find it and bring it's head to me, I can learn more about these lizards, and why they're so varied.");
                                                        ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 8:		break; // waiting for elite head
					
					case 9:		quiet_say(cn,"This is quite amazing! The reason these lizards are so varied is due to them being able to somehow absorb magical energy. To much of it seems to affect their mind however, as was the case with this elite lizard.");
							ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 10:	quiet_say(cn,"Thank you for helping out! I guess you are sturdier than you look, even though your kind looks skinnier than a dwarven skeleton!");
                                                        ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 11:	break; // all done

				}
				if (didsay) {
					dat->last_talk=ticker;
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

                // talk back
		if (msg->type==NT_TEXT) {
			co=msg->dat3;

			if (ch[co].flags&CF_PLAYER) {
				ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));
                                switch((didsay=analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,co))) {
					case 2:         if (ppd && ppd->dwarfshaman_state<=2) { dat->last_talk=0; ppd->dwarfshaman_state=0; }
                                                        if (ppd && ppd->dwarfshaman_state>=3 && ppd->dwarfshaman_state<=5) { dat->last_talk=0; ppd->dwarfshaman_state=3; }
							if (ppd && ppd->dwarfshaman_state>=6 && ppd->dwarfshaman_state<=8) { dat->last_talk=0; ppd->dwarfshaman_state=6; }
							if (ppd && ppd->dwarfshaman_state>=9 && ppd->dwarfshaman_state<=11) { dat->last_talk=0; ppd->dwarfshaman_state=9; }
                                                        break;
					case 3:		if (ch[co].flags&CF_GOD) { say(cn,"reset done"); ppd->dwarfshaman_state=0; ppd->dwarfshaman_count=0; }
							break;
				}
                                if (didsay) {
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

		// got an item?
		if (msg->type==NT_GIVE) {
			co=msg->dat1;
			
			ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));

                        if ((in=ch[cn].citem)) {	// we still have it
				if (it[in].ID==IID_LIZARDTOOTH && ppd && ppd->dwarfshaman_state<3) {
					ppd->dwarfshaman_count++;
					if (ppd->dwarfshaman_count>=9) {
						ppd->dwarfshaman_state=3;
						ppd->dwarfshaman_count=0;
						dat->last_talk=0;
						questlog_done(co,51);						
					} else {
						quiet_say(cn,"%d done, %d to go.",ppd->dwarfshaman_count,9-ppd->dwarfshaman_count);
					}
				} else if (it[in].ID==IID_BROWNBERRY && ppd && ppd->dwarfshaman_state>=3 && ppd->dwarfshaman_state<=5) {
					ppd->dwarfshaman_count++;
					if (ppd->dwarfshaman_count>=9) {
						ppd->dwarfshaman_state=6;
						ppd->dwarfshaman_count=0;
						dat->last_talk=0;
						questlog_done(co,52);
					} else {
						quiet_say(cn,"%d done, %d to go.",ppd->dwarfshaman_count,9-ppd->dwarfshaman_count);
					}
				} else if (it[in].ID==IID_LIZARDHEAD && ppd && ppd->dwarfshaman_state>=6 && ppd->dwarfshaman_state<=8) {
                                        ppd->dwarfshaman_state=9;
					dat->last_talk=0;
					questlog_done(co,53);
					destroy_item_byID(co,IID_LIZARDHEAD);
				} else if (give_char_item(co,in)) {
					quiet_say(cn,"Thou hast better use for this than I do. Well, if there is use for it at all.");
					ch[cn].citem=0;
				}
			
				// let it vanish, then
				if (ch[cn].citem) destroy_item(ch[cn].citem);
				ch[cn].citem=0;
			}
		}

		remove_message(cn,msg);
	}

        // do something. whenever possible, call do_idle with as high a tick count
	// as reasonable when doing nothing.

	if (talkdir) turn(cn,talkdir);

	if (dat->last_talk+TICKS*30<ticker) {
		if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,ret,lastact)) return;
	}

        do_idle(cn,TICKS);
}
示例#29
0
void dwarfsmith_driver(int cn,int ret,int lastact)
{
	struct dwarfsmith_data *dat;
	struct staffer_ppd *ppd;
        int co,in,didsay=0,talkdir=0,in2;
	struct msg *msg,*next;

        dat=set_data(cn,DRD_DWARFSMITHDRIVER,sizeof(struct dwarfsmith_data));
	if (!dat) return;	// oops...

        // loop through our messages
	for (msg=ch[cn].msg; msg; msg=next) {
		next=msg->next;

                // did we see someone?
		if (msg->type==NT_CHAR) {
			
                        co=msg->dat1;

			// dont talk to other NPCs
			if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; }

			// dont talk to players without connection
			if (ch[co].driver==CDR_LOSTCON) { remove_message(cn,msg); continue; }
			
			// only talk every ten seconds
			if (ticker<dat->last_talk+TICKS*4) { remove_message(cn,msg); continue; }

			if (ticker<dat->last_talk+TICKS*10 && dat->current_victim!=co) { remove_message(cn,msg); continue; }

                        // dont talk to someone we cant see, and dont talk to ourself
			if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; }

			// dont talk to someone far away
			if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; }

                        // get current status with player
                        ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));

                        if (ppd) {
                                switch(ppd->dwarfsmith_state) {
					case 0:         quiet_say(cn,"Welcome to my smithy! If you are in need of my services, come to me and I will see what I can do for you. For now though, I'm afraid I can't do a whole lot.");
							ppd->dwarfsmith_state++; didsay=1;
                                                        break;
					case 1:         break;	// waiting for mold
					case 2:		break;	// waiting for silver
				}
				if (didsay) {
					dat->last_talk=ticker;
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

                // talk back
		if (msg->type==NT_TEXT) {
			co=msg->dat3;

			if (ch[co].flags&CF_PLAYER) {
				ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));
                                switch((didsay=analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,co))) {
					//case 2:         if (ppd && ppd->dwarfsmith_state<=3) { dat->last_talk=0; ppd->dwarfsmith_state=0; }
                                                        //break;
					case 3:		if (ch[co].flags&CF_GOD) { say(cn,"reset done"); ppd->dwarfsmith_state=0; }
							break;
				}
                                if (didsay) {
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

		// got an item?
		if (msg->type==NT_GIVE) {
			co=msg->dat1;
			
			ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));

                        if ((in=ch[cn].citem)) {	// we still have it
				if (it[in].ID==IID_LIZARDMOLD && ppd && ppd->dwarfsmith_state<=1) {
					ppd->dwarfsmith_state=2;
					ppd->dwarfsmith_type=it[in].drdata[0];
					quiet_say(cn,"What's this? A mold from the lizards? I guess I can make a key out of this, but I will need 5,000 silver to make it. You can't expect me to sacrifice my own ore for your adventuring!");
				} else if (it[in].driver==IDR_ENHANCE && it[in].drdata[0]==1 && *(unsigned int*)(it[in].drdata+1)==5000 && ppd && ppd->dwarfsmith_state==2) {
                                        quiet_say(cn,"There you go, one key for the adventurer.");
					switch(ppd->dwarfsmith_type) {
						case 1:		in2=create_item("lizard_elite_key1"); break;
						case 2:		in2=create_item("lizard_elite_key2"); break;
						case 3:		in2=create_item("lizard_elite_key3"); break;
						default:	in2=0; quiet_say(cn,"oops. bug # 3266/%d",ppd->dwarfsmith_type); break;
					}
					if (in2) {
						if (!give_char_item(co,in2)) destroy_item(in2);						
                                        }
					ppd->dwarfsmith_state=1;
					ppd->dwarfsmith_type=0;
					
				} else if (give_char_item(co,in)) {
					if (it[in].driver==IDR_ENHANCE) {
						if (it[in].drdata[0]!=1) quiet_say(cn,"I'll need silver, not any other material.");
						else if (*(unsigned int*)(it[in].drdata+1)!=5000) quiet_say(cn,"I'll need exactly 5000 units of silver.");
						else quiet_say(cn,"I'll need a mold first.");
					} else quiet_say(cn,"Thou hast better use for this than I do. Well, if there is use for it at all.");
					ch[cn].citem=0;
				}
			
				// let it vanish, then
				if (ch[cn].citem) destroy_item(ch[cn].citem);
				ch[cn].citem=0;
			}
		}

		remove_message(cn,msg);
	}

        // do something. whenever possible, call do_idle with as high a tick count
	// as reasonable when doing nothing.

	if (talkdir) turn(cn,talkdir);

	if (dat->last_talk+TICKS*30<ticker) {
		if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,ret,lastact)) return;
	}

        do_idle(cn,TICKS);
}
示例#30
0
void lostdwarf_driver(int cn,int ret,int lastact)
{
	struct lostdwarf_data *dat;
	struct staffer_ppd *ppd;
        int co,in;
	struct msg *msg,*next;

        dat=set_data(cn,DRD_LOSTDWARFDRIVER,sizeof(struct lostdwarf_data));
	if (!dat) return;	// oops...

	if ((ch[cn].flags&CF_INVISIBLE) && dat->invis_tick<ticker) {
		ch[cn].flags&=~CF_INVISIBLE;
		set_sector(ch[cn].x,ch[cn].y);
	}

        // loop through our messages
	for (msg=ch[cn].msg; msg; msg=next) {
		next=msg->next;

                // did we see someone?
		if (msg->type==NT_CREATE) {
                        if (ch[cn].arg) {
				dat->nr=atoi(ch[cn].arg);
			}
		}

		// did we see someone?
		if (msg->type==NT_CHAR) {
			
                        co=msg->dat1;

			// dont talk to other NPCs
			if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; }

			// dont talk to players without connection
			if (ch[co].driver==CDR_LOSTCON) { remove_message(cn,msg); continue; }
			
			// only talk every ten seconds
			if (ticker<dat->last_talk+TICKS*60) { remove_message(cn,msg); continue; }

                        // dont talk to someone we cant see, and dont talk to ourself
			if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; }

			// dont talk to someone far away
			if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; }

			quiet_say(cn,"I hope you have a dwarven recall scroll for me! If not, be off with you!");
			dat->last_talk=ticker;

		}

                // got an item?
		if (msg->type==NT_GIVE) {
			co=msg->dat1;
                        if ((in=ch[cn].citem)) {	// we still have it
				ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));
				
				if (ppd && ppd->dwarfchief_state<=3 && dat->nr==1 && it[in].ID==IID_DWARFRECALL1) {
					ppd->dwarfchief_state=4;
					say(cn,"Thank you for saving me, %s. I got so hungry I almost ate my beard.",ch[co].name);
					log_area(ch[cn].x,ch[cn].y,LOG_INFO,cn,10,"%s uses a scroll of recall and vanishes.",ch[cn].name);
					ch[cn].flags|=CF_INVISIBLE;
					dat->invis_tick=ticker+TICKS*30;
					set_sector(ch[cn].x,ch[cn].y);
				}

				if (ppd && ppd->dwarfchief_state>=5 && ppd->dwarfchief_state<=6 && dat->nr==2 && it[in].ID==IID_DWARFRECALL2) {
					ppd->dwarfchief_state=7;
					say(cn,"Thank you for saving me, %s. I got so hungry I almost ate my boots.",ch[co].name);
					log_char(co,LOG_SYSTEM,0,"You notice that the dwarf's beard looks somewhat thin.");
					log_area(ch[cn].x,ch[cn].y,LOG_INFO,cn,10,"%s uses a scroll of recall and vanishes.",ch[cn].name);
					ch[cn].flags|=CF_INVISIBLE;
					dat->invis_tick=ticker+TICKS*30;
					set_sector(ch[cn].x,ch[cn].y);
				}

				if (ppd && ppd->dwarfchief_state>=8 && ppd->dwarfchief_state<=9 && dat->nr==3 && it[in].ID==IID_DWARFRECALL3) {
					ppd->dwarfchief_state=10;
					say(cn,"Thank you for saving me, %s. I got so hungry I almost ate my pick-axe.",ch[co].name);
					log_char(co,LOG_SYSTEM,0,"You notice that the dwarf is barefoot.");
					log_area(ch[cn].x,ch[cn].y,LOG_INFO,cn,10,"%s uses a scroll of recall and vanishes.",ch[cn].name);
					ch[cn].flags|=CF_INVISIBLE;
					dat->invis_tick=ticker+TICKS*30;
					set_sector(ch[cn].x,ch[cn].y);
				}

				if (ppd && ppd->dwarfchief_state>=11 && ppd->dwarfchief_state<=12 && dat->nr==4 && it[in].ID==IID_DWARFRECALL4) {
					ppd->dwarfchief_state=13;
					say(cn,"Thank you for saving me, %s. I got so hungry I did eat my pick-axe.",ch[co].name);
                                        log_area(ch[cn].x,ch[cn].y,LOG_INFO,cn,10,"%s uses a scroll of recall and vanishes.",ch[cn].name);
					ch[cn].flags|=CF_INVISIBLE;
					dat->invis_tick=ticker+TICKS*30;
					set_sector(ch[cn].x,ch[cn].y);
				}
			
				// let it vanish, then
				destroy_item(ch[cn].citem);
				ch[cn].citem=0;
			}
		}

		remove_message(cn,msg);
	}

        // do something. whenever possible, call do_idle with as high a tick count
	// as reasonable when doing nothing.

        if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,ret,lastact)) return;

        do_idle(cn,TICKS);

}