Jump to content

Recommended Posts

Posted

Here script for AutoFighter L2Net231

 

//**** Fighter script v0.2 ****//

//Remember to set weapon ID at line 133 and 137 (in the killtarget sub)

//****** User Settings ******//
DEFINE INT MIN_ATTACKDELAY 1500
DEFINE INT MAX_ATTACKDELAY 2500
DEFINE INT LOOT_RANGE 100
DEFINE INT MIN_PICKUPDELAY 150
DEFINE INT MAX_PICKUPDELAY 300
DEFINE INT MIN_TARGETDELAY 500
DEFINE INT MAX_TARGETDELAY 1000
DEFINE INT MOVETO_DISTANCE 400

//***********************Kite Stuff*********************//
DEFINE INT KiteRange 450
DEFINE DOUBLE VX 0
DEFINE DOUBLE VY 0
DEFINE DOUBLE VX1 0
DEFINE DOUBLE VY1 0
DEFINE DOUBLE LEN 0
//*****************************************************//

//*******time*******//
DEFINE INT StartTime 0
DEFINE INT EndTime 0
DEFINE INT UsedTime 0
DEFINE INT MaxTime 100000000
DEFINE INT MaxPickTime 50000000

//******Rest Settings******//
//set here at what hp/mp to rest. (in %)
DEFINE INT RESTHPPERCENT 40
DEFINE INT RESTMPPERCENT 0

DEFINE INT TEMP 0
DEFINE INT i 0
DEFINE INT TEN 10
DEFINE INT FOUR 4
DEFINE INT HUNDRED 100
DEFINE INT COUNT 0
DEFINE INT Rest 0
DEFINE INT RESTHP 0
DEFINE INT RESTMP 0
DEFINE INT SKILLMP 0
DEFINE INT DISTANCE_TO_TARGET 0
DEFINE INT PICKUP_X 0
DEFINE INT PICKUP_Y 0
DEFINE INT TEMPX 3
DEFINE DOUBLE X 0
DEFINE DOUBLE Y 0
DEFINE DOUBLE Range 50


MATH RESTHP CHAR_MAX_HP MULTIPLY RESTHPPERCENT
MATH RESTHP RESTHP DIVIDE HUNDRED
MATH RESTMP CHAR_MAX_MP MULTIPLY RESTMPPERCENT
MATH RESTMP RESTMP DIVIDE HUNDRED

//****** MAIN ******//

//just a printout 
PRINT_TEXT "rest below <&RESTHP&> HP"
DO
TARGET_NEAREST
GET_RAND TEMP "<&MIN_TARGETDELAY&>" "<&MAX_TARGETDELAY&>"
SLEEP "<&TEMP&>"
IF TARGET_CUR_HP > ZERO
	CALLSUB MovetoTarget
	SLEEP 500
	CALLSUB KillTarget
ENDIF	

//Target is dead, pick up
GET_TIME StartTime
SET PICKUP_X "<&CHAR_X&>"
SET PICKUP_Y "<&CHAR_Y&>"
	WHILE NEAREST_ITEM_DISTANCE < LOOT_RANGE
		GET_TIME EndTime
		MATH UsedTime EndTime SUBTRACT StartTime
		IF UsedTime > MaxPickTime
			BREAK 2
		ENDIF
		DISTANCE TEMP CHAR_X CHAR_Y TEMP PICKUP_X PICKUP_Y TEMP
		IF TEMP > LOOT_RANGE
			BREAK 2
		ENDIF
		CALLSUB Pickup
	WEND

	IF COUNT_NPC_TARGETME == ZERO
		IF CHAR_CUR_HP < RESTHP
			CALLSUB Rest
		ENDIF
	ENDIF
LOOP ZERO == ZERO
SCRIPT_END

//***************** SUBS *****************//
SUB MovetoTarget
SET i 0
GET_TIME StartTime
DISTANCE DISTANCE_TO_TARGET CHAR_X CHAR_Y CHAR_Z TARGET_X TARGET_Y TARGET_Z
IF DISTANCE_TO_TARGET <= MOVETO_DISTANCE
	RETURNSUB
ENDIF
SET TEMPX "<&TARGET_X&>"
MOVE_TO "<&TARGET_X&>" "<&TARGET_Y&>" "<&TARGET_Z&>"
WHILE DISTANCE_TO_TARGET > MOVETO_DISTANCE
                GET_TIME EndTime
	MATH UsedTime EndTime SUBTRACT StartTime
	DISTANCE DISTANCE_TO_TARGET CHAR_X CHAR_Y CHAR_Z TARGET_X TARGET_Y TARGET_Z
	GET_RAND TEMP "<&MIN_TARGETDELAY&>" "<&MAX_TARGETDELAY&>"
	SLEEP "<&TEMP&>"
	IF UsedTime > MaxTime
		CALLSUB Stuck
		RETURNSUB
	ENDIF	
	IF TARGET_X != TEMPX
		MOVE_TO "<&TARGET_X&>" "<&TARGET_Y&>" "<&TARGET_Z&>"
	ENDIF	
