Item Breaking System

Axe.killer

New Member
Reaction score
24
A little system to contribute a little something, since you guys have contributed to my needs.

Declaring % system. Each integer variable array represents 2%. (50 x 2 = 100%) This makes things a little less harder. Anyway, you can do it up to 100 as well.
Code:
Start
    Events
        Map initialization
    Conditions
    Actions
        Set arrows_2[1] = 1
        Set arrows_2[2] = 2
        Set arrows_2[3] = 3
        Set arrows_2[4] = 4
        Set arrows_2[5] = 5
        Set arrows_2[6] = 6
        Set arrows_2[7] = 7
        Set arrows_2[8] = 8
        Set arrows_2[9] = 9
        Set arrows_2[10] = 10
        Set arrows_2[11] = 11
        Set arrows_2[12] = 12
        Set arrows_2[13] = 13
        Set arrows_2[14] = 14
        Set arrows_2[15] = 15
        Set arrows_2[16] = 16
        Set arrows_2[17] = 17
        Set arrows_2[18] = 18
        Set arrows_2[19] = 19
        Set arrows_2[20] = 20
        Set arrows_2[21] = 21
        Set arrows_2[22] = 22
        Set arrows_2[23] = 23
        Set arrows_2[24] = 24
        Set arrows_2[25] = 25
        Set arrows_2[26] = 26
        Set arrows_2[27] = 27
        Set arrows_2[28] = 28
        Set arrows_2[29] = 29
        Set arrows_2[30] = 30
        Set arrows_2[31] = 31
        Set arrows_2[32] = 32
        Set arrows_2[33] = 33
        Set arrows_2[34] = 34
        Set arrows_2[35] = 35
        Set arrows_2[36] = 36
        Set arrows_2[37] = 37
        Set arrows_2[38] = 38
        Set arrows_2[39] = 39
        Set arrows_2[40] = 40
        Set arrows_2[41] = 41
        Set arrows_2[42] = 42
        Set arrows_2[43] = 43
        Set arrows_2[44] = 44
        Set arrows_2[45] = 45
        Set arrows_2[46] = 46
        Set arrows_2[47] = 47
        Set arrows_2[48] = 48
        Set arrows_2[49] = 49
        Set arrows_2[50] = 50

You can replace the unit is attacked with unit uses item or something of that sort. But for my archery map, when a unit has an item of type Beginner's Bow, then when the unit attacks, it has a chance to break. So lets proceed

Code:
UnitAttackNormalBow
    Events
        Unit - A unit Is attacked
    Conditions
        ((Attacking unit) has an item of type Wind Arrow(s)) Equal to True
        ((Attacking unit) has an item of type Beginner's Bow) Equal to True
        (Unit-type of (Attacking unit)) Equal to Archer
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                arrows_2[(Random integer number between 1 and 50)] Greater than 47
            Then - Actions
                Item - Remove (Item carried by (Attacking unit) of type Beginner's Bow)
                Hero - Create Broken Bow and give it to (Attacking unit)
                Sound - Play EtherealHeavyHit3 <gen> at 100.00% volume, attached to (Attacking unit)
                Game - Display to (All players) the text: |c00FF2158You just ...
            Else - Actions

The random integer is the heart of the breaking. Remember that every 1, represents 2%. So if we wanted a 6% chance to break, the random integer range would have to be greater than 47 - which is equivilant to (48 , 49, 50 ) 3 integers, = 3 possibilities. Since its divided by 2, (100 / 50) then we multiply 2. This would be equal to 6%. There you have it. If you wanted 4 %, the range would be greater than 48 which is = 49, 50. 2 integers times 2 = 4. So that's a 4% chance. Just remember that whatever the % you want for the item to break - it must be the number of possiblities (the greater than 47 thing, which would be 3 possibilities and so on, change to your liking.) multiplied by 2.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Random integer number from 1 to 1000 less than or equal to 42

would be a 4.2% chance...


There's also a "random real" function, for things like
Random real number from 1.0 to 100.0 less than or equal to 4.2
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Who cares?

It's always better to have tried something and got it to work,
than not trying at all...

Rome wasn't build in a day either.


Sometimes though, there's just a simpler way :p
 

Axe.killer

New Member
Reaction score
24
i concur old chap. Straying from the point, my trigger was redundant, because of the contrasts of both pros and cons. not to be too political in my views but, ur triggers owns. :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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