Question about Threat System and using Custom Scripts

tommerbob

Minecraft. :D
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
set udg_boolean_for_gui = ZTS_GetCombatState(unit PU)

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

tommerbob

Minecraft. :D
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
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
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
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
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
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

tommerbob

Minecraft. :D
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
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.
  • tom_mai78101 tom_mai78101:
    Make sure you keep checking out my news..
    +2
  • Jesus4Lyf Jesus4Lyf:
    Man, I made this account 15 years ago? Wild. :)
  • Ghan Ghan:
    Seeing J4L is definitely a blast from the past.
  • Jesus4Lyf Jesus4Lyf:
    Oh hey Ghan! Long time. :)
    +1
  • jonas jonas:
    J4L! What has happened in your life
  • Jesus4Lyf Jesus4Lyf:
    Hmm, how to summarize... Moved to the USA and got married. Became a professional software engineer and solution lead. Learning Godot for game dev. :)
  • jonas jonas:
    So you are pursuing game dev as a hobby? What industry is your dayjob in?
  • jonas jonas:
    FAANG?
  • Jesus4Lyf Jesus4Lyf:
    Not quite FAANG, less pay for a less hours/stress. Yeah, game dev as a hobby.
  • jonas jonas:
    makes sense. Do we have a hobby game dev subforum to showcase some work?
  • Blackveiled Blackveiled:
    Happy Thursday
    +1
  • The Helper The Helper:
    Happy Thursday!
  • The Helper The Helper:
    TGIF!
  • The Helper The Helper:
    hey tom_mai please do not archive anymore news
  • Ghan Ghan:
    AMD Ryzen 7000 next week :D
    +1
  • The Helper The Helper:
    noice!
  • tom_mai78101 tom_mai78101:
    "hey tom_mai please do not archive anymore news" ----> Got it. What should we do with the "News Archive" subforum?
  • The Helper The Helper:
    I think leave it for real old news that cannot be sorted the reason we had it in the first place was a server issue that we do not have anymore. I don't want to get rid of the archive just not put anything in it for now until we figure it out more
  • The Helper The Helper:
    The side chat has nothing on the discord. it is not possible but the biggest thing on my wish list right now is a sidechat channel on the disord that hooks up to this...
  • Ghan Ghan:
    I've been selected for the Diablo IV beta.
    +1
  • Ghan Ghan:
    Woo!
    +1
  • The Helper The Helper:
    that is so cool
  • V-SNES V-SNES:
    Eh just noticed the new discord section on the side. Looks great!
    +1
  • Blackveiled Blackveiled:
    :( feels bad I can't ever get selected for any beta I sign up for. It's annoying as heck.
    +1

    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