Walls and friendly fire

Talk about general things concerning Forged Alliance Forever.

Moderators: FtXCommando, Ze Dogfather

Walls and friendly fire

Postby Krapougnak » 19 Oct 2014, 09:45

Hi,

What files do I need to change to make a wall block friendly fire ?

(i'm using a mod with T2 and T3 walls and my units firing through them look ridiculous)

Thanks for your help.
User avatar
Krapougnak
Contributor
 
Posts: 340
Joined: 12 Jul 2012, 11:03
Has liked: 193 times
Been liked: 24 times
FAF User Name: Krapougnak

Re: Walls and friendly fire

Postby IceDreamer » 19 Oct 2014, 14:11

unit.lua, OnCollisionCheck. if EntityCategoryContains(categories.WALL, other) then return true
IceDreamer
Supreme Commander
 
Posts: 2607
Joined: 27 Dec 2011, 07:01
Has liked: 138 times
Been liked: 488 times

Re: Walls and friendly fire

Postby Krapougnak » 20 Oct 2014, 10:08

Thanks a lot !

I will try this as soon as I get home. :)
User avatar
Krapougnak
Contributor
 
Posts: 340
Joined: 12 Jul 2012, 11:03
Has liked: 193 times
Been liked: 24 times
FAF User Name: Krapougnak

Re: Walls and friendly fire

Postby Krapougnak » 21 Oct 2014, 09:29

Didn't work... what I'm I doing wrong ?

I put the file in the mod "hook/lua/sim" folder correct ?

Code: Select all
local UnitOld = Unit

Unit = Class(UnitOld) {

    OnCollisionCheck = function(self, other, firingWeapon)

        if EntityCategoryContains(categories.WALL, other) then
   return true

        end
            UnitOld.OnCollisionCheck(self, other, firingWeapon)
    end,
}

User avatar
Krapougnak
Contributor
 
Posts: 340
Joined: 12 Jul 2012, 11:03
Has liked: 193 times
Been liked: 24 times
FAF User Name: Krapougnak

Re: Walls and friendly fire

Postby Sheeo » 21 Oct 2014, 10:16

Right, that won't work.

If you just want walls to block everything, replace it with:

Code: Select all
local UnitOld = Unit
Unit = Class(UnitOld) {
    OnCollisionCheck = function(self, other, firingWeapon)
        if EntityCategoryContains(categories.WALL, self) then
            return true
        end
        return UnitOld.OnCollisionCheck(self, other, firingWeapon)
    end,
}


Remember to return the value that UnitOld.OnCollisionCheck yields :)
Support FAF on patreon: https://www.patreon.com/faf?ty=h

Peek at our continued development on github: https://github.com/FAForever
Sheeo
Councillor - Administrative
 
Posts: 1038
Joined: 17 Dec 2013, 18:57
Has liked: 109 times
Been liked: 233 times
FAF User Name: Sheeo

Re: Walls and friendly fire

Postby IceDreamer » 21 Oct 2014, 15:00

Oh, it works that way around huh? My bad mate.
IceDreamer
Supreme Commander
 
Posts: 2607
Joined: 27 Dec 2011, 07:01
Has liked: 138 times
Been liked: 488 times

Re: Walls and friendly fire

Postby Krapougnak » 21 Oct 2014, 22:58

It worked !!! Thanks a lot ! :D

Sheeo wrote:
Remember to return the value that UnitOld.OnCollisionCheck yields :)


What do you mean by that ?
User avatar
Krapougnak
Contributor
 
Posts: 340
Joined: 12 Jul 2012, 11:03
Has liked: 193 times
Been liked: 24 times
FAF User Name: Krapougnak

Re: Walls and friendly fire

Postby Sheeo » 22 Oct 2014, 01:09

Krapougnak wrote:It worked !!! Thanks a lot ! :D

Sheeo wrote:
Remember to return the value that UnitOld.OnCollisionCheck yields :)


What do you mean by that ?


I meant there was a difference between the snippet you posted and mine:

Code: Select all
UnitOld.OnCollisionCheck(self, other, firingWeapon)


vs

Code: Select all
return UnitOld.OnCollisionCheck(self, other, firingWeapon)



The return keyword is crucial to ensure everything else doesn't stop colliding :)
Support FAF on patreon: https://www.patreon.com/faf?ty=h

Peek at our continued development on github: https://github.com/FAForever
Sheeo
Councillor - Administrative
 
Posts: 1038
Joined: 17 Dec 2013, 18:57
Has liked: 109 times
Been liked: 233 times
FAF User Name: Sheeo

Re: Walls and friendly fire

Postby Krapougnak » 22 Oct 2014, 09:02

Oh, OK that explains a lot... .

Thanks again for making my playing experience better. :)
User avatar
Krapougnak
Contributor
 
Posts: 340
Joined: 12 Jul 2012, 11:03
Has liked: 193 times
Been liked: 24 times
FAF User Name: Krapougnak


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest