wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 11-01-2006, 07:22 PM   #1
Fulla
Evil Overlord
 
Fulla's Avatar
 
Join Date: Jan 2006
Posts: 1,416

Submissions (3)

Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)

Default JASS: Quick simple system trouble

K what I want to do eventually is>

I have X number of beacons across the map.
I want to randomly shuffle them i.e. share them amongst the players PLAYING.

So I thought id run a loop with a local player array setting them to the active players like so

Collapse JASS:
function Trig_RandomOwner_Check takes integer temp returns boolean
    return (GetPlayerSlotState(ConvertedPlayer(temp)) == PLAYER_SLOT_STATE_PLAYING )
endfunction

function Trig_RandomOwner_Actions takes nothing returns nothing
    local player array owner
    local integer temp = 0
    loop
        exitwhen temp == 12
        if Trig_RandomOwner_Check(temp) then
        set owner[temp] = ConvertedPlayer(temp)
        call DisplayTextToForce(GetPlayersAll(), "1")
        else
        call DisplayTextToForce(GetPlayersAll(), "2") 
        endif
        set temp = temp + 1
    endloop        
endfunction

//===========================================================================
function InitTrig_RandomOwner takes nothing returns nothing
    set gg_trg_RandomOwner = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_RandomOwner, 1.00 )
    call TriggerAddAction( gg_trg_RandomOwner, function Trig_RandomOwner_Actions )
endfunction

This causes a crash? ;/

I was hoping to get something like this

player array 0 = player 0 (active)
player 1 inactive
player 2 inactive
player 3 inactive
player array 1 = player 4 (active)
etc.

Then I count how many players active in the game & run a loop.
Sharing beacons amongst the active players.

- Why does this crash?
- Is this a good method to do it?

thx
__________________
Fulla is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 11-01-2006, 07:47 PM   #2
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,375

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

ConvertedPlayer(temp)

Should be:

Player(temp)

You are passing 0 to ConvertedPlayer, which crashes (no player -1).
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 11-01-2006, 09:23 PM   #3
Chuckle_Brother
Oh for the sake of fudge
 
Chuckle_Brother's Avatar


Respected User
 
Join Date: Dec 2005
Posts: 782

Submissions (2)

Chuckle_Brother will become famous soon enough (53)Chuckle_Brother will become famous soon enough (53)

Send a message via ICQ to Chuckle_Brother Send a message via AIM to Chuckle_Brother Send a message via MSN to Chuckle_Brother Send a message via Yahoo to Chuckle_Brother
Default

Verily, keep in mind that with Player, you should only go up to 11.
__________________
"...you play a mean banjo"
Chuckle_Brother is offline   Reply With Quote
Old 11-01-2006, 09:34 PM   #4
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,375

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

He does only go up to 11. He goes from 0 to 11.
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 11-01-2006, 09:42 PM   #5
Fulla
Evil Overlord
 
Fulla's Avatar
 
Join Date: Jan 2006
Posts: 1,416

Submissions (3)

Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)

Default

ok I managed to get that part working.

Now part 2 crashes again :-(

Collapse JASS:
function Trig_RandomOwner_Count takes nothing returns boolean
    return (GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING)
endfunction

function Trig_RandomOwner_Check takes integer ppl returns boolean
    return (GetPlayerSlotState(Player(ppl)) == PLAYER_SLOT_STATE_PLAYING)
endfunction

function Trig_RandomOwner_Group takes nothing returns nothing
    call SetUnitOwner(GetEnumUnit(), udg_owner[udg_number], true)
endfunction

function Trig_RandomOwner_Actions takes nothing returns nothing
    local integer temp = 1
    local integer ppl = 0
    local integer count = CountPlayersInForceBJ(GetPlayersMatching(Condition(function Trig_RandomOwner_Count)))
    loop
        exitwhen temp == 13
        if Trig_RandomOwner_Check(ppl) then
        set udg_owner[temp] = Player(ppl)
        call DisplayTextToForce(GetPlayersAll(), "1")
        else
        call DisplayTextToForce(GetPlayersAll(), "2") 
        endif
        set temp = temp + 1
        set ppl = ppl + 1
    endloop
    set temp = 1
    loop
        exitwhen temp == 5 // currently there are only 4 regions on map
        if udg_number > count then
        set udg_number = 1
        endif
        call ForGroupBJ(GetUnitsInRectAll(udg_R_Towns[temp]), function Trig_RandomOwner_Group)
        set temp = temp + 1
        set udg_number = udg_number + 1
    endloop        
endfunction

//===========================================================================
function InitTrig_RandomOwner takes nothing returns nothing
    set gg_trg_RandomOwner = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_RandomOwner, 1.00 )
    call TriggerAddAction( gg_trg_RandomOwner, function Trig_RandomOwner_Actions )
endfunction

Should be distributing units within each rect amongst the active human players.

thx for any help again.

EDIT: Got it working now, edited code above.
__________________

Last edited by Fulla : 11-01-2006 at 11:49 PM.
Fulla is offline   Reply With Quote
Old 11-01-2006, 11:56 PM   #6
Fulla
Evil Overlord
 
Fulla's Avatar
 
Join Date: Jan 2006
Posts: 1,416

Submissions (3)

Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)

Default

Ok, the above now all works, id like to move onto 'part 3'
Asking a dif question.

Currently is goes like this:
E.g. Player 1 / Player 2 / Player 3 are active

Region 1 - Goes to ppl 1
Region 2 - Goes to ppl 2
Region 3 - Goes to ppl 3
Region 4 - Goes to ppl 1
Region 5 - Goes to ppl 2
etc. etc.

Id like to make it random thou
So instead of going from rect 1-X in order
it goes through them randomly.

I have no idea how to do this?
Id understand how to do it if it was units instead of rects via group checks.

Advice needed :D
__________________
Fulla is offline   Reply With Quote
Old 11-02-2006, 05:46 AM   #7
ArchWorm
User
 
ArchWorm's Avatar
 
Join Date: May 2006
Posts: 249

ArchWorm is on a distinguished road (14)

Send a message via ICQ to ArchWorm
Default

Quote:
Originally Posted by Fulla
d understand how to do it if it was units instead of rects via group checks.
And what's the problem, then? Create some units that represent the regions and do it like you said.
__________________
Nuclear Arbitor: this is ur map so if u don't like what ppl say ignore them and make it any way. they'll laugh in ur face and tell u it still sucks afterwards if they don't like it but they're not making it.
ArchWorm is offline   Reply With Quote
Old 11-02-2006, 10:41 AM   #8
Fulla
Evil Overlord
 
Fulla's Avatar
 
Join Date: Jan 2006
Posts: 1,416

Submissions (3)

Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)

Default

I dont quite understand sorry.
How could you link units + regions?
__________________
Fulla is offline   Reply With Quote
Old 11-02-2006, 12:46 PM   #9
ArchWorm
User
 
ArchWorm's Avatar
 
Join Date: May 2006
Posts: 249

ArchWorm is on a distinguished road (14)

Send a message via ICQ to ArchWorm
Default

That's very easy:
1. Create a unit
2. Set its UserData to handle index of the region.
3. Then jump beetween units with group funcs.
__________________
Nuclear Arbitor: this is ur map so if u don't like what ppl say ignore them and make it any way. they'll laugh in ur face and tell u it still sucks afterwards if they don't like it but they're not making it.
ArchWorm is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 08:40 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2020, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services