L2JMobius

High Five Steps to add buff by a command

vert · 10 · 9267

Offline vert

  • Knight
  • ***
    • Posts: 70
Hi guys,

I'm studying Java and working on a fake players engine for the highfive version, I'll share when I done the basic, but I'm with a little difficult to add effects (buffs) to fake player instances...

[OK] Fake players hunt mobs
[OK] Fake player use skills
[OK] Fake player receive default buffs when spawned
[OK] Teleport to village when fake player die

I'm working only with a single class (saggitarius) to be more easy to debug;

Someone can help me with the step to start a new instance of a buff effect and add him to any L2PcInstance ?

Until now, I've done this:

Code: [Select]
                Skill skill = SkillData.getInstance().getSkill(buff[0], buff[1]);
                skill.applyEffects(_fakePlayer, _fakePlayer);

                BuffInfo newBuff = new BuffInfo(_fakePlayer, _fakePlayer, skill);
//                newBuff.addEffect(AbstractEffect.createEffect(null, null, ));

                newBuff.setInUse(true);

                _fakePlayer.getEffectList().add(newBuff);


But when I add a new buff in player effectList, this is the result:

https://i.imgur.com/qKPEpHT.png

But I want this:

https://i.imgur.com/q0prdhl.png

I'm working on this engine by elfocrash (https://github.com/Elfocrash/L2jRoboto/) for aCis;

I'm not overwrinting the mobius fake players, this engine can co-exist with the mobius fakes...


Online Mobius

  • Distinguished King
  • *****
    • Posts: 19656
With my fake players you can just make a script that buffs them when they are spawned. As any other NPC.
Or check data/scripts/custom/FakePlayers/RecieveAdventurerBuffs.java on how to get buffs from adventurer NPC.


Offline vert

  • Knight
  • ***
    • Posts: 70
Thank you Mobius, I'll take a look as soon as possible;

Yeah, Liamxroy said to me: "I have fake players configured and they work so nice in my live server";

I'm just improving my skills...

Thank you for the path of a example code;


Offline vert

  • Knight
  • ***
    • Posts: 70
Feedback:

No success... I don't want the character cast the buff like the file you said Mobius (I'm using highfive but I found the file in GC repository);

I want just add the instance of buff into character effects, but I can't create a "AbstractEffect" :S

Someone can help me, please ? Mobius ?


Online Mobius

  • Distinguished King
  • *****
    • Posts: 19656
As you go on you will find more and more things that cannot be done,
because of the flaud logic of using true player instances and how AI and scripting works on any l2j.

I do not want to be harsh, but there is no point working on something that already works fine for my fake players with zero effort.
My fake players can be scripted as any NPC, for yours, since they are players, you have to make that scripting support from zero.
As said before, not interested.

The only thing that can come from my mind is check how NPC buffers buff players.


Offline vert

  • Knight
  • ***
    • Posts: 70
Yeah, you're right! I really agree;

But I need something to incentive me and the idea of "code a fake players engine" sounds good;

Hum... understand, thank you!


Offline vert

  • Knight
  • ***
    • Posts: 70
Solved;

Thanks Mobius, I followed the character cast skill (buff -> bless the body) methods and solved the steps;


If someone want to do something like this, here is the final code as example:

Code: [Select]
Skill skill = SkillData.getInstance().getSkill(buff[0], buff[1]);

final BuffInfo info = new BuffInfo(_fakePlayer, _fakePlayer, skill);

skill.applyEffectScope(EffectScope.SELF, info, false, true);
 _fakePlayer.getEffectList().add(info);

skill.applyEffects(_fakePlayer, _fakePlayer);

OBS:
Code: [Select]
buff[0] = id of buff (skill id);
buff[1] = level of buff (skill level);

_fakeplayer = my class who extends from L2PcInstance;



Offline Liamxroy

  • Distinguished King
  • *****
    • Posts: 885
    • Adenaplease!
I am very interested in the topic, for auto buff of fake players

Just add the buffs as skills on them lol


Offline javierdc

  • Heir
  • **
    • Posts: 10
    • JDC Tecnologia
I have added the benefits as a skill, but not auto buff.

Code: [Select]
<npc id="80106" level="76" type="Monster" name="Himan">
<race>HUMAN</race>
<sex>FEMALE</sex>
<stats str="23" int="46" dex="21" wit="45" con="27" men="39">
<vitals hp="6500" hpRegen="150" mp="6500" mpRegen="150" />
<attack physical="1494" magical="1900" random="30" critical="100" accuracy="250"
attackSpeed="400" type="SWORD" range="40" distance="26" width="120" />
<defence physical="2722" magical="2700" />
<speed>
<walk ground="80" />
<run ground="132" />
</speed>
</stats>
<status fakePlayer="true" talkable="false" attackable="true" />
<ai type="MAGE" clanHelpRange="9000" aggroRange="9000" isAggressive="true"> <!--
FIGHTER,ARCHER, BALANCED, MAGE, HEALER -->
<clanList>
<clan>003</clan>
</clanList>
</ai>
<collision>
<radius normal="7.5" />
<height normal="22.8" />
</collision>
<parameters>
<skill name="Skill01_ID" id="1031" level="10" />
<skill name="Skill02_ID" id="1028" level="22" />
<skill name="Skill03_ID" id="47267" level="15" />
<skill name="Skill04_ID" id="4099" level="2" /> <!-- Berserker Spirit -->
</parameters>
<skillList>
<skill id="1031" level="10" />
<skill id="1028" level="22" />
<skill id="47267" level="15" />
<skill id="4099" level="2" /> <!-- Berserker Spirit -->
</skillList>
</npc>