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
3bf03505
Commit
3bf03505
authored
11 years ago
by
St3eT
Browse files
Options
Downloads
Patches
Plain Diff
BETA: Reworking '''!FleeNpc''' AI.
* Patch by: Pandragon, Nos * Tested by: Pandragon
parent
0bb3efe9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
L2J_DataPack_BETA/dist/game/data/scripts.cfg
+1
-1
1 addition, 1 deletion
L2J_DataPack_BETA/dist/game/data/scripts.cfg
L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/FleeMonsters.java
+94
-0
94 additions, 0 deletions
...ist/game/data/scripts/ai/group_template/FleeMonsters.java
with
95 additions
and
1 deletion
L2J_DataPack_BETA/dist/game/data/scripts.cfg
+
1
−
1
View file @
3bf03505
...
...
@@ -100,6 +100,7 @@ ai/group_template/DragonValley.java
ai/group_template/EnergySeeds.java
ai/group_template/FairyTrees.java
ai/group_template/FeedableBeasts.java
ai/group_template/FleeMonsters.java
ai/group_template/FrozenLabyrinth.java
ai/group_template/GiantsCave.java
ai/group_template/IsleOfPrayer.java
...
...
@@ -150,7 +151,6 @@ ai/individual/DivineBeast.java
ai/individual/DrChaos.java
ai/individual/Epidos.java
ai/individual/EvasGiftBox.java
ai/individual/FleeNpc.java
ai/individual/FrightenedRagnaOrc.java
ai/individual/GeneralDilios.java
ai/individual/Gordon.java
...
...
This diff is collapsed.
Click to expand it.
L2J_DataPack_BETA/dist/game/data/scripts/ai/
individual/FleeNpc
.java
→
L2J_DataPack_BETA/dist/game/data/scripts/ai/
group_template/FleeMonsters
.java
+
94
−
0
View file @
3bf03505
...
...
@@ -16,61 +16,79 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
ai.
individual
;
package
ai.
group_template
;
import
ai.npc.AbstractNpcAI
;
import
com.l2jserver.Config
;
import
com.l2jserver.gameserver.GeoData
;
import
com.l2jserver.gameserver.ai.CtrlIntention
;
import
com.l2jserver.gameserver.model.Location
;
import
com.l2jserver.gameserver.model.actor.L2Npc
;
import
com.l2jserver.gameserver.model.actor.L2Summon
;
import
com.l2jserver.gameserver.model.actor.instance.L2PcInstance
;
import
com.l2jserver.gameserver.model.interfaces.ILocational
;
import
com.l2jserver.gameserver.util.Util
;
public
final
class
FleeNpc
extends
AbstractNpcAI
/**
* Flee Monsters AI.
* @author Pandragon, Nos
*/
public
final
class
FleeMonsters
extends
AbstractNpcAI
{
// NPCs
private
static
final
int
[]
MOBS
=
{
20432
,
22228
,
18150
,
18151
,
18152
,
18153
,
18154
,
18155
,
18156
,
18157
18150
,
// Victim
18151
,
// Victim
18152
,
// Victim
18153
,
// Victim
18154
,
// Victim
18155
,
// Victim
18156
,
// Victim
18157
,
// Victim
20002
,
// Rabbit
20432
,
// Elpy
22228
,
// Grey Elpy
25604
,
// Mutated Elpy
};
// Misc
private
static
final
int
FLEE_DISTANCE
=
500
;
private
Flee
Npc
()
private
Flee
Monsters
()
{
super
(
Flee
Npc
.
class
.
getSimpleName
(),
"ai/
individual
"
);
super
(
Flee
Monsters
.
class
.
getSimpleName
(),
"ai/
group_template
"
);
addAttackId
(
MOBS
);
}
@Override
public
String
onAttack
(
L2Npc
npc
,
L2PcInstance
attacker
,
int
damage
,
boolean
isSummon
)
{
if
((
npc
.
getId
()
>=
18150
)
&&
(
npc
.
getId
()
<=
18157
))
npc
.
disableCoreAI
(
true
);
npc
.
setRunning
();
final
L2Summon
summon
=
isSummon
?
attacker
.
getSummon
()
:
null
;
final
ILocational
attackerLoc
=
summon
==
null
?
attacker
:
summon
;
final
double
radians
=
Math
.
toRadians
(
Util
.
calculateAngleFrom
(
attackerLoc
,
npc
));
final
int
posX
=
(
int
)
(
npc
.
getX
()
+
(
FLEE_DISTANCE
*
Math
.
cos
(
radians
)));
final
int
posY
=
(
int
)
(
npc
.
getY
()
+
(
FLEE_DISTANCE
*
Math
.
sin
(
radians
)));
final
int
posZ
=
npc
.
getZ
();
final
Location
destination
;
if
(
Config
.
GEODATA
>
0
)
{
npc
.
getAI
().
setIntention
(
CtrlIntention
.
AI_INTENTION_MOVE_TO
,
new
Location
((
npc
.
getX
()
+
getRandom
(-
40
,
40
)),
(
npc
.
getY
()
+
getRandom
(-
40
,
40
)),
npc
.
getZ
(),
npc
.
getHeading
()));
npc
.
getAI
().
setIntention
(
CtrlIntention
.
AI_INTENTION_IDLE
,
null
,
null
);
return
null
;
destination
=
GeoData
.
getInstance
().
moveCheck
(
npc
.
getX
(),
npc
.
getY
(),
npc
.
getZ
(),
posX
,
posY
,
posZ
,
attacker
.
getInstanceId
());
}
else
if
((
npc
.
getId
()
==
20432
)
||
(
npc
.
getId
()
==
22228
))
else
{
if
(
getRandom
(
3
)
==
2
)
{
npc
.
getAI
().
setIntention
(
CtrlIntention
.
AI_INTENTION_MOVE_TO
,
new
Location
((
npc
.
getX
()
+
getRandom
(-
200
,
200
)),
(
npc
.
getY
()
+
getRandom
(-
200
,
200
)),
npc
.
getZ
(),
npc
.
getHeading
()));
}
npc
.
getAI
().
setIntention
(
CtrlIntention
.
AI_INTENTION_IDLE
,
null
,
null
);
return
null
;
destination
=
new
Location
(
posX
,
posY
,
posZ
);
}
npc
.
getAI
().
setIntention
(
CtrlIntention
.
AI_INTENTION_MOVE_TO
,
destination
);
return
super
.
onAttack
(
npc
,
attacker
,
damage
,
isSummon
);
}
// Register the new Script at the Script System
public
static
void
main
(
String
[]
args
)
{
new
Flee
Npc
();
new
Flee
Monsters
();
}
}
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