Is it possible to make an EC command script for this please?

We have a 'target injured' party member or follower. But what if I see someone struggling and want to just go in and slap a bandy to help? He's not in party, he's just some random blue. Is there a way to make a command script to target injured friendly?  I've tried 'nearest friendly' but if there are 2 people, it can't tell which one to target, and if they're neck deep in spawn, targeting manually isn't always quick enough to save them from death.

Comments

  • Arnold7Arnold7 Posts: 1,291
    I have problems with this too.  Had to target any specific player or monster when the action gets hot.  Sometimes in EC I use the control shift keys to display all the names and try to click-on the name.
  • KhyroKhyro Posts: 227
    edited May 2022
    Not sure about only using command scripts, but if you are comfortable making changes to the UI files, it's pretty easy to add:

    Edit your Actions.lua file, and add the following to the file (can be anywhere, bottom is fine):
    function Actions.InjuredFriendly()
    	local lowerId = 0
    	local lowerHP = -1
    	for i = 1, table.getn(MobilesOnScreen.MobilesSort) do
    		local mobileId = MobilesOnScreen.MobilesSort[i]
    		local data = WindowData.MobileName[mobileId]
    		local noto = data.Notoriety+1
    		if (Actions.TargetAllowed(mobileId) and not IsPartyMember(mobileId) and noto == NameColor.Notoriety.INNOCENT) then
    			local mobileData = Interface.GetMobileData(mobileId, true)
    			if mobileData then
    				local curHealth = mobileData.CurrentHealth
    				if (curHealth < 25) then				
    					if curHealth < lowerHP or lowerHP == -1 then
    						lowerHP = curHealth
    						lowerId = mobileId
    					end
    				end
    			end
    		end
    	end
    	
    	if (lowerId ~= 0) then
    		HandleSingleLeftClkTarget(lowerId)
    	end
    end

    Then create a Macro with a command block for this:

    script Actions.InjuredFriendly()
    This will target the most critically injured blue mobile near you that isn't in your party. It scans the blue mobiles bars, so they must be enabled.

    You can add this to the targeting action window as well if you want so you don't have to use a Command block each time.

    Edit ActionsWindow.lua

    Go to line 274 and after "ActionsWindow.ActionData[5207]" add the following line:

    ActionsWindow.ActionData[5208] = { type=SystemData.UserAction.TYPE_SPEECH_USER_COMMAND,			inActionWindow=true, iconId=865002, detailString=L"Targest Lowest Health Friendly", nameString=L"Target Injured Friendly", callback=L"script Actions.InjuredFriendly()" }
    Then go down to what should now be line 441, which has "ActionsWindow.Groups[6]", and in the number index on that line, add 5208 to the list:

    ActionsWindow.Groups[6]  = { nameString=L"Targeting",				nameTid=1079383, index={ 55, 22, 71, 77, 23, 72, 78, 24, 73, 79, 69, 74, 80, 70, 75, 81, 25, 76, 82, 11, 5200, 5201, 5202, 5203, 5204, 5205, 5206, 5207, 5208 } }
    This should put this new targeting action in the Actions list under Targeting

    https://www.uo-cah.com
    Home of the Pet Intensity Calculator, Pet Planner, Trainable Animal Bestiary, and other Tools, Guides, and Information. 

  • YoshiYoshi Posts: 3,322
    edited May 2022
    “(In pvp they use a similar script, but they exclude pets as a target, as you don’t want your guild mate healing your mount instead of you, but for trammel you guys probably don’t need to add such exclusions.)

    you might want to exclude poisoned or mortalled targets though unless you’re using cleansing winds, or get it to hold until target is no longer poisoned or mortalled so you don’t have to recast”


    Posts on this account have been pre filtered from personal comment or opinion in an effort to suppress conservative views in order to protect the reader.
  • Petra_FydePetra_Fyde Posts: 1,321
    @Khyro For clarification. To do as you suggest I will need to copy the Actions.lua file into the UI folder I created for my icons? and re-copy, re-edit when there is a new publish in order to stay current?
    Currently that folder looks like this: C:\Program Files (x86)\Electronic Arts\Ultima Online Enhanced\UserInterface\petra\Icons\Macro Icons\Numbers
    I think I need to add a folder called 'source' and put the copied file into that?
  • Arroth_ThaielArroth_Thaiel Posts: 1,020
    edited May 2022
    @Khyro

    Hope you don't mind, I'm going to add the following.

    @Petra_Fyde
    Directory Structure

    ...\UserInterface\petra
    -----\Icons...
    -----\Source
    ----------Actions.lua


    With this setup, you would need to call the function with the script Khyro described above using the Action>Command.

    You only need to make the edit to Actions.lua once. The only time you would need to update it, would be if the dev team updates the Actions.lua in the default directory and you want to incorporate whatever change they have made, or they changed something about the way they called the file and you had to perform the edit a second time.

    I have very rarely run into updates that required mod changes. Once in awhile you may have to load with default, log out, and then reload with your mod, but that is just selecting from the drop down list at the login screen.


    --
    If you want to have the function appear in the Actions widow, rather than calling it from the Action>Command, then follow the second set of instructions. Directory structure would look like this.

    ...\UserInterface\petra
    -----\Icons...
    -----\Source
    ----------Actions.lua
    ----------ActionsWindow.lua


    If you want to add a custom icon you can. Create your icon and follow the steps I laid out for you in the icons thread: add the icon and assign the icon a number in Icons.xml and if you want Macropicker.lua. 

    Let's say you added the icon to Icons.xml as 900001.
    Modify the line:
    ActionsWindow.ActionData[5208]...

    to read:
    ActionsWindow.ActionData[900001]...


    Now your custom icon will also appear in the actions window.


    --
    If you want to change the numbers at which the targeting takes place, the following two lines control that operation.

    curHealth < 25
    local lowerHP = -1


    curHealth < 50 =  will target below 50 HP
    local lowerHP = -10 will target if you have 10 less than maximum hitpoints (90/100)

    I believe these are direct values and not percentages, but I could be wrong. Working from memory. 


    --
    As for what Yoshi is suggesting, you should be able to add those exemptions following the,

    if (Actions.TargetAllowed....

    with "and not" follower, poisoned, etc., but I don't remember the actual calls off the top of my head. You can probably find these yourself in the Actions.lua by examining the other similar functions, there is one that excludes (or includes) followers, so you could just copy paste from there (Target severly injured follower I think...???).  

    --

    Welcome to modding the EC. It can get as complicated as you want to make it. :)
    It's addictive though. 
    -Arroth
  • KhyroKhyro Posts: 227
    Just 2 points of clarification:
    curHealth < 25
    Health is returned by the server in blocks of 4%, so that above line is making sure only damaged mobiles will be scanned. A value of 25 is 100% health (25*4).

    lowerHP = -1
    lowerHP stores the current lowest health value scanned. It starts -1 to indicate there is currently no mobile stored. So it starts -1 until it finds a mobile that is not 100% health, then stores that value as it loops through, until it finds the lowest health mobile visible.

    If you want to excluded pets, change this line:
    if (Actions.TargetAllowed(mobileId) and not IsPartyMember(mobileId) and noto == NameColor.Notoriety.INNOCENT) then

    to this:

    if (Actions.TargetAllowed(mobileId) and not IsPartyMember(mobileId) and noto == NameColor.Notoriety.INNOCENT and not MobilesOnScreen.IsPet(mobileId)) then
    https://www.uo-cah.com
    Home of the Pet Intensity Calculator, Pet Planner, Trainable Animal Bestiary, and other Tools, Guides, and Information. 

  • Arroth_ThaielArroth_Thaiel Posts: 1,020
    Too early in the morning to be working from memory. Thanks for the clarification Khyro.
    -Arroth
  • Petra_FydePetra_Fyde Posts: 1,321
    edited May 2022
    Thank you both :) I have made the edit to just the one file, and used the command for the other part. It seems to be working, but I've not had the opportunity to use it other than testing on my 'traveller' char in the house. 
    So far I've stuck with the original plan for icons, overwriting the numbers. Number 11 now looks like this:
     
    This is the 'gif' version, just in case anyone else wants to use it. Obviously it needs to be .dds to actually work in game

    Yoshi failed to notice that the intended macro is not for casting a spell, but for applying a bandage. 
  • SethSeth Posts: 2,904
    edited May 2022
    @Mariah Is it possible to ask @Mesanna to create a wiki page or section for custom EC codes like this. So that the effort spent n writing these will be useful and easy to find in future. 

    It's easy to create a bank page and url, it's easy to copy and paste. But it takes relatively more time to write useful stuff which ends up buried with the other less useful discussions in this forum.
    If it ain't broke, don't fix it. 
    ESRB warning: Some Blood. LOTS of Alcohol. Some Violence. LOTS of Bugs
  • Victim_Of_SiegeVictim_Of_Siege Posts: 1,797
    Bunch of Scripters . . .
    A Goblin, a Gargoyle, and a Drow walk into a bar . . .

    Never be afraid to challenge the status quo

  • MariahMariah Posts: 2,943Moderator
    I can add it too this page? or create a page linked to it. I did ask people to submit macros for both clients, but didn't get much response.
  • Petra_FydePetra_Fyde Posts: 1,321
    k, I have a further question. After using the macro last night, I was confused by sometimes getting the 'cannot perform beneficial acts' message.  I'm looking through the actions.lua and, while I don't understand the thing at all, I wonder if the piece I added should be more like the 'party member' entry that has a line if (mobileId ~= WindowData.PlayerStatus.PlayerId) then ? 
    Any thoughts?
  • SethSeth Posts: 2,904
    edited May 2022
    Mariah said:
    I can add it too this page? or create a page linked to it. I did ask people to submit macros for both clients, but didn't get much response.
    Add to which page?
    I think it's alright to add to a wiki page, as when and when players like Arroth or Khyro post them, like some of the earlier posts in the bugs or here. We resolved some of the EC client issues by ourselves. I think I kept my own notes in Evernote. 
    If it ain't broke, don't fix it. 
    ESRB warning: Some Blood. LOTS of Alcohol. Some Violence. LOTS of Bugs
  • SethSeth Posts: 2,904
    Bunch of Scripters . . .
     B) 
    If it ain't broke, don't fix it. 
    ESRB warning: Some Blood. LOTS of Alcohol. Some Violence. LOTS of Bugs
  • MariahMariah Posts: 2,943Moderator
    Seth said:
    Mariah said:
    I can add it too this page? or create a page linked to it. I did ask people to submit macros for both clients, but didn't get much response.
    Add to which page?
    I think it's alright to add to a wiki page, as when and when players like Arroth or Khyro post them, like some of the earlier posts in the bugs or here. We resolved some of the EC client issues by ourselves. I think I kept my own notes in Evernote. 


    if you'd like to link me to other threads containing such info, I'll see what I can do. It seems this one might need a bit of adjustment.


  • KHANKHAN Posts: 510
    WOW! If I have to start making "scripts" (legal or not) just to play the game, it might be time for me to start shutting down accounts! There is a big difference in whatever this is, and simply making a macro. Just my opinion.
    If you sell UO items for R.L. $$$, you need to quit playing UO , and get a BETTER R.L. JOB!
  • keven2002keven2002 Posts: 2,081
    KHAN said:
    WOW! If I have to start making "scripts" (legal or not) just to play the game, it might be time for me to start shutting down accounts! There is a big difference in whatever this is, and simply making a macro. Just my opinion.
    Yea I was thinking the same thing about the complexity of the "macro" provided versus what we were creating 20 years ago.

    I was a bit intrigued that this is something that could be scripted and thought maybe I should try it myself but kind of lost focus about 10 lines into it after thinking how long it would take me to create some of these scripts myself. 
  • PawainPawain Posts: 8,972
    Ya while sitting at Whataburger, I am reading the internet, ordered a canopy from academy for vacation next week, paid for it.  Got an email saying it's ready.

    Amazing what we can do with computers.
    Focus on what you can do, not what you can't.
  • Petra_FydePetra_Fyde Posts: 1,321
    KHAN said:
    WOW! If I have to start making "scripts" (legal or not) just to play the game, it might be time for me to start shutting down accounts! There is a big difference in whatever this is, and simply making a macro. Just my opinion.
    Command scripts have been possible in EC since its launch, if you look you can find examples on Stratics going back to 2009. No one says you have to start making them. You can play just fine without them.  I just wanted to know if I could make something for this single purpose.
  • TimStTimSt Posts: 1,779
    Think of these as user provided fixes and enhancements the devs could make if they had the time to.
  • SethSeth Posts: 2,904
    Because the Dev team is too busy, we already made some changes to the client ourselves to solve certain bugs. 

    These EC scripts are useful for those who feel Pinco is too heavy.

    I dont think we are looking at automated, afk or macro scripts where we can go to bed while the toon craft, hunt and collect stuff.  :D
    If it ain't broke, don't fix it. 
    ESRB warning: Some Blood. LOTS of Alcohol. Some Violence. LOTS of Bugs
Sign In or Register to comment.