Jump to content

[one] [Eluna] installer/utiliser un script Lua


syneau

Recommended Posts

Bonjour,

J'ai créé un script Lua pour gérer les actions répétables d'un mob.

A priori je n'ai pas réussi à l'installer correctement sur mon serveur car le mob ne réagit pas du tout comme je l'attends.

J'ai créé les sous-répertoires \scripts\eastern_kingdoms sous la structure \src\modules\Eluna. J'y ai copié mon script spectral_charger.lua

J'ai fait un build du projet et testé le comportement du mob.

Les actions attendues n'arrivent pas, et je n'ai pas, sauf erreur de ma part, d'erreurs dans les logs.

Est-ce mon script qui est faux ou la façon dont j'ai fait l'installation ?

Peut être faut il modifier certains CMakeLists, vu que c'est, sauf erreur de ma part encore, le premier script lua de mon serveur ?

Merci de votre aide :)

Sylvain.

pour info, mon script :

--[[

Spectral charger, in Karazhan.

Made by syneau, for The Geek Crusade server (Mangos).
By using this script, you accept that the software is delivered "AS IS"
and that I take no responsibility whatsoever if you choose to use this
software.

You may not sell this or redistribute this under your name in any way,
shape or form. If you choose to modify this script, do so at your own
discretion and know that I cannot be held responsible for any damage
this may cause to any of your property.

Enjoy the Script!

RUN SQL for remove EventAI:
   DELETE FROM `creature_ai_scripts` WHERE creature_id = 15547;
   UPDATE `creature_template` SET `AIName` = '' WHERE `entry` = 15547;

]]--

SpectralCharger = {}
SpectralCharger.SpellID = {}

---------- Config ----------
SpectralCharger.EntryID = 15547

SpectralCharger.SpellID.Charge = 29320
SpectralCharger.SpellID.Fear = 29321

-- SpectralCharger.ChargeInterval = 20000

---------- Config End ----------

-- Charge the farthest player, every 20s, in 45 m (yard ?)
function SpectralCharger.ChargeAndFear (eventid, delay, repeats, pUnit)
local target = Creature:GetAITarget( 4, false, 1, 45 )
pUnit:CastSpell(target, SpectralCharger.SpellID.Charge, true)
pUnit:CastSpell(pUnit, SpectralCharger.SpellID.Fear, true)
end

function SpectralCharger.OnCombat(event, pUnit, pPlayer)
pUnit:RegisterEvent(SpectralCharger.ChargeAndFear, 20000, 0)
end

function SpectralCharger.OnLeaveCombat(event, pUnit)
pUnit:RemoveEvents()
end

function SpectralCharger.OnDied(event, pUnit, pPlayer)
pUnit:RemoveEvents()
end

RegisterCreatureEvent(SpectralCharger.EntryID, 1, SpectralCharger.OnCombat)
RegisterCreatureEvent(SpectralCharger.EntryID, 2, SpectralCharger.OnLeaveCombat)
RegisterCreatureEvent(SpectralCharger.EntryID, 4, SpectralCharger.OnDied)

Link to comment
Share on other sites

Ho !!

Donc les scripts sont ajoutés après construction du projet ; en quelque sorte ils sont "bindés" à la volée ?

Je teste de suite.

Je suppose qu'on garde la structure \scripts\eastern_kingdoms, mais sous \lua_scripts ?

Merci Tal.

Link to comment
Share on other sites

Effectivement, ça fonctionne :)

lua_scripts/scripts/eastern_kingdoms/spectral_charger.lua:38: calling 'GetAITarg
et' on bad self (bad argument : Creature expected, got table)
Stack Traceback
===============
(1)  C function 'function: 01366B40'
(2) method C function 'GetAITarget'
(3) Lua function 'SpectralCharger' at file 'lua_scripts/scripts/eastern_kingdoms
/spectral_charger.lua:38' (best guess)
       Local variables:
        eventid = number: 10
        delay = number: 20000
        repeats = number: 0
        pUnit = Creature: (16608C20)

Link to comment
Share on other sites

J'ai modifié mon script :

local target = pUnit:GetAITarget( 4, false, 1, 45 )

