Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
L2j Server Datapack
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
L2j
L2j Server Datapack
Commits
3d4b1629
Commit
3d4b1629
authored
9 years ago
by
Zoey76
Browse files
Options
Downloads
Patches
Plain Diff
Porta should keep aggro after teleporting the player, fixes #270
parent
3037ecfa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dist/game/data/scripts/ai/group_template/SummonPc.java
+29
-23
29 additions, 23 deletions
dist/game/data/scripts/ai/group_template/SummonPc.java
with
29 additions
and
23 deletions
dist/game/data/scripts/ai/group_template/SummonPc.java
+
29
−
23
View file @
3d4b1629
...
...
@@ -18,14 +18,14 @@
*/
package
ai.group_template
;
import
ai.npc.AbstractNpcAI
;
import
com.l2jserver.gameserver.model.actor.L2Attackable
;
import
com.l2jserver.gameserver.model.actor.L2Npc
;
import
com.l2jserver.gameserver.model.actor.instance.L2PcInstance
;
import
com.l2jserver.gameserver.model.holders.SkillHolder
;
import
com.l2jserver.gameserver.model.skills.Skill
;
import
ai.npc.AbstractNpcAI
;
/**
* Summon Pc AI.<br>
* Summon the player to the NPC on attack.
...
...
@@ -38,6 +38,9 @@ public final class SummonPc extends AbstractNpcAI
private
static
final
int
PERUM
=
20221
;
// Skill
private
static
final
SkillHolder
SUMMON_PC
=
new
SkillHolder
(
4161
,
1
);
// Misc
private
static
final
int
MIN_DISTANCE
=
300
;
private
static
final
int
MIN_DISTANCE_MOST_HATED
=
100
;
private
SummonPc
()
{
...
...
@@ -49,39 +52,29 @@ public final class SummonPc extends AbstractNpcAI
@Override
public
String
onAttack
(
L2Npc
npc
,
L2PcInstance
attacker
,
int
damage
,
boolean
isSummon
)
{
final
int
chance
=
getRandom
(
100
);
final
boolean
attacked
=
npc
.
getVariables
().
getBoolean
(
"attacked"
,
false
);
if
((
npc
.
calculateDistance
(
attacker
,
true
,
false
)
>
300
)
&&
!
attacked
)
if
(
attacked
)
{
return
super
.
onAttack
(
npc
,
attacker
,
damage
,
isSummon
);
}
final
int
chance
=
getRandom
(
100
);
final
double
distance
=
npc
.
calculateDistance
(
attacker
,
true
,
false
);
if
(
distance
>
MIN_DISTANCE
)
{
if
(
chance
<
50
)
{
if
((
SUMMON_PC
.
getSkill
().
getMpConsume
()
<
npc
.
getCurrentMp
())
&&
(
SUMMON_PC
.
getSkill
().
getHpConsume
()
<
npc
.
getCurrentHp
())
&&
!
npc
.
isSkillDisabled
(
SUMMON_PC
.
getSkill
()))
{
npc
.
setTarget
(
attacker
);
npc
.
doCast
(
SUMMON_PC
.
getSkill
());
}
if
((
SUMMON_PC
.
getSkill
().
getMpConsume
()
<
npc
.
getCurrentMp
())
&&
(
SUMMON_PC
.
getSkill
().
getHpConsume
()
<
npc
.
getCurrentHp
())
&&
!
npc
.
isSkillDisabled
(
SUMMON_PC
.
getSkill
()))
{
npc
.
setTarget
(
attacker
);
npc
.
doCast
(
SUMMON_PC
.
getSkill
());
npc
.
getVariables
().
set
(
"attacked"
,
true
);
}
doSummonPc
(
npc
,
attacker
);
}
}
else
if
(
(
npc
.
calculateDistance
(
attacker
,
true
,
false
)
>
100
)
&&
!
attacked
)
else
if
(
distance
>
MIN_DISTANCE_MOST_HATED
)
{
final
L2Attackable
monster
=
(
L2Attackable
)
npc
;
if
(
monster
.
getMostHated
()
!=
null
)
{
if
(((
monster
.
getMostHated
()
==
attacker
)
&&
(
chance
<
50
))
||
(
chance
<
10
))
{
if
((
SUMMON_PC
.
getSkill
().
getMpConsume
()
<
npc
.
getCurrentMp
())
&&
(
SUMMON_PC
.
getSkill
().
getHpConsume
()
<
npc
.
getCurrentHp
())
&&
!
npc
.
isSkillDisabled
(
SUMMON_PC
.
getSkill
()))
{
npc
.
setTarget
(
attacker
);
npc
.
doCast
(
SUMMON_PC
.
getSkill
());
npc
.
getVariables
().
set
(
"attacked"
,
true
);
}
doSummonPc
(
npc
,
attacker
);
}
}
}
...
...
@@ -95,10 +88,23 @@ public final class SummonPc extends AbstractNpcAI
{
player
.
teleToLocation
(
npc
);
npc
.
getVariables
().
set
(
"attacked"
,
false
);
// TODO(Zoey76): Teleport removes the player from all known lists, affecting aggro lists.
addAttackPlayerDesire
(
npc
,
player
);
}
return
super
.
onSpellFinished
(
npc
,
player
,
skill
);
}
private
static
void
doSummonPc
(
L2Npc
npc
,
L2PcInstance
attacker
)
{
if
((
SUMMON_PC
.
getSkill
().
getMpConsume
()
<
npc
.
getCurrentMp
())
&&
(
SUMMON_PC
.
getSkill
().
getHpConsume
()
<
npc
.
getCurrentHp
())
&&
!
npc
.
isSkillDisabled
(
SUMMON_PC
.
getSkill
()))
{
npc
.
setTarget
(
attacker
);
npc
.
doCast
(
SUMMON_PC
.
getSkill
());
npc
.
getVariables
().
set
(
"attacked"
,
true
);
}
}
public
static
void
main
(
String
[]
args
)
{
new
SummonPc
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment