Few JASS problems +REP!

Lightstalker

New Member
Reaction score
55
1) I'm trying to pick all units of type X and change their ownership to Neutral Extra, but for some strange reason, it is not working.

JASS:
private function ChangeOwnership takes nothing returns boolean
    local unit u = GetEnumUnit()
    
    call BJDebugMsg(GetUnitName(u))
    if GetUnitTypeId(u) == ARMORY or GetUnitTypeId(u) == MARKETPLACE then
        call SetUnitOwner(u, Player(bj_PLAYER_NEUTRAL_EXTRA), false)
    endif
    
    set u = null
    return false
endfunction

private function Init takes nothing returns nothing
    call GroupEnumUnitsOfPlayer(TEMPGROUP, Player(PLAYER_NEUTRAL_PASSIVE), Condition(function ChangeOwnership))
endfunction


2) All my quests info are indented... Take this for example:

JASS:
    //CREDITS
    set q = CreateQuest()
    call QuestSetTitle(q, "Credits")
    call QuestSetDescription(q, "|cffFFCC00Denu|r: Behemoth skin
    |cffFFCC00General Frank|r: Bloodlord, Dragonlord, & Chaos Knight models
    |cffFFCC00jigrael|r: Skeletal Archer King model
    |cffFFCC00Norinrad|r: High-Elven Champion, Shield Master, & Battle Priest models
    |cffFFCC00Sephiroth_VII|r: Dark Mage model & icon
    |cffFFCC00unwirklich|r: Enhanced Attributes icons
    |nVisit |cff7777AATHUNDERPOWERstudios.co.cc|r for news, strategy guides, and more--all about THUNDERPOWER's maps!")
    call QuestSetIconPath(q, "ReplaceableTextures\\CommandButtons\\BTNMassTeleport.blp")
    call QuestSetRequired(q, false)
    call QuestSetDiscovered(q, true)
    call QuestSetCompleted(q, false)
    set q = null


When in-game, the first line is OK, but every line thereafter is indented.

3) The following trigger is supposed to give gold to players based on how many allied players are on their team:

JASS:
scope Income initializer Init

globals
    force INCOMEFORCE = CreateForce()
    integer PLAYERAMOUNT = -1
endglobals

private function CountPlayers takes nothing returns nothing
    set PLAYERAMOUNT = PLAYERAMOUNT + 1
endfunction

private function PickPlayers takes nothing returns nothing
    local player p = GetEnumPlayer()
    
    call ForceEnumAllies(bj_FORCE_ALL_PLAYERS, p, Condition(function True))
    call ForForce(INCOMEFORCE, function CountPlayers)
    call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + 500 / PLAYERAMOUNT)
endfunction

private function Actions takes nothing returns nothing
    call ForForce(INCOMEFORCE, function PickPlayers)
endfunction 

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEvent(t, 15.0, true)
    call TriggerAddAction(t, function Actions)
endfunction
endscope


For some reason, the gold added is always different...
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56


I don't think you need the Player() for that. Try it without.

JASS:
    call QuestSetDescription(q, "|cffFFCC00Denu|r: Behemoth skin
    |cffFFCC00General Frank|r: Bloodlord, Dragonlord, & Chaos Knight models
    |cffFFCC00jigrael|r: Skeletal Archer King model
    |cffFFCC00Norinrad|r: High-Elven Champion, Shield Master, & Battle Priest models
    |cffFFCC00Sephiroth_VII|r: Dark Mage model & icon
    |cffFFCC00unwirklich|r: Enhanced Attributes icons
    |nVisit |cff7777AATHUNDERPOWERstudios.co.cc|r for news, strategy guides, and more--all about THUNDERPOWER's maps!")
    call QuestSetIconPath(q, "ReplaceableTextures\\CommandButtons\\BTNMassTeleport.blp")


Use |n for a new line. For my quest log, I wrote it "all in one line" using delim comments. Works like a charm. I also didn't know you could just enter it out on new lines like that in JASS. Just put a |n before each comment and it will put in a new line.

JASS:
"BLAAAAAAAAAA |n /*
*/AAAAAAAAAAAAAAAA |n/*
*/AAAAAAAAA"


3) How do the alliances work in your map? Can they change? Also, the way you have that setup is a little confusing. Why not just have an integer keep track of the number of players in the force, and subtract one each time a player leaves or is defeated? The whole system only needs to execute one ForForce which only executes one line.
 

