Fortress Forever

Go Back   Fortress Forever > Editing > Mapping > Lua

Reply
 
Thread Tools Display Modes
Old 03-04-2010, 08:46 AM   #1
Bridget
Banned
 
Bridget's Avatar
 
Join Date: Sep 2008
Class/Position: Soldier
Gametype: AVD
Affiliations: TALOS
Posts Rated Helpful 5 Times
Question about player_ondamage()

Does player_ondamage() still get called if someone hits a team mate and friendly fire is on? I need to make an effect similar to the Engineer's wrench repairing team mate's armor. Is there any other way to do this? If not, then I suggest player_onrepair( player, inflictor ) for Engineer's wrench. Maybe a more general function player_meleefriendly( player, inflictor ) or something like that.
Bridget is offline   Reply With Quote


Old 03-10-2010, 04:58 PM   #2
Dexter
internet user
Fortress Forever Staff
 
Dexter's Avatar
 
Join Date: Jun 2007
Posts Rated Helpful 42 Times
You could try this. No promises, I type this over vnc so I can't really test

Code:
function player_ondamage( player, damageinfo )
    local attacker = damageinfo:GetAttacker()

    -- If no attacker do nothing
    if not attacker then 
  	  damageinfo:SetDamage(0)
	  return
    end

    -- If attacker not a player do nothing
    if not IsPlayer(attacker) then 
  	  damageinfo:SetDamage(0)
	  return
    end

    local playerAttacker = CastToPlayer(attacker)
    -- if you need to know which weapon .. local weapon = damageinfo:GetInflictor():GetClassName()
    local team = playerAttacker:GetTeam()

    -- if same team
    if player:GetTeamId() == playerAttacker:GetTeamId() then
            -- do whatever, this will give to the victim
            damageinfo:SetDamage(0)
            player:AddHealth( 1 )
	    player:AddArmor( 23 )
    end
end
mostly stolen from squeek dm
__________________
9:17 PM - DEXTER: can you teach me how to play o
9:17 PM - squeek.: you jump a lot
9:18 PM - squeek.: and do sweet moves

8:55 PM - FDA: fart in you fridge and blame it on wild animals
Dexter is offline   Reply With Quote


Old 03-10-2010, 05:17 PM   #3
Dexter
internet user
Fortress Forever Staff
 
Dexter's Avatar
 
Join Date: Jun 2007
Posts Rated Helpful 42 Times
I lied I got it cooking on laptop, while its hard to test friendly fire alone, player_ondamage() appears to always be called so you should be good
__________________
9:17 PM - DEXTER: can you teach me how to play o
9:17 PM - squeek.: you jump a lot
9:18 PM - squeek.: and do sweet moves

8:55 PM - FDA: fart in you fridge and blame it on wild animals
Dexter is offline   Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:33 AM.


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