Getting the game_action_causer from DamagedEvent?

I’m attempting to figure out how a player was damaged/eliminated.

Is it possible to find out if a player was damaged by a pickaxe?

There is no ToString for the Source

    OnDamaged(Result:damage_result):void=
        Print("damaged:  {Result.Source?}")

Haven’t got source working yet, not even sure its fully implemented yet…

Source is implemented. you have to listen to the damage event with something like: FortCharacter.DamagedEvent().Subscribe(OnPlayerDamaged)

I agree that there doesn’t appear to be any way to determine what source caused the damage and log it - doesnt appear that you can convert the source (which is apparently a “game_action_causer” to string to see what object actually caused the damage

I was trying the same thing - looks like the weapon api is not implemented yet so there is no way to determine if the source was a pickaxe as far as I know. I got a pretty good response from staff in this post.

Determine damage causer

bump, any update on this?
I’ve subscribed to vehicle damage event and it’s triggered but can’t seem to get who and how. This only prints ‘Ouch!’

OnPlayerCarDamaged<public>(Damage : damage_result) : void = 
    Logger.Print("Ouch!")
    var wasDamagedByOtherPlayer : ?player = false
    if(dInstigator:=Damage.Instigator?):
        Logger.Print("damage instigator is set to something")
        if(Player:=player[dInstigator]):
            Logger.Print("damage instigator is player")
            set wasDamagedByOtherPlayer = option{Player}
    if(Source:=Damage.Source?):
        Logger.Print("damage source is set to something")
        if(Player:=player[Source]):
            Logger.Print("damage source is player")
            set wasDamagedByOtherPlayer = option{Player}
        if(Vehicle:=fort_vehicle[Source]):
            Players:=Vehicle.GetPassengers()
            if(Player:=Players[0]):
                set wasDamagedByOtherPlayer = option{player[Player]}
                Logger.Print("damaged by passanger 0")
            Logger.Print("damage source is vehicle")

damage_result has also a Source property. Try checking both to find out the root for the damage.

I am, in middle of that code. Source seems to be ‘empty’ as well.

Ah I missed that, try casting the interfaces into fort_character on both paths. If it succeeds you can use that to fetch the associated vehicle from that character. I‘m not particularly sure the damage event actually provides an erase vehicle object. In fact fort_vehicle does not refine the instigator nor the cause interfaces, so will unlikely to succeed that way.

If both properties are empty, you’re out of luck I guess.

1 Like