Fortress Forever

Fortress Forever (https://forums.fortress-forever.com/index.php)
-   Lua (https://forums.fortress-forever.com/forumdisplay.php?f=44)
-   -   Need lua to disallow the conc explosion (https://forums.fortress-forever.com/showthread.php?t=16035)

Dr.Satan 05-28-2008 10:05 PM

Need lua to disallow the conc explosion
 
Ok here's what I want / need.

I want for a conc to only be able to be fired inside the trigger IF the player is holding it.

If they toss it, I want it to either disappear or not be fired.

I tired using this code from the no_annoyances and it's not working for some reason:

Code:

function noannoyances:onexplode( explode_entity )
        if IsGrenade( explode_entity ) then
                return EVENT_DISALLOWED
        end
        return EVENT_ALLOWED
end

Right now I have the trigger going around the whole room...do I need to just make it like 4 units high on the ground...so that if the conc gets tossed in there is doesn't work or do I need a new code for it?

Pon 05-28-2008 10:42 PM

Well, this isn't perfect, but it does what you want...

Code:

function player_onthrowgren2(player, prime)
        return EVENT_DISALLOWED
end

... should do it. As long as you don't mind that the timer for disabled grenades still appears :D

Dr.Satan 05-28-2008 11:00 PM

lol not really...as long as they can't toss it down then that's fine by me. Plus this is all I need to run my last compile and release so something that small isn't really going to bug / stop me.

Pon 05-28-2008 11:08 PM

Thats good 'cos I'm not sure how to remove it :P

Jester 05-28-2008 11:26 PM

You could just remove their concs when they are out of the area and add them again when they are back?

Dr.Satan 05-29-2008 12:42 AM

well I want / need them to be able to HH the conc, but not to toss it. :cry:

Also me and pon have been going back and forth trying shit and nothing is working...any other ideas?

Jester 05-29-2008 12:51 AM

Something like if the grenade is yours and is not more than 1 unit away, allow blast. Dunno how to code that though.

squeek. 05-29-2008 12:55 AM

You could try enabling a trigger_remove that only removes grenades in player_onthrowgren2()

Jester 05-29-2008 12:57 AM

I think if the whole onthrowgren2 thing was working, the above code from Pon would have fixed it already.

squeek. 05-29-2008 12:59 AM

Quote:

Originally Posted by Jester
I think if the whole onthrowgren2 thing was working, the above code from Pon would have fixed it already.

It does work. It just doesn't work like onexplode; it's not meant to return a true/false allowed statement, it's meant to be a function (like player_spawn, entity:ontrigger, etc).

Dr.Satan 05-29-2008 01:04 AM

yeah that seems to be the problem...I can't tie it to a trigger_ff_script b/c it's an entity so it either works all the time or never.

Jester 05-29-2008 01:14 AM

Quote:

Originally Posted by squeek.
You could try enabling a trigger_remove that only removes grenades in player_onthrowgren2()

I guess you could try this thing out, just do a disallow instead of removing though.

Pon 05-29-2008 01:46 AM

Ok, on the offchance that this might help someone else finish it off, here's what i was trying to do:

Code:

local c = Collection()

nonades = trigger_ff_script:new({})

function nonades:ontouch( touch_entity )
        if IsPlayer( touch_entity ) then
                local player = CastToPlayer( touch_entity )
                -- Add this player to the collection
                c:AddItem( player )
        end
end


function nonades:onendtouch( touch_entity )
        if IsPlayer( touch_entity ) then
                local player = CastToPlayer( touch_entity )
                -- Remove player from collection
                c:RemoveItem( player )
        end       
end


-- This is fired when everyone has stopped touching "nonades"
-- and it goes to its inactive state
function nonades:oninactive()
        -- Clear out the items in the collection
        c:RemoveAllItems()
end



function player_onthrowgren2(player, prime)

        if c:Count() == 0 then
                return EVENT_ALLOWED
        end

        for temp in c.items do
                local c_player = CastToPlayer( temp )
               
                if c_player == player then
                        return EVENT_DISALLOWED
                end
        end

        return EVENT_ALLOWED
end

Didn't work, however using a gren inside the nonades area did produce an error, whereas using it outside of it did not... so it must be on the right track, I think.

Dr.Satan 05-29-2008 03:09 AM

so yeah...I'm an idiot and am very sorry to have wasted everyone's time:

http://developer.valvesoftware.com/wiki/Trigger_push

Speed of Push:

2000

Flags:

Clients (un-check)
Physics Objects (check)
FF Grenades (check)

Dropping conc sends it flying across the room, problem solved!

Again very sorry everyone...

Jester 05-29-2008 03:48 AM

Oh good it worked :)

We are victorious!

Dr.Satan 05-29-2008 05:57 AM

yeah I didn't have the map you told me about, but I did remember that concmap_cave had the same thing so I decompiled it and copied what PSF had in there and it worked great!

thanks for your help everyone! I am running the last (hopefully) compile right now and should have this thing released tomorrow.


All times are GMT. The time now is 02:10 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.