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

Memory Leak and request of JASS system

Status
Not open for further replies.
Level 7
Joined
Jun 23, 2009
Messages
297
Ok, so, I removed almost all my leaks, except for this one
  • Actions
  • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit))) and do (Actions)
    • Loop - Actions
      • Unit - Kill (Picked unit)
  • Custom script: call call DestroyGroup(udg_UnitGroup)
But it says "Script error: expected a name"
I really have no idea how this custom script works, so, what name is it expecting?


Besides that, I'd like to request a JASS system, I'm not entirely sure whether to request it here, or in another thread, but anyways...
I just want a basic "-claim" and "-oust" system, much like Vampirism Beast system, my map has a few bases, which each player could claim by typing "claim" when certain unit is in the base. Then, when another unwanted (ally) player enters the base, the original player can say -oust, and the second player will be ousted from the base, along with all his units.
I'm not sure if I made myself clear, if not, just say so, I'll clarify it.
Thanks for your time
 
Level 11
Joined
Oct 13, 2005
Messages
233
Ok, so, I removed almost all my leaks, except for this one
  • Actions
  • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit))) and do (Actions)
    • Loop - Actions
      • Unit - Kill (Picked unit)
  • Custom script: call call DestroyGroup(udg_UnitGroup)
But it says "Script error: expected a name"
I really have no idea how this custom script works, so, what name is it expecting?

By "expected a name", the error really means that you don't have a global variable named UnitGroup. Now, creating a variable named UnitGroup will solve your syntax error, but it will create further problems in the code becase you would be destroying UnitGroup without ever giving it a value.

What you need to do, in addition to creating a variable named UnitGroup, is to then use the variable. Since I don't have the editor in front of me, the trigger would resemble something like this:
Code:
set UnitGroup = Units owned by (Owner of (Triggering Unit))
Unit Group - Pick every unit in <UnitGroup> and do Actions
...
Custom Script: call DestroyGroup(udg_UnitGroup)

Besides that, I'd like to request a JASS system, I'm not entirely sure whether to request it here, or in another thread, but anyways...
I just want a basic "-claim" and "-oust" system, much like Vampirism Beast system, my map has a few bases, which each player could claim by typing "claim" when certain unit is in the base. Then, when another unwanted (ally) player enters the base, the original player can say -oust, and the second player will be ousted from the base, along with all his units.
I'm not sure if I made myself clear, if not, just say so, I'll clarify it.
Thanks for your time
I'm sure there's a request forum somewhere which would be a better location to request such a system. However, making such a system isn't as complicated as you might think.

First, make a region for each base in the map. When a player types the "-claim" message, check each region to see if to see if that player has their specific unit in it. Once you know the region, check to see if another player has already claimed it (I recommend using a global array to store whether or not a player has claimed a certain base, each index in the array could refer to a different region and the value would be the player number of the owning player). Ex:
set regionOwnership[regionOne] = 1
Sets the owner of regionOne to Player(1)

Now, if the region isn't already owned (the values in the array should be set to 0 at map init to represent that each area isn't owned), then you just set ownership of the region to the player that typed the message.

With this all done, the "-oust" command is fairly trivial. When a player types "-oust", figure out which base region they own (if any) and then pick all units that are:
1. An ally of the triggering player
2. Not controlled by the triggering player
And if both conditions are met, move the unit somewhere else.

I hope this helps.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I think you have to add this:
  • Custom script: set bj_wantDestroyGroup = true
For each unit group you are about to use
Put that command above the Unit Group Action
By doing so, your unit group will be cleaned right after its usage

Example:
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Bla Bla Bla
 
Level 7
Joined
Jun 23, 2009
Messages
297
By "expected a name", the error really means that you don't have a global variable named UnitGroup. Now, creating a variable named UnitGroup will solve your syntax error, but it will create further problems in the code becase you would be destroying UnitGroup without ever giving it a value.

What you need to do, in addition to creating a variable named UnitGroup, is to then use the variable. Since I don't have the editor in front of me, the trigger would resemble something like this:
Code:
set UnitGroup = Units owned by (Owner of (Triggering Unit))
Unit Group - Pick every unit in <UnitGroup> and do Actions
...
Custom Script: call DestroyGroup(udg_UnitGroup)


Wow... that seems kinda complicated... Wouldn't defskull's method work better?



I'm sure there's a request forum somewhere which would be a better location to request such a system. However, making such a system isn't as complicated as you might think.

First, make a region for each base in the map. When a player types the "-claim" message, check each region to see if to see if that player has their specific unit in it. Once you know the region, check to see if another player has already claimed it (I recommend using a global array to store whether or not a player has claimed a certain base, each index in the array could refer to a different region and the value would be the player number of the owning player). Ex:
set regionOwnership[regionOne] = 1
Sets the owner of regionOne to Player(1)

Now, if the region isn't already owned (the values in the array should be set to 0 at map init to represent that each area isn't owned), then you just set ownership of the region to the player that typed the message.

With this all done, the "-oust" command is fairly trivial. When a player types "-oust", figure out which base region they own (if any) and then pick all units that are:
1. An ally of the triggering player
2. Not controlled by the triggering player
And if both conditions are met, move the unit somewhere else.

I hope this helps.


Well yeah, I actually kinda know how to make it via triggers, but I thought It'd be rather inefficient... I'm not sure, correct me if I'm wrong...
Like, creating a separate trigger for each player (since Player - Triggering Player doesn't exist)...
Anyways, thank you both for the help, I'll make it via triggers until someone makes me a JASS version.
+REP, again, thanks
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Both ways will work
wyrmlord's way is by setting up variables first, before calling Unit Group function whereas mine, doesn't set the Unit Group variable first, I just use default Unit Group and clean it by using that custom script
If you follow my way, it's not specific, since we usually use Pick every unit in Playable map area
But if you set a variable out of it, you can be more specific with "in range matching conditions"
Choice is yours.
 
Level 11
Joined
Oct 13, 2005
Messages
233
Well yeah, I actually kinda know how to make it via triggers, but I thought It'd be rather inefficient... I'm not sure, correct me if I'm wrong...

Whether you create this system in GUI or have someone else give you a system in JASS, there should be no perceivable difference when playing the game.

In this case, efficiency is not important at all since the triggers will be run (relatively) rarely. Unless you're creating a spell/system that needs to run many times every second, efficiency is rarely a problem.

Because of this, I recommend trying to create the system on your own and then asking others for help if you run into difficulty along the way. The only way to become better at something is to practice it.
 
Status
Not open for further replies.
Top