L2Tower Discord Let's keep the community alive with discord. Discussions about plugins and scripts L2Tower Discord

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script: Healer | Desarrollo paso a paso
Author Message
rORUMI Offline
Expired VIP Member
**

Posts: 278
Joined: May 2014
Reputation: 50
Version: 1.4.2.142
Post: #1
Script: Healer | Desarrollo paso a paso

Hola a todos. Este tema es para todos aquellos que quieran aprender como hacer o mejorar un Script de un Healer nivel 85+ escrito en LUA para L2Tower.

Lo primero que vamos a entender es como organizar un Script:


Definimos: variables globales

Definimos funciones(): Incluyen variables locales, toman datos de variables globales, ejecutan condiciones de codigo, devuelven resultados que pueden ser: true | false o una respuesta por ejemplo, un resultado matematico

por ultimo:

usamos el concepto: repetir, hasta que sea falso, nuestras funciones y codigo.

quedaria algo asi:

    LUA Programming
variables
 
funciones()
 
repeat
 
 funciones()
 
until false;



Ok, comencemos:
--------------


Es comun en todos los Script, informarnos a nosotros mismos que lo hemos ejecutado. Entonces lo primero que vamos a hacer es enviarle la orden del que el cliente nos muestre algo de texto

    LUA Programming
ShowToClient("GOD", "HEALER ACTIVE", 3); -- Esto se muestra en mi cliente, de color verde. Sin el [,3] aparece en Rojo igual que un PM



Ahora, utilziando recstart y recstop obtenemos los ids de algunos de los skiils que vamos a utilizar.

Para nuestro ejemplo: Vamos a curar, usar salvation, resucitar, hacer rebirth o Cristalizarnos. A este punto podemos tener nuestro primer script, el cual no hace nada mas que mostrar un mensaje y definir variables globales:

Healer85 v0.1
    LUA Programming
ShowToClient("GOD", "HEALER ACTIVE", 3);
 
--ID's-Healer-----------------------------------------
--Heal------------------------------------------------
RebirthID = 11768; -- Rebirth = 11768
 
BalanceHealID = 11762; --Balance Heal ID
BrilliantHealID = 11757; --Brilliant Heal ID
 
--Self Buff-------------------------------------------
SalvationID = 11826; -- Aeore Emblem of Salvation = 11826
 
--Ultimate--------------------------------------------
CrystalRegenerationID = 11765; -- Crystal Regeneration
 
--Ress------------------------------------------------
ResSkillAeoreID = 11784; -- Aeore Blessed Resurrection = 11784; 
 
repeat
 
until false;



Ahora vamos a hacer que nuestro Healer haga algo. Por ejemplo que revise si tiene en si mismo: salvation

Esto lo voy a hacer a traves de una funcion escrita que voy a llamar CheckBuffOnME() y otra llamada CastOnTarget()

    LUA Programming
-- CheckBuffOnME(id) [OK] | Verifico si YO tengo o necesito uno de mis buff
-- requiere: CastOnTarget()
------------------------------------------------------
function CheckBuffOnME(id)
 local me = GetMe(); -- No Global [defino la variable me = yo en forma local]
 if (me ~= nil) and not (me:IsAlikeDeath()) then -- [si "me" no es NULO o No estoy muerto]
 if (me:GotBuff(id) == false) then -- [Si "NO" tengo X Buff]
 CastOnTarget(id,me); -- Castearme el Buff
 end;
 end;	
end;
------------------------------------------------------
--CastOnTarget() [OK]| Autocast de skills
function CastOnTarget(id,target)
 if id then
 local MySkills = GetSkills():FindById(id)
 if MySkills and (MySkills:CanBeUsed()) then
 Target(target)
 UseSkillRaw(id,false,false)
 Sleep(500)
 ClearTarget();
 CancelTarget(false);
 CancelTarget(false);
 CancelTarget(false);
 return true
 end;
 end;
return false
end;
------------------------------------------------------



Ahora, voy a unir las variables que defini y las funciones a un script estructurado y funcional

v.0.2 | Healer + Salvation
    LUA Programming
-- L2TOWER: LUA - MainHealer() v0.2 | Script Healer Paso a Paso
----------------------------------------------------------
ShowToClient("GOD", "HEALER ACTIVE", 3); -- Esto se muestra en mi cliente, de color verde. Sin el [,3] aparece en Rojo igual que un PM
 
--ID's-Healer-----------------------------------------
--Heal------------------------------------------------
RebirthID = 11768; -- Rebirth = 11768
 
