Page 1 of 1
[Request] Duke Nukem 2D Style resource pickup
Posted: 18 Oct 2007, 08:52
by Forboding Angel
Ok, I'm afraid to even ask for this, but I'm told it's not as complicated to do as it sounds.
Basically, in evolution, the units when they die will drop ammo boxes. I want to have it so that whenever a unit of any team collides with the boxes, they spin around and go up into the air and disappear (duke nukem 2d style) and the resources in that feature are given to the team of the unit that touched it...
Pretty please?
(admit it, compared to reclaiming corpses, this is pretty cool

)
Posted: 18 Oct 2007, 10:34
by KDR_11k
Try making the ammo box a gaia-owned mine that does no damage when it explodes.
Posted: 18 Oct 2007, 14:19
by imbaczek
...or check for unit presence every N frames in some radius around a point. (N frames so it doesn't slow the game that much.)
Posted: 18 Oct 2007, 14:29
by AF
pseudo code goes a long way
Code: Select all
on gadget update function
for each unit
farray = array of features within the units radius+100
for each feature 'f' in farray
if f is a dropoff
do whatever is needed for that dropoff
make unit vanish
make dropoff vanish
give team bonus
end if
end for
end for
end function
Posted: 18 Oct 2007, 16:07
by BigHead
It's better to iterate over features as there are less features than units.
Spring runs at 32 frames/sec. Let's say there are 32 features, so the best way to reduce lag is to update 1 feature per frame (100 features - 3 features/frame). I update nanos in upcoming version of my gadget this way and it works well.
Edit: Oh and you need to update features multiple times per second - that changes my calculations a bit.
Posted: 18 Oct 2007, 18:31
by AF
Possibly but eitherway the engine is going to iterate over each and every unit and feature anyway to determine wether its close enough to return.
Instead a logical change would be to cache all instances of the dropoff features created, then to cache the ids of all non flying mobile units that could possibly crush the dropoff, then to only iterate through those.
Posted: 18 Oct 2007, 19:07
by KDR_11k
when you ask the engine for the units in a radius it uses its quads to determine which ones are even in the position to be nearby.
Posted: 18 Oct 2007, 19:20
by BigHead
Yup, my point was that native engine C++ implementation is most likely faster than what can be achieved by lua. I forgot to mention it though.
Offtopic: Are there any charts showing lua execution speed compared to C++?
Posted: 18 Oct 2007, 21:00
by AF
well its obvious lua is slower than C++ however C++ isnt an option as including code specific to forebodings mod in it would be irresponsible, and itd be a huge pain for foreboding if he ever wanted to update the code or his mod.
Posted: 18 Oct 2007, 21:26
by imbaczek
http://shootout.alioth.debian.org/gp4/b ... &lang2=lua
as you can see, it can be everything in between 2x-60x times slower. depends on what you do.
Posted: 18 Oct 2007, 22:04
by Forboding Angel
well ok forget the spinning and all that, how about is just diappears, fires of a defined CEG effect(if possible) and plays a sound (if possible)?
Posted: 19 Oct 2007, 20:31
by AF
all perfectly possible, probably doable with a 1 liner for each individual action.
All the necessary logic is in the block of pseudocode I put up. Converting it into pure lua should teach you a lot while being nice and easy. Valuable skills to learn.
Posted: 20 Oct 2007, 05:07
by Maelstrom
Actually the spiny upwards bit wouldn't be that hard at all. DrawUnitShape() or something would be what your looking for. Really, its a fairly simple script.
Posted: 01 Nov 2007, 17:31
by Forboding Angel
Anyone interested in making this happen? Would be immensely helpful to me...
I know I said widget, but I meant gadget...
Posted: 02 Nov 2007, 10:07
by BigHead
I'd help but real life is too demanding. I haven't even played spring for two weeks.
The answer from me is no and will remain no until maybe Christmas holiday.

Posted: 02 Nov 2007, 17:31
by Forboding Angel
Hey that's fine dude. I'm just extremely appreciative of the stuff you've already done on my behalf, believe me, I do appreciate it.
In the meantime I thing I've figured out a way that I can make this happen in a different manner. Not nearly as good by any means, but it works...