C'est presque ça :)

Je ne sais pas si les erreurs proviennent de mon script ou pas.

Visuellement, c'est pas tout à fait ça ; on ne vois pas la charge, et elle arrive parfois sur le player le plus prêt, ce qui ne devrait pas arriver.

J'ai du travail encore :)

AttackerStateUpdate: (NPC)    85182 attacked 2 (TypeId: 4) for 1009 dmg, absorbe
d 0, blocked 0, resisted 0.
Map::GetHitPosition vmaps corrects gained with static objects! new dest coords a
re X:-10990.069336 Y:-2017.353882 Z:94.824600
Map::GetHitPosition vmaps corrects gained with static objects! new dest coords a
re X:-10937.981445 Y:-1976.383545 Z:50.491699
Sending SMSG_SPELL_GO id=29320
Spell 29320 Effect1 : 58 Targets: Player Plopy (Guid: 7), -, -
Sending SMSG_SPELL_GO id=29321
Spell 29321 Effect0 : 6 Targets: Player Lala (Guid: 2), -, -
Spell: Aura is: 7
Aura: construct Spellid : 29321, Aura : 7 Target : 22 Damage : 0
Player Lala (Guid: 2) flee from Creature (Entry: 15547 Guid: 85182)
Holder of spell 29321 now is in use
WORLD: Received opcode CMSG_TIME_SYNC_RESP: counter 29, client ticks 1398916725,
time since last sync 10142
WORLD: Opcode CMSG_TIME_SYNC_RESP -- Our ticks: 1398916882, diff 157, latency 0

WORLD: Received opcode CMSG_MOVE_NOT_ACTIVE_MOVER
STORAGE_SIZE: 37
02 00 00 00 00 00 00 00 | 00 00 00 00 00 6B C5 61
53 AD F6 2C C6 49 88 F6 | C4 09 90 47 42 90 E2 34
40 00 00 00 00
HandleMoveNotActiveMover: incorrect mover guid: mover is Player Lala (Guid: 2) a
nd should be Player Lala (Guid: 2) instead of Player Lala (Guid: 2)
WORLD: Received opcode CMSG_MOVE_TIME_SKIPPED
WORLD: Received opcode CMSG_TIME_SYNC_RESP: counter 24, client ticks 1398916854,
time since last sync 10105
WORLD: Opcode CMSG_TIME_SYNC_RESP -- Our ticks: 1398917111, diff 257, latency 5

WORLD: Received opcode CMSG_MOVE_TIME_SKIPPED
WORLD: Received opcode CMSG_TIME_SYNC_RESP: counter 22, client ticks 1398916831,
time since last sync 10051
WORLD: Opcode CMSG_TIME_SYNC_RESP -- Our ticks: 1398917088, diff 257, latency 0

Spell 29320 Effect0 : 96 Targets: Player Plopy (Guid: 7), -, -
creature 85182 stopped attacking player 2
WORLD: Sent SMSG_AI_REACTION, type 2.
WORLD: Sent SMSG_ATTACKSTART
Spell 29320 Effect2 : 6 Targets: Player Plopy (Guid: 7), -, -
Spell: Aura is: 4
Aura: construct Spellid : 29320, Aura : 4 Target : 6 Damage : 0
Holder of spell 29320 now is in use
DealDamageStart
deal dmg:4149 to health:881279
DealDamageAlive
DealDamageEnd returned 4149 damage
creature 85182 stopped attacking player 7
WORLD: Sent SMSG_AI_REACTION, type 2.
WORLD: Sent SMSG_ATTACKSTART
Creature (Entry: 15547 Guid: 85182) chase to Player Lala (Guid: 2)

Link to comment
Share on other sites

Effectivement, tout est ajouté par la suite. L'emplacement où tu le mets sous le dossier lua_scripts n'a pas d'importance (sauf dans extension) :-)

Bon courage ! Pour info, tu peux recharger ton script avec "eluna reload".

Ha, merci pour cette info très utile :)

Dans la doc (Eluna API) ils ne disent pas si il est possible d'afficher des infos de debug. Est-ce possible ?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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. Privacy Policy Terms of Use