Thread: Bottle Help
View Single Post
  #8  
Old 06-22-2012, 06:46 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
PHP Code:
// NPC made by E-Man 
if (playerenters) { 
  
show
  
setimg eman_red_potion.png
  
x=24
  
y=29.9
  
timeout 0.05
  
this.redpotion 1

if (!
hasweapon(Empty Bottle) && playertouchsme) { 
  
say2 
  You 
require an Empty Bottle

if (
hasweapon(Empty Bottle) && playertouchsme) { 
  
toweapons Red Potion
  
this.redpotion 1
  
hide

if (
weaponfired && this.redpotion 1) { 
  
playerhearts=100
  
setplayerprop #c, *gulp*; 
  
this.redpotion 0

if (
this.redpotion && timeout) { 
  
setimg eman_water_potion.png
  
toweapons Empty Bottle

if (
timeout) { 
  
timeout 0.05

The problem is with your replacement of the weapon after using it. The only upperhand you have is you can use setimg and stuff to manipulate the image of the weapon whilst it's in your inventory.

I made a bottle weapon which was used to obtain water, but instead of replacing the weapon I instead manipulated a client stored variable.

PHP Code:
// NPC made by tricxta
if (playerenters){
  if (!
isweapon)toweapons bottle;
  
this.watertiles={0x142};
}

if (
weaponfired){
  if (
strtofloat(#s(client.bottle))==0){//the bottle is empty!
    
if (tiles[playerx+1.5+vecx(playerdir),playery+2+vecy(playerdir)] in this.watertiles){
      
freezeplayer 2;
      
setani watercanfill,;
      
//change the state of the string and weapon image
      
setimg nmbottlewicon.png;
      
setstring client.bottle,1;
      
sleep 2;
      
setani idle,;
    }
  }
  else {
//Hey! there's water in that bottle
    
setstring client.bottle,0;
    
playerhearts+=2;
    
setimg nmbottleicon.png;
  }

Reply With Quote