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 08-28-2011, 07:04 AM   #1
Matarael
User
 
Matarael's Avatar
 
Join Date: Oct 2006
Posts: 260

Submissions (2)

Matarael will become famous soon enough (49)Matarael will become famous soon enough (49)

Default Can I get some help with this Assisting System?

Originally from this thread:

http://www.wc3c.net/showthread.php?t=82929

2 problems with it:

1. I have my own "announcement" function for when a unit kills a Hero unit, complete with Hero name and team colour. I am trying to use mine instead of the one inside this script I linked but when I alter the function it gives me a bunch of errors ("Expected a name" errors).
2. I am supposed to use this function:
Trigger:
Custom Script: call AssistanceSystem_Register(unit)
To register units created later in the game to the Assistance system but where the hell do I put this trigger because it kept asking me that it "Expected a function name".

Unfortunately the thread/script creator is no longer active and I don't know how to get in touch with him, so here I am asking the rest of you gentlemen.
Matarael is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 08-29-2011, 02:29 AM   #2
busterkomo
User
 
Join Date: Aug 2007
Posts: 68

Submissions (1)

busterkomo is on a distinguished road (10)

Default

Quote:
Originally Posted by Matarael
1. I have my own "announcement" function for when a unit kills a Hero unit, complete with Hero name and team colour. I am trying to use mine instead of the one inside this script I linked but when I alter the function it gives me a bunch of errors ("Expected a name" errors).
2. I am supposed to use this function:
Remove any lines that have
Collapse JASS:
call DisplayTimedTextToForce()
and (optionally, thought recommended because they're no longer needed) remove the GetPlayerNameColored() function from the 'Needed Functions' list, and the three constant functions at the top of the main script.
Quote:
Trigger:
Custom Script: call AssistanceSystem_Register(unit)
To register units created later in the game to the Assistance system but where the hell do I put this trigger because it kept asking me that it "Expected a function name".
How are units created later in the game? If you're creating them in GUI,
Collapse JASS:
call AssistanceSystem_Register(bj_lastCreatedUnit)
will add the last created unit to the system.

Last edited by busterkomo : 08-29-2011 at 02:30 AM.
busterkomo is offline   Reply With Quote
Old 08-29-2011, 11:00 AM   #3
Bribe
User
 
Bribe's Avatar
 
Join Date: Mar 2010
Posts: 233

Submissions (1)

Bribe will become famous soon enough (30)Bribe will become famous soon enough (30)

Send a message via AIM to Bribe
Default

He could use AutoIndex to detect when a new unit enters the map,
for example he might want to get summoned units or newly-trained
units.
Bribe is offline   Reply With Quote
Old 08-30-2011, 05:45 AM   #4
Matarael
User
 
Matarael's Avatar
 
Join Date: Oct 2006
Posts: 260

Submissions (2)

Matarael will become famous soon enough (49)Matarael will become famous soon enough (49)

Default

Thanks guys, I managed to circumcise the first problem by first renaming my own global var and then referring to that for the actual trigger. It seems to be working...

And as for the second question, that snippet worked, I only want to register 1 unit per player anyway (which is what the script allows anyway).

I do have another question in this subject, I want to add a value to a player's integer for when he successfully assists, like I have done for kills/deaths. I guess I should insert a code somewhere in the script for when the " assister[*] != null " but it won't take/register the input. Perhaps it's because I'm a JASS newbie and I might have coded it wrong...
Here's what I wrote:
Collapse JASS:
            set udg_AssistCount[GetConvertedPlayerId(assister[1])] = ( udg_AssistCount[GetConvertedPlayerId(assister[1])] + 1 )

As you can see I'm still thinking in GUI and that might've been the problem?
Matarael is offline   Reply With Quote
Old 08-30-2011, 02:16 PM   #5
Fledermaus
default string
 
Fledermaus's Avatar
 
Join Date: May 2006
Posts: 705

Submissions (1)

Fledermaus is a jewel in the rough (194)Fledermaus is a jewel in the rough (194)Fledermaus is a jewel in the rough (194)

Send a message via MSN to Fledermaus
Default

Chuck a udg_ in front of (when referring to them in jass) any global variable you create in the Variables part of the trigger editor.
Fledermaus is offline   Reply With Quote
Old 09-05-2011, 06:55 PM   #6
Matarael
User
 
Matarael's Avatar
 
Join Date: Oct 2006
Posts: 260

Submissions (2)

Matarael will become famous soon enough (49)Matarael will become famous soon enough (49)

Default

*Back from holidays*.
The variable isn't global as far as I know. That's what's confusing to me. "assister[x]" should be a variable, right? And that by assigning the number ("assister[1]") I am telling the trigger to get the owner of the killing unit and assign a number to it; so that when I call the number of the owner to add the integer, I should be able to just use that. Right?

Right?
Matarael is offline   Reply With Quote
Old 09-05-2011, 08:42 PM   #7
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

It's difficult to comment on that line of code without context. The code of the system isn't posted anywhere and I would rather not have to download and open the system's demo map. Can you try posting at least the entire function where you put that line?

I'm surprised there isn't a newer system available for this. All I can think of is this thing. It got stuck in the review process, but is probably still better than what you're using now, however if you stick with your current setup I can probably help you if you post more code.
__________________
Anitarf is offline   Reply With Quote
Old 09-06-2011, 06:40 AM   #8
Matarael
User
 
Matarael's Avatar
 
Join Date: Oct 2006
Posts: 260

Submissions (2)

Matarael will become famous soon enough (49)Matarael will become famous soon enough (49)

Default

Hello Anitarf, thanks for the reply. That one you linked to does sound better and if you think it's safe to use instead, I'd probably convert to that since it offers a bit more function than this one.

I'll try it and get back after I'm done or if I encounter some difficulty. Meanwhile +rep for all.

Edit:
Ah bollocks I can't open the sample map presumably because I'm using vanilla World Editor. Anitarf if you're still interested in having a look at the code, here's the whole snippet:
Hidden information:

Collapse JASS:
function AssistanceSystem_DeathCondition takes nothing returns boolean
    return IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true
endfunction

function AssistanceSystem_Reset takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i > 372 or GetExpiredTimer() == udg_AssistanceTimer[i]
        set i = i + 1
    endloop
    set udg_AssistanceTarget[i] = null
endfunction

function AssistanceSystem_Timer takes nothing returns nothing
    local unit attacked = GetTriggerUnit()
    local unit attacker = GetEventDamageSource()
    local player p1 = GetOwningPlayer(attacked)
    local player p2 = GetOwningPlayer(attacker)
    local integer id1 = GetPlayerId(p1)
    local integer id2 = GetPlayerId(p2)
    if IsUnitEnemy(attacker, p1) and id2 < 12 then
        loop
            exitwhen id2 > 372 or udg_AssistanceTarget[id2] == attacked or udg_AssistanceTarget[id2] == null
            set id2 = id2+20
        endloop
        if udg_AssistanceTarget[id2] == null then
            call TimerStart(udg_AssistanceTimer[id2], AssistanceSystem_ResetValue(), false, function AssistanceSystem_Reset)
            set udg_AssistanceTarget[id2] = attacked
        elseif udg_AssistanceTarget[id2] == attacked then
            call TimerStart(udg_AssistanceTimer[id2], AssistanceSystem_ResetValue(), false, function AssistanceSystem_Reset)
        endif
    endif
    set attacked = null
    set attacker = null
    set p1 = null
    set p2 = null
endfunction

function AssistanceSystem_DeathActions takes nothing returns nothing
    local player array assister
    local player array assistplayer
    local unit d = GetDyingUnit()
    local unit u = GetKillingUnit()
    local player pd = GetOwningPlayer(d)
    local player pu = GetOwningPlayer(u)
    local integer i = 0
    local integer i2 = 0
    local force f = CreateForce()
    local string array s
    local boolean array bg
    local integer gold = GetRandomInt(AssistanceSystem_InitialRandom(), AssistanceSystem_EndingRandom())
    local string losegold
    local boolean bounty = AssistanceSystem_ShareBounty()
    //Add players to a force to prevent a force leak
    //when messaging all players:
    loop
        exitwhen i > 11
        call ForceAddPlayer(f, Player(i))
        set i=i+1
    endloop
    set i=0
    if bounty == true then
        //If the the unit doesnt have the bounty gold to lose,
        //set the gold lost to its current gold:
        if GetPlayerState(pd, ConvertPlayerState(1)) <= gold then
            set gold = GetPlayerState(pd, ConvertPlayerState(1))
        endif
        set losegold = "-" + I2S(gold)
        //Display bounty only if the assister has more than 0 gold:
        set i=1
        loop
            exitwhen i>13
            set s[i] = "+" + I2S(gold)
            set s[i+1] = "+" + I2S(gold / i+1)
            set i=i+1
        endloop
    endif
    set i = 0
    set i2 = 0
    //Start setting the assisters:
    loop
        exitwhen i > 11
        loop
            exitwhen i2 > 372 or udg_AssistanceTarget[i2+i] == d
            set i2 = i2 + 20
        endloop
        if GetPlayerSlotState(Player(i)) != ConvertPlayerSlotState(0) and Player(i) != pu and udg_AssistanceTarget[i2+i] == d then
            set assistplayer[i] = Player(i)
            set udg_AssistanceTarget[i2+i] = null
        endif
        set i = i + 1
        set i2 = 0
    endloop
    set i = 1
    set i2 = 0
    //Resort the assisters list so there wont be an empty
    //assister slot:
    loop
        exitwhen i > 11
        loop
            exitwhen assistplayer[i2] != null or i2 > 11
            set i2 = i2 + 1
        endloop
        if assistplayer[i2] != null then
            set assister[i] = assistplayer[i2]
            set assistplayer[i2] = null
        endif
        set i = i + 1
        set i2 = 0
    endloop
    set i = 1
    set i2 = 2
    loop
        exitwhen i > 11
        if assister[i] == null then
            loop
                exitwhen i2 > 11 or assister[i2] != null
                if assister[i2] != null then
                    set assister[i] = assister[i2]
                    set assister[i2] = null
                endif
                set i2 = i2 + 1
            endloop
        endif
        set i = i + 1
        set i2 = i + 2
    endloop
    set i = 1
    if d == u then
        call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_SuicideMessage() + ".")
    elseif u == null and d != u then
        call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + ".")
    elseif assister[1] == null and assister[2] == null and assister[3] == null and assister[4] == null and assister[5] == null and assister[6] == null and assister[7] == null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
        call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " !")
    elseif assister[1] != null and assister[2] == null and assister[3] == null and assister[4] == null and assister[5] == null and assister[6] == null and assister[7] == null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
        call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + " !")
        if bg[1] and bounty then
            call FadingTextSingle(assister[1], s[2], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
            call SetPlayerState(assister[1], ConvertPlayerState(1), GetPlayerState(assister[1], ConvertPlayerState(1)) + gold / 2)
            set udg_AssistCount[GetConvertedPlayerId(assister[1])] = udg_AssistCount[GetConvertedPlayerId(assister[1])] + 1
        endif


Basically it works properly. But I'm trying to save the value on the scoreboard, and I'm having trouble identifying the player assisting to properly add the integer to credit, blah blah.

Last edited by Matarael : 09-06-2011 at 06:46 PM.
Matarael is offline   Reply With Quote
Old 09-17-2011, 08:40 AM   #9
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Sorry it took until now to get back to you, next time you should post a new post instead of editing an old one. You're lucky I stumbled upon this at all.

In the //Start setting the assisters: loop, inside the if statement, use Player(i) to refer to the assisting player or simply i to refer to that player's id, so to increase an integer array (your score) for that player, simply do set score[i]=score[i]+1. Note that Player 1's index is 0 in JASS.
__________________
Anitarf is offline   Reply With Quote
Old 09-24-2011, 05:01 AM   #10
Matarael
User
 
Matarael's Avatar
 
Join Date: Oct 2006
Posts: 260

Submissions (2)

Matarael will become famous soon enough (49)Matarael will become famous soon enough (49)

Default

Hi Anitarf, thanks for the input and help, I didn't want to get yelled at for double posting ha ha ha (also the reason why I decided not to reply until I've tried absolutely every option first). Which brings me to my failure...

