Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legion Scripting #275

Merged
merged 70 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
db22aac
Initial LScript commit
bittiez Nov 26, 2024
95d114f
Move execution status to script to prepare for multiple scripts running
bittiez Nov 26, 2024
9ffe041
Add load, unload and update calls
bittiez Nov 26, 2024
f8af79b
Add lscript command, msg command working
bittiez Nov 26, 2024
b3b779c
Update default aliases
bittiez Nov 26, 2024
5c1303b
Update LScript.md
bittiez Nov 26, 2024
2dd80ef
Add a bunch of default vars(mana, hits, etc)
bittiez Nov 26, 2024
1a25ac4
Update LScript.md
bittiez Nov 26, 2024
2eb6d8d
Add stam, hits and maxstam, maxhits default values
bittiez Nov 27, 2024
3d92753
Added several commands
bittiez Nov 27, 2024
0743a78
Add loading and playing scripts from files
bittiez Nov 27, 2024
ff580d9
Update bandaging
bittiez Nov 27, 2024
98f09d6
Added target, waitfortarget, and usetype commands
bittiez Nov 27, 2024
2446a6d
Add simple script play and stop gump
bittiez Nov 29, 2024
7898d3f
Added useskill, walk, run, canceltarget, and sysmsg commands
bittiez Nov 29, 2024
4da5ee7
Added moveitem, moveitemoffset, cast, and waitforjournal commands
bittiez Nov 30, 2024
f1afd86
Fix scrollbar positioning
bittiez Nov 30, 2024
f208d19
Add timers and true/false values
bittiez Dec 1, 2024
8b41807
Update LegionScripting.cs
bittiez Dec 1, 2024
60cd36d
Reload scripts on opening script managing gump
bittiez Dec 1, 2024
501e8af
Start work on script editor gump
bittiez Dec 1, 2024
622ab46
Update LScript.md
bittiez Dec 2, 2024
734b28c
Update ScriptEditor.cs
bittiez Dec 2, 2024
d2158c6
Add setalias, unsetalias, movetype
bittiez Dec 2, 2024
35a7b5f
Added findtype and anycolor
bittiez Dec 2, 2024
ce1a15d
Commit utility
bittiez Dec 2, 2024
4b388f9
Added findalias, skill
bittiez Dec 2, 2024
4d124c1
Added removetimer, msg, toggleautoloot, poisoned, war
bittiez Dec 2, 2024
14f668c
Fix scripts running without being able to stop them in background
bittiez Dec 2, 2024
d655327
Update LegionScripting.cs
bittiez Dec 2, 2024
65b3f19
Fix findtype and moveitem
bittiez Dec 2, 2024
8d5674b
Added info, setskill, contents, findobject, distance
bittiez Dec 2, 2024
1695617
Add legion scripting to top bar
bittiez Dec 2, 2024
0dfbe7e
Update CounterBarGump.cs
bittiez Dec 2, 2024
de5b080
Added injournal, inparty, property and getproperties
bittiez Dec 2, 2024
f7a3bad
Added buffexists and findlayer expressions
bittiez Dec 3, 2024
2234236
Added gumpexists, listcount, listexists, inlist
bittiez Dec 3, 2024
724e391
Added turn, createlist
bittiez Dec 3, 2024
6a29c77
Add pushlist, rename, logout and stop scripts on logout
bittiez Dec 3, 2024
29769f0
Added nearesthostile, counttype, shownames, removelist
bittiez Dec 4, 2024
942308e
Added dead expression
bittiez Dec 4, 2024
a8df8eb
Added togglehands, equipitem, togglemounted, promptalias, waitforgump
bittiez Dec 5, 2024
bcc4b21
Added replygump, closegump, clearjournal, poplist, ping
bittiez Dec 5, 2024
3003147
Redo usetype
bittiez Dec 5, 2024
46648ab
Enable auto start for scripts
bittiez Dec 5, 2024
67e3a97
UI changes to script manager gump
bittiez Dec 5, 2024
556df28
Fix nearesthostile, dead
bittiez Dec 5, 2024
d23cc1b
Many improvements to the in-game editor
bittiez Dec 6, 2024
f6b79f3
Add targettilerel, edit external button, add itemamt
bittiez Dec 6, 2024
6918010
Added str, dex, int, diffhits, findtypelist, added followers, maxfoll…
bittiez Dec 6, 2024
4f2dcdf
Add public script browser
bittiez Dec 6, 2024
14a9dc0
Add back button to browser
bittiez Dec 6, 2024
fc9b9cf
Add setinscreen command to fix gumps out of bounds
bittiez Dec 8, 2024
f9fd3e5
Remove some usings not in use
bittiez Dec 8, 2024
12ca3c3
- Remove script browser
bittiez Dec 8, 2024
01e2038
Added virtue, primaryabilityactive, secondaryabilityactive, mounted, …
bittiez Dec 8, 2024
74ffb59
Refactoring
bittiez Dec 8, 2024
a5b9821
Added playmacro, headmsg, partymsg, allymsg, guildmsg, whispermsg, ye…
bittiez Dec 8, 2024
fad871c
Added cncelprompt, prompresponse, contextmenu
bittiez Dec 8, 2024
7644276
Added clearignorelist, ignoreobject
bittiez Dec 8, 2024
5012cdc
Add ignoreobject, clearignorelist, minor fixes, script manger gump re…
bittiez Dec 9, 2024
9168877
Add script groups
bittiez Dec 10, 2024
098cf07
Remove new button, and reposition refresh button
bittiez Dec 11, 2024
c6d83ed
Added goto, return
bittiez Dec 11, 2024
0dc6fe3
Merge branch 'dev' of https://github.com/jsebold666/TazUO into legion…
bittiez Dec 11, 2024
71a80fc
Add follow
bittiez Dec 11, 2024
c9290e8
Add pathfind, cancelpathfind, pathfinding
bittiez Dec 13, 2024
02edc9d
Merge branch 'dev' of https://github.com/jsebold666/TazUO into legion…
bittiez Dec 13, 2024
3dcf7c8
Fix findalias, and foreach loops of serial lists
bittiez Dec 13, 2024
22aff79
Updated hits, maxhits, and diffhits to support a serial paramater
bittiez Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ClassicUO.Client/Configuration/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,9 @@ public List<Gump> ReadGumps(string path)
case GumpType.DurabilityGump:
gump = new DurabilitysGump();
break;
case GumpType.ScriptManager:
gump = new LegionScripting.ScriptManagerGump();
break;
}

