• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Unit Life Linking, can it be done.

Status
Not open for further replies.
Level 7
Joined
Feb 15, 2005
Messages
183
Ok, I have been working on a map for quiet sometime on and off, its pretty cool but there is one aspect that I would really like to implement, but can't seem to find the proper triggers to do so.

Essentialy, what I want to happen is to have 2 units have linked life. If one unit takes damage, the linked unit takes the exact same damage and vica versa. I also wanted this to be the case with healing as well, if one unit is healed, then the link unit is also healed. The trouble is, I want it to all happen instantaneously. I have tried alot of triggers involved real compparisons and average life of the 2 unit's health, and they Kinda work, but its not as clean as I would like it to be. Any suggestions?
 
Level 7
Joined
Feb 15, 2005
Messages
183
I did think about the spiritlink ability, but that only mitigates damage, it doens't heal. And this is more of a trigger than a spell.

The idea behind the trigger is this. You can go into houses by using the "move" command on the house, you are then moved to a seperate location on the map which is enclosed and has a "door". People can attack the house unit on the main map, when they kill the house on the main map, everything inside the house is pushed outside onto the map. All these triggers work fine, but what I want the person inside the house to be able to repair his house from the inside, thereby making it much harder for the person to break in. So what i was thinking, is to make a "door" unit inside the house, that the person could repair, thus effecting the house on the map. Does that make any sense?

What i have tried to do, which works, is use the "set life to value" trigger and use arithmatic to set both the door and the house's life to an average of both the house and the door. It works, but its messy. It looks something like this

Event -
unit is attacked

Condition -
Unit type of triggering unit equal to house
Unit type of triggering unit is in region house00 equal to true

Action -
-If-
Triggering unit life not equal to at least 99% health
-Then-
-set life of triggering unit = to (life of triggering unit + life of door) / 2
-set life of door = to (life of triggering unit + life of door) / 2
-run this trigger checking conditions
-Else-
-do nothing


This is as close to a solution as I could get, and its pretty dicey.

I am having some other issues with this map I am working on, with multiplayer drops and such. I have done alot of testing of the trigger with the test map function, but when i try to get multiple people in there, they all drop consistantly. If anyone is willing or interested in taking a look at what i have done, i would be appreciative.

The map itself is unlike anything I have played on battle.net. Its almost like a sim, 4 teams, trying to take control of a town. 4 teams are divided into 4 religions that are trying to convert the town, what ever team does the best job of spread their religion wins (exact winning conditions have not been banged out, but that is the gist). You convert the people of the town, and you can send them to perform different tasks for your religion, you can send them to your temple to worship you (there by gaining your teams hero EXP) or you can send them to a house to work for you and earn you money as well as have kids, and finaly you can send them to the barracks to get armed in order to fight off or attack other religions. You can even go into other player's temples and slaughter their worshipers, thereby cutting off their exp, or you can go around destroying their houses, cutting off their population and growth. And all onto of this, there are different ranking citizens you can convert. It is very in depth and there is room for numerous amount of strat to be involved, especialy since you are working with 2 other team-mates.

Anyways, if that sounds at all interesting to anyone, or if anyone is interested in helping me with triggers i would be very greatful!
 
Level 7
Joined
Jul 30, 2004
Messages
451
i dunno, something i might try is setting (if its only pairs of units that have to be linked) one unit into an array of units and the other unit into another array, using the units custom value to index which other unit to affect
then add the event (unit takes damage) or whatever it is for all the units (dynamically if more linked units get created in due time) to some trigger that basically says
(set life of linkedunit[custom value of triggering unit] to life of triggering unit)
and in all cases you just use that notation to access what unit is linked to it

if you need more than pairs perhaps use an array of unit groups

another way i suppose, which is more OO using handle variables, would be to have a function that takes 2 units (or a unit group) and builds a new local trigger assigning the units to it as handle variables doing pretty much the same thing as before mentioned only it would be using trigger->unit1 and trigger->unit2 or trigger->unitgroup
 
It would require two triggers really...


Event
--------
Unit is attacked

Condition
----------------
Unit under attack equal to (unit 1) [also try unit 2 there for alt trigger]

Action
----------------
Set unit under attack life equal to life of (unit 2) [unit 1 for alt]

that should work, Im not sure if there is a unit under attack function though...

O well i tried to help, ill check it now.
 
Level 7
Joined
Jul 30, 2004
Messages
451
Deathbringer said:
It would require two triggers really...


Event
--------
Unit is attacked

Condition
----------------
Unit under attack equal to (unit 1) [also try unit 2 there for alt trigger]

