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

Some Code makes my Game crash.

Status
Not open for further replies.
Level 2
Joined
Feb 17, 2010
Messages
6
I postet it under another Topic, but then i saw that it belongs here...

this is my script that causes the crash. a screenshot of the crash is attached below. the intention of this script is to check if an ability was cast of the kind "Flee". in my map combats are fought on battlefields and when you flee from battle half of ur units should die and the rest can be seen from script. the error tells something about "could not read memory" o_O any ideas?

  • flee
    • Ereignisse
      • Einheit - A unit Beginnt, eine Fähigkeit zu wirken
    • Bedingungen
      • (Ability being cast) Gleich Flee!
    • Aktionen
      • For each (Integer A) from 1 to 3, do (Actions)
        • Schleifen - Aktionen
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Bedingungen
              • Or - Any (Conditions) are true
                • Bedingungen
                  • (Owner of (Triggering unit)) Gleich (Player(battlefield_attacker[(Integer A)]))
                  • (Owner of (Triggering unit)) Gleich (Player(battlefield_victim[(Integer A)]))
            • 'THEN'-Aktionen
              • Spezialeffekt - Destroy player_heroes_effects[battlefield_attacker[(Integer A)]]
              • Spezialeffekt - Destroy player_heroes_effects[battlefield_victim[(Integer A)]]
              • Einheit - Change ownership of player_heroes[battlefield_attacker[(Integer A)]] to (Player(battlefield_attacker[(Integer A)])) and Farbe wechseln
              • Einheit - Change ownership of player_heroes[battlefield_victim[(Integer A)]] to (Player(battlefield_victim[(Integer A)])) and Farbe wechseln
              • Einheit - Make player_heroes[battlefield_attacker[(Integer A)]] Verwundbar
              • Einheit - Make player_heroes[battlefield_victim[(Integer A)]] Verwundbar
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Bedingungen
                  • (Owner of (Triggering unit)) Gleich (Player(battlefield_attacker[(Integer A)]))
                • 'THEN'-Aktionen
                  • Set battlefield_winner[(Integer A)] = battlefield_victim[(Integer A)]
                  • Spiel - Display to (All players) the text: (((player_txtcolor[battlefield_attacker[(Integer A)]] + (Name of (Player(battlefield_attacker[(Integer A)])))) + |r ) + fled from combat)
                  • Einheitengruppe - Pick every unit in (Units in battlefield_regions[(Integer A)] owned by (Player(battlefield_winner[(Integer A)]))) and do (Actions)
                    • Schleifen - Aktionen
                      • Einheit - Move (Picked unit) instantly to (Center of player_regions[battlefield_winner[(Integer A)]])
                      • Einheit - Order (Picked unit) to Position halten
                  • Set x = (Number of units in (Units in battlefield_regions[(Integer A)] owned by (Owner of (Triggering unit))))
                  • Einheitengruppe - Pick every unit in (Random (x / 2) units from (Units in battlefield_regions[(Integer A)] owned by (Owner of (Triggering unit)))) and do (Einheit - Kill (Picked unit))
                  • Einheitengruppe - Pick every unit in (Units in battlefield_regions[(Integer A)] owned by (Owner of (Triggering unit))) and do (Actions)
                    • Schleifen - Aktionen
                      • Einheit - Move (Picked unit) instantly to (Center of player_regions[(Player number of (Owner of (Triggering unit)))])
                      • Einheit - Order (Picked unit) to Position halten
                  • Einheit - Move player_heroes[(Player number of (Owner of (Triggering unit)))] instantly to (Position of (Random unit from (Units owned by (Owner of (Triggering unit)) of type Castle)))
                • 'ELSE'-Aktionen
                  • Set battlefield_winner[(Integer A)] = battlefield_attacker[(Integer A)]
                  • Spiel - Display to (All players) the text: (((player_txtcolor[battlefield_victim[(Integer A)]] + (Name of (Player(battlefield_victim[(Integer A)])))) + |r ) + fled from combat)
                  • Einheitengruppe - Pick every unit in (Units in battlefield_regions[(Integer A)] owned by (Player(battlefield_winner[(Integer A)]))) and do (Actions)
                    • Schleifen - Aktionen
                      • Einheit - Move (Picked unit) instantly to (Center of player_regions[battlefield_winner[(Integer A)]])
                      • Einheit - Order (Picked unit) to Position halten
                  • Set x = (Number of units in (Units in battlefield_regions[(Integer A)] owned by (Owner of (Triggering unit))))
                  • Einheitengruppe - Pick every unit in (Random (x / 2) units from (Units in battlefield_regions[(Integer A)] owned by (Owner of (Triggering unit)))) and do (Einheit - Kill (Picked unit))
                  • Einheitengruppe - Pick every unit in (Units in battlefield_regions[(Integer A)] owned by (Owner of (Triggering unit))) and do (Actions)
                    • Schleifen - Aktionen
                      • Einheit - Move (Picked unit) instantly to (Center of player_regions[(Player number of (Owner of (Triggering unit)))])
                      • Einheit - Order (Picked unit) to Position halten
                  • Einheit - Move player_heroes[(Player number of (Owner of (Triggering unit)))] instantly to (Position of (Random unit from (Units owned by (Owner of (Triggering unit)) of type Castle)))
              • Kamera - Pan camera for (Player(battlefield_attacker[(Integer A)])) to (Position of player_heroes[(Player number of (Player(battlefield_attacker[(Integer A)])))]) over 0.00 seconds
              • Kamera - Pan camera for (Player(battlefield_victim[(Integer A)])) to (Position of player_heroes[(Player number of (Player(battlefield_victim[(Integer A)])))]) over 0.00 seconds
              • Set battlefield_use[(Integer A)] = False
              • Set battlefield_attacker[(Integer A)] = 0
              • Set battlefield_victim[(Integer A)] = 0
              • Set battlefield_winner[(Integer A)] = 0
            • 'ELSE'-Aktionen
 
Level 2
Joined
Feb 17, 2010
Messages
6
ok, i've discovered the problem by myself now... the problem was, that i have my player-number vaiables on default as 0, but the game can't handle Player0, so i changed the default to 12 and now it works. So everyone with similar problems, try that ;)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,199
Wrong, Players are in the range of 0 - 15.
Player(0) is usually red while players 12-15 are neutral.
12 real players 4 neutral.

What you must have been doing is refering to Player(<0) or Player(>15) which will return null. This does not crash the game I believe but passing null as a palyer to many functions however will. All I recommend is mapping players to an array and referencing that rather, as not only is it faster but it is also garunteed to not crash (if that is the source of the crash and not a null to an other function).

Remember that in GUI the stupid action subtracts 1 from the passed integer before getting the player.
 
Level 2
Joined
Feb 17, 2010
Messages
6
but the problem was this:
(Owner of (Triggering unit)) Gleich (Player(battlefield_attacker[(Integer A)]))
and when i changed the default-value of battlefield_attacker[] to 12 it works, with 0 it does not
 
Status
Not open for further replies.
Top