Skip to content

Commit

Permalink
Added ContextMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonSlayer62 committed Dec 17, 2023
1 parent 36e5883 commit 48f1e64
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 0 deletions.
3 changes: 3 additions & 0 deletions data/dictionaries/dictionary.CSY
Original file line number Diff line number Diff line change
Expand Up @@ -5256,5 +5256,8 @@
19059=Musíte počkat několik sekund, než budete moci přivolat svého mazlíčka.
19060=Křišťálová koule se plní zelenou mlhou. Váš mazlíček byl přivolán.
19061=připojený mazlíček:
19062=Tato křišťálová koule již není spojena s domácím mazlíčkem.
19063=Nové jméno mazlíčka je: %s
19064=To se nezdá být platným mazlíčkem.
}
EOF
3 changes: 3 additions & 0 deletions data/dictionaries/dictionary.ENG
Original file line number Diff line number Diff line change
Expand Up @@ -5257,5 +5257,8 @@
19059=You must wait a few seconds before you can summon your pet.
19060=The Crystal Ball fills with a green mist. Your pet has been summoned.
19061=linked pet:
19062=This crystal ball is no longer linked to a pet.
19063=The new name of the pet is: %s
19064=That does not seem to be a valid pet.
}
EOF
3 changes: 3 additions & 0 deletions data/dictionaries/dictionary.FRE
Original file line number Diff line number Diff line change
Expand Up @@ -5412,5 +5412,8 @@
19059=Vous devez attendre quelques secondes avant de pouvoir invoquer votre animal de compagnie.
19060=La Boule de Cristal se remplit d'une brume verte. Votre animal a été invoqué.
19061=animal lié :
19062=Cette boule de cristal n'est plus liée à un animal de compagnie.
19063=Le nouveau nom de l'animal est : %s
19064=Cela ne semble pas être un animal de compagnie valide.
}
EOF
3 changes: 3 additions & 0 deletions data/dictionaries/dictionary.GER
Original file line number Diff line number Diff line change
Expand Up @@ -5256,5 +5256,8 @@
19059=Du musst ein paar Sekunden warten, bevor du dein Haustier herbeirufen kannst.
19060=Die Kristallkugel füllt sich mit einem grünen Nebel. Ihr Haustier wurde gerufen.
19061=verknüpftes Haustier:
19062=Diese Kristallkugel ist nicht mehr mit einem Haustier verknüpft.
19063=Der neue Name des Haustiers ist: %s
19064=Das scheint kein gültiges Haustier zu sein.
}
EOF
3 changes: 3 additions & 0 deletions data/dictionaries/dictionary.ITA
Original file line number Diff line number Diff line change
Expand Up @@ -5251,6 +5251,9 @@
19059=Devi attendere qualche secondo prima di poter evocare il tuo animale domestico.
19060=La sfera di cristallo si riempie di una nebbia verde. Il tuo animale domestico è stato evocato.
19061=animale domestico collegato:
19062=Questa sfera di cristallo non è più collegata ad un animale domestico.
19063=Il nuovo nome dell'animale è: %s
19064=Non sembra essere un animale domestico valido.
}
// Clothing Bless Deed
19001=Selezionare il capo di abbigliamento che si desidera benedire.
Expand Down
3 changes: 3 additions & 0 deletions data/dictionaries/dictionary.POL
Original file line number Diff line number Diff line change
Expand Up @@ -5251,6 +5251,9 @@
19059=Musisz poczekać kilka sekund, zanim będziesz mógł przywołać swojego zwierzaka.
19060=Kryształowa Kula wypełnia się zieloną mgłą. Twoje zwierzę zostało wezwane.
19061=połączone zwierzę:
19062=Ta kryształowa kula nie jest już powiązana ze zwierzakiem.
19063=Nowa nazwa zwierzaka to: %s
19064=Wygląda na to, że to nie jest prawidłowe zwierzę.
}
// Clothing Bless Deed
19001=Wybierz element odzieży, który chcesz pobłogosławić.
Expand Down
3 changes: 3 additions & 0 deletions data/dictionaries/dictionary.PTG
Original file line number Diff line number Diff line change
Expand Up @@ -5256,5 +5256,8 @@
19059=Você deve esperar alguns segundos antes de invocar seu animal de estimação.
19060=A Bola de Cristal se enche de uma névoa verde. Seu animal de estimação foi convocado.
19061=animal de estimação vinculado:
19062=Esta bola de cristal não está mais vinculada a um animal de estimação.
19063=O novo nome do animal de estimação é: %s
19064=Esse não parece ser um animal de estimação válido.
}
EOF
3 changes: 3 additions & 0 deletions data/dictionaries/dictionary.SPA
Original file line number Diff line number Diff line change
Expand Up @@ -5256,5 +5256,8 @@
19059=Debes esperar unos segundos antes de poder convocar a tu mascota.
19060=La Bola de Cristal se llena de una niebla verde. Tu mascota ha sido convocada.
19061=mascota vinculada:
19062=Esta bola de cristal ya no está vinculada a una mascota.
19063=El nuevo nombre de la mascota es: %s
19064=Esa no parece ser una mascota válida.
}
EOF
3 changes: 3 additions & 0 deletions data/dictionaries/dictionary.ZRO
Original file line number Diff line number Diff line change
Expand Up @@ -5251,5 +5251,8 @@
19059=You must wait a few seconds before you can summon your pet.
19060=The Crystal Ball fills with a green mist. Your pet has been summoned.
19061=linked pet:
19062=This crystal ball is no longer linked to a pet.
19063=The new name of the pet is: %s
19064=That does not seem to be a valid pet.
}
EOF
128 changes: 128 additions & 0 deletions data/js/item/ballofpetsummoning.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,132 @@ function onTimer( iUsed, timerID )
}
}

