HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Finding Highest Value of all Player Controlled Units

06-21-2006, 11:49 PM#1
Kevin
HI!:D

I want to make a more dynamic creep system for my multiplayer map.

And I discovered the best system would be if I take a regular creep, spawn it, then do the following:

1. Increase the creep's damage = to the highest damage from a player controllled unit.
2. Increase the creep's armor = to the highest armor value of a player controlled unit.
4. Increase the creep's health = to the highest health value of a player controlled unit.


So basically what I need to do is I need to compare all of the player controlled units on the map, record the highest armor, the highest health, and the highest damage of all the player controlled units in three arrays.

Then I need to spawn a creep, add that value to the creep's values.


I barely understand what I need to do, but I'm so confused as to how to do this.

Does anyone have an idea of what basic actions I need to use to begin this?

Can I do it in a single trigger action? or should I set up multiple trigger actions-- One trigger for each attribute, then a final fourth trigger for spawning a creep and increasing its abilities.

How should I do this? How can I do this?
06-22-2006, 01:58 AM#2
PipeDream
One action should be fine, but whatever is cleanest for you
Outline:
Code:
Initialize maxattr1,2,3 = 0
Iterate over each unit in the map
 If unit's attr1 > maxattr1
  set maxattr1 = attr1
 If unit's attr2 > cur
   .....
Spawn creep
Use bonusmod to boost creep stats. You can find a newer version in the drag and drop system if necessary.
06-22-2006, 02:09 AM#3
Kevin
:(

I am confused now. ok I will try to read that and understand it. If all else fails, would it be alright for me to ask you to add that function to my map, PD? :)
06-22-2006, 02:13 AM#4
PipeDream
Do your best and post if you get stuck.
06-22-2006, 05:25 AM#5
aquilla
There aren't any simple ways of getting a unit's armor or damage that work well. Hit points, however, should be easy. Made an example of a simple trigger that could be improved but would do the trick;
Trigger:
Untitled Trigger 001
Collapse Events
Unit - A unit enters (Playable map area)
Unit - A unit Acquires an item
Collapse Conditions
(Life of (Triggering unit)) Greater than MaxLife
Collapse Actions
Set MaxLife = (Life of (Triggering unit))
06-22-2006, 09:53 AM#6
Kevin
Ok thank you!:D


edit: Now I just have to figure out how to find for either max damage and defense of all heroes on the map, or how to find for max strength, int and agility.

it is very late. I will try to figure that jass stuff out tomorrow.

Anyway tyvm :D

Edit: AH HA Found where they hid hero attributes in the trigger pull down menu.
06-22-2006, 10:44 AM#7
Kevin
ok hey I have a new question.

I have made four separate triggers.

One to get max life (real) and store it in "maxlife" variable
Three to get Strength, Int, and Agi.

These variables can be used in other triggers right? Or do I have to do something special to make it so I can use them in other trigger functions :s
06-22-2006, 11:32 AM#8
Rising_Dusk
Yes, those variables can be used in other triggers.
They are global variables, thus being global across all functions across the entire map until you change them or remake the map.
06-22-2006, 01:27 PM#9
Anvilsmith
What pipedream is basically saying is that you could apply a trigger which goes over every single unit on the map and checks their armor/hit points/attack damage (or some other attribute). If you plan to check the units' MPs, create a variable called Max_Mana. Give a periodic trigger (which fires before every wave) a "Get All Units in area and do [...]" action. If the picked unit's maximum mana has a value greater than Max_Mana, make Max_Mana adopt that value. Once it's gone through all units on the map, this trigger will ensure that Max_Mana equals the highest maximum mana of any unit.

