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 > Resources > Code Resources > vJass Spells
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 08-09-2007, 09:14 PM   #16
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)

Default

Offtopic:
There is no such thing as common knowledge in JASS

USE NAMED CONSTANTS FFS.

constant real WIDGET_MIN_LIFE = 0.405

and than you put a comment by that constant.

Besides why would this be wrong?
Collapse JASS:
if GetWidgetLife(W.dummy) < 0 then
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.
cohadar is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 08-09-2007, 09:56 PM   #17
blu_da_noob
Nonchalant
 
blu_da_noob's Avatar


Respected User
 
Join Date: Mar 2006
Posts: 1,933

Submissions (2)

blu_da_noob is just really nice (398)blu_da_noob is just really nice (398)blu_da_noob is just really nice (398)blu_da_noob is just really nice (398)blu_da_noob is just really nice (398)blu_da_noob is just really nice (398)

[Quicksilver #2] - 2nd Place[Quicksilver#1] 1st place

Send a message via MSN to blu_da_noob
Default

Moyack, your version will come up with the same problem. It's essentially the same as his original method. The way Anitarf suggested is exactly the way I was thinking, and the way I would do it.

Your current method isn't as good an implementation of that method as I think it could be. I would have a separate node struct to form the linked list and have a linked list attached to the caster. I would then have a single timer and keep an array of units with webs out and run through it on timer expire. Then you have your level integer and iterate through the linked list of webs, if a web is dead you remove the node from the list and relink, otherwise you set the level to max(current,web) if the unit is in range of the web. Then you carry on with adding invisibility if level > 0 etc.
__________________
blu_da_noob is offline   Reply With Quote
Old 08-09-2007, 09:59 PM   #18
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)

Default

Well that was the idea I got in the first place but it has one small flaw.

Using linked list that can be accessed by every caster on the map
is not thread safe.
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.
cohadar is offline   Reply With Quote
Old 08-09-2007, 10:10 PM   #19
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,266

Submissions (17)

moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

Quote:
Originally Posted by blu_da_noob
It's because each web checks if the hero is in range and removes the ability if it is not. So you're in range of one, it adds the ability, then the second web runs and sees that you aren't so it removes the ability.

Then I'm afraid I didn't understood the bug, The bug, as far as I know, is that the caster put several webs, then if the caster leaves one web and enter to other and then comes back to the previous web, the invisibility effect didn't take effect. If it's not that, then explain me what is the bug.

Blu: I did my test, and this bug is not happening with my version. Download here: http://www.wc3campaigns.net/attachme...1&d=1186520259

Last edited by moyack : 08-09-2007 at 10:14 PM.
moyack is offline   Reply With Quote
Old 08-09-2007, 10:16 PM   #20
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)

Default

Quote:
Originally Posted by blu_da_noob
Moyack, your version will come up with the same problem.

Not true. his version will work fine.
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.
cohadar is offline   Reply With Quote
Old 08-10-2007, 01:09 AM   #21
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,266

Submissions (17)

moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

Ok, I've changed the range of effect in this ability, and now I can see what Blu means. That flickering effect made me understand why are you setting one timer for all the system and all that stuff.

I propose to solve this in the easiest way possible, and is only allow to have one web at a time. Probably you're calling me lazy, but I think this solution is better and safer than having a complicated code to only prevent that bug.

Last edited by moyack : 08-10-2007 at 01:13 AM.
moyack is offline   Reply With Quote
Old 08-10-2007, 05:56 AM   #22
Av3n
Roar!
 
Av3n's Avatar


Project Leader: TBR
Project Member: PoC
 
Join Date: May 2006
Posts: 1,853

Submissions (7)

Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)

Hero #4 extra-official winner2008 Spell olympics - Fire - BronzeHero Contest #3 - 3rd Place

Default

Im glad you guys are having a nice conversation about this.

Grr Im gettin confused about the linked lists part though. Any idea how should I do this? Right now Im thinking about a struct that holds a caster and his webs, to add it more web's I'll loop through and see in the beginning of the trigger if the caster is the same person etc. . I currently know now the way Im doing it is a bit... messy and complicated.

-Av3n
__________________

Thanks to FatherTime for the sig
.:
Current ProjectsSubmissions
Power of CorruptionMy Terrain
The Black RoadMy Resources
Strikeforce
Twitter

Last edited by Av3n : 08-10-2007 at 06:01 AM.
Av3n is offline   Reply With Quote
Old 08-10-2007, 06:50 AM   #23
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)

Default

For using 1 timer, this is how I would do it:

Create a global struct variable that holds the first struct in the series. (the code would check to see if its empty and if it is, set it to the new one, and if not, get the back one (either go through the structs or use another global variable) and then add it to the back.

Each struct would then have 2 more values, a previous struct, and then a next struct.

When you need to remove a struct, you change the "Next" value of the previous stuct the the "Next" value of the current struct, and then the "Previous" value of the next struct is set to the "Previous" value of the current struct; then destroy it.

When your global timer expires, go through the stack of structs and do all your code, like in a loop.
__________________
Ammorth is offline   Reply With Quote
Old 08-10-2007, 08:28 AM   #24
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)

Default

Quote:
Originally Posted by moyack
I propose to solve this in the easiest way possible, and is only allow to have one web at a time. Probably you're calling me lazy, but I think this solution is better and safer than having a complicated code to only prevent that bug.

Awww man don't give up so easily.

Ok I did this spell using ABC, it was petty easy.
And for you people that think linked lists are a good idea in JASS,
well you have a lot lot to learn about programming.

Here it is:
Collapse JASS:
//==============================================================================
//  JESP Web spell v3.0
//==============================================================================
//
//  AUTHORS:
//      * Av3n    - original map, idea and spell
//      * Moyack  - ward, spellbook and summon trigger improvements
//      * Cohadar - converting to ABC, global group loop, removing flicker bug
//  
//       Contact us at [url]www.wc3campaigns.net[/url]
//
//  REQUIREMENTS:
//      * JASSHelper preprocessor
//      * ABC system
//
//==============================================================================



scope ABCWeb

globals
    private constant real AOE = 500.
    
    private constant integer AID_SpellBook = 'A000' // Ability ID
    private constant integer SID_Web = 'A001'       // Spell ID
    private constant integer UID_Web = 'e000'       // Unit ID
    
    private constant real DEATH_BORDER = 0.405 // no I don't know why.
    
    private integer web_count = 0  // number of webs on the map
    private group websGroup = CreateGroup()  // this group holds all the webs on the map
    
    private timer websTimer = CreateTimer() //We use this as a global timer for checking web
    private constant integer GENERIC_TIMER = 'BTLF' 
    private constant real checkPeriod = .1     //Loop rate for checking if the caster within the web
endglobals


// This struct will be attached to every Web that is summoned
// All summoned webs will ge kept in global group websGroup
private struct WebData
    unit caster = null
    player owner = null
    integer level = 0
endstruct

// This method is called for every web on the map
// so it is here where real action happens
function ForWebs takes nothing returns nothing
    local unit web = GetEnumUnit()
    local WebData data = GetStructA(web)
    
    if IsUnitInRange(data.caster, web, AOE) and GetUnitAbilityLevel(data.caster, AID_SpellBook) < 1 then
        call UnitAddAbility(data.caster, AID_SpellBook)
    endif
    if not IsUnitInRange(data.caster, web, AOE) and GetUnitAbilityLevel(data.caster, AID_SpellBook) > 0 then
        call UnitRemoveAbility(data.caster, AID_SpellBook)
    endif

    if GetWidgetLife(web) < DEATH_BORDER then
        if GetUnitAbilityLevel(data.caster, AID_SpellBook) > 0 then
            call UnitRemoveAbility(data.caster, AID_SpellBook)
        endif
        call GroupRemoveUnit(websGroup, web)  // first we remove web from global group
        call ClearStructA(web) // than we remove web->struct attachment
        call data.destroy() // than we destroy the struct
    endif

    set web_count = web_count + 1
    set web = null
endfunction

// Global timer is periodically startig this
// It basically does a loop through all webs on the map
// ADVICE: Always start your periodic functions with Periodic prefix
private function PeriodicWebCheck takes nothing returns nothing
    set web_count = 0
    
    call ForGroup(websGroup , function ForWebs )  // this will also increase web_count
    
    if web_count == 0 then
        call PauseTimer(websTimer) //Pausing the timer if there is no webs
    endif
endfunction


private constant function webDuration takes real level returns real
    return 30.*level //Web's life time. The value is real 
endfunction

public function Actions takes nothing returns nothing
    local unit web = GetSummonedUnit()
    local WebData data = WebData.create()

    set data.caster = GetSummoningUnit()
    set data.owner = GetOwningPlayer(data.caster)
    set data.level = GetUnitAbilityLevel(data.caster, SID_Web)
    
    call SetStructA(web, data)        // first attach the data to web
    call GroupAddUnit(websGroup, web) // and then add web to the global web group

    call UnitApplyTimedLife(web,GENERIC_TIMER,webDuration(I2R(data.level)))
    
    // If there were no webs timer was stopped, so we must start it again
    if web_count == 0 then
        call TimerStart(websTimer,checkPeriod,true,function PeriodicWebCheck) //Starting the Timer if it isn't started
    endif

    set web = null