function onContextMenuRequest( socket, targObj )
{
var Pet = CalcCharFromSer(parseInt( targObj.GetTag( "petSerial" )));
// handle your own packet with context menu here
var pUser = socket.currentChar;
var offset = 12;
if( ValidateObject( Pet ))
{
var numEntries = 3;
}
else
{
var numEntries = 1;
}

// Prepare packet
var toSend = new Packet();
var packetLen = ( 12 + ( numEntries * 8 ));
toSend.ReserveSize( packetLen );
toSend.WriteByte( 0, 0xBF );
toSend.WriteShort( 1, packetLen );
toSend.WriteShort( 3, 0x14); // subCmd
toSend.WriteShort( 5, 0x0001); // 0x0001 for 2D client, 0x0002 for KR (maybe this needs to be 0x0002?)
toSend.WriteLong( 7, targObj.serial );
toSend.WriteByte( 11, numEntries ); // Number of entries

if( ValidateObject( Pet ))
{
toSend.WriteShort( offset, 0x000a ); // Unique ID
toSend.WriteShort( offset += 2, 6181 ); // summon pet
toSend.WriteShort( offset += 2, 0x0020 ); // Flag, color enabled
toSend.WriteShort( offset += 2, 0x03E0 ); // Hue of text

offset += 2; // for each additional entry

toSend.WriteShort( offset, 0x000b ); // Unique ID
toSend.WriteShort( offset += 2, 6183 ); // update pet name
toSend.WriteShort( offset += 2, 0x0020 ); // Flag, color enabled
toSend.WriteShort( offset += 2, 0x03E0 ); // Hue of text

offset += 2; // for each additional entry

toSend.WriteShort( offset, 0x000c ); // Unique ID
toSend.WriteShort( offset += 2, 6182 ); //unlink
toSend.WriteShort( offset += 2, 0x0020 ); // Flag, color enabled
toSend.WriteShort( offset += 2, 0x03E0 ); // Hue of text
}
else
{

toSend.WriteShort( offset, 0x000a ); // Unique ID
toSend.WriteShort( offset += 2, 6180 ); // summon pet
toSend.WriteShort( offset += 2, 0x0020 ); // Flag, color enabled
toSend.WriteShort( offset += 2, 0x03E0 ); // Hue of text
}

//Send packet
socket.Send( toSend );
toSend.Free();

return false;
}

function onContextMenuSelect( socket, targObj, popupEntry )
{
var Pet = CalcCharFromSer( parseInt( targObj.GetTag( "petSerial" )));
var pUser = socket.currentChar;
// Handle checking popupEntry here, to make sure it matches one of the context menu options sent in custom packet in onContextMenuRequest
switch( popupEntry )
{
case 10:
if( ValidateObject( Pet ))
{
SummonPet( pUser, targObj );
}
else
{
socket.tempObj = targObj;
socket.CustomTarget( 0, GetDictionaryEntry( 19050, socket.language ));// Target your pet that you wish to link to this Crystal Ball of Pet Summoning.
}
break;
case 11:
pUser.SpeechInput( 1, Pet );
targObj.Refresh();
break;
case 12:
socket.SysMessage( GetDictionaryEntry( 19062, socket.language )); // This crystal ball is no longer linked to a pet.
targObj.SetTag( "petSerial", null );
targObj.SetTag( "linked", null );
break;
}
return false;
}

function onSpeechInput( pUser, targObj, pSpeech, pSpeechID )
{
var pSocket = pUser.socket;
if( pSpeech == null || pSpeech == " " )
{
pSocket.SysMessage( GetDictionaryEntry( 9270, pSocket.language )); // That name is too short, or no name was entered.
return;
}

switch( pSpeechID )
{
case 1: // Rename Pet
if( pSpeech.length > 50 )
{
pSocket.SysMessage( GetDictionaryEntry( 9271, pSocket.language )); // That name is too long. Maximum 50 chars.
return;
}

if( ValidateObject( targObj ))
{
targObj.name = pSpeech;
var tempMsg = GetDictionaryEntry( 19063, socket.language ); // The new name of the Pet is: %s
pSocket.SysMessage( tempMsg.replace( /%s/gi, targObj.name ));
}
else
{
pSocket.SysMessage( GetDictionaryEntry( 19064, socket.language )); // That does not seem to be a valid pet.
}
break;
default:
break;
}
}

function _restorecontext_() { }

0 comments on commit 48f1e64

Please sign in to comment.