New Jasser with some questions

Shadow

TH.net Regular
Reaction score
23
Question 1

Alright first off, hello!

So i've been jassing on and off for a few months now. I had a teacher but he stopped playing so now i'm on my own for now.

So first off I wanna make a trigger where at the start all allies of red ally neutral victim.

So I start in Gui and construct my my trigger.

Trigger:
  • Select Players
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Player - Make (Picked player) treat Neutral Victim as an Ally with shared vision)


Then I convert to custom text
JASS:
function Trig_Select_Players_Func002002 takes nothing returns nothing
    call SetPlayerAllianceStateBJ( GetEnumPlayer(), Player(bj_PLAYER_NEUTRAL_VICTIM), bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_Select_Players_Actions takes nothing returns nothing
    call ForForce( GetPlayersAllies(Player(0)), function Trig_Select_Players_Func002002 )
endfunction

//===========================================================================
function InitTrig_Select_Players takes nothing returns nothing
[/FONT]    set gg_trg_Select_Players = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Select_Players, function Trig_Select_Players_Actions )
endfunction



Normally I would inline ( I believe this means finding the root function in some of the functions written in red)
but when I attempt to inline SetPlayerAllianceStateBJ a whole bunch comes up so i think maybe if I created a function that cycled (looped) through the players and allied neutral victim would be the best way to go, no? But unfortunately my players on the teams aren't in integer order, example Player Red (0) and Player Blue (1) are on separate teams so now I believe the way to go is to make a filter but I am clueless how to set one up.


----------------
Question 2

How can I determine the attack damage of a unit because I want it so when a hero gets a powerup he does 2x damage
 
For the first one, I would choose to loop through all players and in the loop have an if statement. If the player is an ally of Red, ally that player with Neutral Victim.

For the second one, you would need some complex scripting or some ingenious method to pull this off. There's no real good way to get damage. You can alternatively script all aspects of damage with something like Damage.
 
For the first one, I would choose to loop through all players and in the loop have an if statement. If the player is an ally of Red, ally that player with Neutral Victim.

What would the if statement look like sorry im not that used to using conditions only thing i know how to do in ifs is to compare an integer value

like

if i == 2
then blah
endif

I feel it must be a boolean but im just not sure what the condition would look like
 
Dang I was so close I had that but put call infront of it XD

edit

whats wrong with this?

JASS:
function Select_Team_One takes nothing returns nothing
    local integer i
    set i = -1
loop
    if IsPlayerAlly(Player(i),Player(0)) then
    call SetPlayerAlliance( Player(i), Player(13), bj_ALLIANCE_ALLIED_VISION,true )
    endif
    set i = i + 1
    exitwhen i == 11
endloop
endfunction


//===========================================================================
function InitTrig_Select_Players takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Select_Team_One)
    endfunction


says something like cannot convert integer to alliance type
 
Because [LJASS]SetPlayerAlliance[/LJASS] takes an [ljass]alliancetype[/ljass] as its third argument, and [ljass]bj_ALLIANCE_ALLIED_VISION[/ljass] is an integer.

You have to use one of these ally types:

Which are all defined in common.j.

Also, indent properly. Every block is indented four spaces per convention.

There is no reason to declare [ljass]integer i[/ljass] and then set it on the next line. You can do it all in one line as [ljass]local integer i = -1[/ljass].

I hope you also realize you are doing a worthless comparison by starting at [ljass]Player(-1)[/ljass], because that's an invalid player.

Your whole code should end up looking like this.
JASS:
function Select_Team_One takes nothing returns nothing
    local integer i = 1
    
    loop
        if IsPlayerAlly(Player(i), Player(0)) then
            call SetPlayerAlliance(Player(i), Player(13), ALLIANCE_SHARED_VISION, true)
        endif
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
endfunction

function InitTrig_Select_Players takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Select_Team_One)
endfunction
 
