Post by hello on Feb 1, 2019 20:18:47 GMT
Here is the lab5 (Ishtar originally called it lab2) water function in which I added several improvements, including being able to receive water bowls with an item in your hand, taking a different # based off which side of the pool you grab water on, and being able to bless all bowls in the inventory at once.
Additional stuff for the pools:
void lab2_water(int in, int cn)
{
int n, nr, inv, in2, in3, cnt, sprite;
if (cn) {
if (it[in].drdata[0]==1) {
sprite = it[in].sprite;
switch (it[in].sprite) {
case 20793: nr=1; break;
case 20794: nr=2; break;
case 20795: nr=3; break;
case 20796:
default: nr=4;
}
for(n=0; n<nr; n++) {
in2=create_item("lab2_waterbowl");
if (!give_char_item(cn,in2)){
destroy_item(in2);
break;
}
}
if (n==0)
log_char(cn,LOG_SYSTEM,0,"You can't carry any more water.");
else
{
log_char(cn,LOG_SYSTEM,0,"You received %d %s%s.",n,it[in2].name,(n==1? "": "s"));
if (ch[cn].flags&CF_PLAYER) dlog(cn,in2,"took from lab2_water");
ch[cn].flags|=CF_ITEMS;
}
/*
if (ch[cn].citem) { log_char(cn,LOG_SYSTEM,0,"You won't throw this into the water, will you?"); return; }
in2=create_item("lab2_waterbowl");
log_char(cn,LOG_SYSTEM,0,"You received a %s.",it[in2].name);
if (ch[cn].flags&CF_PLAYER) dlog(cn,in2,"took from lab2_water");
ch[cn].citem=in2;
ch[cn].flags|=CF_ITEMS;
it[in2].carried=cn;
*/
}
else if (it[in].drdata[0]==2) {
cnt=0;
if (ch[cn].citem && it[ch[cn].citem].drdata[0]==4) { // water in hand
in2=ch[cn].citem;
in3=create_item("lab2_holywaterbowl");
if (in3) {
replace_item_char(in2,in3);
free_item(in2);
}
cnt++;
}
for (n=30; n<INVENTORYSIZE; n++) {
if (ch[cn].item[n] && it[ch[cn].item[n]].drdata[0]==4) { // water in inventory
inv=ch[cn].item[n];
ch[cn].item[n]=0; //remove item
in2=create_item("lab2_holywaterbowl");
if (in2) {
if (!give_char_item(cn,in2)) {
destroy_item(in2);
}
}
cnt++;
}
}
if (cnt>0) {
ch[cn].flags|=CF_ITEMS;
log_char(cn,LOG_SYSTEM,0,"The holiness of the Altar blesses all the water in your inventory."); return;
}
else {
log_char(cn,LOG_SYSTEM,0,"You feel the holiness of the Altar. Water would be holy now, if you had some."); return; }
}
else if (it[in].drdata[0]==4 || it[in].drdata[0]==5) { // can't happen, item has no IF_USE flag ;-)
log_char(cn,LOG_SYSTEM,0,"Skoll!");
}
}
else {
if (it[in].drdata[0]==0) {
// init
switch(it[in].sprite) {
case 11008:
case 11009:
case 11010: it[in].drdata[0]=2; break;
case 20793:
case 20794:
case 20795:
case 20796: it[in].drdata[0]=1; break;
case 11011: it[in].drdata[0]=3; break;
case 11012: it[in].drdata[0]=4; break;
case 11013: it[in].drdata[0]=5; break;
default: xlog("unknown sprite %d/%s in %s %d",it[in].sprite,it[in].name,__FILE__,__LINE__); break;
}
}
}
}
Additional stuff for the pools:
lab2_well1:
name="Well"
description="A well filled with water. There is one bowl on its ground."
sprite=20793
flag=IF_USE
flag=IF_MOVEBLOCK
driver=196
;
lab2_well2:
name="Well"
description="A well filled with water. There are two bowls on its ground."
sprite=20794
flag=IF_USE
flag=IF_MOVEBLOCK
driver=196
;
lab2_well3:
name="Well"
description="A well filled with water. There are three bowls on its ground."
sprite=20795
flag=IF_USE
flag=IF_MOVEBLOCK
driver=196
;
lab2_well4:
name="Well"
description="A well filled with water. There are four bowls on its ground."
sprite=20796
flag=IF_USE
flag=IF_MOVEBLOCK
driver=196
;