BalanceHealID = 11762; --Balance Heal ID
BrilliantHealID = 11757; --Brilliant Heal ID
 
--Self Buff-------------------------------------------
SalvationID = 11826; -- Aeore Emblem of Salvation = 11826
 
--Ultimate--------------------------------------------
CrystalRegenerationID = 11765; -- Crystal Regeneration
 
--Ress------------------------------------------------
ResSkillAeoreID = 11784; -- Aeore Blessed Resurrection = 11784; 
 
--Funciones-Comunes-----------------------------------
 
--CastOnTarget() [OK]| Autocast de skills
function CastOnTarget(id,target)
	if id then
local MySkills = GetSkills():FindById(id)
 if MySkills and (MySkills:CanBeUsed()) then
 Target(target)
 UseSkillRaw(id,false,false)
 Sleep(500)
 ClearTarget();
 CancelTarget(false);
 CancelTarget(false);
 CancelTarget(false);
 return true
 end;
	end;
return false
end;
------------------------------------------------------
 
-- CheckBuffOnME(id) [OK] | Verifico si YO tengo o necesito uno de mis buff
-- requiere: CastOnTarget()
------------------------------------------------------
function CheckBuffOnME(id)
 local me = GetMe(); -- No Global
 if (me ~= nil) and not (me:IsAlikeDeath()) then
 if (me:GotBuff(id) == false) then
 CastOnTarget(id,me);
 end;
 end;	
end;
------------------------------------------------------
 
------------------------------------------------------
--HEALER----------------------------------------------
function MainHealer()
 
	local me = GetMe(); -- No Global
 
 CheckBuffOnME(SalvationID); -- Salvation ID Skill	
 Sleep(300)
end;
--End-Healer------------------------------------------
 
repeat
	if not IsPaused() then
--Check Clase: | AeoreCardinal" = 179 | AeoreEvasSaint" = 180 | AeoreShillienSaint" = 181	
 if (GetMe():GetClass() == 179) or (GetMe():GetClass() == 180) or (GetMe():GetClass() == 181) then
 if not (GetMe():IsBlocked(true)) then 
 MainHealer();
 end;
 end;
 end; --not paused
until false;




Ahora que ya nuestro healer se puede dar salvation, cada que este disponible, vamos a Agregarle la posibilidad de resucitar a cualquier miembro de nuestra party que este muerto.

La funcion es la siguiente:

    LUA Programming
------------------------------------------------------
-- RessParty | [OK]
------------------------------------------------------
function RessParty()
local party2resslist = GetPartyList(); -- No Global
 
	for member2ress in party2resslist.list do -- partylist: Ress para party - playerlist: ress para cualquiera cerca
 if member2ress:IsAlikeDeath() then
 CastOnTarget(ResSkillAeoreID, member2ress);
 Sleep (300)
 end;
	end;
end;
------------------------------------------------------



v0.3 | Healer + Salvation + Ress Party
    LUA Programming
-- L2TOWER: LUA - MainHealer() | Script Healer Paso a Paso
----------------------------------------------------------
ShowToClient("GOD", "HEALER ACTIVE", 3); -- Esto se muestra en mi cliente, de color verde. Sin el [,3] aparece en Rojo igual que un PM
 
--ID's-Healer-----------------------------------------
--Heal------------------------------------------------
RebirthID = 11768; -- Rebirth = 11768
 
BalanceHealID = 11762; --Balance Heal ID
BrilliantHealID = 11757; --Brilliant Heal ID
 
--Self Buff-------------------------------------------
SalvationID = 11826; -- Aeore Emblem of Salvation = 11826
 
--Ultimate--------------------------------------------
CrystalRegenerationID = 11765; -- Crystal Regeneration
 
--Ress------------------------------------------------
ResSkillAeoreID = 11784; -- Aeore Blessed Resurrection = 11784; 
 
 
--Funciones-Comunes-----------------------------------
 
--CastOnTarget() [OK]| Autocast de skills
function CastOnTarget(id,target)
	if id then
local MySkills = GetSkills():FindById(id)
 if MySkills and (MySkills:CanBeUsed()) then
 Target(target)
 UseSkillRaw(id,false,false)
 Sleep(500)
 ClearTarget();
 CancelTarget(false);
 CancelTarget(false);
 CancelTarget(false);
 return true
 end;
	end;
return false
end;
------------------------------------------------------
 
-- CheckBuffOnME(id) [OK] | Verifico si YO tengo o necesito uno de mis buff
-- requiere: CastOnTarget()
------------------------------------------------------
function CheckBuffOnME(id)
 local me = GetMe(); -- No Global
 if (me ~= nil) and not (me:IsAlikeDeath()) then
 if (me:GotBuff(id) == false) then
 CastOnTarget(id,me);
 end;
 end;	
end;
------------------------------------------------------
 
------------------------------------------------------
-- RessParty | [OK]
------------------------------------------------------
function RessParty()
local party2resslist = GetPartyList(); -- No Global
 
	for member2ress in party2resslist.list do -- partylist: Ress para party - playerlist: ress para cualquiera cerca
 if member2ress:IsAlikeDeath() then
 CastOnTarget(ResSkillAeoreID, member2ress);
 Sleep (300)
 end;
	end;
end;
------------------------------------------------------
 
 
------------------------------------------------------
--HEALER----------------------------------------------
function MainHealer()
 
	local me = GetMe(); -- No Global
 
 CheckBuffOnME(SalvationID); -- Salvation ID Skill	
 Sleep(300)
 
 RessParty(); -- Ress Any dead
 Sleep(300)
end;
--End-Healer------------------------------------------
 
repeat
	if not IsPaused() then
--Check Clase: | AeoreCardinal" = 179 | AeoreEvasSaint" = 180 | AeoreShillienSaint" = 181	
 if (GetMe():GetClass() == 179) or (GetMe():GetClass() == 180) or (GetMe():GetClass() == 181) then
 if not (GetMe():IsBlocked(true)) then 
 MainHealer();
 end;
 end;
 end; --not paused
until false;



Por Ultimo, ahora vamos a darle a nuestro healer, la posibilidad de curarse a si mismo, a los miembros de la party, tanto si baja el CP o el HP y por ultimo de ser necesario, cristalizarce

Para esto, cree una funcion llamada NeedSurvive()

Notas: En party funciona, resucita, helea, etc, ingrese algunos cambios para que tambien responda estando sin party y al menos lo que probe funciona, pero veran que lleva tiempo generar todas las situaciones para verificar si una parte del codigo funciona o no, lo cual se los dejo a ustedes X)

v.0.4 | Healer + Salvation + Ress party + control de CP/HP por porcentaje y Cristalizacion

    LUA Programming
-- L2TOWER: LUA - MainHealer() | Script Healer Paso a Paso
----------------------------------------------------------
ShowToClient("GOD", "HEALER ACTIVE", 3); -- Esto se muestra en mi cliente, de color verde. Sin el [,3] aparece en Rojo igual que un PM
 
--ID's-Healer-----------------------------------------
--Heal------------------------------------------------
RebirthID = 11768; -- Rebirth = 11768
 
BalanceHealID = 11762; --Balance Heal ID
BrilliantHealID = 11757; --Brilliant Heal ID
 
--Self Buff-------------------------------------------
SalvationID = 11826; -- Aeore Emblem of Salvation = 11826
 
--Ultimate--------------------------------------------
CrystalRegenerationID = 11765; -- Crystal Regeneration
 
--Ress------------------------------------------------
ResSkillAeoreID = 11784;  -- Aeore Blessed Resurrection = 11784; 
 
 
--Funciones-Comunes-----------------------------------
 
--CastOnTarget() [OK]| Autocast de skills
function CastOnTarget(id,target)
	if id then
local MySkills = GetSkills():FindById(id)
		if MySkills and (MySkills:CanBeUsed()) then
			Target(target)
			UseSkillRaw(id,false,false)
			Sleep(500)
			ClearTarget();
			CancelTarget(false);
			CancelTarget(false);
			CancelTarget(false);
			return true
		end;
	end;
return false
end;
------------------------------------------------------
 
-- CheckBuffOnME(id) [OK] | Verifico si YO tengo o necesito uno de mis buff
-- requiere: CastOnTarget()
------------------------------------------------------
function CheckBuffOnME(id)
		local me = GetMe(); -- No Global
		if (me ~= nil) and not (me:IsAlikeDeath()) then
			if (me:GotBuff(id) == false) then
			CastOnTarget(id,me);
			end;
		end;	
end;
------------------------------------------------------
 
------------------------------------------------------
-- RessParty | [OK]
------------------------------------------------------
function RessParty()
local party2resslist = GetPartyList(); -- No Global
 
	for member2ress in party2resslist.list do -- partylist: Ress para party - playerlist: ress para cualquiera cerca
		if  member2ress:IsAlikeDeath() then
			CastOnTarget(ResSkillAeoreID, member2ress);
			Sleep (300)
		end;
	end;
end;
------------------------------------------------------
 