Action
----------------
Set unit under attack life equal to life of (unit 2) [unit 1 for alt]

that should work, Im not sure if there is a unit under attack function though...

O well i tried to help, ill check it now.

you do realize a unit is (attacked) before it is damaged, the units hps won't be in sync since say an archer fires an arrow at your guy, thats considered being attacked, not when the arrow hits your guy

consider the previous
 
Level 7
Joined
Feb 15, 2005
Messages
183
thanks for the input guys. Raptor, I must say I am not that familiar with array's yet, but i have done some reading on them. maybe you could walk me through setting up an array? I have a feeling that many triggers in my map could be replaced by a single array trigger.

But yes, raptor is correct about the unit is under attack, that is why i made the condition to be lessthan or equal to 99% life. And I use the region to identify the house because if the house dies, it respawns later as a different house.


I am going to have to see what i can do with array's, would there be a time you could help me out with that Raptor?
 
Level 7
Joined
Jul 30, 2004
Messages
451
i'd like to help and i mean i would if i had time, but i don't really have time right now to be teaching basic programming concepts...

i can give u a basis that arrays are basically just a series of variables of the same type that all use the same name, but are referenced by number instead, so like unitAtt[0], unitAtt[1], unitAtt[2] that way you can pick a variable based on a number

and this is useful since many things can use numbers, like loops, player numbers, and you can synchronize multiple variables together by using the same index

maybe someone else can give you a more indepth look into arrays, at a later time if you want me to post some kind of initial direction as to how to set up the trigger you're looking for then go ahead and ask
 
Level 7
Joined
Feb 15, 2005
Messages
183
oh its ok, i understand raptor. I got the basic idea of what an array is persay, the concept and everything, its just the implemntation that has me confused. I am by no means a programer, but I think I am pretty good when it comes to logic and number expressions.

My first question, is how do you know what specific unit in your unitgroup array is what number? do you assign them individualy?

I have some triggers that I have copy pasted many many times because i am trying to make pairings for each building. I have 64 houses, 16 townhouses, and 4 castles. each of which require something between 4-6 triggers EACH. All I am doing really in all these triggers, is simply chaging the regions one by one through the trigger, so that I can designate what pair exactly i want to be involved. but if there was a way to condense these copy and pasted triggers, that would make life so much nicer, and if i ever wanted to edit a single function which effects all the houses, I don't have to change 100 triggers. here is an example trigger i have for entering a house :

-Event-
-A unit is issued an order targeting an object
-Condition-
-issued order equal to order(move)
-Owner of target unit of isued order not equal to neutral passive
-target unit of issued order is a unit-type house equal to true
-target unit belongs to an ally of owner of target unit of issued order equal to true
-Region house 00 contains target unit of issued order equal to True
-Actions-
-wait until Region house 00 contains triggering unit equal to true, checking every 1 second
-IF-
-unit type of triggering unit is A hero equal to
true.
-THEN-
-move ordered unit instantly to center of region
insidehouse 00
-Pan camera for owner of triggering unti to center
of region insidehouse 00
-ELSE-
-move ordered unit instantly to center of region
insidehouse 00
-wait .01 seconds
-order triggering unit to Stop.

Now, this whole trigger makes it so that one unit can enter one house. I have 64 houses. And I also have similar triggers for exiting the house, moving all units from inside the house to the outside of the house if it dies, and also a house locator button. In each trigger, I am only changing the regions in each line to match another pair, so i would use region house x and region insidehouse x, to specify which room is associated with which house on the map. But if i could somehow put all the room regions into an array, and all the house regions into an arry, and simply match up the number of the house to the number of the room, I think i might wet myself. Is something like that possible using arrays?
 
Level 7
Joined
Feb 15, 2005
Messages
183
raptor, if you coudl just post and walk me through setting up one array trigger, I am pretty sure I can figure out how to apply it to everything else. I learn by taking things apart, so, if you coudl present me with a completed trigger involving an array, I could get a handle for it. or if you could tell me how to incorporate an array into the trigger i mention earlier, I am sure i could do it.
 
Level 7
Joined
Feb 15, 2005
Messages
183
ok, I made 2 region array's and set each region to a variable in a region array from 1-64.

now what i want to do is make it so that

FARMregions(x)Will send units to the matching region number in a different array.
DOORregions(x)

so, if you click on a farm in FARMregions (1) you will be moved to DOORregions (1), or if you are in FARMregions (2) you will be moved to DOORregions (2)

am I on the right track?
 
Status
Not open for further replies.
Top