Fortress Forever

Go Back   Fortress Forever > Editing > Mapping > Lua

Reply
 
Thread Tools Display Modes
Old 02-18-2008, 09:07 AM   #1
Lt Llama
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
quad and invul

After an evening of disturbing the peace of the players with various painful lua experiments Turbowolf ended up asking about quad in the IRC channel.

As I've seen so many threads about it and way smarter people than me have rubbed their grey brain cells to solve it, I thought, naah, this can't be done.

But squeek was very helpful and he helped us put together the following simple function:

Code:
function player_ondamage( player, damageinfo )
	if player:GetClass() ~= Player.kSoldier then
	    local damageforce = damageinfo:GetDamageForce()
	    damageinfo:SetDamageForce(Vector( damageforce.x * 4, damageforce.y * 4, damageforce.z * 4))
	    damageinfo:SetDamage( 0 )
	end
	if player:GetClass() ~= Player.kDemoman then
	    local damageforce = damageinfo:GetDamageForce()
	    damageinfo:SetDamageForce(Vector( damageforce.x * 4, damageforce.y * 4, damageforce.z * 4))
	    damageinfo:SetDamage( 0 )
	end
end
This simply adds * 4 damage force and invul to sollys and demomens.
I just added an IncludeScript("base_quad"); to the exisiting conc luas I already got for the concmaps.

We tested to play with it for a couple of hours and we all agree that * 4 damage is very close to TFC. Its much easier to rocket and pipe jump in FF with this than in TFC.

If you want to test it quad and invul is added to conc_oneeyed_b2, conc_adam and conc_adam2_r on the Euroskillz FF server 85.114.140.42:27015.

Maybe some lua pro can help us tweek it and make it better. Maybe add glow to the classes who got quad.

CURRENT TWEEKED VERSION

Credits:
DD who optimised the lua
Galdur who made the quad hud icon

This gives sollys and demomens quad and invul on red team.
To fix: When you go spec from red solly or demo the hud icon don't disappear.

Download hud icon (Put in materials/vgui)


Code:
-- base_quad.lua

----------------------------------------------------------------------
-- Quad icon
----------------------------------------------------------------------

hudicon = "hud_quad"
hudx = 5
hudy = 110
hudw = 48
hudh = 48
huda = 1
hudstatusicon = "hud_quad.vtf"

----------------------------------------------------------------------
-- Set hud icon at spawn
----------------------------------------------------------------------

function player_spawn( player_entity )
	local player = CastToPlayer( player_entity )
	local class = player:GetClass()
    	if class == Player.kSoldier or class == Player.kDemoman then
	    if player:GetTeamId() ~= Team.kRed then
		RemoveHudItem( player, hudstatusicon )
	    else
		AddHudIcon(player, hudicon, hudstatusicon, hudx, hudy, hudw, hudh, huda)
	    end
	else
	    RemoveHudItem( player, hudstatusicon )
	end
end

----------------------------------------------------------------------
-- Remove hud icon if player changes to spectator
----------------------------------------------------------------------

function player_switchteam( player, currentteam, desiredteam )
    if desiredteam == Team.kSpectator then
    	RemoveHudItem( player, hudstatusicon )
    end
    return true
end

----------------------------------------------------------------------
-- Set quad and invul when damage is taken by soldier and demoman
-- on red team
----------------------------------------------------------------------

function player_ondamage( player, damageinfo )
    if player:GetTeamId() ~= Team.kRed then return end
    local class = player:GetClass()
    if class == Player.kSoldier or class == Player.kDemoman then
	local damageforce = damageinfo:GetDamageForce()
	damageinfo:SetDamageForce(Vector( damageforce.x * 4, damageforce.y * 4, damageforce.z * 4))
	damageinfo:SetDamage( 0 )
    end
end
Hud icon

__________________
http://www.signaturebar.com/uploads/images/50033.png

