Random skills achieving process

Fobosus

New Member
Reaction score
0
Ok, so to begin:

My destination is to create a trigger, which gives three random basic skills to the hero once it is spawned. The 4th one is gonna be ulti (random as well).

If I count properly, there are 72 hero abilities (besides ultis).

I thought of making it one by one, using IF/THEN/ELSE beginning from condition Random=1 to Random=72 and then copying it twice. The triggers would happen one after one, so that the hero would receive 3 skills, BUT.

The problem is - doing like this, there appears a chance of hero getting 2 or 3 the same abilities. I want to avoid it, but don't really have idea how to.

Any suggestions? I'll be thankful to hear.

Fobosus
 

the_ideal

user title
Reaction score
61
Create a unit group array, from UnitGroup[1] to UnitGroup[72]. When a player selects a hero, add the hero to every unit group. (For every integer from 1 to 72, add hero to Unit Group[A]) Have each unit group correspond to an ability, and when a player gets an ability, remove them from that unit group. In the "random number from 1 to 72" trigger, add a condition that checks to see if the hero is in the unit group. If not, reroll.
 

crazyfanatic

New Member
Reaction score
20
Welcome to The Helper!

Now for your problem:
Make the trigger periodic and each period check if the unit has the ability that should be given. If so, run trigger again. If not, give next one or turn the trigger off.
 

Fobosus

New Member
Reaction score
0
Could you guys explain it little further? It looks I haven't understood at all and I'm doing something wrong. Tried both methods.
Code examples would be appreciated coz I still hardly got a clue, specially that Ive never used that Array variable before.
 

crazyfanatic

New Member
Reaction score
20
each 0.10 seconds of the game
Set (random) = random integer number between 1 and 72
If level of Skill[random] for (your unit) greater than 0 or skillsnumber(your player number) greater than 2
Then - actions
Do nothing
Else - actions
Give skill(random) to (your unit)
set (skillsnumber[your player number]) equal to (same integer)+ 1

Edit: Srry for the hand writing, not on my computer.
 

Fobosus

New Member
Reaction score
0
Ok, thank you, just what is the condition "skillsnumber(your player number) greater than 2" cuz I can't find anything like that; and the same to "set (skillsnumber[your player number]) equal to (same integer)+ 1" ?

Sorry for asking so many little questions, but I just can't deal with this by myself :S
 

crazyfanatic

New Member
Reaction score
20
the first one is integer comparsion from the conditions
The second one is set variable. The meaning is is if V is a variable A is array, so set V with array A = (V with array A) + 1

Edit: skillnumber is an integer variable with array, player number isthe array soyou can make it MPI
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
This trigger should work for what you need. :)

Trigger:
  • For each (Integer Temp) from 1 to 3, do (Actions)
    • Loop - Actions
      • Set AbilitySet = (Random integer number between 1 and 72)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AbilitySet Equal to AbilityMem
        • Then - Actions
          • Set Temp = (Temp - 1)
        • Else - Actions
          • Unit - Add Ability[AbilitySet] to (Triggering unit)
          • Set AbilityMem = AbilitySet
 

crazyfanatic

New Member
Reaction score
20
so this trigger will run only 3 times and if the unit has the same skill it will give one skill less
 

Moridin

Snow Leopard
Reaction score
144
Note that the variable "skillsnumber" is an array and not a single variable. The brackets after it () indicate the position in that array.
Code:
skillsnumber[Player number]
  Name^    Position in Array^

Dameon, that trigger is flawed....for more than one reason.

Trigger:
  • Trigger 1
    • Events
      • Map initialization
    • Conditions
      • No_Given_Abilties Less than 3 -> Integer comparison
    • Actions
      • Set Random = (Random integer number between 1 and 72)
      • If (All Conditions are True) then do (Then actions) else do (Else Actions)
        • If - Conditions
          • (Level of Abilities[Random] for <Your unit>) Greater than 0
        • Then - Actions
          • Else - Actions
            • Set No_Given_Abilities = No_Given_Abilities + 1 -> Arithmetic
            • Unit - Add Abilities[Random] to <Your unit>
      • If (All Conditions are True) then do (Then actions) else do (Else actions)
        • If - Conditions
          • No_Given_Abilities Greater than or Equal to 3
        • Then - Actions
          • Trigger - Turn off (this trigger)
        • Else - Actions
          • Trigger - Run (this trigger) checking conditions


This should work....unless I made an error somewhere. You will need:

No_Given_Abilities -> Integer Variable
Abilities[ ] -> Ability array (Ability variable with Array checked and size 72)
Random -> Integer Variable

Note:
1) Freehand
2) Abilities[] needs to have the abilities stored in it's 72 locations.
 

Fobosus

New Member
Reaction score
0
It almost works, Moridin, thanks. I mean, if I launch warcraft and do a test game, random hero I get is always [13]kotg with always atribute bonus[2], bash[4] and roar[5]. Then when this hero is killed in a battle and I create a new one, which does not get abilities.

Also, if I open Warcraft normally, after the first command game shuts down, no error window, no anything, just shuts.

Im going to try to figure out what the case is, should you have any idea please tell me.

Edit: Ok, I have fixed it, somehow.

Thank you all for trying to solve my prob :) Your help was immediate :D

Edit2: Now it's like the spell giving trigger works only once. For further hero creations, it gives no spells. Im still working on it.
 

HappyPeasant

New Member
Reaction score
8
You could do it by setting each spell to its own variable as an array then just have it roll a random number between 0-73 then do it again excluding the last number.
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
so this trigger will run only 3 times and if the unit has the same skill it will give one skill less

No it will give 3, I however meesed up on it a bit, it is a jass trick that will stop the loop from ending till you get your condtions meet. Give me a sec I will fix it and post a working demo for it.

