Fortress Forever

Go Back   Fortress Forever > Editing > Mapping > Maps

Reply
 
Thread Tools Display Modes
Old 12-26-2008, 06:33 AM   #21
yfni&len
 
Join Date: Dec 2008
Gametype: Capture the Flag
Posts Rated Helpful 0 Times
Squeek wrote the following code for falldamage but can be easily changed for all damage. The problem is however that the server crashes the moment two people move inside the trigger. One can stand still with the other moving but the moment they both start moving the server crashes.

It still is very interesting code. And it does work up to the point where it crashes the server ;p.

I hope someone can fix it. We tried a few variations to this code but never had a non crashing, working version.

We replaced the code with a general nofalldamage for medic. Which is a good substitute for that specific problem in my map. But it would be useful for many maps that want spawn protection.

Code:
local no_fall_collection = Collection()

-----------------------------------------------------------------------------
-- Player spawn
-----------------------------------------------------------------------------
function player_spawn( player_entity ) 
	local player = CastToPlayer( player_entity ) 

	-- remove from collection
	for playerx in no_fall_collection.items do
		playerx = CastToPlayer(playerx)
		if playerx:GetId() == player:GetId() then
			no_fall_collection:RemoveItem( player )
		end
	end
end

-----------------------------------------------------------------------------
--trigger no_fall_damage
-----------------------------------------------------------------------------

no_fall_damage = trigger_ff_script:new()

function no_fall_damage:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then 
		local player = CastToPlayer( touch_entity )
		no_fall_collection:AddItem( player )
	end
end

function no_fall_damage:onendtouch( touch_entity )
	if IsPlayer( touch_entity ) then 
		local player = CastToPlayer( touch_entity )
		-- remove from collection
		for playerx in no_fall_collection.items do
			playerx = CastToPlayer(playerx)
			if playerx:GetId() == player:GetId() then
				no_fall_collection:RemoveItem( player )
			end
		end
	end
end

-----------------------------------------------------------------------------
-- ondamage; remove fall damage
-----------------------------------------------------------------------------

function player_ondamage ( player, damageinfo )

	-- if no damageinfo do nothing
	if not damageinfo then return end
	
	-- Get Damage Force
	local damagetype = damageinfo:GetDamageType()
	
	ConsoleToAll( "damage type: "..damagetype.." - expected: "..Damage.kFall )

	if damagetype == Damage.kFall then
		for playerx in no_fall_collection.items do
			playerx = CastToPlayer(playerx)
			if playerx:GetId() == player:GetId() then
				damageinfo:SetDamage(0)
			end
		end
	end
end
yfni&len 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 12:16 PM.


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