Lightstalker

New Member
Reaction score
55
Removing Player() gives errors. :(

If I put |n before each line, it skips a space. I guess I'd have to write EVERYTHING on one line if I'm going to use |n...

Alliances only change early on. There are 2 forces, each with 5 unallied players. However, after a player chooses a Hero he becomes allied to all other players in his force who have already selected a Hero.
Also, wouldn't I need to count all players in All Players to figure out what the starting integer would be?
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Removing Player() gives errors. :(

Ok, was wrong on that one.



If I put |n before each line, it skips a space. I guess I'd have to write EVERYTHING on one line if I'm going to use |n...

See my example using the comments? The code is all on one line, but it gives the appearance of many. The comments will actually ignore the enter in the code :)

Alliances only change early on. There are 2 forces, each with 5 unallied players. However, after a player chooses a Hero he becomes allied to all other players in his force who have already selected a Hero.
Also, wouldn't I need to count all players in All Players to figure out what the starting integer would be?[/QUOTE]

Yes, but you'd only have to do it once for the whole game. Also, interesting fact, yours will keep adding players.

JASS:
private function CountPlayers takes nothing returns nothing
    set PLAYERAMOUNT = PLAYERAMOUNT + 1
endfunction


After a few minutes each force will have hundreds of players :) That is probably the problem. It never resets.
 

Lightstalker

New Member
Reaction score
55
My PickPlayers function now looks like this:
JASS:
private function PickPlayers takes nothing returns nothing
    local player p = GetEnumPlayer()
    
    call ForceEnumAllies(bj_FORCE_ALL_PLAYERS, p, Condition(function True))
    call ForForce(INCOMEFORCE, function CountPlayers)
    call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + 500 / PLAYERAMOUNT)
    set PLAYERAMOUNT = 0
endfunction


Will that work? It works fine testing it by myself, but if multiple players are in-game, will it work?

Also, I have another quest in which I tried the */ thing. Maybe I did it wrong, but it's not working correctly, and in-game the */ show.