WEND
RETURNSUB
//******************************************************************************//
SUB KillTarget
GET_TIME StartTime
DO
	MATH i i ADD ONE
	PRINT_TEXT "Entering loop <&i&>"		
	GET_TIME EndTime
	MATH UsedTime EndTime SUBTRACT StartTime
	IF i == FOUR
		IF TARGET_CUR_HP == TARGET_MAX_HP
			USE_ITEM 13 //Equip Short Bow
			SLEEP 1000
			ATTACK_TARGET
			SLEEP 3500
			USE_ITEM 2543 //Equip duals
			SET i 0
		ENDIF
	ENDIF	
	IF UsedTime > MaxTime
		IF TARGET_CUR_HP == TARGET_MAX_HP
			CALLSUB Stuck
			RETURNSUB
		ENDIF
	ENDIF	
	ATTACK_TARGET
	GET_RAND TEMP "<&MIN_ATTACKDELAY&>" "<&MAX_ATTACKDELAY&>"
	SLEEP "<&TEMP&>"
LOOP TARGET_CUR_HP > ZERO
RETURNSUB
//******************************************************************************//
SUB Pickup
CLICK_NEAREST_ITEM
GET_RAND TEMP "<&MIN_PICKUPDELAY&>" "<&MAX_PICKUPDELAY&>"
SLEEP "<&TEMP&>"
RETURNSUB
//******************************************************************************//
SUB Rest
PRINT_TEXT "starting to rest"
SLEEP 1000
COMMAND "/sit"
//USE_SKILL 226
WHILE CHAR_CUR_HP < CHAR_MAX_HP
	IF COUNT_NPC_TARGETME != ZERO
		COMMAND "/stand"
		RETURNSUB
	ENDIF
SLEEP 1000
WEND
//done resting lets stand
COMMAND "/stand"
SLEEP 200
RETURNSUB
//******************************************************************************//
SUB Stuck
//need to get a vector for from the monster to us
MATH VX CHAR_X SUBTRACT TARGET_X
MATH VY CHAR_Y SUBTRACT TARGET_Y
//now we have the vector from the target to us... lets normalize it now
DISTANCE LEN ZERO ZERO ZERO VX VY ZERO
MATH VX VX DIVIDE LEN
MATH VY VY DIVIDE LEN
//now lets scale back up to our range
MATH VX VX MULTIPLY KiteRange
MATH VY VY MULTIPLY KiteRange
SET VX1 "<&VX&>"
SET VY1 "<&VY&>"	
//then we add this offset to our location
MATH VX VX ADD CHAR_X
MATH VY VY ADD CHAR_Y
//and finally... we move
MOVE_TO "<&VX&>" "<&VY&>" "<&CHAR_Z&>" 
SLEEP 1500
//left turn
MATH VX CHAR_X SUBTRACT VY1
MATH VY CHAR_Y ADD VX1
MOVE_TO "<&VX&>" "<&VY&>" "<&CHAR_Z&>"
SLEEP 1500
MOVE_TO "<&TARGET_X&>" "<&TARGET_Y&>" "<&TARGET_Z&>"
SLEEP 1500
RETURNSUB


//**** Developed by Oddi 2007 ****//
//Thanks to Slothmo & Asmodin88 for providing useful pre-code

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • And Discord: https://discord.gg/3aYqWNqb
    • Ofc: https://discord.gg/3aYqWNqb
    • You can find some H5 skins shared in old L2 modding Discords, but most of the higher‑quality ones are either paid or come bundled with full client edits. I usually mix in commissioned work and whatever I can patch myself. On a side note, I fund a lot of these commissions by selling off game items through instant sell cs2 skins, which has been a quick way for me to get some cash for projects.
    • There is no need for gRPC in this case, even tho originally it was gRPC based but since we don't need it to be bi-directional, we switched to simple http requests for the web calls and SSEs for the data streamed from the server. There are distributed locks in place to precent race conditions between actions that can happen between multiple web instances and the server.   Local models can also be slow depending on the model, and most external models can actually be faster than local ones if you use Flash 2.5 or something along those lines. I am running on 512GB of Unified Memory on my Mac Studio M3 Ultra so the speed of the local model for a small model is pretty good but I tested it with Gemini too and it works equally as fast and in some cases faster. The way it works is that I'm using pgvector (one of the benefits of moving to Postgres) to search the data and see what the player can see etc and there is some batching of the next few actions for 2-4 seconds for the user until the next LLM request fires. The batching also includes branching on logic so if they for example fall under some HP they will move to kiting instead of attacking or maybe they heal etc.   Everything is authed and permission-based. The server and the backend of the frontend have secure communication between them, either with a symmetric key (not recommended for production) or a certificate (the recommended way), so there is no worry. It's all tied to the account's access level, etc., so nobody can make an action that they normally wouldn't be allowed to do. Even the MCP is token-based, and there are prompt injection protections in place. The MCP is audited, and every mutation needs confirmation. The admin area is only accessible to the admin account anyway so normal users can't access it.  
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..