Thread: Light sources system

Results 1 to 10 of 10
  1. #1 Light sources system 
    Registered Member
    hacker's Avatar
    Join Date
    Jun 2013
    Posts
    1,409
    Thanks given
    576
    Thanks received
    580
    Rep Power
    5000
    Legendary contribution by hacker here

    Code:
    package com.notorious.world.content.obj;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import com.notorious.definition.ItemDefinition;
    import com.notorious.entity.item.Item;
    import com.notorious.entity.player.Player;
    
    /**
     * @author Raw Envy
     */
    
    public class LightSources
    {
    
    	public static final int TINDERBOX = 590;
    
    	/**
    	 * Enum used for storing the light sources data
    	 */
    
    	public enum LightSource
    	{
    		TORCH(1, 596, 594),
    		CANDLE(1, 36, 33),
    		BLACK_CANDLE(1, 38, 32),
    		CANDLE_LANTERN(4, 4529, 4531),
    		OIL_LAMP(12, 4522, 4524),
    		OIL_LANTERN(26, 4537, 4539),
    		BULLSEYE_LANTERN(49, 4548, 4550),
    		SAPPHIRE_LANTERN(49, 4701, 4702),
    		EMERALD_LANTERN(49, 9064, 9065),
    		MINING_HELMET(65, 5014, 5013);
    
    		private int levelReq;
    		private int unlitId;
    		private int litId;
    
    		private static Map<Integer, LightSource> sources = new HashMap<>();
    
    		static
    		{
    			for (LightSource s : values())
    			{
    				sources.put(s.unlitId, s);
    				sources.put(s.litId, s);
    			}
    		}
    
    		/**
    		 * Enum constructor
    		 * 
    		 * @Param levelRequirement
    		 * @Param unlitItemID
    		 * @Param litItemID
    		 */
    		private LightSource(final int levelRequirement, final int unlitItemId, final int litItemId) // Enum constructors always private
    		{
    			this.levelReq = levelRequirement;
    			this.unlitId = unlitItemId;
    			this.litId = litItemId;
    		}
    
    		public int getlevelReq()
    		{
    			return levelReq; // Checks the level requirement 
    		}
    
    		public int getUnlitId()
    		{
    			return unlitId; // Gets the unlit item Id
    		}
    
    		public int getLitId()
    		{
    			return litId; // Gets the lit item Id
    		}
    
    		public static LightSource getSource(int id)
    		{
    			return sources.get(id);
    		}
    
    	}
    
    	/**
    	 * Method used to light an unlit source. Checks the item used id and
    	 * lights if its unlit and if player has a tinderbox
    	 * 
    	 * @Param player
    	 * @Param itemUsed
    	 * @Param usedWith
    	 */
    	public static boolean lightSource(Player p, int itemUsed, int usedWith)
    	{
    		final int item = (itemUsed != TINDERBOX ? itemUsed : usedWith);
    
    		LightSource s = LightSource.getSource(item);
    
    		if (s == null)
    		{
    			return false;
    		}
    		
    		p.getFields().getInventory().remove(new Item(item));
    		p.getFields().getInventory().add(new Item(s.getLitId()));
    		p.sendMessage("You light the " + ItemDefinition.getName(item).toLowerCase() + ".");
    		return true;
    	}
    
    	public static boolean extinguish(Player p, int itemId)
    	{
    
    		LightSource s = LightSource.getSource(itemId);
    
    		if (s == null || !p.getFields().getInventory().contains(itemId))
    		{
    			return false;
    		}
    
    		p.getFields().getInventory().remove(itemId, 1);
    		p.getFields().getInventory().add(new Item(s.getUnlitId(), 1));
    		p.sendMessage("You extinguish the " + ItemDefinition.getName(itemId).toLowerCase() + ".");
    		return true;
    	}
    
    }
    Attached image
    Reply With Quote  
     

  2. #2  
    nice


    Join Date
    Jul 2014
    Posts
    740
    Thanks given
    382
    Thanks received
    562
    Rep Power
    4239
    this is an amazing contribution, gonna nominate u for contributor asap
    Attached image
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    hacker's Avatar
    Join Date
    Jun 2013
    Posts
    1,409
    Thanks given
    576
    Thanks received
    580
    Rep Power
    5000
    Quote Originally Posted by Suic View Post
    this is an amazing contribution, gonna nominate u for contributor asap
    thank you friend, ill buy u some subway one day
    Attached image
    Reply With Quote  
     

  5. #4  
    Donator

    .css's Avatar
    Join Date
    Dec 2018
    Age
    29
    Posts
    579
    Thanks given
    89
    Thanks received
    270
    Rep Power
    351
    Wow ty remember to import doors.cfg tho
    Reply With Quote  
     

  6. #5  
    Chemist

    Advocatus's Avatar
    Join Date
    Dec 2009
    Posts
    2,622
    Thanks given
    201
    Thanks received
    813
    Rep Power
    1462
    Light Sources require different FM levels to be lit. There is also the periodic damage and also the chance of explosion for non covered sources in the Lumbridge swamp.
    Quote Originally Posted by blakeman8192 View Post
    Quitting is the only true failure.
    Reply With Quote  
     

  7. #6  
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    wow never thought it was doable thanks
    Reply With Quote  
     

  8. #7  
    Vitality

    Raw Envy's Avatar
    Join Date
    Dec 2010
    Posts
    3,034
    Thanks given
    869
    Thanks received
    1,186
    Rep Power
    3054
    10/10 release, this wasn't even my code btw from 7 years ago I just authored it
    Reply With Quote  
     

  9. Thankful user:


  10. #8  
    Registered Member

    Join Date
    Sep 2009
    Posts
    1,919
    Thanks given
    479
    Thanks received
    1,687
    Rep Power
    1262
    Quote Originally Posted by Raw Envy View Post
    10/10 release, this wasn't even my code btw from 7 years ago I just authored it
    It's almost entirely ripped from Arios.
    Attached image
    Reply With Quote  
     

  11. #9  
    Vitality

    Raw Envy's Avatar
    Join Date
    Dec 2010
    Posts
    3,034
    Thanks given
    869
    Thanks received
    1,186
    Rep Power
    3054
    Quote Originally Posted by Cjay0091 View Post
    It's almost entirely ripped from Arios.
    Potentially, I was doing it on Teamviewer with someone else who was helping me with it but maybe he was ripping it lol. Either way its from like 2015 or before.
    Reply With Quote  
     

  12. #10  
    Community Veteran

    Dexter Morgan's Avatar
    Join Date
    Nov 2008
    Age
    28
    Posts
    4,419
    Thanks given
    1,184
    Thanks received
    757
    Rep Power
    3098
    Quote Originally Posted by Raw Envy View Post
    Potentially, I was doing it on Teamviewer with someone else who was helping me with it but maybe he was ripping it lol. Either way its from like 2015 or before.
    This is what I wrote for you back in those days. I don't know about that documentation though lol
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Light sources system
    By Raw Envy in forum Snippets
    Replies: 33
    Last Post: 09-15-2015, 04:33 PM
  2. Light Sources
    By Red Bull in forum Snippets
    Replies: 4
    Last Post: 12-23-2012, 01:53 PM
  3. Replies: 25
    Last Post: 11-09-2012, 09:36 PM
  4. Light Sourcing
    By Death Grips in forum Showcase
    Replies: 10
    Last Post: 08-26-2011, 10:25 PM
  5. Light Sourcing.PSD
    By Death Grips in forum Resources
    Replies: 0
    Last Post: 08-26-2011, 11:45 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •