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

[General] Rusty looking for help with AI Spawning

Status
Not open for further replies.
Level 2
Joined
Jan 16, 2021
Messages
12
Hi guys. im looking to make a defense mode that can go for long periods without crashes (little leaking)

So im just starting to set up my variables, im using Ints and bools to keep it simple for now

Recommendations on best framework for the system to be clean and smooth?

plan so far:
-Wave counter, enemy counter, generate next wave on a timer and increase enemy count and levels
The part im unsure of is the actual mechanics: do i need to use a dummy object and copy it or something crazy to avoid leaks when spawning tons of enemies? I'm new to doing this technically (did it as a teen)

if you need more details this is going to be a mode where you build a base anywhere you want and waves of ai seek you out
I'm planning to spawn them in a region which uses triggers to direct them from the spawn region to an enemy base (probably an EnemyTargetSlot variable and have it reiterate and go higher idk)

any help would be appreciated<3
 
Level 2
Joined
Jan 10, 2021
Messages
10
Create too many units cause lag not crash and it doesn't leak because you are creating "normal" units which can be damaged, killed later not dummy units. Avoid forgetting remove or kill dummy units when you don't need them anymore. About "clean and smooth" problem, it depends on your computer.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
Unit creation leaks a Point unless you handle it properly.

So whenever you do:
Create 1 Unit at Center of region

You're leaking a Point. What's happening is the game generates a Point automatically for you at the "Center of Region", but it never removes this Point.

So what you have to do is Create the Point yourself, then reference said Point, and then manually Remove it.

This is done like so:
  • Set Variable TempPoint = Center of some Region
  • Unit - Create 1 Footman at TempPoint
  • Custom script: call RemoveLocation (udg_TempPoint)
The most common cause of crashing that you'll run into is due to infinite loops. These are triggers that either cause themselves to run again or cause a second trigger to run which then runs the first trigger again, causing this to happen endlessly.

Read more about leaks here: Memory Leaks
 
Status
Not open for further replies.
Top