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
 

Sevion

The DIY Ninja
Reaction score
424
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.
 

Shadow

TH.net Regular
Reaction score
23
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
 

Shadow

TH.net Regular
Reaction score
23
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
 

tooltiperror

Super Moderator
Reaction score
231
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
 

Shadow

TH.net Regular
Reaction score
23
its not working i tested being player red but player 13 still is an enemy
 

Sevion

The DIY Ninja
Reaction score
424
Because it's not setting player red to an ally.

Change the starting integer to 0 instead of 1.
 

Shadow

TH.net Regular
Reaction score
23
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.
 

Sevion

The DIY Ninja
Reaction score
424
Try commenting out the if statement and see if anything works.

You really ought to learn how to debug your own code >_>
 

tooltiperror

Super Moderator
Reaction score
231
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?
 

tooltiperror

Super Moderator
Reaction score
231
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
 

Shadow

TH.net Regular
Reaction score
23
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 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