If you're using heroes, you might want to know that their armor and attack are based on their attributes, whose progress you can track by storing them in arrays. Have the arrays' values go up whenever the heroes gain a level, read a tome etc. So, for instance, if player 1's hero gained 0.3 intelligence per level, you would increase Intelligence[1] by 0.3 whenever he gained a level, and by 1 whenever he read a tome of intelligence. There are ways to calculate damage based on these attributes. Still, you'd also have to take into account which items they own and how much damage / armor / whatever they add - this would be easiest if your map's inventories were all virtual, but I suppose that's not the case.
06-22-2006, 02:01 PM#10
PipeDream
Keeping track of stats would be a nightmare. Fortunately we have:
Collapse JASS:
native          GetHeroStr          takes unit whichHero, boolean includeBonuses returns integer
native          GetHeroAgi          takes unit whichHero, boolean includeBonuses returns integer
native          GetHeroInt          takes unit whichHero, boolean includeBonuses returns integer
And I suspect you want to ignore inventory bonuses, which will make your life much easier.
06-22-2006, 06:43 PM#11
Kevin
:(

ok umm maybe I screwed up. Last night before I went to sleep I made all those triggers.

I will show you what I did.

Thing is I don't know Jass very well at all so I got confused about how to get the values.

So I made triggers to substitute getting the values.

so this is what I did before I saw your post this morning pipe :(

Trigger:
Get Life
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Life of (Attacking unit)) Greater than maxlife
Collapse Then - Actions
Set maxlife = (Life of (Attacking unit))
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Life of (Attacked unit)) Greater than maxlife
Collapse Then - Actions
Set maxlife = (Life of (Attacking unit))
Collapse Else - Actions
Do nothing
Trigger:
Get Strength
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Strength of (Attacking unit) (Exclude bonuses)) Greater than maxstrength
Collapse Then - Actions
Set maxstrength = (Strength of (Attacking unit) (Exclude bonuses))
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Strength of (Attacked unit) (Exclude bonuses)) Greater than maxstrength
Collapse Then - Actions
Set maxstrength = (Strength of (Attacked unit) (Exclude bonuses))
Collapse Else - Actions
Do nothing
Trigger:
Get Agility
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Agility of (Attacking unit) (Exclude bonuses)) Greater than maxagility
Collapse Then - Actions
Set maxagility = (Agility of (Attacking unit) (Exclude bonuses))
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Agility of (Attacked unit) (Exclude bonuses)) Greater than maxagility
Collapse Then - Actions
Set maxagility = (Agility of (Attacked unit) (Exclude bonuses))
Collapse Else - Actions
Do nothing
Trigger:
Get Intelligence
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Intelligence of (Attacking unit) (Exclude bonuses)) Greater than maxint
Collapse Then - Actions
Set maxint = (Intelligence of (Attacking unit) (Exclude bonuses))
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Intelligence of (Attacked unit) (Exclude bonuses)) Greater than maxint
Collapse Then - Actions
Set maxint = (Intelligence of (Attacked unit) (Exclude bonuses))
Collapse Else - Actions
Do nothing
Trigger:
Get Level
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of (Attacking unit)) Greater than maxlevel
Collapse Then - Actions
Set maxlevel = (Level of (Attacking unit))
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of (Attacked unit)) Greater than maxlevel
Collapse Then - Actions
Set maxlevel = (Level of (Attacked unit))
Collapse Else - Actions
Do nothing
Trigger:
Putting It Together
Collapse Events
Time - Every 60.00 seconds of game time
Conditions
Collapse Actions
Set damagetemp = (((maxagility + maxstrength) + maxint) / 3)
Set defensetemp = (maxagility / 3)


Basically right now those values get Strength, Agility, Intelligence, Level and Hit Points. I use S+A+I to calculate the creep's damage value and AGI to calculate defense value every 60 seconds (which works for me).


is this too much should I use the jass script instead to get all of those values?


If my triggers will work ok and not lag the whole map, then should I use them?



Now if I am using them, how do I use the custom Jass Script to spawn regular creeps in various regions of the map (I have 5 regions for each side), and adjust the values I have stored in defensetemp, damagetemp, maxlevel, maxhealth into the creeps:

Life
Damage
Defense
Level


Do I have to run a custom script for each of the regions?

I am very sorry I just don't know very much jass at all and I am having a hard time understanding how to stick it in my map :(
06-25-2006, 04:24 AM#12
Kevin
:sighs:

If nobody can help me with these scripts then I guess I'll just have to base the creep system off of heroes.
06-25-2006, 03:04 PM#13
BertTheJasser
Oh my goodness! GUI burns so hard in my eyes!
Plx have a look at some jass tuts before starting a thread of such a big, comlictated system.

EDIT:
How to do it:
1. Create a hero(at Map init), pause him, hide him, use its hero states and customvalue to store your values.
2. Create a trigger that fires every 30-120 sec. to update all the values and whenever a unit enters the map
3. Create creep camps and store them in gamecache (have a look at Vex demo map engine or PM me if you can not find)
4. Respawn (with some delay, I would say 45-90sec, depending on gametype) when all units of a creepcamp are killed

To do it properly, it requires you to learn jass or get a slave that does it job for you. ;?
06-26-2006, 08:27 AM#14
Kevin
Well I was asking for help from someone who wants to work with me on the map. I just need a trigger that modifies creep values after I have the creep respawn.

The trigger to spawn a creep really isn't an issue cause all of that is just a reoccuring trigger I can do on my own without jass. I just don't have any time to fool around with jass for a stupid trigger that only modifies attack defense and hit points.

And as for your four steps, I have no idea why you think it's that complicated, let alone why on god's green earth you think you have to create a hero for the trigger I need, it makes absolutely no sense, Bert.
06-26-2006, 12:32 PM#15
BertTheJasser
You do not need the hero itself, you need a .. let'ssay a "box" to store the info easily. If you create a hero, you can easily refer to it's states, max hp, max mana which you can change dynamically. So you could store 6 values at once on one hero.

And actually, if you want to create a good creep respawn system, you will have to store creep camps and only respawn if all creeps of a camp are dead and not, maybe while a combat is challenging at that place with a creep while another one gets respawn. I guess the last sentence was not very good english, but I hope you understood.
Last, to make all these things dynamically possible, you actually require to learn/use jass.