Last edited by Lt Llama; 03-07-2008 at 03:05 PM.
Lt Llama is offline   Reply With Quote


Old 02-18-2008, 03:06 PM   #2
Sidd
Lua Team
 
Join Date: Mar 2007
Posts Rated Helpful 1 Times
~= is "not equal" in lua

you seem to be under the impression that ~= is equals.
In your code: A soldier is not a demoman, therefore multiply by 4
and a soldier is not a pyro, so multiply by 4 again

Fixed:
Code:
function player_ondamage( player, damageinfo )
	if player:GetClass() == Player.kSoldier then
	    local damageforce = damageinfo:GetDamageForce()
	    damageinfo:SetDamageForce(Vector( damageforce.x * 4, damageforce.y * 4, damageforce.z * 4))
	    damageinfo:SetDamage( 0 )
	elseif player:GetClass() == Player.kDemoman then
	    local damageforce = damageinfo:GetDamageForce()
	    damageinfo:SetDamageForce(Vector( damageforce.x * 4, damageforce.y * 4, damageforce.z * 4))
	    damageinfo:SetDamage( 0 )
	elseif player:GetClass() == Player.kPyro then
	    local damageforce = damageinfo:GetDamageForce()
	    damageinfo:SetDamageForce(Vector( damageforce.x * 4, damageforce.y * 4, damageforce.z * 4))
	    damageinfo:SetDamage( 0 )
	end
end
edit: silly lua should use elif. It's like sooo much shorter

Last edited by Sidd; 02-18-2008 at 04:17 PM.
Sidd is offline   Reply With Quote


Old 02-18-2008, 03:46 PM   #3
DD`
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
It's great to finally be able to use proper quad & invulnerability, it seems even more fun that it was in TFC.

When testing with my map I noticed the top piece of code worked but was bugged slightly in that every class got quad+invul (medics could just use quad nades instead of concing etc). I decided to have a play around with the lua and came up with this:

Code:
function player_ondamage( player, damageinfo )
	class = player:GetClass()
	if class == Player.kSoldier or class == Player.kDemoman then
	    local damageforce = damageinfo:GetDamageForce()
	    damageinfo:SetDamageForce(Vector( damageforce.x * 4, damageforce.y * 4, damageforce.z * 4))
	    damageinfo:SetDamage( 0 )
	end
The next bit of code has soldier, demo and pyro:

Code:
function player_ondamage( player, damageinfo )
	class = player:GetClass()
	if class == Player.kSoldier or class == Player.kDemoman or class == Player.kPyro then
	    local damageforce = damageinfo:GetDamageForce()
	    damageinfo:SetDamageForce(Vector( damageforce.x * 4, damageforce.y * 4, damageforce.z * 4))
	    damageinfo:SetDamage( 0 )
	end
tried your code btw sidd and it just errored.
DD` is offline   Reply With Quote


Old 02-18-2008, 04:16 PM   #4
Sidd
Lua Team
 
Join Date: Mar 2007
Posts Rated Helpful 1 Times
it probably should be "elseif" wherever i wrote "elif"
too much python, not enough lua :/
Sidd is offline   Reply With Quote


Old 02-18-2008, 06:43 PM   #5
Lt Llama
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
Thanks DD, added to first post as current tweeked version.
Lt Llama is offline   Reply With Quote


Old 02-18-2008, 10:54 PM   #6
GeoKill----->
Community Member
Server Owner
Beta Tester
Forum Moderator
 
GeoKill----->'s Avatar
 
Join Date: Mar 2007
Location: Hawthorne, California
Class/Position: Soldier/Spy/Scout
Gametype: AvD
Affiliations: :e0:Eternal Order Leader
Posts Rated Helpful 12 Times
You should add this to Wiki
__________________

:e0: Will live on Forever
Support FF:
GeoKill-----> is offline   Reply With Quote


Old 02-19-2008, 06:43 PM   #7
Sh4x
Retired FF Staff
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
Would it be possible to have a tweaked version that affects BLUE team only? If so, anyone care to write the code down?
Sh4x is offline   Reply With Quote


