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

empty

Status
Not open for further replies.
Level 12
Joined
Jun 15, 2016
Messages
472
No, no not at all! I don't want a dead AI! I just need the AI to obey when you want to intervene with what it's doing, that's all.

That's not going to be as easy as you think. My best idea for how to do this goes like this:

1. Once you send the computer controlled hero a command, store the order id and the target location\unit whatever.
2. Start a timer for X seconds, during which, if the hero receives an order, send the order you stored again.
3. Once the timer stops/target has been reached, stop overriding methods received.

This is the basic outline. BUT, and you might want to allow some orders because some might be essential for normal unit action. And there are a lot of things to consider, like: aggro range and recurring orders, orders following your own walk order (might create something akin to an infinite loop), non immediate build and spell orders (including mana/resource refunding in case of order interrupts), and the effect of a stray unit on general AI behavior (might cause captains to act funky).

Sounds like an interesting experiment, and something someone probably tried doing already. I really suggest searching the hive for questions about this. If you want to try my way, go here for more info:

Orders repo

Missions (see mission 1 - order tracking)
 
Level 4
Joined
Jan 9, 2019
Messages
70
Hmm, maybe you can change the ownership of the unit for 10 second and give back to the original owner after this. Is a posibility...
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
You probably gave the best answer/idea to this.
Per ABronzeCross's other post:

  • Events
    • Unit - A unit is issued an order targeting an object //"object" may not be the correct term
    • Unit - A unit is issued an order targeting a point
    • Unit - A Unit is issued an order with no target
  • Conditions
    • (Owner of (Triggering Unit)) not equal to (Triggering Player) //Triggering Player should work here
  • Actions
    • Custom script: local unit udg_Change_Unit
    • Custom script: local player udg_Change_Player
    • Set Change_Unit = (Triggering Unit)
    • Set Change_Player = (Owner of (Triggering Unit))
    • Unit - Change owner of Change_Unit to (Triggering Player) without changing color
    • Wait 10.00 game-time seconds
    • Unit - Change owner of Change_Unit to Change_Player without changing color
    • -------- might not need these lines, but my suspicion is you will: --------
    • Custom script: set udg_Change_Unit = null
    • Custom script: set udg_Change_Player = null
 
Level 12
Joined
Jun 15, 2016
Messages
472
Per ABronzeCross's other post:

  • Events
    • Unit - A unit is issued an order targeting an object //"object" may not be the correct term
    • Unit - A unit is issued an order targeting a point
    • Unit - A Unit is issued an order with no target
  • Conditions
    • (Owner of (Triggering Unit)) not equal to (Triggering Player) //Triggering Player should work here
  • Actions
    • Custom script: local unit udg_Change_Unit
    • Custom script: local player udg_Change_Player
    • Set Change_Unit = (Triggering Unit)
    • Set Change_Player = (Owner of (Triggering Unit))
    • Unit - Change owner of Change_Unit to (Triggering Player) without changing color
    • Wait 10.00 game-time seconds
    • Unit - Change owner of Change_Unit to Change_Player without changing color
    • -------- might not need these lines, but my suspicion is you will: --------
    • Custom script: set udg_Change_Unit = null
    • Custom script: set udg_Change_Player = null

You can create local variables with udg then refer to them with gui set variable? What sorcery is this?!
I mean it makes sense, global/local modifiers shouldn't matter when assigning variables but that is a neat trick.
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
Research is no-target, build is point-target, item drop is either point- or object-target (idk). They’re all covered.

You can create local variables with udg then refer to them with gui set variable? What sorcery is this?!
I mean it makes sense, global/local modifiers shouldn't matter when assigning variables but that is a neat trick.
No those variables have to be created in the variable editor. What I did is called local shadowing to make them behave as local variables.
 
Level 12
Joined
Jun 15, 2016
Messages
472
No those variables have to be created in the variable editor. What I did is called local shadowing to make them behave as local variables.
So this is hiding a global variable with a local variable, same as hiding a static variable in java for example? Does the value assigned to the local variable stick to the global variable, or are they two separate entities?
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
So this is hiding a global variable with a local variable, same as hiding a static variable in java for example? Does the value assigned to the local variable stick to the global variable, or are they two separate entities?
Yes basically the same thing, but within the scope of the trigger if a global is shadowed only the local 'copy' can be accessed (no way to refer to the global 'copy'). They keep separate values and the shadowed 'copy' can leak if it's a handle so you still need to null it. This trick only works in GUI because you can't re-use a variable name for a global and a local in JASS without throwing an error.
 
As a C++ coder, I find that unusual.
What if you want it to leak? Will it crash or error?
JASS is strange.

It is strange if you're accustomed to the coding world. GUI is weird in a way.

Leak in JASS would be where the data is inaccessible, yet it still consumes some memory spaces. This result in the map becoming laggier and laggier with more leaks occurring.
 
Status
Not open for further replies.
Top