--Survive-Functions-----------------------------------
function NeedSurvive()
		local partylist = GetPartyList(); -- No Global
		local me = GetMe(); -- No Global
 
-- me
-- MP/HP
 
		if (me:GetHpPercent() < 20) or (me:GetMpPercent() < 40) then -- Recharge HP/MP Rebirth
			CastOnTarget(RebirthID,me);	
 
		elseif (me:GetHpPercent() < 20) then
 
			CastOnTarget(CrystalRegenerationID,me);
			Sleep (300)	
 
-- CP/HP	
		elseif (me:GetCpPercent() < 75) or (me:GetHpPercent() < 75) then
 
			CastOnTarget(BalanceHealID,me);
			Sleep (300)
			CastOnTarget(BrilliantHealID,me);
			Sleep (300)
 
		end;	
 
 
-- Party/me
	for member in partylist.list do
 
-- MP/HP
 
		if (member:GetHpPercent() < 20) or (member:GetMpPercent() < 20)  then -- Recharge HP/MP Rebirth
 
			CastOnTarget(RebirthID,member);	
 
		elseif (me:GetHpPercent() < 40) then
 
			CastOnTarget(CrystalRegenerationID,member);
			Sleep (300)	
 
-- CP/HP	
		elseif (member:GetCpPercent() < 75) or (member:GetHpPercent() < 75) then
 
			CastOnTarget(BalanceHealID,member);
			Sleep (300)
			CastOnTarget(BrilliantHealID,member);
			Sleep (300)
 
		return true;
 
		else
 
		return false;		
		end;	
	end;	
end;
 
------------------------------------------------------
--HEALER----------------------------------------------
function MainHealer()
 
	local me = GetMe(); -- No Global
		if not NeedSurvive() then
 
			CheckBuffOnME(SalvationID); -- Salvation ID Skill		
			Sleep(300)
 
			RessParty(); -- Ress Any dead
			Sleep(300)
		end;	
end;
--End-Healer------------------------------------------
 
repeat
	if not IsPaused() then
--Check Clase: | AeoreCardinal" = 179 | AeoreEvasSaint" = 180 | AeoreShillienSaint" = 181	
 		if (GetMe():GetClass() == 179) or (GetMe():GetClass() == 180) or (GetMe():GetClass() == 181) then
			if not (GetMe():IsBlocked(true)) then 
				MainHealer();
				Sleep(1000)				
			end;
		end;
    end; --not paused
until false;

(This post was last modified: 09-03-2014 12:20 PM by rORUMI.)
09-03-2014 07:58 AM
Find all posts by this user Quote this message in a reply
 Reputed by : alku(+1) , argentinianjesus(+2) , ExoDo(+1) , diegol(+2) , Yoxo(+2)
mardukx Offline
VIP Member
***

Posts: 240
Joined: Jan 2012
Reputation: 0
Version: 1.4.2.142
Post: #2
RE: Script: Healer | Desarrollo paso a paso

increible men!!!!! este scrip sirve par la version 131?, hay un script en el foro que se cae leere bien tu script y lo testeare haber que tel

saludos.
09-04-2014 02:04 AM
Find all posts by this user Quote this message in a reply
argentinianjesus Offline
Expired VIP Member
**

Posts: 131
Joined: Jan 2012
Reputation: 12
Version: 1.4.3.143
Post: #3
RE: Script: Healer | Desarrollo paso a paso

Excelente aporte, +rep de una.

Ahora le estoy agregando recharge de mp con skill normal individualmente, y también con el recharge de py si el mana es < a "X" porcentaje.
(This post was last modified: 09-04-2014 03:21 AM by argentinianjesus.)
09-04-2014 03:16 AM
Find all posts by this user Quote this message in a reply
whome Offline
Fallen Donator

Posts: 8
Joined: Sep 2013
Version: 1.4.2.142
Post: #4
RE: Script: Healer | Desarrollo paso a paso

Great, Thnx!
09-04-2014 03:50 AM
Find all posts by this user Quote this message in a reply
mardukx Offline
VIP Member
***

Posts: 240
Joined: Jan 2012
Reputation: 0
Version: 1.4.2.142
Post: #5
RE: Script: Healer | Desarrollo paso a paso

(09-04-2014 03:16 AM)Guxz Wrote:  Excelente aporte, +rep de una.

Ahora le estoy agregando recharge de mp con skill normal individualmente, y también con el recharge de py si el mana es < a "X" porcentaje.

anda posteandolo para verlo Tongue
09-04-2014 04:57 AM
Find all posts by this user Quote this message in a reply
rORUMI Offline
Expired VIP Member
**