if (gump == null)
Expand Down
61 changes: 51 additions & 10 deletions src/ClassicUO.Client/Game/GameActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public static void OpenStatusBar()
/// <returns>False if no status gump open</returns>
public static bool CloseStatusBar()
{
Gump g = StatusGumpBase.GetStatusGump();
Gump g = StatusGumpBase.GetStatusGump();
if (g != null)
{
g.Dispose();
Expand Down Expand Up @@ -929,6 +929,23 @@ public static void CastSpell(int index)
}
}

/// <summary>
///
/// </summary>
/// <param name="name">Can be a partial match</param>
public static bool CastSpellByName(string name)
{
name = name.Trim();

if (!string.IsNullOrEmpty(name) && SpellDefinition.TryGetSpellFromName(name, out var spellDef))
{
CastSpell(spellDef.ID);
return true;
}

return false;
}

public static void OpenGuildGump()
{
Socket.Send_GuildMenuRequest();
Expand All @@ -944,6 +961,20 @@ public static void Rename(uint serial, string name)
Socket.Send_RenameRequest(serial, name);
}

public static void Logout()
{
if ((World.ClientFeatures.Flags & CharacterListFlags.CLF_OWERWRITE_CONFIGURATION_BUTTON) != 0)
{
Client.Game.GetScene<GameScene>().DisconnectionRequested = true;
NetClient.Socket.Send_LogoutNotification();
}
else
{
NetClient.Socket.Disconnect();
Client.Game.SetScene(new LoginScene());
}
}

public static void UseSkill(int index)
{
if (index >= 0)
Expand Down Expand Up @@ -1090,7 +1121,7 @@ public static void QuestArrow(bool rightClick)
Socket.Send_ClickQuestArrow(rightClick);
}