Old 02-19-2008, 07:38 PM   #8
Adam-g1
 
Join Date: Sep 2007
Posts Rated Helpful 0 Times
Oh my god. You guys are amazing! If this works as stated.. I'll have to start porting some of my quad maps to FF, among some new ones
Adam-g1 is offline   Reply With Quote


Old 02-19-2008, 10:22 PM   #9
Lt Llama
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
Quote:
Originally Posted by Sh4x
Would it be possible to have a tweaked version that affects BLUE team only? If so, anyone care to write the code down?
Code:
function player_ondamage( player, damageinfo )
    if player:GetTeamId() ~= Team.kBlue then return end
    local class = player:GetClass()
    if class == Player.kSoldier or class == Player.kDemoman then
	local damageforce = damageinfo:GetDamageForce()
	damageinfo:SetDamageForce(Vector( damageforce.x * 4, damageforce.y * 4, damageforce.z * 4))
	damageinfo:SetDamage( 0 )
    end
end
Lt Llama is offline   Reply With Quote


Old 02-19-2008, 10:42 PM   #10
trepid_jon
Ray Ray Johnson
Fortress Forever Staff
 
trepid_jon's Avatar
 
Join Date: Feb 2005
Location: Dallas, TX
Class/Position: D Civilian
Gametype: Rocket Jousting
Affiliations: EAFD
Posts Rated Helpful 78 Times
Send a message via ICQ to trepid_jon Send a message via AIM to trepid_jon
Now all we need is our god damn glow effect.
__________________
Support FF:
Trepid
steamcommunity.com/id/trepid_jon/
trepid_jon is offline   Reply With Quote


Old 02-19-2008, 10:55 PM   #11
Doompiggy
Banned
 
Doompiggy's Avatar
 
Join Date: Sep 2007
Location: Internet
Posts Rated Helpful 0 Times
Is it possible to add some client side message or pic to show you have quad? That would be easier, and quicker(Maybe).
Doompiggy is offline   Reply With Quote


Old 02-19-2008, 11:54 PM   #12
squeek.
Stuff Do-er
Lua Team
Wiki Team
Fortress Forever Staff
 
squeek.'s Avatar
 
Join Date: Mar 2007
Location: Northern California
Class/Position: Rallygun Shooter
Gametype: Conc tag (you just wait)
Affiliations: Mustache Brigade
Posts Rated Helpful 352 Times
Send a message via AIM to squeek.
Quote:
Originally Posted by Doompiggy
Is it possible to add some client side message or pic to show you have quad? That would be easier, and quicker(Maybe).
Yeah. That would be quite easy.
__________________
#FF.Pickup ยค Fortress-Forever pickups

My Non-official Maps
Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic
Beta FF_Myth - FF_Redlight_Greenlight

Sick of the people on the internet, always moanin'. They just moan.
- Karl Pilkington
squeek. is offline   Reply With Quote


Old 02-20-2008, 06:42 AM   #13
Lt Llama
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
I think we need a new hud icon for this. I looked at all the stuff in the materials/vgui folder but couldnt find anything suitable. It would also be good with some triggers which enables quad and invul. Btw, what models is it in the models/items/armour/ folder?

If someone could make a 256 x 256 helmet texture with a white background. I can make the vtf and vmt files.

Last edited by Lt Llama; 02-20-2008 at 08:44 AM.
Lt Llama is offline   Reply With Quote


Old 02-20-2008, 02:06 PM   #14
DD`
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
Quote:
Originally Posted by Adam-g1
Oh my god. You guys are amazing! If this works as stated.. I'll have to start porting some of my quad maps to FF, among some new ones
It does indeed work great, I was first ever person to finish conc_adam & conc_adam_2_r as quad sol and demo

More maps being either ported or made from scratch would be more than welcome as there's a short supply of skills maps atm sadly.
DD` is offline   Reply With Quote


Old 02-20-2008, 02:25 PM   #15
Doompiggy
Banned
 
Doompiggy's Avatar
 
Join Date: Sep 2007
Location: Internet
Posts Rated Helpful 0 Times
Quote:
Originally Posted by DD`
It does indeed work great, I was first ever person to finish conc_adam & conc_adam_2_r as quad sol and demo

More maps being either ported or made from scratch would be more than welcome as there's a short supply of skills maps atm sadly.
Someone ported qr_adam3 already :O
Doompiggy is offline   Reply With Quote


Old 02-20-2008, 03:36 PM   #16
Dr.Satan
Wiki Team
Fortress Forever Staff
 
Dr.Satan's Avatar
 
Join Date: Sep 2007
Location: Greeley, CO
Class/Position: Med / Solly
Gametype: PAYLOAD
Affiliations: DET-
Posts Rated Helpful 19 Times
Quote:
Originally Posted by trepid_jon
Now all we need is our god damn glow effect.
jon, are we able to use the glow from the Sg's and call it to a player command by chance?
__________________
(Released) conc_school | hellion_classic | ksour_PAYLOAD | mulch_faf
(Beta) alchimy_b1
(Lua) base_payload_2015
(Models) props_trainyard
Support FF:
Dr.Satan is offline   Reply With Quote


Old 02-20-2008, 09:52 PM   #17
Lt Llama
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
Added a hud icon made by Galdur and tried to make a lua that works.
It works for red team's solly and demo.
The hud icon disappears when you change to any other class or team.

But, if you change to spectator from solly or demo on red team the hud icon stays. What forward can I use to catch when a player goes spec so I can remove it from them to?

Btw, changed to red team as thats the traditional quad team. Sorry Sh4x.

Updated first post.

Last edited by Lt Llama; 02-20-2008 at 09:58 PM.
Lt Llama is offline   Reply With Quote


Old 02-20-2008, 11:17 PM   #18
trepid_jon
Ray Ray Johnson
Fortress Forever Staff
 
trepid_jon's Avatar
 
Join Date: Feb 2005
Location: Dallas, TX
Class/Position: D Civilian
Gametype: Rocket Jousting
Affiliations: EAFD
Posts Rated Helpful 78 Times
Send a message via ICQ to trepid_jon Send a message via AIM to trepid_jon
Quote:
Originally Posted by Dr.Satan
jon, are we able to use the glow from the Sg's and call it to a player command by chance?
They're essentially setup so a glow texture is quickly swapped in/out...rendering them differently for X time when they take damage.

For true glowing, we need to essentially draw models twice, making the second model scaled up and using a glow material.

Of course, another method would be to just draw some cool shit in the first pass.

Anyways, we have shit planned, but haven't done anything cool yet. Now that 2.0 is out of the way, we can finally get back to doing a lot more aesthetic shit like this.
__________________
Support FF:
Trepid
steamcommunity.com/id/trepid_jon/
trepid_jon is offline   Reply With Quote


Old 02-25-2008, 05:51 AM   #19
Lt Llama
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
Really annoying, but I can't get the hud_quad.vtf and hud_quad.vmt to upload to clients and my res files looks normal to me. Is it a matter of precaching or something?

The res file for conc_adam when I tested on that:

Code:
"resources"
{
    "maps/conc_adam.bsp"	"file"
    "maps/conc_adam.txt"	"file"
    "maps/conc_adam.lua"	"file"
    "materials/vgui/hud_quad.vtf"	"file"
    "materials/vgui/hud_quad.vmt"	"file"
}
Lt Llama is offline   Reply With Quote


Old 03-01-2008, 09:12 AM   #20
public_slots_free
 
Join Date: Sep 2007
Posts Rated Helpful 0 Times
download hud icon link does not work and nice work boys
public_slots_free is offline   Reply With Quote


Reply


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

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 02:28 PM.


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