I still can't seem to get it to work. As I said I tried every combination of spacing and format but this code won't give me an increase in the integer for some reason. Here is my last code snippet before I gave up and ran back here for help:
Collapse JASS:
elseif assister[1] != null and assister[2] == null and assister[3] == null and assister[4] == null and assister[5] == null and assister[6] == null and assister[7] == null and assister[8] == null and assister[9] == null and assister[10] == null and assister[11] == null and assister[12] == null then
        call DisplayTimedTextToForce(f, 10, GetPlayerNameColored(pd) + " " + AssistanceSystem_DeathMessage() + " by " + GetPlayerNameColored(pu) + " " + AssistanceSystem_AssistMessage() + " " + GetPlayerNameColored(assister[1]) + " !")
        if bg[1] and bounty then
            call FadingTextSingle(assister[1], s[2], 255, 220, 0, GetUnitX(d), GetUnitY(d), 0.03, 2, 5)
            call SetPlayerState(assister[1], ConvertPlayerState(1), GetPlayerState(assister[1], ConvertPlayerState(1)) + gold / 2)
            set udg_AssistCount[i]=udg_AssistCount[i]+1
        endif

The AssistCount won't increase. WHYYY won't it argh.
Matarael is offline   Reply With Quote
Old 09-24-2011, 08:32 AM   #11
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Use debug messages. Put one in every if statement to see which parts of the code run and which don't. Is it a problem with the bg[1] or the bounty boolean? Maybe you have more than one assister? the code you posted a few posts ago doesn't seem to do anything if there are more assisters, unless that part got cut off. Anyway, as I suggested in my previous post, you should just increase your assist count in the loop previously, rather than in the assist messages part of the code. If you try to do it elsewhere, don't use the variable i, that only has the right value inside that specific loop, not anywhere in the code.
__________________

Last edited by Anitarf : 09-24-2011 at 08:34 AM.
Anitarf is offline   Reply With Quote
Old 10-01-2011, 04:51 PM   #12
Matarael
User
 
Matarael's Avatar
 
Join Date: Oct 2006
Posts: 260

Submissions (2)

Matarael will become famous soon enough (49)Matarael will become famous soon enough (49)

Default

Yesss. Finally. You're absolutely right, it should be placed at the Setting Up part. I guess I was still thinking in GUI.
I did this and it gave me the right number all the time, then I applied this into a score board and that too took me a while to get right since I didn't know exactly where to Call the function.

Anyway, long story short, problems solved AND every other functions I wanted to do is also achieved thanks to your tips. I wish I could +1 you more mate.
Matarael 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:47 AM.


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

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