Posts: 278
Joined: May 2014
Reputation: 50
Version: 1.4.2.142
Post: #6
RE: Script: Healer | Desarrollo paso a paso

(09-04-2014 03:16 AM)Guxz Wrote:  Excelente aporte, +rep de una.

Ahora le estoy agregando recharge de mp con skill normal individualmente, y también con el recharge de py si el mana es < a "X" porcentaje.

Yo le agregue lo siguiente:

- Lumi al target
- DarkForceID, si algo se te acerca mucho, lo empuja lejos
- Recharge individual y recharge masivo
- Cree una funcion llamada KeepMeAlive() que trabaja en paralelo con NeedSurvive(), pero KeepMeAlive [mantenme vivo] le doy menos importancia en precision.. osea es bien para pve que no pasa nada

NeedSurvive... es bien para pve jodido.. o pvp directamente.
- Safeplace() ahora cree esta funcion, para sobrevivir en ciertos lugares como GF, que si te acercan los guardias te matan.. entonces corre para el lugar seguro
- Le agregue otra funcion llamada MoveAway() que en ciertas condiciones, el healer tiene que escaparce solo [mas bien pvp] correr alrededor o algo, si se queda quieto.. muere rapido.
- Le agregue la opcion true|false de pickup selectivo de items con un codigo que encontre aqui
- Agregue q asista al main (sin importar quien sea en la party) y/o si paso a ser yo (healer el main) chequeando si hay pk cerca, hay pvp cerca, si estoy involucrado en el pvp, si me estan atacando.. si alguien de la party se flagueo, etc. hay un monton de cosas para ir agregando codigo.


A medida que pueda ir probando voy a ir agregandole a este script mas funciones asi lo dejamos mejor

Si alguien tiene algo en especial o codigo para agregarle posteelo y lo vemos
(This post was last modified: 09-04-2014 09:04 AM by rORUMI.)
09-04-2014 08:44 AM
Find all posts by this user Quote this message in a reply
ExoDo Offline
Restrainer of Glory
*

Posts: 171
Joined: Feb 2014
Reputation: 12
Version: 1.4.2.142
Post: #7
RE: Script: Healer | Desarrollo paso a paso

Muy buena guia Smile
09-04-2014 23:02 PM
Find all posts by this user Quote this message in a reply
Soax Offline
VIP Member
***

Posts: 272
Joined: Sep 2011
Reputation: 12
Version: 1.4.2.135
Post: #8
RE: Script: Healer | Desarrollo paso a paso

l2divine.com
09-05-2014 02:21 AM
Find all posts by this user Quote this message in a reply
kahelmo Offline
Elpy
*

Posts: 3
Joined: Jan 2012
Reputation: 0
Version: 1.4.2.133
Post: #9
RE: Script: Healer | Desarrollo paso a paso

Hola.
No puedo llegar a curar solamente!
¿Cómo puedo poner para curar eso?
Ponga el ello y iskil i id?
(This post was last modified: 09-05-2014 22:53 PM by kahelmo.)
09-05-2014 22:50 PM
Find all posts by this user Quote this message in a reply
ExoDo Offline
Restrainer of Glory
*

Posts: 171
Joined: Feb 2014
Reputation: 12
Version: 1.4.2.142
Post: #10
RE: Script: Healer | Desarrollo paso a paso

(09-05-2014 22:50 PM)kahelmo Wrote:  Hola.
No puedo llegar a curar solamente!
¿Cómo puedo poner para curar eso?
Ponga el ello y iskil i id?

curar qué , el Script hace todas esas Funciones...
para encontrar las ID de tus skilles, hace un .rec y los skilles que necesitas...
09-06-2014 08:23 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Script: Tiny ISS | Desarrollo paso a paso rORUMI 21 11,817 07-28-2016 01:03 AM
Last Post: vannsito
  ayuda con Aeore Healer xdimitrisx 0 1,359 11-07-2015 22:50 PM
Last Post: xdimitrisx
  Scrip Para healer !!!! arrowfly 5 3,743 06-22-2015 03:53 AM
Last Post: alberyan
Exclamation Cleanse o Radiant Purge Healer lord_knox 0 1,458 02-14-2015 18:55 PM
Last Post: lord_knox
  healer alku 2 2,247 09-02-2014 08:55 AM
Last Post: alku
  ress aeore healer majesty01 0 1,794 02-24-2014 18:34 PM
Last Post: majesty01
Heart Busco Script/Find Script brianheick 3 4,029 07-15-2013 04:55 AM
Last Post: Faraon



User(s) browsing this thread: 1 Guest(s)