• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJass][Zinc] Arcing Loot

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Based on the loot visual used in Diablo III.
Can easily make items much more exciting.

Requires JNGP, otherwise just copy and paste the code and import the dummy unit to your map. Then call the Apply function like shown in the demo.

Thanks to KILLCIDE for the GIF.
151496d1452194691-vjass-zinc-arcing-loot-gifpreview.gif

JASS:
//! zinc
	library Arc
	{
		constant real arc          = 75; //modifies the  arcing shape
		constant real arcHeight    = 350; //how high the arc reach at its peak
		constant real travelTime   = 0.60; //time it takes for the arc to reach destination
		constant real convertArc   = arc / 100.00; // do not touch	
		constant integer dummy     = 'h000'; //dummy unit used
		constant string sfx        = "Objects\\InventoryItems\\TreasureChest\\treasurechest.mdl"; //effect, the item chest in this case
		constant real loopSpeed    = 0.03; //how often the system runs its loop. Higher value equals better perfomance
		
		constant group g           = CreateGroup();
		constant hashtable hash    = InitHashtable();
		constant timer t           = CreateTimer();
		
		function Update()
		{
			unit u                 = GetEnumUnit();
			integer h              = GetHandleId(u);
			real angle             = LoadReal(hash, h, 1);
			real initDistance      = LoadReal(hash, h, 2);
			real currentDistance   = LoadReal(hash, h, 3);
			real maxHeight         = LoadReal(hash, h, 4);
			real time              = LoadReal(hash, h, 5);
			real newHeight;
			real cx                = GetUnitX(u);
			real cy                = GetUnitY(u);
			real nx                =  cx + time * Cos(angle * bj_DEGTORAD);
			real ny                =  cy + time * Sin(angle * bj_DEGTORAD);
			integer id;
			currentDistance        += time;
			newHeight              = ((4.00 * (maxHeight / initDistance)) * ((initDistance - currentDistance) * (currentDistance / initDistance)));
			SetUnitX               (u, nx);
			SetUnitY               (u, ny);
			SetUnitFlyHeight       (u, newHeight, 0.00);
			
			SaveReal               (hash, h, 3, currentDistance);
			
			if(newHeight <= 0)
			{
				id = LoadInteger   (hash, h, 6);
				CreateItem         (id, nx, ny);
				DestroyEffect      (LoadEffectHandle(hash, h, 7));
				UnitApplyTimedLife (u, 'BTLF', 0.01);
				FlushChildHashtable(hash, h);
				GroupRemoveUnit    (g, u);
				if(FirstOfGroup(g) == null)
				{
					PauseTimer(t);
				}
			}
			u = null;
		}
		
		function GroupFunc()
		{
			ForGroup(g, function Update);
		}
		
		public function Apply(real sx, real sy, real dx, real dy, integer i)
		{
			unit u            = CreateUnit(Player(12), dummy, sx, sy, 0); 
			integer h         = GetHandleId(u);
			real tx           = dx - sx;
			real ty           = dy - sy;
			real angle        = bj_RADTODEG * Atan2(ty, tx);
			real distance     = SquareRoot(tx * tx + ty * ty);
			real height       = arcHeight;  //distance * convertArc;
			real time         = distance / (travelTime / loopSpeed);
			PauseUnit(u, true);
			SaveReal          (hash, h, 1, angle);
			SaveReal          (hash, h, 2, distance);
			SaveReal          (hash, h, 4, height);
			SaveReal          (hash, h, 5, time);
			SaveInteger       (hash, h, 6, i);
			SaveEffectHandle  (hash, h, 7, AddSpecialEffectTarget(sfx, u, "origin"));
			if(FirstOfGroup(g) == null)
			{
				TimerStart(t, loopSpeed, true, function GroupFunc);
			}
			GroupAddUnit      (g, u);	
			u = null;
		}
			
		
	}
//! endzinc


Keywords:
MUI, system, loot, item, items, arc, parabola, visual, vjass, zinc, Chaosy
Contents

Just another Warcraft III map (Map)

Reviews
13th Jan 2016 IcemanBo: Looks neat, but some things mentiond in thread. Read my reply in thread. 20.01.2016 BPower: Cool system, but .... There is room for improvement.

Moderator

M

Moderator

13th Jan 2016
IcemanBo: Looks neat, but some things mentiond in thread.
Read my reply in thread.

20.01.2016 BPower:
Cool system, but [self=http://www.hiveworkshop.com/forums/spells-569/vjass-zinc-arcing-loot-274412/index2.html#post2778755]...[/self]. There is room for improvement.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Why location handles over coordinates when you are using zync?
I was going to mention this to you when I first saw the RemoveLocation(), but I forgot xD


Here you go, butt. This will be a really cool system if you can somehow hide that birth animation :D maybe creating the item and hiding it elsewhere, and then just moving the item + unhiding it will work?
 

Attachments

  • GIFPreview.gif
    GIFPreview.gif
    4.8 MB · Views: 566
  • SNPreview.png
    SNPreview.png
    186 KB · Views: 114

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
Because the GUI function requires locations :p

I replaced a few BJs and a few locations. Still needs a few touches in the update function though.
Will be (properly/fully) updated when.. I am in the mood. But within 24 hours.

edit: All BJs are now removed and locations replaced with reals. And the timer is now paused. Though I had to use BJs to check if a group was empty. (technically I can use my own function, but it would be just as effective)
 
Last edited:
A cool fancy dropping. :D
Please add user for info and how to use the system.

I currently have no good idea, but in the GIF I see that treasure chest is used,
and then it potentialy is an other item model. And in custom RPGs or something,
it might be even a bit more often that they use other models.
So maybe if we find a good model that can be used but still hides the identity of the item, it would be cool.
 
Last edited:
Level 22
Joined
Feb 6, 2014
Messages
2,466
Some suggestions:
- Use Vexorian, Anitarf, InfraNe model while the treasure is flying, so that you can make it face the proper facing. Because currently, when the item hits the ground, it instantly changes the treasure chest's facing direction. Another benefit is, you can hide the treasure chest's death animation when you use that dummy model.
- Use FirstOfGroup to check if the group is empty.
- You forgot u = null
- Make the configuration variables constant for them to be inlined.

Edit:
- Lacking documentation.
 
Last edited:
Level 19
Joined
Mar 18, 2012
Messages
1,716
In a real map you will run into pathing issues frequently, simply because CreateItem() does
check for pathing. Item pathing can quickly escalate up to 1024 units from the desired location.

You can even see it in you GIF ( where is not unwalkable terrain, doodads, other units, ... )
that the items are never created at the dummys landing position.

I guess you have to at least check for pathing before calculating arc and landing position.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
Yeah, I might include a path checking library if I can find one.

The demo perfectly shows how to use the system without additional API.
If this was a complex/advanced system with dozens of variables and functions/methods it would be understandable to have a detailed API since the system is naturally harder to use. (and can't really be showcased in a single demo trigger most of the time)

But in this case we're talking about one single function.
I wont bother just because of a pointless jass principle.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
Yus, better argue senseless about to write proper comments,
instead of just doing something useful and with even less effort.
Stubbornness at a wrong place.

Quite true sadly.

____________

And if I get what you mean by string arguments it requires the user to check if the item is one of the tomes and then send that away.
Too much work for the user.
I might be misunderstanding completely, wouldn't surprise me.
 
Level 33
Joined
Apr 24, 2012
Messages
5,113
- Use Vexorian, Anitarf, InfraNe model

Bribe, what have you done.

anyways, we call it "Dummy.mdx" XD


On-topic:

The idea is quite nice, reminds me of Maker's Arcing TextTag. Never expected someone would come up to this idea whom noone ever came up to.

Tho considering this as a system,library or whatnot, you should add a more descriptive comments for your configuration and AN API OF YOUR LIBRARY(for the users' sake)
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
1.) The effect used on the dummy is never destroyed. For me the question comes up:
Do you test your spells or do you just write and submit?

2.) Hashtable, handle id and ForGroup. I know you like it. It's crap, but we can accept it.
You allocate close to limitless data storage space, for I don't know 3 - 20 objects.

3.) As you don't check for pathing, the items don't appear where they should.
Solution:
Place the item, hide it, Fire the missile towards the item, when they collide destroy the missile and show the item. Before showing, check that the item wasn't picked up etc.

4.) Provide an API. Your code is Zinc which 90% of the users here can't read.
How should someone know how to use this system.

5.) Constants should be written like MY_CONSTANT

6.) The dummy uses an ability which should not be on the default dummy unit.
 
Top