Forum

> > CS2D > General > Jumping Idea
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Jumping Idea

30 replies
Page
To the start Previous 1 2 Next To the start

old Re: Jumping Idea

archmage
User Off Offline

Quote
This is simple. It will not detect walls or obstacles.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
addhook("serveraction", "action");

parse("bind \"space\" \"serveraction1\"");


player_move = function (id, mx, my)
if ( not (type(id) == 'number' and type(mx) == 'number' and type(my) == 'number') ) then
	error("in call to player_move(number, number, number) received player_move("..type(id)..", "..type(mx)..", "..type(my)..")");
end

parse("setpos "..id.." "..player(id,"x")+mx.." "..player(id,"y")+my);
end

Jump = function(id, modifier)
if ( not (type(id) == 'number' and type(modifier) == 'number')) then
	error("in call to Jump(number, number) received Jump("..type(id)..", "..type(modifier)..")");
end

player_move(id, math.sin(math.rad(player(id, "rot")))*modifier, -math.cos(math.rad(player(id,"rot")))*modifier);

end

function action(id, a)
	if ( a == 1 ) then
		Jump(id, 65);
	end
end

old Re: Jumping Idea

Jaso
BANNED Off Offline

Quote
@Dark Byte
Thanks i will try. But you cant make that it detect walls?

old Re: Jumping Idea

archmage
User Off Offline

Quote
Yes of course I could. I just did not want to lol. I will sometime. Atm I am doing something.

old Re: Jumping Idea

Phenixtri
User Off Offline

Quote
I was thinking of making such a script for NTDs HL2D that would let you jump onto obstacle map entities & over any tiles excluding walls.

The player would be able to jump 1 tile in any direction unless jumping forward (direction player is facing) in which the distance the player jumps is determined by how fast that player is moving.

This was to work in conjunction with a sprint lua that lets you run faster for a shot amount of time kinda like in HL2.

Max forward jump range would be about 3-5 tiles depending on the players speed.

My main issue was that the lua used server command keys like DC said

I don t know how I would make a auto load program that would bind the keys to space bar for jump & shift Key for sprint. Ill figure it out eventually >>

old Re: Jumping Idea

Surplus
User Off Offline

Quote
bind space "say !jump"

No serveraction requried
But you must edit the script to jump on "!jump"

old Re: Jumping Idea

TDShuft
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function anglerad(angle)
	if (angle<=90) then
			angle = (angle + 360)
		end
	return math.rad(math.abs( angle + 90 ))-math.pi
end
addhook("say","jumping")
function jumping(id,text)
rot = player(id,"rot")
local angle = anglerad(rot)
local newx = player(id,"x") + math.cos(angle)* 64
local newy = player(id,"y") + math.sin(angle)* 64
local olgx = player(id,"x") + math.cos(angle)* 32
local olgy = player(id,"y") + math.sin(angle)* 32
local tx = math.floor(olgx/32)
local ty = math.floor(olgy/32)
local gx = math.floor(newx/32)
local gy = math.floor(newy/32)
if text=="!jump" then
	if tile(tx,ty,"obstacle") then
		if tile(gx,gy,"walkable") then
			parse("setpos "..id.." "..newx.." "..newy)
		end
	end
end
end
Maybe this will help .. i think ..

old Re: Jumping Idea

archmage
User Off Offline

Quote
I think you should add the variables AFTER
1
if (txt == "jump" ) then
so they are not created every time someone sends a message.

old Re: Jumping Idea

TDShuft
User Off Offline

Quote
Dark Byte has written
I think you should add the variables AFTER
1
if (txt == "jump" ) then
so they are not created every time someone sends a message.

ok, Script Correction !
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function anglerad(angle)
     if (angle<=90) then
               angle = (angle + 360)
          end
     return math.rad(math.abs( angle + 90 ))-math.pi
end
addhook("say","jumping")
function jumping(id,text)
if ( text=="!jump" ) then
rot = player(id,"rot")
local angle = anglerad(rot)
local newx = player(id,"x") + math.cos(angle)* 64
local newy = player(id,"y") + math.sin(angle)* 64
local olgx = player(id,"x") + math.cos(angle)* 32
local olgy = player(id,"y") + math.sin(angle)* 32
local tx = math.floor(olgx/32)
local ty = math.floor(olgy/32)
local gx = math.floor(newx/32)
local gy = math.floor(newy/32)
     if tile(tx,ty,"obstacle") then
          if tile(gx,gy,"walkable") then
               parse("setpos "..id.." "..newx.." "..newy)
          end
     end
end
end

old Re: Jumping Idea

TimeQuesT
User Off Offline

Quote
why you changed to "!jump" instead of "jump" ? "jump" is correct and you don't need to have a "!" in front of it
bäähh

old Re: Jumping Idea

Jaso
BANNED Off Offline

Quote
I tried the script so i said jump but nofing happend so how do you jump?
To the start Previous 1 2 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview