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



Reply
 
Thread Tools Search this Thread
Old 10-26-2008, 08:54 PM   #16
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Why
Collapse JASS:
struct EventTarget extends array
You didn't use this feature in your code or i misunderstood something ?
__________________
Cool != Useful
Troll-Brain is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 10-26-2008, 09:16 PM   #17
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

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

I was more looking for a screenshot or something of it being used to prove that it worked as listed in-game. I am well aware that there is a function in the comments that shows its usage, I can read after all.
__________________
Rising_Dusk is offline   Reply With Quote
Old 11-05-2008, 12:09 AM   #18
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

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

Anyways, this is cool, so I'm just going to approve it. If someone uses it and finds out it doesn't work as listed, we'll work with it from there, otherwise I'll assume it works.

Approved.
__________________
Rising_Dusk is offline   Reply With Quote
Old 11-05-2008, 07:52 PM   #19
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

I guess I will stop being lazy and post a picture since you already approved it.



This makes use of the ".test()" method I just added. The event I used to test it was indeed based on EVENT_PLAYER_UNIT_SPELL_CHANNEL.

The library's been tested thoroughly, I'd be very surprised if anyone found a bug.

Last edited by grim001 : 11-05-2008 at 08:04 PM.
grim001 is offline   Reply With Quote
Old 11-05-2008, 09:38 PM   #20
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

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

Awesome, thanks. Moved it to the first post. I had a feeling it worked, I just wanted some legitimate proof. :)
__________________
Rising_Dusk is offline   Reply With Quote
Old 11-06-2008, 01:20 AM   #21
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default

Wish there was some demo map of some sort. I'm still confuzzled even with your documentation.
Joker is offline   Reply With Quote
Old 11-06-2008, 07:07 PM   #22
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

A demo map isn't needed but I'll give you some demo code.

Collapse JASS:
library EventTargetLibTest initializer Init

function SpellCast takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local EventTarget et = EventTarget.create()

    local real ang = et.angle() //ang is now set to the angle between caster and target, in radians.
    local real dist = et.distance() //dist is now set to the distance between caster and target.
    
    //et.ox, et.oy, et.oz will be the coordinates of the caster
    //et.x, et.y, et.z will be the coordinates of the target

    //If the spell was capable of targeting either a unit or the ground,
    //you can tell which type of target it was with the following comparison.
    if et.targettype == EVENTTARGET_UNIT then
        //...
    elseif et.targettype == EVENTTARGET_POINT then
        //....
    endif
endfunction

function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == YourSpellID
endfunction

function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST)
        call TriggerAddCondition(t, Condition(function Conditions))
        call TriggerAddAction(t, function SpellCast)
endfunction

endlibrary

The point is just to be able to easily grab the coordinates of the caster and target and the distancexy/distance/angle/pitch between them. The thing that makes it useful is that is is always as simple as the above example, no matter if it is an order or a spell or what it can target.

Last edited by grim001 : 11-06-2008 at 07:08 PM.
grim001 is offline   Reply With Quote
Old 11-09-2008, 09:34 AM   #23
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Gj.
Just a minor thing :
The integer variables EVENTTARGET_... should be constants.

Oh and what about .caster and .target ?
__________________
Cool != Useful

Last edited by Troll-Brain : 11-09-2008 at 10:38 AM.
Troll-Brain is offline   Reply With Quote
Old 11-09-2008, 07:16 PM   #24
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

Yes, those should be constants.

The problem with including things like .caster and .target is that it would be holding handle references hostage. That's not a good thing since the structs never get destroyed.

I could make a method that returns the caster or target, but the problem is that the target can be a unit, item, or destructable. So you'd get .targetUnit(), targetItem(), and targetDestructable(), otherwise it would have to return a widget. And returning a widget is not very useful since you can't downcast it to the proper type without the return bug. The methods would also cease to work if any time passed since the struct was created, since they'd just be returning GetSpellTargetUnit() etc...

