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 > Tutorials > JASS/AI scripts tutorials
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 02-22-2007, 05:44 PM   #16
emjlr3
Rehabbing
 
emjlr3's Avatar
 
Join Date: Jun 2005
Posts: 1,386

Submissions (14)

emjlr3 is a jewel in the rough (151)emjlr3 is a jewel in the rough (151)

Mapping Contest First Place

Send a message via AIM to emjlr3 Send a message via MSN to emjlr3
Default

so i tried to start learning this, since it seems to be the "wave of the future", and I feel like before I should continue from basically the beginning, I should know what Pools are (I have never know or seen it described anywhere)

it seems some function are not there, like CreatePool() and PoolAddItem(), I am terribly lost as the what the purpose of Pools are, and why you used them here

**Correct me if I am wrong, you used the Pool system thing like a global variable array, to store the abilities that need to be removed from units if they have them that would keep their sight range big, and when the ability is cast, you loop through all these stored integer abilities and remove them if needed??
__________________

Last edited by emjlr3 : 02-22-2007 at 05:49 PM.
emjlr3 is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 02-22-2007, 05:55 PM   #17
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

yes, pool stuff was just used for that, so I replaced it with a global array
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 02-22-2007, 06:53 PM   #18
emjlr3
Rehabbing
 
emjlr3's Avatar
 
Join Date: Jun 2005
Posts: 1,386

Submissions (14)

emjlr3 is a jewel in the rough (151)emjlr3 is a jewel in the rough (151)

Mapping Contest First Place

Send a message via AIM to emjlr3 Send a message via MSN to emjlr3
Default

once you declare a global like you did here at the top in globals, can you never name another variable, local or global, that same name again? or how does that work?

does the struct function have to be above or below the globals function, since it seems like you use a variable of type flaredata in your globals?

set OpticalFlare_total=OpticalFlare_total+1
set OpticalFlare_Ar[ OpticalFlare_total-1 ] = dat

why do you use -1, why not just use the same number there? just seems like it would be easier for me to keep straight, and then just change in your timer function

exitwhen i>OpticalFlare_total

another thing, it seems like the whole timer recycling bit could be made so you did not need to do the same process over and over, as in, it seems like there could be a function written that takes your stuff, and does what is needed, or something, I hope you understand what i am saying, cuz it seems like the most complicated part, and the only part that is really just monotonous for each spell you would make

also, if the use of 1 timer is not good, im sure there would be a simple function(maybe not simple for me) that could be made to give you a timer and recycle it when you don't need it anymore, and keep them recycling, create more if needed/there are none available at the moment, this could be a global array for like each spell you have

another question, what about the custom script section of the map, can you still put stuff there? cuz if I remember correctly, it has been a while, no functions are in it in the newest Caster System map


the rest however i got, this whole system is really neat, and completely trumps older GC syst
__________________
emjlr3 is offline   Reply With Quote
Old 02-28-2007, 03:15 PM   #19
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

Didn't he place the whole caster system in a library in a standard trigger in the last couple incarnations of the CS?

Either way, the custom script section still works fine.

The reason he was running the count the way he did is because when you have no casts in progress it would hit -1. Which isn't logical, you don't store the last index used, you store the number of indices filled.

About where you put the globals, it doesn't matter, since the typedef isn't REALLY a type, its just there for the sanity of people using it. So long as you defined the struct type, it will work fine.
__________________
"...you play a mean banjo"
Chuckle_Brother is offline   Reply With Quote
Old 03-01-2007, 06:17 AM   #20
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Quote:
Originally Posted by emjlr3
another thing, it seems like the whole timer recycling bit could be made so you did not need to do the same process over and over, as in, it seems like there could be a function written that takes your stuff, and does what is needed

although you wouldn't want to use a function call in a periodic timer (unless you dont care about performance) you could probably write a textmacro to handle it fairly easily... and the global declaration as well if you wanted to be super lazy.

Last edited by grim001 : 03-01-2007 at 06:17 AM.
grim001 is offline   Reply With Quote
Old 03-01-2007, 10:11 PM   #21
Toink
User
 
Join Date: Oct 2006
Posts: 1,086

Submissions (3)

Toink is on a distinguished road (17)

Send a message via Yahoo to Toink
Default

Ok, so I decided to try and learn this super duper struct. I understand almost all of it, but is it multi-instanceable?
Toink is offline   Reply With Quote
Old 03-02-2007, 01:22 PM   #22
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

You can have multiple structs out and about, and each one will be contained wholly within itself, but maintaining it is totally up to you. So you need to handle each instance of the spell, personally I like the method Vex used for his sample, its dead easy and works for any spell based heavily on timers.
__________________
"...you play a mean banjo"
Chuckle_Brother is offline   Reply With Quote
Old 05-05-2007, 01:35 PM   #23
Sooda
User
 
