• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Issues with creating a series of Triggers in sequence

Status
Not open for further replies.
Level 13
Joined
Jul 26, 2008
Messages
1,009
I'm having trouble with a Quest series. Basically the quest activates for every player who is currently playing (And not Player(3))

I figured I had it perfect, but the quests show up twice when you initiate it by stepping into the rect. Also, it does not destroy the first trigger on the second trigger like it should.

Thanks for the help! I'm trying to make it MPI. I've also created a dummy FX in a localized string and move it for each player so player A will see a kid by the lighthouse after completing the quest but player B will see him at the hideout. I know strings are a little specialized with desyncs so it'd be good to know if I did this part right as well.

JASS:
scope LightHouseQuest initializer Init

globals
    public trigger array Quest1
    public trigger array Quest2
    public trigger array Quest3
    private effect FX
endglobals

private function Actions3 takes nothing returns nothing
 local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0, "|cffffd700LIGHTHOUSE KEEPER|r: You Found Him! Here are the keys! Its all yours!" )
    if GetOwningPlayer(gg_unit_nC48_0523) == Player(PLAYER_NEUTRAL_PASSIVE) then
        call SetUnitOwner( gg_unit_nC48_0523, GetOwningPlayer(GetTriggerUnit()), true )
        call SetUnitInvulnerable( gg_unit_nC48_0523, false )
    else
        set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 'nC06', 10735, 5739, 270)
        call IssuePointOrder(bj_lastCreatedUnit, "move", GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()))
    endif
 call DestroyTrigger( Quest3[id] )
 set Quest3[id] = null
endfunction

private function Actions2 takes nothing returns nothing
 local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    if IsUnitType(GetTriggerUnit(), UNIT_TYPE_UNDEAD) and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetPlayerController(GetOwningPlayer(GetTriggerUnit())) == MAP_CONTROL_USER then
        call DestroyTrigger( Quest1[id] )
        set Quest1[id] = null
        call DestroyTrigger( Quest2[id] )
        set Quest2[id] = null
        call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0,"|cffffd700KEEPERS SON|r: My dad sent you? oh... I come here to play with my friends sometimes... I guess I stayed out too long. You look weird, Oh well, I better go" )
        set Quest3[id] = CreateTrigger()
            call TriggerRegisterEnterRectSimple( Quest3[id], gg_rct_QuestLightHouse )
            call TriggerAddAction( Quest3[id], function Actions3 )
        call TriggerSleepAction( 2.00 )
        call IssuePointOrderLoc( gg_unit_nvlk_0611, "move", GetRandomLocInRect(gg_rct_QuestLHouseSon) )
        call IssuePointOrderLoc( gg_unit_nvlk_0612, "move", GetRandomLocInRect(gg_rct_QuestLHouseSon) )
        call TriggerSleepAction( 10.00 )
        if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
            call DestroyEffect(FX)
            set FX = AddSpecialEffect("units\\critters\\VillagerKid1\\VillagerKid1.mdl", 10818, 5357 )
        endif
    endif
endfunction

private function Actions1 takes nothing returns nothing
 local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    if IsUnitType(GetTriggerUnit(), UNIT_TYPE_UNDEAD) and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetPlayerController(GetOwningPlayer(GetTriggerUnit())) == MAP_CONTROL_USER then
        if Quest2[id] == null then
            call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0, "|cffffd700LIGHTHOUSE KEEPER|r: Please..... I don't know what you are, but find my boy and bring him back... I don't have much, but you can have my Armoured Car if you find him. Its not as fast as other cars, but it has Weaponry and formidable armour. I last saw my son to the southeast of Bob's Guns, near the cities walls." )
             set Quest2[id] = CreateTrigger()
                call TriggerRegisterEnterRectSimple( Quest2[id], gg_rct_QuestLHouseSon )
                call TriggerAddAction( Quest2[id], function Actions2 )
        else
            call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0, "|cffffd700LIGHTHOUSE KEEPER|r: My son, I saw him just southeast of Bobs. Find him, please." )
        endif
    endif
endfunction

//===========================================================================
public function Init takes nothing returns nothing
local integer i = 0
    set FX = AddSpecialEffect("units\\critters\\VillagerKid1\\VillagerKid1.mdl", 1320, 4358 )
    loop
    exitwhen i == 12
        if i != 3 and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
         set Quest1[i] = CreateTrigger()
            call TriggerRegisterEnterRectSimple( Quest1[i], gg_rct_QuestLightHouse )
            call TriggerAddAction( Quest1[i], function Actions1 )
        endif
     set i = i + 1
    endloop
endfunction

endscope
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
When you're using strings locally try to make sure that the primary string is initialized for all players, and then changed for the players who aren't supposed to see it.

Basically:

JASS:
local string s = "special"
local integer i = 0
loop
    exitwhen i == 12
    if (somePlayerProperty(i)) then
        s = null
    endif
    set i = i + 1
endloop

Rather than:

JASS:
local string s = null
local integer i = 0
loop
    exitwhen i == 12
    if not (somePlayerProperty(i)) then
        set s = "special"
    endif
    set i = i + 1
endloop

Just make sure that every player has an initialized copy of the string before it is used; this prevents certain players having different string tables than others (which could cause a desync).
 
Status
Not open for further replies.
Top