public static void GrabItem(uint serial, ushort amount, uint bag = 0)
public static void GrabItem(uint serial, ushort amount, uint bag = 0, bool stack = true)
{
//Socket.Send(new PPickUpRequest(serial, amount));

Expand All @@ -1115,14 +1146,24 @@ public static void GrabItem(uint serial, ushort amount, uint bag = 0)

PickUp(serial, 0, 0, amount);

DropItem
(
serial,
0xFFFF,
0xFFFF,
0,
bag
);
if (stack)
DropItem
(
serial,
0xFFFF,
0xFFFF,
0,
bag
);
else
DropItem
(
serial,
0,
0,
0,
bag
);
}
}
}
3 changes: 3 additions & 0 deletions src/ClassicUO.Client/Game/GameObjects/PlayerMobile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public PlayerMobile(uint serial) : base(serial)
public ref Ability SecondaryAbility => ref Abilities[1];
protected override bool IsWalking => LastStepTime > Time.Ticks - Constants.PLAYER_WALKING_DELAY;

public bool HasGump { get; set; }
public uint LastGumpID { get; set; }

internal WalkerManager Walker { get; } = new WalkerManager();
public Ability[] Abilities = new Ability[2]
{
Expand Down
13 changes: 13 additions & 0 deletions src/ClassicUO.Client/Game/Managers/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,19 @@ public static void Initialize()
{
Task.Run(SpellDefinition.SaveAllSpellsToJson);
});

Register("setinscreen", (s) =>
{
for (LinkedListNode<Gump> last = UIManager.Gumps.Last; last != null; last = last.Previous)
{
Gump c = last.Value;

if (!c.IsDisposed)
{
c.SetInScreen();
}
}
});
}


Expand Down
15 changes: 15 additions & 0 deletions src/ClassicUO.Client/Game/Managers/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,21 @@ public static Gump GetGump(uint serial)
return null;
}

public static Gump GetGumpServer(uint serial)
{
for (LinkedListNode<Gump> last = Gumps.Last; last != null; last = last.Previous)
{
Control c = last.Value;

if (!c.IsDisposed && c.ServerSerial == serial)
{
return c as Gump;
}
}

return null;
}

public static TradingGump GetTradingGump(uint serial)
{
for (LinkedListNode<Gump> g = Gumps.Last; g != null; g = g.Previous)
Expand Down
4 changes: 4 additions & 0 deletions src/ClassicUO.Client/Game/Scenes/GameScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ public override void Load()
{
XmlGumpHandler.TryAutoOpenByName(xml);
}

LegionScripting.LegionScripting.Init();
}

private void ChatOnMessageReceived(object sender, MessageEventArgs e)
Expand Down Expand Up @@ -359,6 +361,8 @@ public override void Unload()
return;
}

LegionScripting.LegionScripting.Unload();

ProfileManager.CurrentProfile.GameWindowPosition = new Point(
Camera.Bounds.X,
Camera.Bounds.Y
Expand Down
4 changes: 2 additions & 2 deletions src/ClassicUO.Client/Game/UI/Controls/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ public virtual Control SetInternalScale(double scale)
return this;
}

public void ForceSizeUpdate()
public void ForceSizeUpdate(bool onlyIfLarger = true)
{
int h = Height, w = Width;
int h = onlyIfLarger ? Height : 0, w = onlyIfLarger ? Width : 0;
for (int i = 0; i < Children.Count; i++)
{
Control c = Children[i];
Expand Down
4 changes: 2 additions & 2 deletions src/ClassicUO.Client/Game/UI/Controls/DataBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public DataBox(int x, int y, int w, int h)

public bool ContainsByBounds { get; set; }

public void ReArrangeChildren()
public void ReArrangeChildren(int vspacing = 0)
{
for (int i = 0, height = 0; i < Children.Count; ++i)
{
Expand All @@ -58,7 +58,7 @@ public void ReArrangeChildren()
{
c.Y = height;

height += c.Height;
height += c.Height + vspacing;
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/ClassicUO.Client/Game/UI/Controls/ScrollArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ public override void SlowUpdate()
}
}

public void UpdateScrollbarPosition()
{
if (_isNormalScroll)
_scrollBar.X = Width - 14;
else
_scrollBar.X = Width - 19;
}

public int ScrollBarWidth()
{
if (_scrollBar == null)
Expand Down
Loading
Loading