Jump to content
  • 0

Item on inventory which can change time of buffs !


0flee

Question

Ello folks, i want to ask if this method added on Skill.java do what i want. What i want? A item keeped on inventory by player and for change bufftime to 2 hours in this case. If SkillDurationList it;s 1 hour, with this Item ( 2 hours ) Total i want to be 3 hours.
Here it is method. ( I don't know if it's good as method )

P.S.- if player doesn;t have this item, he can get time of buffs from SkillDurationList.
Project L2j-Mobius !
Greetings !

if (player.getInventory().getItemByItemId(17423) != null)
		{
			if (player.getInventory().getInventoryItemCount(17423, -1, false) < 1)
			{
				player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
				return;
			}
			
			int duration = 7200;
			
			abnormalTime = abnormalTime + duration;
		}

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I'm not into hi5 but, i guess your coded can be written like this:

 

if (player.getInventory().getInventoryItemCount(17423, -1, false) > 0 )
	abnormalTime += TimeUnit.HOURS.toMillis(2);

 

  • No null check
  • No return (its probably the issue you faced if the code stopped)

 

Also, i'm not sure where you coded that. But. I didn't get the message part. If a player request a full buff, it will send (buffs count) messages if the item is not in player's inventory?

Link to comment
Share on other sites

  • 0

It is simple think. If player no have this item on inventory and he get buffs, he get buff time specified on SkillDurationList. If player have this item on inventory and he rebuff or relog, he get time of buffs +2 hours in this case.

https://i.imgur.com/szC64yX.jpg
Why i get this?

I've tryed like this..
 

final PlayerInstance player = Skill.getActingPlayer();
        if (player.getInventory().getInventoryItemCount(17423, -1, false) > 0)
        {
            abnormalTime += TimeUnit.HOURS.toMillis(2);
        }
    }

But i get error on getActingPlayer() ..... This method should be created

 

Edited by 0flee
Link to comment
Share on other sites

  • 0

Because you don't need to be a developer to realize that "the variable can be only null at this time", means that the variable on top of that warning is assigned null and haven't change.

 

In addition both of you are wrong. Changing the abnormal duration won't affect the buff time individually. What you want to dig in is the following method: 

 

public void applyEffects(final L2Character effector, final L2Character effected, final boolean instant, final int abnormalTime)

 

Inside that method you will find the code that assign the buff a duration

 

final BuffInfo info = new BuffInfo(effector, effected, this);

if (addContinuousEffects && abnormalTime > 0)
{
	info.setAbnormalTime(abnormalTime);
}

 

There you can do your check and affect the abnormal time individually. 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...