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.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top