[Request] Duke Nukem 2D Style resource pickup

[Request] Duke Nukem 2D Style resource pickup

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

[Request] Duke Nukem 2D Style resource pickup

Post 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 :-))
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Try making the ammo box a gaia-owned mine that does no damage when it explodes.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post 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.)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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
User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

Post 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.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post 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.
User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

Post 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++?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post 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.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Post 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)?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post 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.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Post by Forboding Angel »

Anyone interested in making this happen? Would be immensely helpful to me...

I know I said widget, but I meant gadget...
User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

Post 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.
:(
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Post 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...
Post Reply

Return to “Lua Scripts”