endfunction

public function Conditions takes nothing returns boolean
    return GetUnitTypeId(GetSummonedUnit()) == UID_Web
endfunction

//===========================================================================
function InitTrig_Web takes nothing returns nothing
    //Creating an local trigger creating it then nulling it. 
    //No global trigger varibles are needed
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        // Disables to all players the spell container ability
        // so it can't display in the command card.
        exitwhen i > 15
        call SetPlayerAbilityAvailable(Player(i), AID_SpellBook, false)
        set i = i + 1
    endloop
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SUMMON )
    call TriggerAddCondition(t, Condition( function Conditions ) )
    call TriggerAddAction(t, function Actions )
    set t = null
endfunction

endscope

Attached Files
File Type: w3x ABC-Web.w3x (45.7 KB, 5 views)
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.
cohadar is offline   Reply With Quote
Old 08-10-2007, 10:08 AM   #25
Av3n
Roar!
 
Av3n's Avatar


Project Leader: TBR
Project Member: PoC
 
Join Date: May 2006
Posts: 1,853

Submissions (7)

Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)

Hero #4 extra-official winner2008 Spell olympics - Fire - BronzeHero Contest #3 - 3rd Place

Default

Wow... Everyone is being nice to me all of a sudden? I want to see everyone else's comments first and suggestions then piling it up for the end result. And I have to make a damn long credit/help list as well. Thanks cohadar 4 yr suggestion, my brain is being filled up with loads of info etc. i'll have to link to these diff versions after when v3.00 of the 'real' web comes out.

-Av3n
__________________

Thanks to FatherTime for the sig
.:
Current ProjectsSubmissions
Power of CorruptionMy Terrain
The Black RoadMy Resources
Strikeforce
Twitter

Last edited by Av3n : 08-10-2007 at 10:10 AM.
Av3n is offline   Reply With Quote
Old 08-10-2007, 06:26 PM   #26
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)

Default

Oh come on give me a break.
What are you going to do now? Waste more time on this.
Find an alternative method that does just the same? why?
So you can call it 100% yours?

And we are not "being nice to you"
nor we are trying to take over your spell.

Moyack made some really good modifications on your map
because he tried to help you
and I made modifications of his map because there was
an interesting problem of attaching variable number of structs to a periodic event (and because I wanted to show off with my ABC system :P )

So there is nothing 'unreal' about this last version of Web,
you simply need a better understanding of what "open source"
is all about.

I suggest you relax, stop wasting your time,
and use experience from this thread in your future spells.

nuff said.
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.
cohadar is offline   Reply With Quote
Old 08-11-2007, 05:04 AM   #27
Av3n
Roar!
 
Av3n's Avatar


Project Leader: TBR
Project Member: PoC
 
Join Date: May 2006
Posts: 1,853

Submissions (7)

Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)

Hero #4 extra-official winner2008 Spell olympics - Fire - BronzeHero Contest #3 - 3rd Place

Default

I think that it would be stupid looking for another solution for my spell(Since this is my first time experimenting with vJass) I'll go with cohadar/moyack version. Since why Im using their version... I know moyack and cohadar been really helpful. Im gonna do some changes to the code.(But trying to keep it the same way.) Reppies for you guys. The new version will be released tomorrow

-Av3n

EDIT: Here's a quick reference of the updated web spell. I still got that multiple web probelm on this version so I want to see your say of this version or the current official Web v2.02a.
If you want to keep the official find a better way than the way im doing it. If you want this version fix the multiple web problem or agree to only have 1 web at a time.
Attached Files
File Type: w3x Web v3.00.w3x (31.2 KB, 2 views)
__________________

Thanks to FatherTime for the sig
.:
Current ProjectsSubmissions
Power of CorruptionMy Terrain
The Black RoadMy Resources
Strikeforce
Twitter

Last edited by Av3n : 08-12-2007 at 03:46 AM.
Av3n is offline   Reply With Quote
Old 08-12-2007, 06:54 PM   #28
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)

Default

Made it to work finally.
But there are some tradeoffs.

Invisibility is no longer added in a spellbook, it is now casted by a web.
Hero regen is no longer added to a hero, web has regen aura now.
I also made the web locust, but that is optional.

Spell is working fine but:
Hero cannot attack from the web,
this is because casted invisibility is stopping attacks.

Witch is fine by me, I cannot attack them from the web, they cannot attach me in the web, pretty balanced.