Two other possibilities are that I force the user to call some cleaning method that nulls the references or it leaks, or I automatically null the references after some amount of time passes. Those both sound rather lame to me.

If you have any good ideas on this subject let me know.
grim001 is offline   Reply With Quote
Old 11-09-2008, 08:07 PM   #25
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Yes i had forgotten you use a struct array, it's new for me.
Why you don't use a "normal" struct, for speed, for don't need to destroy it ?

Anyway i don't think a simple short line calling destroy method will make the code lamer.
You could add a boolean parameter for the create method (takes handles widgets or not) or why not an altCreate method.

If it's true you could set .caster. and .widget if it's a target event.

For the target you could use different names depends if the target is an unit, an item or a destructable like you said.
The user can use the EVENTTARGET... to know which event is fired.

You can also put warnings in the documentation and say to the users using locals if they want to add TriggerSleepAction/PolledWait.

I would like .caster . target .targetUnit .targetDestructable, just because the syntax.

But well that's only a suggestion, it's your system.
I will add it for me but i can't blame you if you don't :p
__________________
Cool != Useful
Troll-Brain is offline   Reply With Quote
Old 11-18-2008, 05:22 PM   #26
xombie
Banned
 
Join Date: Oct 2006
Posts: 858

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

Default

Quote:
Originally Posted by grim001
structs never get destroyed.

So are there only a set number of structs or do they keep getting created? I didn't take much liberty to read the entire thing because it seems like a whole lot of code to just return a few calculations.

The only values that I see might cause a little bit of trouble is the Event Type and the Target Type... but when making spells you generally already know what that is. In my opinion it sounds/looks like way too much for anybody to really need to use, simple functions for calculating the range/angle/etc. appeal to me a little more than a gigantic struct.
xombie is offline   Reply With Quote
Old 02-22-2009, 01:09 PM   #27
Definit
User
 
Join Date: Dec 2008
Posts: 5

Definit has little to show at this moment (0)

Default

Jass helper gives error:
Quote:
Line388: Unable to find the struct/interface array
for the line
Code:
struct EventTarget extends array
am i doing something wrong ? i'm somewhat new about jass and a really newbie about vjass . i copied library to a new text trigger.
i'm using newgen5a , and CasterSystem 15.2

Last edited by Definit : 02-22-2009 at 01:48 PM.
Definit is offline   Reply With Quote
Old 02-22-2009, 01:17 PM   #28
Deaod
User
 
Join Date: Jan 2007
Posts: 542

Submissions (11)

Deaod is a jewel in the rough (192)Deaod is a jewel in the rough (192)Deaod is a jewel in the rough (192)

Default

try using newgen 5b
__________________
Deaod is offline   Reply With Quote
Old 02-22-2009, 01:47 PM   #29
Definit
User
 
Join Date: Dec 2008
Posts: 5

Definit has little to show at this moment (0)

Default

Quote:
Originally Posted by Deaod
try using newgen 5b
ok thanks it solved the problem
Definit is offline   Reply With Quote
Old 10-19-2009, 03:06 PM   #30
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

Continuing with my task of making all my old submissions useful again, EventTargetLib has become EventData. The idea is the same, but it has undergone some improvements...
  • Removed return bug usage.
  • Changed around quite a few methods, API works differently now.
  • Now never creates or destroys locations, thanks to GetSpellTargetX/Y.
  • EventData instances will auto-self-destruct after any time has elapsed, unless you call .preserve(). This means manual cleanup is not needed unless you called .preserve().
  • Now fully supports EVENT_PLAYER_UNIT_SPELL_FINISH, EVENTPLAYER_UNIT_SPELL_ENDCAST, EVENT_UNIT_SPELL_FINISH, and EVENT_UNIT_SPELL_ENDCAST. These events suck because the native event responses stop working. However, if you call EventData.create() in one of these events, it will still be populated with all the correct data automagically.

Last edited by grim001 : 10-19-2009 at 06:10 PM.
grim001 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 09:11 PM.


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