Sooda's Avatar
 
Join Date: Apr 2007
Posts: 27

Sooda has little to show at this moment (4)

Default

Good tutorial but some things seems odd.
Collapse JASS:
function OpticalFlare_Timer takes nothing returns nothing
 local integer i=0
 local flaredata dat
 local real nx
 local real ny
 local real a
 local real d

    loop
        exitwhen i==OpticalFlare_total
        set dat= OpticalFlare_Ar[i]
        if (dat.destroyplease) then
             //This is tricky.
             // We already have the ith flaredata referenced by dat, so we
             // will first remove it from the array, since the order does not matter
             // we can simply move the last flaredata to this position and decrease
             // the total

             set  OpticalFlare_Ar[i]= OpticalFlare_Ar[ OpticalFlare_total - 1]
             set OpticalFlare_total=OpticalFlare_total-1

             //now we are free to destroy the dat
             call dat.destroy() //another way to destroy struct objects.

             //If we don't substract i, it will skip the new object we just moved
             // to the ith position (we are increasing i later)
             set i=i-1

        else //Notice how this ressembles the original expire function
              set nx=GetUnitX(dat.b)
              set ny=GetUnitY(dat.b)
              set a=ModuloReal( Atan2(ny-dat.y , nx-dat.x ) , 2*bj_PI)
              set d= SquareRoot(Pow(dat.x-nx,2) +Pow(dat.y-ny,2))

              if ModuloReal(a+bj_PI/4,bj_PI*2)<=bj_PI then
                  set d=d*40
              endif
              call SetUnitPosition(dat.sh,nx+d*Cos(a),ny+d*Sin(a) )
              set dat.x=nx
              set dat.y=ny
              call SetUnitFacing(    dat.sh,GetUnitFacing( dat.b ))
              call SetUnitFlyHeight( dat.sh, GetUnitFlyHeight( dat.b )+120,0)
        endif
        set i=i+1
    endloop

    if (OpticalFlare_total==0) then
        // let's pause the timer, it is not needed anymore
        call PauseTimer(OpticalFlare_timer)
    endif

endfunction
Well if OpticalFlare_total would be 20 and i would be 10:
Collapse JASS:
             set  OpticalFlare_Ar[10]= OpticalFlare_Ar[ 20 - 1]
             set 20 = 20 - 1
When there are 20 instances, every time last one is skipped because of i==OpticalFlare_total shouldn' t it be i > OpticalFlare_total so even last one would be checked ? Back to point when OpticalFlare_Ar[10] will be destroyed why "last one" is OpticalFlare_Ar[19] not OpticalFlare_Ar[20] ? Lastly set 20 = 20 - 1 always skips real last one (OpticalFlare_Ar[20]).
Main question would be if you set OpticalFlare_Ar[10] = OpticalFlare_Ar[19] dosn' t they point to same things ? Shouldn' t OpticalFlare_Ar[19] be destroyed then ?
Sooda is offline   Reply With Quote
Old 05-06-2007, 02:34 AM   #24
UnMi
User
 
UnMi's Avatar
 
Join Date: Aug 2006
Posts: 213

Submissions (1)

UnMi is on a distinguished road (18)

Default

Collapse JASS:
function OpticalFlare_Timer takes nothing returns nothing
 local integer i=0
 local flaredata dat
 local real nx
 local real ny
 local real a
 local real d

    loop
        exitwhen i==OpticalFlare_total
        set dat= OpticalFlare_Ar[i]
        if (dat.destroyplease) then
             set  OpticalFlare_Ar[i]= OpticalFlare_Ar[ OpticalFlare_total - 1]
Hmm, why declaring the local i = 0, if setting it as 1 would spare the -1 from OpticalFlare_total? The array does not start with 0, because OpticalFlare_Ar[0] would mean that OpticalFlare_total is 0 thus there wouldn't be any timers.

Last edited by UnMi : 05-06-2007 at 03:04 AM.
UnMi is offline   Reply With Quote
Old 05-06-2007, 03:25 AM   #25
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Sooda:

Check this line:
Collapse JASS:
set i=i-1

--
UnMi: I don't get what you mean.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 05-06-2007, 04:41 AM   #26
UnMi
User
 
UnMi's Avatar
 
Join Date: Aug 2006
Posts: 213

Submissions (1)

UnMi is on a distinguished road (18)

Default