But I have extra regen in the web, we fight I get dmgd,
run into the web like a scared girl, and after couple of sec when I regen
I come out and pwnzor you, mwahahahhahaha.

There is also a nice little buff that tells you that you are in the web.

Anyways Av3n, web is far from complete,
you should add spell level checking and possibly
ability for all friendly units to hide in the web,
or maybe all friendly units that are spiders :D


Collapse JASS:
scope Web
//==============================================================================
//  JESP Web spell v3.01
//==============================================================================
//
//  AUTHORS:
//      * Av3n    - original map, idea and spell
//      * Moyack  - ward, spellbook and summon trigger improvements
//      * Cohadar - converting to ABC, global group loop, removing flicker bug
//  
//       Contact us at [url]www.wc3campaigns.net[/url] and visit [url]www.clancbs.com[/url]
//
//  REQUIREMENTS:
//      * JASSHelper preprocessor
//      * ABC system
//
//==============================================================================

//Configuration
globals

    // Make sure that web insibility has this casting range
    // and Web regen aura has this AOE
    private constant real AOE = 300.
    
    //private constant integer AID_SpellBook = 'A003' // Ability ID of "Web Book"
    private constant integer SID_Web = 'A000'       // Spell ID of "Web"
    private constant integer UID_Web = 'e000'       // Unit ID of "Web" 
    
    // Should not be less than one second, this is basically a fade-out time now
    private constant real checkPeriod = 1.0 //Loop rate for checking if the caster within the web
endglobals
//All other configuration is edited at the spell object

//Support
globals
    private integer web_count = 0  // number of webs on the map
    private group websGroup = CreateGroup()  // this group holds all the webs on the map    
    private timer websTimer = CreateTimer() //We use this as a global timer for checking web
endglobals
    
private struct WebData
    unit caster = null
    integer level = 0
endstruct


//Check all Webs
function CheckRanges takes nothing returns nothing
    local unit web = GetEnumUnit()
    local WebData data = GetStructA(web)

    if GetWidgetLife(web) < 0.405 then
        call GroupRemoveUnit(websGroup, web)
        call ClearStructA(web) 
        call data.destroy()        
    else
        set web_count = web_count + 1
        
        if IsUnitInRange(data.caster, web, AOE) then
            call IssueTargetOrder( web, "invisibility", data.caster )
        endif
    endif

    set web = null
endfunction

private function PeriodicWebCheck takes nothing returns nothing
    set web_count = 0

    call ForGroup(websGroup , function CheckRanges )

    if web_count == 0 then
        call PauseTimer(websTimer)
    endif
endfunction

//Primary Functions
private function Actions takes nothing returns nothing
    local unit web = GetSummonedUnit()
    local WebData data = WebData.create()
    set data.caster = GetSummoningUnit()
    set data.level = GetUnitAbilityLevel(data.caster, SID_Web)
    call SetStructA(web, data)
    call GroupAddUnit(websGroup, web)
    if web_count == 0 then
        call TimerStart(websTimer,checkPeriod,true,function PeriodicWebCheck)
    endif
    set web = null
endfunction

private function Conditions takes nothing returns boolean
    return GetUnitTypeId(GetSummonedUnit()) == UID_Web
endfunction

//Init function
function InitTrig_Web takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SUMMON )
    call TriggerAddCondition(t, Condition( function Conditions ) )
    call TriggerAddAction(t, function Actions )
    set t = null
endfunction
endscope
Attached Files
File Type: w3x Web v3.01.w3x (30.1 KB, 3 views)
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.
cohadar is offline   Reply With Quote
Old 08-12-2007, 08:54 PM   #29
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,266

Submissions (17)

moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

I'm sure that this spell has become a good exercise to fix and stupid but complex problem in jass. Stupid in the sense that the effect is "simple" and complex because it requires a lot of work to get it working properly.

I have one idea to fix this but I'll discuss privately with av3n, of course if he and me are online on messenger.
moyack is offline   Reply With Quote
Old 08-13-2007, 11:16 AM   #30
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)

Default

Quote:
Originally Posted by moyack
I'm sure that this spell has become a good exercise to fix and stupid but complex problem in jass. Stupid in the sense that the effect is "simple" and complex because it requires a lot of work to get it working properly.

I have one idea to fix this but I'll discuss privately with av3n, of course if he and me are online on messenger.

Witch of the problems exactly?
And why private talk? The whole purpose of this forum is for peoples to
find solutions together.

EDIT:
Btw one of the solutions is in my signature :P
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.

Last edited by cohadar : 08-13-2007 at 04:06 PM.
cohadar 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 07:51 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

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