function use_102 (id,tgt_id,alt,itm,bcode,x,y,z) use_pill(1, id,tgt_id,alt,itm,bcode,x,y,z) end function use_104 (id,tgt_id,alt,itm,bcode,x,y,z) use_pill(2, id,tgt_id,alt,itm,bcode,x,y,z) end function use_105 (id,tgt_id,alt,itm,bcode,x,y,z) use_pill(3, id,tgt_id,alt,itm,bcode,x,y,z) end function use_106 (id,tgt_id,alt,itm,bcode,x,y,z) use_pill(4, id,tgt_id,alt,itm,bcode,x,y,z) end function use_107 (id,tgt_id,alt,itm,bcode,x,y,z) use_pill(5, id,tgt_id,alt,itm,bcode,x,y,z) end function use_112 (id,tgt_id,alt,itm,bcode,x,y,z) use_pill(6, id,tgt_id,alt,itm,bcode,x,y,z) end function use_114 (id,tgt_id,alt,itm,bcode,x,y,z) use_pill(7, id,tgt_id,alt,itm,bcode,x,y,z) end function use_pill(n,id,tgt_id,alt,itm,bcode,x,y,z) e=vars:get_int("pill"..n) if e==1 then effect_heal (id,tgt_id,alt,itm,bcode,x,y,z) elseif e==2 then effect_mana (id,tgt_id,alt,itm,bcode,x,y,z) elseif e==3 then effect_cure (id,tgt_id,alt,itm,bcode,x,y,z) elseif e==4 then effect_invis (id,tgt_id,alt,itm,bcode,x,y,z) elseif e==5 then effect_combat (id,tgt_id,alt,itm,bcode,x,y,z) elseif e==6 then effect_nothing (id,tgt_id,alt,itm,bcode,x,y,z) elseif e==0 then effect_rage (id,tgt_id,alt,itm,bcode,x,y,z) end end -- helper func for pill use -- not actually called by euo function use_pill_helper(id, tgt_id, itm) -- common checks for pills -- eg cursed->halluc, or can't drink when choking -- gives empty flask -- returns 1 if something went wrong rc=0 p=get_player_ptr(id) bc=get_base_code(itm) if tgt_id<0 and bc~=0x164 then -- cyan doesnt need target tho it's directional send_message(id,"Use pill on what?") return 1; end -- choking check only for self drink if tgt_id>=0 and id==tgt_id and get_health(tgt_id, HN_CHOKING)~=0 then send_message(id, "You can't eat that - you are choking!") return 1; end if is_cursed(itm) then make_hallucinated(id,50) -- hallucinate the user, regardless of the target rc=1 end if(not p:is_dm()) then remove_item(id, itm) end return rc end -- helper func function healer_helper(id, pot) tgt=get_sent_ptr(id) if(tgt==nil) then return 0; end if(tgt.hp<1) then return 0; end mod=get_modifier(pot) healed=0 if(mod==1) then healed=50+int_rand(21) if(healed<2*tgt:get_hp_max()/5) then healed=2*tgt:get_hp_max()/5; end --40% elseif(mod==2) then healed=70+int_rand(31); if(healed<3*tgt:get_hp_max()/5) then healed=3*tgt:get_hp_max()/5; end -- 60% elseif(mod==3) then healed=100+int_rand(51); if(healed<4*tgt:get_hp_max()/5) then healed=4*tgt:get_hp_max()/5; end -- 80% else healed=30+int_rand(21); if(healed(tgt:get_hp_max()-tgt.hp)) then healed=tgt:get_hp_max()-tgt.hp; end if(tgt:get_health(HN_WOUNDED)~=0) then healed=0; end return healed end function effect_heal (id,tgt_id,alt,itm,bcode,x,y,z) p=get_player_ptr(id) if use_pill_helper(id, tgt_id, itm)~=0 then return ; end hp,hpmax,mana,manamax = get_hp_and_mana(tgt_id) healed=healer_helper(tgt_id,itm) if get_health(tgt_id,HN_WOUNDED)~=0 then healed=0 end if healed>0 then heal(tgt_id, healed) if(is_player(tgt_id)) then send_party_info(tgt_id) sync_stats(tgt_id) if tgt_id~=id then send_message(tgt_id, "Healed "..healed.." HP!") end end update_fov(tgt_id) -- so bars are updated send_message(id, "Healed "..healed.." HP!") else send_message(id, "No effect!") end end function effect_mana (id,tgt_id,alt,itm,bcode,x,y,z) p=get_player_ptr(id) if use_pill_helper(id, tgt_id, itm)~=0 then return ; end sync_health(id) hp,hpmax,mana,manamax = get_hp_and_mana(tgt_id) -- heal to mana healed=manamax-mana; healed=math.floor(healed/3+int_rand(healed*2/3)) if(healed<1) then healed=1 end if(healed>(manamax-mana)) then healed=manamax-mana end if healed>0 then restore_mana(tgt_id, healed) if(is_player(tgt_id)) then send_party_info(tgt_id) sync_stats(tgt_id) if tgt_id~=id then send_message(tgt_id, "Restored "..healed.." mana!") end end send_message(id, "Restored "..healed.." mana!") else send_message(id, "No effect!") end end function effect_cure (id,tgt_id,alt,itm,bcode,x,y,z) -- red pot if use_pill_helper(id, tgt_id, itm)~=0 then return ; end if get_health(tgt_id,HN_POISONED)==0 then send_message(id, "No effect!") else set_health(tgt_id,HN_POISONED,0) send_message(id,"Cured!"); if(id~=tgt_id) then send_message(tgt_id,"Cured!"); end end end function effect_invis (id,tgt_id,alt,itm,bcode,x,y,z) if(id~=tgt_id) then send_message(id,"Use on self only!"); return; end if use_pill_helper(id, tgt_id, itm)~=0 then return; end plyr=get_player_ptr(id) plyr:extinguish_torch() set_health(tgt_id,HN_INVISIBLE,30) send_message(id,"You disappear from view!"); update_everyones_fov(plyr) end function effect_combat (id,tgt_id,alt,itm,bcode,x,y,z) if(id~=tgt_id) then send_message(id,"Use on self only!"); return; end if use_pill_helper(id, tgt_id, itm)~=0 then return; end plyr=get_player_ptr(id) str="rather" if(plyr.thaco_bonus<15 and plyr.dmg_bonus<9) then plyr.thaco_bonus=plyr.thaco_bonus+5; plyr.dmg_bonus=plyr.dmg_bonus+3; if plyr.thaco_bonus>15 then plyr.thaco_bonus=15 ; str="only slightly"; end if plyr.dmg_bonus>9 then plyr.dmg_bonus=9; str="only slightly"; end send_message(id,"Your combat skills feel "..str.." enhanced."); sync_stats(id); else send_message(id,"No effect!"); end end function effect_nothing (id,tgt_id,alt,itm,bcode,x,y,z) if use_pill_helper(id, tgt_id, itm)~=0 then return; end send_message(id,"No effect!"); return end function effect_rage (id,tgt_id,alt,itm,bcode,x,y,z) if(id~=tgt_id) then send_message(id,"Use on self only!"); return; end if use_pill_helper(id, tgt_id, itm)~=0 then return; end if get_health(tgt_id,HN_ENRAGED)~=0 then send_message(id, "No effect!") else set_health(tgt_id,HN_ENRAGED,60) send_message(tgt_id,"You feel enraged!"); plyr=get_player_ptr(id) plyr.rage=100; sync_all(tgt_id) end end