Oh...........
Collapse JASS:
set OpticalFlare_total=OpticalFlare_total+1 
set OpticalFlare_Ar[ OpticalFlare_total-1 ] = dat
You filled the OpticalFlare_Ar[0] spot, I didn't see this.
But why >>;...it might confuse later by always have to decrease the index by 1 when using the OpticalFlare_total.

Last edited by UnMi : 05-06-2007 at 04:43 AM.
UnMi is offline   Reply With Quote
Old 05-06-2007, 04:56 AM   #27
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

I once again don't get your question.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 05-06-2007, 05:20 AM   #28
UnMi
User
 
UnMi's Avatar
 
Join Date: Aug 2006
Posts: 213

Submissions (1)

UnMi is on a distinguished road (18)

Default

OK, step by step.
Collapse JASS:
function OpticalFlare_Effect takes unit b, integer l returns nothing
 local real ac=GetUnitAcquireRange(b)
 local unit sh=CreateUnit( GetOwningPlayer(b), OpticalFlare_FakeSightUnit(), GetUnitX(b), GetUnitY(b), 0)
 local integer abi=OpticalFlareDetectDetector(b )
 local flaredata dat = flaredata.create()
    call SetUnitPathing(sh,false)
    call UnitRemoveAbility(b, abi )
    call UnitAddAbility(b, OpticalFlare_SightDestructorSpellId() )
    call UnitMakeAbilityPermanent(b,true,OpticalFlare_SightDestructorSpellId())
    call UnitMakeAbilityPermanent(b,true,OpticalFlare_BuffId())

    set dat.x=0. //struct fields aren't automatically initialized to 0, unlike handle vars
    set dat.y=0. // It is also possible to make them initialize to a default value inside the struct block
    set dat.b=b
    set dat.sh=sh

    if(OpticalFlare_total==0) then //There are no elements in the array so the timer is inactive
        call TimerStart(OpticalFlare_timer,0.01,true,function OpticalFlare_Timer) //restart it
    endif

    set OpticalFlare_total=OpticalFlare_total+1 //increase the number of elements
    set OpticalFlare_Ar[ OpticalFlare_total-1 ] = dat //add the flaredata to the array, notice that these are arrays
                                                      //that begin with the [0] index...
    loop
        exitwhen IsUnitDeadBJ(b)
        call TriggerSleepAction(0)
        exitwhen not UnitHasBuffBJ(b, OpticalFlare_BuffId() )
    endloop
    call UnitRemoveAbility(b, OpticalFlare_SightDestructorSpellId() )
    call UnitAddAbility(b, abi )

 call RemoveUnit(sh)
 set dat.destroyplease = true //Will send a signal to the timer function so it destroys this object...
 set sh=null
endfunction
OpticalFlare_total is the total amount of elements in OpticalFlare_ar.
OpticalFlare_total is increased by 1 (+1) on every instance of the spell.
If we leave it like this, the index of the last (newest) element of OpticalFlare_ar is always OpticalFlare_total (OpticalFlare_ar[OpticalFlare_total]).
But you did
Collapse JASS:
set OpticalFlare_total=OpticalFlare_total+1 
set OpticalFlare_Ar[ OpticalFlare_total-1 ] = dat
This means the last element of the array is not OpticalFlare_ar[OpticalFlare_total] anymore, but OpticalFlare_ar[OpticalFlare_total-1], and I think this is unnecessary, why not just leave the OpticalFlare_ar[0] blank?
Because of this "nudge", you will always have to decrease the OpticalFlare_total by one when you want to get the last element.
Collapse JASS:
if (dat.destroyplease) then
             set  OpticalFlare_Ar[i]= OpticalFlare_Ar[ OpticalFlare_total - 1]
             set OpticalFlare_total=OpticalFlare_total-1
Nothing serious actually..................but for people like me who likes to forget stuff, it might be the troublesome...
UnMi is offline   Reply With Quote
Old 05-06-2007, 05:21 AM   #29
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Arrays start with index zero, so I am just doing what I am supposed to do, and the sooner people get used to using arrays correctly the better.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 05-15-2007, 03:37 PM   #30
Silvenon
User
 
Silvenon's Avatar
 
Join Date: May 2007
Posts: 492

Submissions (1)

Silvenon will become famous soon enough (63)Silvenon will become famous soon enough (63)Silvenon will become famous soon enough (63)

Send a message via MSN to Silvenon
Default

Nice tutorial, but I'm really not in a mood to learn all that........

It's just that I don't see the point in all that, handle vars/attachable vars are fast enough, with a combination of CS recycling it lags less, and that's cool enough. Why do you need it to be so fast? What are you making that needs such speed? Maybe I'm crazy, but this is just too much for me.........

But I appreciate your work, nice job
Silvenon 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 05:11 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