JASS:
    //COMMANDS
    set q = CreateQuest()
    call QuestSetTitle(q, "Commands")
    call QuestSetDescription(q, "Below is a list of commands that can be typed in the chat dialog to be used. In yellow is the command, and in white is its description./*
        */|n|cffFFCC00-clear|r //clears all text messages from the screen./*
        */|cffFFCC00-camdistXXXX|r //sets the camera distance. Replace all Xs by digits. Default value is 2,500./*
        */|cffFFCC00-camlock|r //locks the camera to your Hero./*
        */|cffFFCC00-camreset|r //resets the camera to default settings./*
        */|cffFFCC00-crtl[|r|cffFFCC00off|r/|cffFFCC00on]|r //denies/grants you control of your allied CPU's forces.")
    call QuestSetIconPath(q, "ReplaceableTextures\\CommandButtons\\BTNScourgeBuild.blp")
    call QuestSetRequired(q, true)
    call QuestSetDiscovered(q, true)
    call QuestSetCompleted(q, false)
    set q = null
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Oh right, I typed it wrong...

JASS:
"this |n" + /*
*/ "that |n" + /*
*/ "the other |n"


Really out of it tonight.
 

saw792

Is known to say things. That is all.
Reaction score
280
What would be easier than the delimited comments would be removing the indentation before each line:
JASS:
//
    call QuestSetDescription(q, "|cffFFCC00Denu|r: Behemoth skin
|cffFFCC00General Frank|r: Bloodlord, Dragonlord, & Chaos Knight models
|cffFFCC00jigrael|r: Skeletal Archer King model
|cffFFCC00Norinrad|r: High-Elven Champion, Shield Master, & Battle Priest models
|cffFFCC00Sephiroth_VII|r: Dark Mage model & icon
|cffFFCC00unwirklich|r: Enhanced Attributes icons
|nVisit |cff7777AATHUNDERPOWERstudios.co.cc|r for news, strategy guides, and more--all about THUNDERPOWER's maps!")
    call QuestSetIconPath(q, "ReplaceableTextures\\CommandButtons\\BTNMassTeleport.blp")
 

Lightstalker

New Member
Reaction score
55
@Frozenzelphir, that's how I typed it in the quest. Look again. :p

@ Saw792, that doesn't do anything. I tried. :(
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
@Frozenzelphir, that's how I typed it in the quest. Look again.

No you didn't! Look again.
Why don't you make it all-in-a-line?

You put " |n " to make the text pass a line. (Like in tooltips)

It is visually messy in the code. Using the delim comments you get the same thing but it appears to be on multiple lines.
 

SanKakU

Member
Reaction score
21
i don't get why the jass display for these forums displays so much text in red...it hurts my eyes to look at it.

anyway...where is the full trigger for your quests section? i've never actually done quests in jass lol...although i probably should...

ok, you're a freaking idiot. first of all, i don't know how you knew you can do this, but this is FREAKING AWESOME!!

I wish i knew how to do this sooner, i'm an idiot!

anyway...dude, look at your freaking code!

call QuestSetDescription(q, "|cffFFCC00Denu|r: Behemoth skin
|cffFFCC00General Frank|r: Bloodlord, Dragonlord, & Chaos Knight models
|cffFFCC00jigrael|r: Skeletal Archer King model
|cffFFCC00Norinrad|r: High-Elven Champion, Shield Master, & Battle Priest models
|cffFFCC00Sephiroth_VII|r: Dark Mage model & icon
|cffFFCC00unwirklich|r: Enhanced Attributes icons
|nVisit |cff7777AATHUNDERPOWERstudios.co.cc|r for news, strategy guides, and more--all about THUNDERPOWER's maps!")

what i did was replace every |c with |n|c and then went to each line and hit backspace twice there. i tested it and it's perfect. now you don't want it all in one line? ok, ctrl z a few times and just backspace once for each line. bam. you're done. i tested it and it's fine.

dude i'm going to plus reputation you for showing me this. i had no idea you could do this for strings. sweet!

back to the topic, just to make it clear what's going on here, and how i figured the solution...and btw saw398 or whatever his name is told you the answer you just weren't listening hard enough or he explained it poorly. that or you tested or implemented it wrong. so...what i mean to say is that...if you can keep everything in the "" marks part of the string, including line breaks why not indentations? so i took out the indentations, and bam, they're gone! it's simple.

edit: i guess i didn't know you could do this because in my WE TESH...which displays the colors for the coding, it does NOT say you can do this...in other words, take a gander at this site's ugly jass colors...the red means it's a string. but in my editor once you line break that string color(in my editor it's white(white on blackbackground)) is no longer there. that's why i had no idea you could do this. someone should fix this error of the editor.
 

Sevion

The DIY Ninja
Reaction score
413
i don't get why the jass display for these forums displays so much text in red...it hurts my eyes to look at it.

anyway...where is the full trigger for your quests section? i've never actually done quests in jass lol...although i probably should...

Um. What was the point of you posting?

Anyways,

JASS:
//CREDITS
    set q = CreateQuest()
    call QuestSetTitle(q, "Credits")
    call QuestSetDescription(q, "|cffFFCC00Denu|r: Behemoth skin
....|cffFFCC00General Frank|r: Bloodlord, Dragonlord, & Chaos Knight models
....|cffFFCC00jigrael|r: Skeletal Archer King model
....|cffFFCC00Norinrad|r: High-Elven Champion, Shield Master, & Battle Priest models
....|cffFFCC00Sephiroth_VII|r: Dark Mage model & icon
....|cffFFCC00unwirklich|r: Enhanced Attributes icons
....|nVisit |cff7777AATHUNDERPOWERstudios.co.cc|r for news, strategy guides, and more--all about THUNDERPOWER's maps!")
    call QuestSetIconPath(q, "ReplaceableTextures\\CommandButtons\\BTNMassTeleport.blp")
    call QuestSetRequired(q, false)
    call QuestSetDiscovered(q, true)
    call QuestSetCompleted(q, false)
    set q = null


See those "...."'s I put in? Those show up because it's just like writing:

Code:
"Blah|n    Blah"

Which will show up as

Code:
"Blah
    Blah"

In essence, this is what you wrote (what JH parses it to):

JASS:
"|cffFFCC00Denu|r: Behemoth skin|n    |cffFFCC00General Frank|r: Bloodlord, Dragonlord, & Chaos Knight models|n    |cffFFCC00jigrael|r: Skeletal Archer King model|n    |cffFFCC00Norinrad|r: High-Elven Champion, Shield Master, & Battle Priest models|n    |cffFFCC00Sephiroth_VII|r: Dark Mage model & icon|n    |cffFFCC00unwirklich|r: Enhanced Attributes icons|n    |nVisit |cff7777AATHUNDERPOWERstudios.co.cc|r for news, strategy guides, and more--all about THUNDERPOWER's maps!"
 

SanKakU

Member
Reaction score
21
"Um. What was the point of you posting?"

when i post in threads to help out i DO NOT simply give them a message. I DO THREE THINGS

FIRST THING: REPLY TO THE MESSAGE WITH MY CURRENT KNOWLEDGE OF THE SITUATION AND GIVE ANY INFORMATION I THINK MIGHT BE USEFUL

SECOND THING: WHEN I HAVE A MOMENT I EXPERIMENT WITH TRYING TO SOLVE THE PROBLEM

THIRD THING: REPLY WITH MY RESULTS

you only saw the first stage of my reply. check the post, i updated it.

anyway...it looks like we're both telling him the same thing.
 

Sevion

The DIY Ninja
Reaction score
413
It'd be a simple thing to skip "stage 1". It doesn't help.

The "bug" you experienced with TESH not highlighting line breaks is because TESH doesn't have that feature. It's a simple thing to use |n instead of enter anyways.
 

SanKakU

Member
Reaction score
21
It'd be a simple thing to skip "stage 1". It doesn't help.

The "bug" you experienced with TESH not highlighting line breaks is because TESH doesn't have that feature. It's a simple thing to use |n instead of enter anyways.

but you don't understand...because I cannot see that JASS allows line breaks when attempting to line break because the color does not stay as string color why would I think that |n would work?

if the uneditable color display for jass on this forums has that feature i think the editable color display for jass in the editor certainly should also.

this stupidity on my part actually stifled my ability to give text messages in my games in JASS for a VERY long time.

doing stage 1 is useful in case i forget to get back to the thread. i can search for threads that i posted in, see my stage 1 post after i completed stage 2, and proceed to stage 3. in the case where i do not reply right away and i only did stage 2 i would never do stage 3, and thus i would never help. so you are wrong about that.
 

Lightstalker

New Member
Reaction score
55
Thanks everyone I fixed it.

When I tried removing the line break, I only removed one indentation, and not the 2 that were in the editor. However, in-game it only appeared as one indentation. I suppose you can only have 1 indent.

Anyway, it's fixed, I did what Sevion said. Thx everyone.

Now if someone could help me with problem 1 & 2, that would be great. :p
 

SanKakU

Member
Reaction score
21
Thanks everyone I fixed it.

When I tried removing the line break, I only removed one indentation, and not the 2 that were in the editor. However, in-game it only appeared as one indentation. I suppose you can only have 1 indent.

Anyway, it's fixed, I did what Sevion said. Thx everyone.

Now if someone could help me with problem 1 & 2, that would be great. :p

yeah that's pretty weird.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top