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
413
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
413
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
413
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 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 The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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