Ok here you go, I didn't feel like making custom abilitys so I just use items instead. To get it to work for abilitys just replace the has item bolean to an interger checking if the level of the ability is greater then 0 for the unit.

Just walk on the grass, then walk off it drop and item of your choice and walk back on it.

Again sorry about the earlyer mistake with the loop :)

Trigger:
  • Untitled Trigger 001 Copy
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • For each (Integer Temp) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set Random = (Random integer number between 1 and 3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp Not equal to 4
              • ((Triggering unit) has an item of type Items[Random]) Not equal to True
            • Then - Actions
              • Hero - Create Items[Random] and give it to (Triggering unit)
            • Else - Actions
              • Set Temp = (Temp - 1)
 

Attachments

  • Random Item.w3x
    16.7 KB · Views: 117

Moridin

Snow Leopard
Reaction score
144
@ Fobosus: Am glad my trigger helped. Here's a bit of advice to get your respawn triggers working.

Firstly, alter the trigger slightly to this:

Trigger:
  • Trigger 1
    • Events
      • Map initialization
    • Conditions
      • No_Given_Abilties Less than 3 -> Integer comparison
    • Actions
      • Set Random = (Random integer number between 1 and 72)
      • If (All Conditions are True) then do (Then actions) else do (Else Actions)
        • If - Conditions
          • (Level of Abilities[Random] for <Your unit>) Greater than 0
        • Then - Actions
          • Else - Actions
            • Set No_Given_Abilities = No_Given_Abilities + 1 -> Arithmetic
            • Unit - Add Abilities[Random] to <Your unit>
      • If (All Conditions are True) then do (Then actions) else do (Else actions)
        • If - Conditions
          • No_Given_Abilities Greater than or Equal to 3
        • Then - Actions
          • Set No_Given_Abilities = 0
        • Else - Actions
          • Trigger - Run (this trigger) checking conditions


...and then in your respawn trigger (wherever you have it), AFTER you respawn the hero, add this action:

Trigger:
  • Trigger - Run (Trigger 1) checking conditions


Where Trigger 1 is the first trigger.

Hope that helped.

Edit: Btw, about the randoms not working in that case, it's because The world editor has preset "random" values that it uses in tests. For it to be actually random, you have to use WC3 to play it.

As for why it crashed...I'm not sure. Maybe an infinite loop somewhere in your triggers or a problem with your computer?
 

Fobosus

New Member
Reaction score
0
Well, the thing I actually lacked was the Set No_Given_Abilities=0 action. I wonder why I haven't figured it out myself, but thank you again :)

About the randoms - at the beginnings I was so confused with the random being the same that I even thought it's connected to the Friday the 13th, as the hero integer was 13 as well ^^

For now it's just what I wanted, everything working. If I have any further problems (which is unskippable), I'll post it here.

Fobosus


Edit: Ok, got stuck already. Action "Add skill points to hero" isn't working. I need the hero to have maximum skill points, as once he receives his skills, they are only level one and the hero does not even have a red plus. It might have something to do with skills removal in object editor - I cleared all heroes of their skills for obvious reason.
 

neckcuttabob

Member
Reaction score
3
I made a hero a lot like this once. Except he changed abilities every 10 seconds, and if anyone reading that thinks its a good idea by all means do it it turns out pretty funny if you mess up though. This being the result of giving a hero avatar, using it and taking it away before it runs out, repeated many times over.

Heres what I did

First divide all of the abilities you want into 4 categories, I suggest;
1 Single target damage
2 Passive Buffs, Castable Buffs, Debuffs
3 AOEs, Summons, Healing
4 Ultimates

Make a custom spell for each of them, modify each spell to have 1 level with its highest values if you want them to be max level from the start, fix them up a bit as necessary.

Make separate triggers for each category of spells to add them by category. This method keeps them from having two of the same spell and keeps the character balanced.
 

Fobosus

New Member
Reaction score
0
Honestly, the point of this game is just for fun, so I don't mind hero getting 3 auras or 3 single target spells + finger of death ulti, although thank you for advices.

I wanted to rather avoid modifying all the standard spells that's why I asked. There must be way, isn't there?

P.S The avatar looks laughable :)
 

Moridin

Snow Leopard
Reaction score
144
Instead of giving the hero maximum skill points, couldn't you just set the level of each ability you give him to the max? That would achieve the same purpose and it would be much easier. Use:

Trigger:
  • Unit - Set Level of Ability for Unit


...action. It's at the VERRRY bottom of the unit actions list.
 

neckcuttabob

Member
Reaction score
3
Honestly, the point of this game is just for fun, so I don't mind hero getting 3 auras or 3 single target spells + finger of death ulti, although thank you for advices.

I wanted to rather avoid modifying all the standard spells that's why I asked. There must be way, isn't there?

P.S The avatar looks laughable :)

If you think thats laughable you should have seen my rabbit map. The Red rabbit hero was 4 times normal rabbit size and shot cluster rockets. The Yellow rabbit hero shot a chain lightning that bounced to 100 targets and had a 99999 range. Oh but the best part... the best part was the rabbit workers. They were exactly like human workers except for 2 things;
1 They looked like rabbits and
2 They had a passive ability, whenever you killed a "Rabbit Worker" it would spawn not one, but TWO "Rabbit Worker"s. When they went through the forest and reached the ghouls harvesting wood of it took less than 30 seconds for enough rabbit workers to spawn for my computer to crash.
 

Fobosus

New Member
Reaction score
0
Right, I supposed I forgot about some action like this. Arigatou gozaimasu :)

Neckut, lol, I would like to see those rabbit workers in ladder ^^
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top