Question about Threat System and using Custom Scripts

tommerbob

Minecraft. :D
Reaction score
110
Question about using custom scripts:

I am using Zwiebelchen's Threat System. He has a function included that lets me check the combat state of a unit. Here's the specific part of the system that is concerned:

JASS:

//      call ZTS_GetCombatState(unit PU) returns boolean:
//
//          Returns the combat state of a player unit.
//          Returns true, if the unit is registered and in combat.
//          Returns false, if the unit is not registered or out of combat.


But I'm noob at Jass, so I'm wondering if anyone can tell me the custom script lines I need to use to check for that boolean in GUI. Thanks in advance.
 

DioD

New Member
Reaction score
57
set udg_boolean_for_gui = ZTS_GetCombatState(unit PU)

then use this boolean global in checks, conditions, events or whatever.
 

tommerbob

Minecraft. :D
Reaction score
110
Hmm, maybe I'm doing it wrong. This is what I have:

I tried this first:

Trigger:
  • GetCombatState
    • Events
      • Player - Player 1 (Red) types a chat message containing -combat as An exact match
    • Conditions
    • Actions
      • Custom script: set udg_ZTS_InCombat[GetConvertedPlayerId(GetTriggerPlayer())] = ZTS_GetCombatState(udg_Hero[GetConvertedPlayerId(GetTriggerPlayer())])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ZTS_InCombat[(Player number of (Triggering player))] Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: Hero is in combat
        • Else - Actions
          • Game - Display to (All players) the text: Hero is NOT in combat


But that didn't work. So I tried this, not knowing what I'm doing:

Trigger:
  • GetCombatState
    • Events
      • Player - Player 1 (Red) types a chat message containing -combat as An exact match
    • Conditions
    • Actions
      • Custom script: call ZTS_GetCombatState(udg_Hero[GetConvertedPlayerId(GetTriggerPlayer())])
      • Custom script: set udg_ZTS_InCombat[GetConvertedPlayerId(GetTriggerPlayer())] = ZTS_GetCombatState(udg_Hero[GetConvertedPlayerId(GetTriggerPlayer())])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ZTS_InCombat[(Player number of (Triggering player))] Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: Hero is in combat
        • Else - Actions
          • Game - Display to (All players) the text: Hero is NOT in combat


But that doesn't work either. No game message shows up. What am I doing wrong?
 

LoveTD's

New Member
Reaction score
34
Custom script: set udg_ZTS_InCombat[GetConvertedPlayerId(GetTriggerPlayer())] = ZTS_GetCombatState(udg_Hero[GetConvertedPlayerId(GetTriggerPlayer())])

shouldn't this be:

Custom script: set udg_ZTS_InCombat[GetConvertedPlayerId(GetTriggerPlayer())] = call ZTS_GetCombatState(udg_Hero[GetConvertedPlayerId(GetTriggerPlayer())])

I'm surprised it's not giving a compiling error 0.o
you have to call the function in order to return the boolean right?
 

Bribe

vJass errors are legion
Reaction score
67
local unit u = GetTriggerUnit()

no "call" keyword is necessary unless it's at the start of the line. Having it anywhere else will cause a syntax error.
 

tommerbob

Minecraft. :D
Reaction score
110
no "call" keyword is necessary unless it's at the start of the line. Having it anywhere else will cause a syntax error.

Yeah I tried that, got a syntax error.

local unit u = GetTriggerUnit()

What does this have to do with anything? I'm not using a local because I want to reference this boolean in several different triggers. And there is no Triggering unit.

Still confused....
 

Bribe

vJass errors are legion
Reaction score
67
What does this have to do with anything?

I was illustrating a common example to demonstrate that the "call" keyword is nowhere to be found so that he could get an idea.

No game message is showing up at all? You need to show where udg_Hero is set because that is probably where the error is.
 

tommerbob

Minecraft. :D
Reaction score
110
I was illustrating a common example to demonstrate that the "call" keyword is nowhere to be found so that he could get an idea.

Ahh okay.

No game message is showing up at all? You need to show where udg_Hero is set because that is probably where the error is.

Here is the trigger where I set the udg_Hero variable: (I know that it works because I reference udg_Hero in several different triggers and they run perfectly fine.)

Trigger:
  • choose hero beta
    • Events
      • Game - GDC_Event becomes Equal to 1.00
    • Conditions
      • (Hero pick <gen> contains (Triggering unit)) Equal to True
    • Actions
      • Unit - Remove Hero[(Player number of (Triggering player))] from the game
      • Unit - Move (Triggering unit) instantly to Hero_Start
      • Unit - Change ownership of (Triggering unit) to (Triggering player) and Retain color
      • Selection - Select (Triggering unit) for (Triggering player)
      • -------- CAMERA SETUP --------
      • Camera - Pan camera for (Triggering player) to Hero_Start over 0.00 seconds
      • -------- STARTING ABILITIES --------
      • Unit - Add Starting Magic Resist to (Triggering unit)
      • Unit - Add Magic Resist to (Triggering unit)
      • ------------------
      • Set Hero[(Player number of (Triggering player))] = (Triggering unit)
      • ------------------
      • Visibility - Create an initially Enabled visibility modifier for (Triggering player) emitting Visibility across (Playable map area)
      • -------- ADD HERO TO THREAT SYSTEM --------
      • Custom script: call ZTS_AddPlayerUnit(GetTriggerUnit())
      • -------- SETUP MULTIBOARD --------
      • Trigger - Turn on One second periodic <gen>
      • Trigger - Run Multiboard Setup <gen> (ignoring conditions)


(The event is from tooltiperror's Double-click system.)

EDIT: Okay now this is stupid. I made a test map, and everything works fine. But all the triggers dealing with the Threat System are the exact same in both maps. Sigh.... :banghead:

here's the test map:
 

Attachments

  • Threat system test.w3x
    40.5 KB · Views: 223

tommerbob

Minecraft. :D
Reaction score
110
Since no message was displayed at all, I thought maybe the trigger was not even running. So I changed it to this:

Trigger:
  • Testing
    • Events
      • Player - Player 1 (Red) types a chat message containing -hello as An exact match
    • Conditions
    • Actions
      • Game - Display to (All players) the text: hello!


And guess what? It doesn't run. I have no idea why. I have several chat message triggers that all run perfect, except this one. Why?

Help would be greatly appreciated.

EDIT: I've done some testing. I created a simple trigger exactly like the one above in a blank map. I tested the map. The trigger runs just fine. I then copied the exact trigger to my map, tested it, it will NOT run. sigh.... So then I created several different types of triggers, periodic triggers, spell casting triggers, etc. NONE OF THEM will work.

All original triggers in my map work flawlessly as expected. Any NEW trigger I create WILL NOT WORK.

Again, anyone have any clue why?
 

tommerbob

Minecraft. :D
Reaction score
110
Problem solved!

I did some more testing. I put several actions in a row, to see if any of them would run. Some did, some did not. The actions that did not run were "Game - Display to (All Players) the message:". But all of the others DID run. I thought that was strange, so I changed (All Players) to (Player Group - Player 1) and GUESS WHAT, the actions ran just fine. So I did a quick search here on the site for "all players bug" and I learned something new: Destroying All Players force is a no no! I went back through my triggers and realized that I was destroying the (All Players) Force in my Initialization trigger. Aha!! :p :) :) :)

Edit: Sorry double post.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top