its not working i tested being player red but player 13 still is an enemy
 
Because it's not setting player red to an ally.

Change the starting integer to 0 instead of 1.
 
JASS:
function Select_Team_One takes nothing returns nothing
    local integer i = 0
    
    loop
        if IsPlayerAlly(Player(i), Player(0)) then
            call SetPlayerAlliance(Player(i), Player(13), ALLIANCE_SHARED_VISION, true)
        endif
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
endfunction
//===============================================================
function InitTrig_Select_Players takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Select_Team_One)
endfunction


still nothing, i even tried changing it to an ally of red thinking maybe red isnt really an ally of red since they are red. But still nothing.
 
Try commenting out the if statement and see if anything works.

You really ought to learn how to debug your own code >_>
 
What does this display?

JASS:
?function Select_Team_One takes nothing returns nothing?
?    local integer i = 0?
    call BJDebugMsg("Start")
?    ?
?    loop?
?        if IsPlayerAlly(Player(i), Player(0)) then?
            call BJDebugMsg("Player " + I2S(i) + " allied")
?            call SetPlayerAlliance(Player(i), Player(13), ALLIANCE_SHARED_VISION, true)?
?        endif?
?        set i = i + 1?
?        exitwhen i == bj_MAX_PLAYER_SLOTS?
?    endloop?
?endfunction?
?//===============================================================?
?function InitTrig_Select_Players takes nothing returns nothing?
?    local trigger t = CreateTrigger()?
?    call TriggerAddAction(t, function Select_Team_One)?
?endfunction?
 
It's because you're using a local trigger and adding an action to it, but the trigger is never executed.

Use a scope.

JASS:
scope TeamSetup initializer onInit
    private function onInit takes nothing returns nothing
        local integer i = 0
        call BJDebugMsg("This is how we do it!")
    
        loop
            if IsPlayerAlly(Player(i), Player(0)) then
                call SetPlayerAlliance(Player(i), Player(13), ALLIANCE_SHARED_VISION, true)
                call BJDebugMsg("Player " + I2S(i) + " allied!")
            endif
            set i = i + 1
            exitwhen i == bj_MAX_PLAYER_SLOTS
        endloop
    endfunction
endscope
 
JASS:
scope TeamSetup initializer onInit
    private function Select_Team_One takes nothing returns nothing
        local integer i = 0
        call BJDebugMsg("This is how we do it!")
    
        loop
            if IsPlayerAlly(Player(i), Player(0)) then
                call SetPlayerAlliance(Player(i), Player(13), ALLIANCE_SHARED_VISION, true)
                call BJDebugMsg("Player " + I2S(i) + " allied!")
            endif
            set i = i + 1
            exitwhen i == bj_MAX_PLAYER_SLOTS
        endloop
    endfunction
    
    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddAction(t, function Select_Team_One)
    endfunction
endscope


did i do it wrong? Cause still no messages displaying

EDIT: nvm I didn't need to add anything.

EDIT2: message displays but they still are not allied

EDIT3: Okay I found the solution ALLIANCE_SHARED_VISION only shares my vision with Player(13)

from what I understand I wanted Alliance Passive

ALLIANCE_PASSIVE
Prevents enemies flagging as hostile.

ALLIANCE_SHARED_XP
Enables hero EXP to be shared.

ALLIANCE_SHARED_SPELLS
Enables the targeting behaviour of spells to be friendly towards them.

ALLIANCE_HELP_REQUEST
ALLIANCE_HELP_RESPONSE
Enables the allied attack notifications.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/
  • The Helper The Helper:
    Happy Thursday!
  • Ghan Ghan:
    I'm not so sure, there's still a lot of Thursday left for it to become unhappy.
    +3
  • The Helper The Helper:
    still a few hours
  • The Helper The Helper:
    Its Friday!!!!
    +1
  • Ghan Ghan:
    Thursday 7/10 would Thursday again
    +3

      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