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
    575
    Thanks received
    567
    Discord
    View profile
    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;
    	}
    
    }
    Reply With Quote  
     

  2. #2  
    nice


    Join Date
    Jul 2014
    Posts
    732
    Thanks given
    363
    Thanks received
    517
    Discord
    View profile
    Rep Power
    4086
    this is an amazing contribution, gonna nominate u for contributor asap
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    hacker's Avatar
    Join Date
    Jun 2013
    Posts
    1,409
    Thanks given
    575
    Thanks received
    567
    Discord
    View profile
    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
    Reply With Quote  
     

  5. #4  
    Donator

    .css's Avatar
    Join Date
    Dec 2018
    Age
    27
    Posts
    455
    Thanks given
    69
    Thanks received
    161
    Discord
    View profile
    Rep Power
    206
    Wow ty remember to import doors.cfg tho


    New #727 open source - click below


    Zed#3343
    Reply With Quote  
     

  6. #5  
    Chemist

    Advocatus's Avatar
    Join Date
    Dec 2009
    Age
    29
    Posts
    2,580
    Thanks given
    193
    Thanks received
    779
    Discord
    View profile
    Rep Power
    1383
    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  
    Wut can u say when theres nothin to tell

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    22
    Posts
    1,565
    Thanks given
    679
    Thanks received
    418
    Discord
    View profile
    Rep Power
    1029
    wow never thought it was doable thanks
    Reply With Quote  
     

  8. #7  
    Retired

    Raw Envy's Avatar
    Join Date
    Dec 2010
    Posts
    3,034
    Thanks given
    863
    Thanks received
    1,184
    Rep Power
    3046
    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  
    Member Market Banned Market Banned


    Join Date
    Sep 2009
    Posts
    1,889
    Thanks given
    436
    Thanks received
    1,655
    Discord
    View profile
    Rep Power
    1107
    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.
    Reply With Quote  
     

  11. #9  
    Retired

    Raw Envy's Avatar
    Join Date
    Dec 2010
    Posts
    3,034
    Thanks given
    863
    Thanks received
    1,184
    Rep Power
    3046
    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
    17
    Posts
    4,365
    Thanks given
    1,028
    Thanks received
    703
    Discord
    View profile
    Rep Power
    2991
    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
    Quote Originally Posted by UberNation View Post
    Did you update the quantum network sockets to match the polarity of the wilderness counter levels in the Boolean that divides the wilderness level by zero?
    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
  •