• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Loading game screws trigger

Status
Not open for further replies.
After some time, I finally realized a bug in my system. When you load the game, something stops functioning. I discovered that the problem it is in this JASS command:

call GroupPointOrderLocBJ( udg_Battallion[udg_BattallionIndex ], generalOrder, target)

If I use a GUI equivalent, it works, but in this case, custom script code went more handy than GUI action, because I could call the function with generalOrder parameter only without need to create the list of all possible order. It works fine, until I save the game and load it, the units won't follow anymore. Here is the complete trigger

  • Battalion order point Copy
    • Events
      • Unit - A unit owned by Player 1 (Red) Is issued an order targeting a point
    • Conditions
      • (Unit-type of (Ordered unit)) Equal to InfantryCaptain
    • Actions
      • Custom script: local real Xmove=GetLocationX(GetOrderPointLoc())
      • Custom script: local real Ymove=GetLocationY(GetOrderPointLoc())
      • Custom script: local location target=Location(Xmove,Ymove)
      • Custom script: local string generalOrder = OrderId2StringBJ(GetIssuedOrderIdBJ())
      • Custom script: local integer udg_BattallionIndex = GetUnitUserData(GetOrderedUnit())
      • Custom script: call GroupRemoveUnitSimple( GetOrderedUnit(), udg_Battallion[udg_BattallionIndex ] )
      • Custom script: call GroupPointOrderLocBJ( udg_Battallion[udg_BattallionIndex ], generalOrder, target)
      • Custom script: call GroupAddUnitSimple( GetOrderedUnit(), udg_Battallion[udg_BattallionIndex ] )
It seems that the problem lies in variable generalOrder, evidently the order doesn't get converted to string.
 
Last edited:
Level 21
Joined
Aug 21, 2005
Messages
3,699
You... might as well just jass the whole thing :p

I also think you can't have more than 1 local in GUI...
Edit: sorry, I didn't see those locals are indeed locals and not "overloaded" globals so it should be ok

You also shouldn't use BJ's. Whether you're doing gui or not :p
EDIT: for some reason this message was posted already, I didn't mean to yet...

  • Battalion order point Copy
    • Events
      • Unit - A unit owned by Player 1 (Red) Is issued an order targeting a point
    • Conditions
      • (Unit-type of (Ordered unit)) Equal to InfantryCaptain
    • Actions
      • Custom script: local real Xmove=GetOrderPointX()
      • Custom script: local real Ymove=GetOrderPointY()
      • Custom script: local integer generalOrder = GetIssuedOrderId()
      • Custom script: local unit orderunit = GetOrderedUnit()
      • Custom script: local integer udg_BattallionIndex = GetUnitUserData(orderunit)
      • Custom script: call GroupRemoveUnit( udg_Battallion[udg_BattallionIndex ], orderunit )
      • Custom script: call GroupPointOrderById( udg_Battallion[udg_BattallionIndex ], generalOrder, Xmove, Ymove)
      • Custom script: call GroupAddUnit( udg_Battallion[udg_BattallionIndex ], orderunit )
      • Custom script: set orderunit = null
I don't know if that fixes the problem, probably not, but meh...

Have you checked on all other possible causes? Like, custom value not being saved for units when saving your map?
 
Finally now works, thank you very much, I always thought that the native value of the GUI Order type was string, not integer. The custom values, unit groups, ... everything was loaded correctly, I tested everything, so I ended up the order to string function not working correctly after loading the game. And about BJs, they are generated with GUI so in the end you are forced to use them if you use GUI

The reason I didn't jass the whole thing is because of easier adding of condition and eventual actions for debugging for example.

And why you cleared the unit variable? I thought that unit variables don't leak.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
I didn't remove the unit. I nulled the unit pointer which "fixes" a reference count bug with locals... So whenever you use a local handle, you need to null it at the end.

Before you freak out now, you only need to null variables when they're local (and not global) and you obviously don't need to "null" integers, reals, etc.

Actions for debugging are much much easier added through jass scripts... And conditions really aren't hard to do either... I just find it weird that you have like 100% custom scripts but you're still making it in gui :p
 
Status
Not open for further replies.
Top