• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Repair Item Help

Status
Not open for further replies.
Level 7
Joined
Sep 24, 2008
Messages
281
Hello, in my survival map, I wish to create a repair system. In order to repair something, you must have a repair kit, and either machinery supplies , or structure supplies (italics are items.)
So, if you are repairing machinery, you will use the repair kit click on the machinery, and begin repairing. Every 5 seconds of repairing, your machinery supplies (which holds ten charges) will lose 1 charge. After 50 seconds, you will be unable to repair anything unless you have any other supplies (this system is subject to change, but it gives you a general idea.)

The problem: would someone mind creating the repair kit item? I can't seem to figure anything out that would work properly. Thanks:grin:

System Update:
So, if you are repairing machinery, you will use the repair kit click on the machinery, and begin repairing. After 5 seconds of work, (nothing has occured yet) your machinery supplies (which holds ten charges) will lose 1 charge, and the machinery will be repaired by 10%. After 50 seconds, you will be unable to repair anything unless you have any other supplies (this system is subject to change, but it gives you a general idea.)
 
Last edited:
Level 10
Joined
Jan 28, 2009
Messages
442
Charges remaining represents an item's condition right?
You can make a trigger that says after you use the item set someBoolean = true. The next (repairable) item you click should trigger some actions if someBoolean = true. The actions should be something like Set RepairedItem = eventResponse_UsedItem. Then turn on a trigger that adds 1 charge to RepairedItem every 5 seconds.
Problem with this is that you can't see a casting cursor (crosshair) after clicking the repair kit.

I hope someone who knows better the system you're trying to make comes and gives you more appropriate advice.

Edit: Repairable is not an item-class or some classification. It's just something you decide. You can reserve an item-class for these items or specify via conditions in triggers which items are repairable. You don't need to lable them "repairable" anywhere.
 
Level 17
Joined
Jun 28, 2008
Messages
776
Just copy this to your map, its some jass code, I hope it works cuz I can't test it now.

JASS:
local unit u = GetOrderedUnit()
local unit n = GetOrderTarget()
local location p1 = null
local location p2 = null
loop

    set p1 = GetUnitLoc(u)
    set p2 = GetUnitLoc(n)
    
    exitwhen (DistanceBetweenPoints(p1, p2) > 100)
    exitwhen (GetItemCharges(GetItemOfTypeFromUnitBJ(u, 'Your Item Code')) == 0)
    
    call SetUnitState(n, UNIT_STATE_LIFE, GetUnitState(n, UNIT_STATE_LIFE) + 10) //Set the 10 to the healed hp
    call SetItemCharges(GetItemOfTypeFromUnitBJ(u, 'Your Item Code') - 1)
    
    call TriggerSleepAction(1)
    
    call RemoveLocation(p1)
    call RemoveLocation(p2)
    
endloop

to get item code just go to the object editor and select the item and press Ctrl + d

Hope it helps
 
Level 7
Joined
Sep 24, 2008
Messages
281
Just copy this to your map, its some jass code, I hope it works cuz I can't test it now.

JASS:
local unit u = GetOrderedUnit()
local unit n = GetOrderTarget()
local location p1 = null
local location p2 = null
loop

    set p1 = GetUnitLoc(u)
    set p2 = GetUnitLoc(n)
    
    exitwhen (DistanceBetweenPoints(p1, p2) > 100)
    exitwhen (GetItemCharges(GetItemOfTypeFromUnitBJ(u, 'Your Item Code')) == 0)
    
    call SetUnitState(n, UNIT_STATE_LIFE, GetUnitState(n, UNIT_STATE_LIFE) + 10) //Set the 10 to the healed hp
    call SetItemCharges(GetItemOfTypeFromUnitBJ(u, 'Your Item Code') - 1)
    
    call TriggerSleepAction(1)
    
    call RemoveLocation(p1)
    call RemoveLocation(p2)
    
endloop

to get item code just go to the object editor and select the item and press Ctrl + d

Hope it helps

Does anyone pay attention to what I ask? I can get the system working, but I can't get a decent "repair kit" item. I only require help on making that item, not the system...
 
Level 7
Joined
Sep 24, 2008
Messages
281
Okay, I've got just about everything working EXCEPT giving the building being repaired more health. What is it called? Event Response- Targeted Unit??? Target Unit of issued order??? I'm trying to get the unit that the hero used the item on.........
 
Level 7
Joined
Sep 24, 2008
Messages
281
Nvm, i made a map that uses it, you could customize the spell to use holy light or somthing, to say if it has full hp

Try this

Alright, however nothing seems to be working at all....My current version will be fine, I just need to know what the unit being cast upon is refered to as.
EDIT: OKAY SERIOUSLY WTF?????? HOW ON EARTH CAN I SET THE UNIT THAT THE ITEM WAS USED ON'S HEALTH TO IT's CURRENT HEALTH PLUS 10%????????????????????????? WHAT IS IT REFERED TO AS. IT IS NOT THE TARGETED UNIT, THE TARGET UNIT OF ISSUED ORDER, OR THE TARGET UNIT OF ABILITY BEING CAST. WHAT IS IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!???????????????????????
 
You cant make it use the Unit uses an item function it has to be
  • Untitled Trigger 001
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Repair
    • Actions
      • Unit - Set life of (Target unit of ability being cast) to ((Percentage life of (Target unit of ability being cast)) + 25.00)%
PS. i gave repair to the item, thats the dummy spell
And i accedentaly edited the map wrong, it should work now, try this
 
Status
Not open for further replies.
Top