• 🏆 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!

We calculation error or my?

Status
Not open for further replies.
Level 6
Joined
Jan 29, 2010
Messages
213
WorldEditor calculation error or mine...
_______________________________________________________________________________________
Hi all, so I have totally messed up here!
I tried to fix it sitting about 4hours, but I can't find any clue...
The skill has to start spining from 1 to 10 pheonix around hero, but the range is leaking... It seems like I done mistakes by calculating distance or angle.
So here's triggers (I hope you'll be able to help me :/):
  • spin1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Ability being cast) Equal to Spin[1] ) and (time[(Player number of (Owner of (Casting unit)))] Equal to 0)
    • Actions
      • Set caster[(Player number of (Owner of (Casting unit)))] = (Casting unit)
      • Set count[(Player number of (Owner of (Casting unit)))] = (Random integer number between 1 and 10)
      • Set angle[(10 x (Player number of (Owner of (Casting unit))))] = (360 / count[(Player number of (Owner of (Casting unit)))])
      • Set time[(Player number of (Owner of (Casting unit)))] = 200
      • For each (Integer A) from (10 x (Player number of (Owner of (Casting unit)))) to ((10 x (Player number of (Owner of (Casting unit)))) + count[(Player number of (Owner of (Casting unit)))]), do (Actions)
        • Loop - Actions
          • Unit - Create 1 Peasant for (Owner of (Casting unit)) at (Position of (Casting unit)) facing Default building facing degrees
          • Set bird[(Integer A)] = (Last created unit)
          • Set angle[(Integer A)] = (angle[(10 x (Player number of (Owner of (Casting unit))))] x angle[(10 x (Player number of (Owner of (Casting unit))))])
      • Trigger - Turn on spin1moving <gen>
  • spin1moving
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set counitingskills[1] = 0
      • For each (Integer B) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • time[(Integer B)] Equal to 0
            • Then - Actions
              • Set counitingskills[1] = (counitingskills[1] + 1)
            • Else - Actions
              • Set time[(Integer B)] = (time[(Integer B)] - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • time[(Integer B)] Equal to 0
                • Then - Actions
                  • For each (Integer A) from (10 x (Integer B)) to ((10 x (Integer B)) + count[(Integer B)]), do (Actions)
                    • Loop - Actions
                      • Unit - Remove bird[(Integer A)] from the game
                      • Set distance[(Integer A)] = 0
                      • Set angle[(Integer A)] = 0
                  • Set caster[(Integer A)] = No unit
                • Else - Actions
                  • For each (Integer A) from (10 x (Integer B)) to ((10 x (Integer B)) + count[(Integer B)]), do (Actions)
                    • Loop - Actions
                      • Set distance[(Integer A)] = (distance[(Integer A)] + 5)
                      • Set angle[(Integer A)] = (angle[(Integer A)] + 5)
                      • Unit - Move bird[(Integer A)] instantly to ((Position of caster[(Integer B)]) offset by (Real(angle[(Integer A)])) towards (Real(distance[(Integer A)])) degrees)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • counitingskills[1] Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
||||||||||For player1||||||||||
Spin1 (trigger)
set Caster[1] = casting unit
set Count[1] = random 1-10 (let's say 10)
set Angle[10] = 360 / count[1] (360/10=36*)
for IntA = 10-20
Unit Create U 1 for [p1] at [caster]
set Bird[10-20] = [LastCUnit]
set Ang[10-20] = 10xangle[10] (10*36=360)
------------------------------
Spin1moving (trigger)
for IntB = 1
for IntA = 10 to 20
set Dis[10-20] = +5
set Ang[10-20] = +5
Unit move Bird[10-20] inst to Cater[1] off [Angle] towards [Distance]


Dowload: randomskills.w3x

For single player (Player1(Red)) It works properly...
Here's the triggers:
  • spin1
  • spin1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Ability being cast) Equal to Spin[1] ) and (time Equal to 0)
    • Actions
      • Set caster = (Casting unit)
      • Set count = (Random integer number between 1 and 10)
      • Set angle[1] = (360 / count)
      • Set time = 200
      • For each (Integer A) from 1 to count, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Peasant for Player 1 (Red) at (Position of caster) facing Default building facing degrees
          • Set bird[(Integer A)] = (Last created unit)
          • Set angle[(Integer A)] = (angle[1] x (Integer A))
      • Trigger - Turn on spin1moving <gen>
  • spin1moving
  • spin1moving
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • time Equal to 0
        • Then - Actions
          • For each (Integer A) from 1 to count, do (Actions)
            • Loop - Actions
              • Unit - Remove bird[(Integer A)] from the game
              • Set distance[(Integer A)] = 0
              • Set angle[(Integer A)] = 0
          • Set caster = No unit
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Set time = (time - 1)
          • For each (Integer A) from 1 to count, do (Actions)
            • Loop - Actions
              • Set distance[(Integer A)] = (distance[(Integer A)] + 5)
              • Set angle[(Integer A)] = (angle[(Integer A)] + 5)
              • Unit - Move bird[(Integer A)] instantly to ((Position of caster) offset by (Real(distance[(Integer A)])) towards (Real(angle[(Integer A)])) degrees)
Dowload: randomskills(p1).w3x (single player)
 
Last edited:
Level 11
Joined
Jun 30, 2008
Messages
580
Um, why do you times everything by 10? I see no reason for it... Or are you trying to make a 2D array? If you are you are doing it wrong:

it is suppose to be ((Max Players*instance) + Player Number)
So for instance 1, for player 1 (With 10 players):
10*1 + 1 = 11
for player 2:
10*1+2 = 12
etc...
For instance 2 player 1:
10*2+1 = 21
etc....

See what I mean?

So why do you have the 10x everything? Try taking that out and see if it works.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Here are some improvements. Whats the spell supposed to do?
Mass trash code; integer A&B; Get() function spam; position leak and much much more.
  • spin1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Ability being cast) Equal to Spin[1])
    • Actions
      • Set someInt = (Player number of (Triggering player))
      • If (All conditions are true) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • time[someInt] Equal to 0
        • Then - Actions
          • Set caster[someInt] = (Triggering unit)
          • Set count[someInt] = (Random integer number between 1 and 10)
          • Set angle[(10 x someInt] = (360 / count[someInt])
          • Set time[someInt] = 200
          • Set p = (Position of caster[someInt])
          • Set someInt = someInt x 10
          • For each (Integer i) from (someInt) to (someInt + count[someInt / 10]), do (Actions)
            • Loop - Actions
              • Unit - Create 1 Peasant for (Triggering Player) at p facing Default building facing degrees
              • Set bird[i] = (Last created unit)
              • Set angle[i] = (angle[someInt] x angle[someInt])
          • Trigger - Turn on spin1moving <gen>
          • Custom script: call RemoveLocation(udg_p)
  • spin1moving
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set counitingskills[1] = 0
      • For each (Integer i) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • time[i] Equal to 0
            • Then - Actions
              • Set counitingskills[1] = (counitingskills[1] + 1)
            • Else - Actions
              • Set time[i] = (time[i] - 1)
              • Set someInt = (i x 10)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • time[i] Equal to 0
                • Then - Actions
                  • For each (Integer A) from (someInt) to (someInt + count[i]), do (Actions)
                    • Loop - Actions
                      • Unit - Remove bird[(Integer A)] from the game
                      • Set distance[(Integer A)] = 0
                      • Set angle[(Integer A)] = 0
                  • Set caster[(Integer A)] = No unit
                • Else - Actions
                  • For each (Integer A) from (someInt) to (someInt + count[i]), do (Actions)
                    • Loop - Actions
                      • Set distance[(Integer A)] = (distance[(Integer A)] + 5)
                      • Set angle[(Integer A)] = (angle[(Integer A)] + 5)
                      • Set p = (Position of caster[i])
                      • Set p2 = (p offset offset by (Real(angle[(Integer A)])) towards (Real(distance[(Integer A)])) degrees)
                      • Unit - Move bird[(Integer A)] instantly to p2
                      • Custom script: call RemoveLocation(udg_p)
                      • Custom script: call RemoveLocation(udg_p2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • counitingskills[1] Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
'someInt' and 'i' are integer variables, while 'p' & 'p2' are Location parameters.
 
Level 6
Joined
Jan 29, 2010
Messages
213
Sorry all for not replying long time...
So this is triggers that works properly but only for Player1(Red)...
(It's all the same...)
  • spin1
  • spin1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Ability being cast) Equal to Spin[1] ) and (time Equal to 0)
    • Actions
      • Set caster = (Casting unit)
      • Set count = (Random integer number between 1 and 10)
      • Set angle[1] = (360 / count)
      • Set time = 200
      • For each (Integer A) from 1 to count, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Peasant for Player 1 (Red) at (Position of caster) facing Default building facing degrees
          • Set bird[(Integer A)] = (Last created unit)
          • Set angle[(Integer A)] = (angle[1] x (Integer A))
      • Trigger - Turn on spin1moving <gen>
  • spin1moving
  • spin1moving
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • time Equal to 0
        • Then - Actions
          • For each (Integer A) from 1 to count, do (Actions)
            • Loop - Actions
              • Unit - Remove bird[(Integer A)] from the game
              • Set distance[(Integer A)] = 0
              • Set angle[(Integer A)] = 0
          • Set caster = No unit
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Set time = (time - 1)
          • For each (Integer A) from 1 to count, do (Actions)
            • Loop - Actions
              • Set distance[(Integer A)] = (distance[(Integer A)] + 5)
              • Set angle[(Integer A)] = (angle[(Integer A)] + 5)
              • Unit - Move bird[(Integer A)] instantly to ((Position of caster) offset by (Real(distance[(Integer A)])) towards (Real(angle[(Integer A)])) degrees)
Dowload: randomskills(p1).w3x

Um, why do you times everything by 10? I see no reason for it... Or are you trying to make a 2D array? If you are you are doing it wrong:
Every 10 becouse there my be created 10 pheonix for one player so I just setting all like this:
Player1 = from 11 to 20
player2 = from 21 to 30
...
player8 = from 81 to 90
(Im trying to make 1variable for all players witch worked allready... In other maps of course...)

Here are some improvements. Whats the spell supposed to do?
Mass trash code; integer A&B; Get() function spam; position leak and much much more.
Sorry at first I want to make triggers work properly than to add custom scripts to remove leaks.
 
Last edited:
Status
Not open for further replies.
Top