if a player presses a button....

Whisp_Rush

Active Member
Reaction score
0
Hi everybody!
I have an rpg map, and I want the following: If you want to cast a healing spell (holy light for example), first you click on the spell, and then you have to select a target.... now, aside from selecting a friendly target by clicking on it with the mouse, I'd like to do it by pressing a button (V for example).... But this button wolud select the friendly unit with the lowest health in the range of holy light....
an example: in my map, everyone controls only one unit.... I am a healer.... in place of finding which character has the lowest life, I click on holy light, then I press V, and automatically it selects the lowest healthed friendly unit in range as a target and ti heals....
could anyone help me?
thankss
:thup:
 

hopy

Active Member
Reaction score
64
First of all I would like to say that I very much like the idea, if you'd allow it I would like to make a version of this in my map, and I'll add your name to the credits ofcourse.

Now I'm not sure how you're supposed to make the "When pressed V" button, since there's no way to detect a button being pressed, as far as I know.
Also I think:
Trigger:
  • Game - The 'Hero Abilities' button is clicked

Would only count for the "Learn abilities button" a hero has to spend skill points, the thing with the hotkey O in standard maps. Maybe with JASS there's a way to detect this, but most likely people will reply with "JASS is not magic" or some thing like that.

But I can help with the "Select lowest health unit" part I think... atleast one of the ways to do this, I don't know if it's the best way to do it but it's the best way I can think of.

Trigger:
  • Auto-Holy Light
    • Events
    • Conditions
    • Actions
      • Set Point = (Position of (Triggering unit))
      • Set Unit = (Triggering unit)
      • Set Unit_Group = (Units within 600.00 of Point matching ((((Triggering unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True) and ((Triggering unit) Not equal to (Triggering unit))))
      • Unit Group - Pick every unit in Unit_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Picked unit)) Less than (Life of Unit)
            • Then - Actions
              • Set Unit = (Picked unit)
            • Else - Actions
      • Unit - Order (Triggering unit) to Human Paladin - Holy Light Unit
      • Custom script: call RemoveLocation (udg_Point)
      • Custom script: call DestroyGroup (udg_Unit_Group)

Basicly what this does is place the hero in Unit, and than check for every unit close to the hero if its health is less than Unit's health and replace the hero with the unit if that's the case.

I'm very sorry I couldn't be of any help with the main part of the question, and I know anyone that can help you with that can also easily create the above trigger...
 

Rouge

New Member
Reaction score
0
Hmm..

Maybe, If you set it so a sub skill with a different hot key this would be possible... A Sub Skill It would automaticly target the lowest unit health,
 

Jedi

New Member
Reaction score
63

I think everything we need is a dummy ability(which based on channel and instant(no target)).When a unit starts effect of this dummy ability, find unit with lowest health and cast him holy light.V is the hotkey of the dummy ability.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
@ hopy: You shouldn't use (Triggering unit) as the first value of the variable "Unit", but some very high number, like 9999999.0 as there can be units with higher life than that unit ;)

@ Whisp_Rush: Just a thought, wouldn't it be better to select the unit with the least percentage life, as if there are two allies around the caster and one has 200 max health and also has max health, and another hero has 2000 max health but is down at 300 then it would be better to heal that hero, right ? :eek: :S
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, if you want that ability to be able to heal the caster, then don't mind what I said to 'hopy'... XD

Do you ?
 

Whisp_Rush

Active Member
Reaction score
0
First of all I would like to say that I very much like the idea, if you'd allow it I would like to make a version of this in my map, and I'll add your name to the credits ofcourse.

Now I'm not sure how you're supposed to make the "When pressed V" button, since there's no way to detect a button being pressed, as far as I know.
Also I think:
Trigger:
  • Game - The 'Hero Abilities' button is clicked

Would only count for the "Learn abilities button" a hero has to spend skill points, the thing with the hotkey O in standard maps. Maybe with JASS there's a way to detect this, but most likely people will reply with "JASS is not magic" or some thing like that.

But I can help with the "Select lowest health unit" part I think... atleast one of the ways to do this, I don't know if it's the best way to do it but it's the best way I can think of.

Trigger:
  • Auto-Holy Light
    • Events
    • Conditions
    • Actions
      • Set Point = (Position of (Triggering unit))
      • Set Unit = (Triggering unit)
      • Set Unit_Group = (Units within 600.00 of Point matching ((((Triggering unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True) and ((Triggering unit) Not equal to (Triggering unit))))
      • Unit Group - Pick every unit in Unit_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Picked unit)) Less than (Life of Unit)
            • Then - Actions
              • Set Unit = (Picked unit)
            • Else - Actions
      • Unit - Order (Triggering unit) to Human Paladin - Holy Light Unit
      • Custom script: call RemoveLocation (udg_Point)
      • Custom script: call DestroyGroup (udg_Unit_Group)

Basicly what this does is place the hero in Unit, and than check for every unit close to the hero if its health is less than Unit's health and replace the hero with the unit if that's the case.

I'm very sorry I couldn't be of any help with the main part of the question, and I know anyone that can help you with that can also easily create the above trigger...

ehm, okay, I've made this and I understand it.... but does it supposed to work? because for me, it doesn't do anything..... if we can't make the targeting by pressing V, it doesn't matter, then it's okay if you click on holy light and it targets automatically the lowest healthed friendly caracter.... ah and I think lowest health is not good, because for example a warrior character basically have 800 health and a wizzard 450.... so if the wizzard has 350, and the warrior 400, the more logical thing is to heal the warrior.... but the wizzard has lesser health than the warrior, so the spell will heal the wizzard... so if there is anything like "unit with the least percentage of life" should be better then unit with the lowest life....
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Use this then ;)

Trigger:
  • Actions
    • Set TempPoint = (Position of (Triggering unit))
    • Set TempGroup = (Units within 512.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True) and ((Matching unit) Not equal to (Triggering unit)))))
    • Set TempUnit = (Random unit from TempGroup)
    • Set TempReal = (Percentage life of TempUnit)
    • Unit Group - Pick every unit in TempGroup and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Percentage life of (Picked unit)) Less than TempReal
          • Then - Actions
            • Set TempUnit = (Picked unit)
            • Set TempReal = (Percentage life of (Picked unit))
          • Else - Actions
    • Custom script: call DestroyGroup(udg_TempGroup)
    • Custom script: call RemoveLocation(udg_TempPoint)
 

Jedi

New Member
Reaction score
63
Trigger:
  • Set TempGroup = (Units within 512.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True) and ((Matching unit) Equal to (Triggering unit)))))
Matching unit NOT equal to triggering unit :p
 

Whisp_Rush

Active Member
Reaction score
0
this part is okay.... but the spell still doesn't work... I was thinking of it, and it's not necesary to do the targeting by pressing a button.... it's better if you press holy light, and then it selects the friendly target with the lowest percentage of helath.... is it possible?
please help me if you can
:thup:
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Just add the event "Unit - A unit Starts the effect of an ability" and the condition "(Ability being cast) Equal to Holy Light" and that should work fine :D

But you shouldn't base the spell on Holy Light but make a new spell based on something like Thunder Clap so you won't have to target a unit :D
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
or on channel since channel suits this sort of ability type perfectly fine in 90% of all cases.
 

Whisp_Rush

Active Member
Reaction score
0
sorry, I'm pretty noob with this yet, I tried to make it but I couldn't Thunder clap isn't a healing spell and I don't know how to make it..... sorry, I don't want to annoy you, so much, but if you have some time, could you make it to me on a map? I would be very very grateful :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top