UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: GerardS0406 on July 30, 2015, 05:03:11 am

Title: Gravity Change
Post by: GerardS0406 on July 30, 2015, 05:03:11 am
How to make gravity change in a certain part of a map.
Title: Re: Gravity Change
Post by: RadimaX on July 30, 2015, 06:05:47 am
you can only change gravity for Everybody or Nobody in cod WaW :P thats why the teleporter in "the bedroom" needs every person to be on it to get into the "space room" with perks otherwise 1 would go there and trigger the gravity command and 3 other people would suddenly go flying around the regular sections of the map lol
Title: Re: Gravity Change
Post by: GerardS0406 on July 30, 2015, 06:08:54 am
you can only change gravity for Everybody or Nobody in cod WaW :P thats why the teleporter in "the bedroom" needs every person to be on it to get into the "space room" with perks otherwise 1 would go there and trigger the gravity command and 3 other people would suddenly go flying around the regular sections of the map lol
makes sense and that is what I wanted to do just don't know the way of doing that, I have a space ship type thing that when triggered everyone would be sent to the moon.
Title: Re: Gravity Change
Post by: vinnyz500 on July 30, 2015, 07:30:27 am
you can only change gravity for Everybody or Nobody in cod WaW :P thats why the teleporter in "the bedroom" needs every person to be on it to get into the "space room" with perks otherwise 1 would go there and trigger the gravity command and 3 other people would suddenly go flying around the regular sections of the map lol
But on leviathan there is low gravity when ur in the water but players are in different areas, i think that is what he is refering to. Some script like that
Title: Re: Gravity Change
Post by: Eternal_Fire on July 30, 2015, 11:03:48 am
you can only change gravity for Everybody or Nobody in cod WaW :P thats why the teleporter in "the bedroom" needs every person to be on it to get into the "space room" with perks otherwise 1 would go there and trigger the gravity command and 3 other people would suddenly go flying around the regular sections of the map lol

Well if you want gravity changing to be simple then yeah, you are restricted to everyone having it or no one having it, but both project viking and leviathan had gravity that only affected certain players. Project viking with afterlife and leviathan with going out into the water and going inside.

EDIT: Actually you probably know this don't you xD considering you helped make leviathan, sorry, bad on my end.
Title: Re: Gravity Change
Post by: DeletedUser on July 30, 2015, 04:17:11 pm
Could you not, check for a player jumping, then use setVelocity when they are in the area you want to have low gravity.

Not too sure, but thought it may work  :poker:
Title: Re: Gravity Change
Post by: MakeCents on July 30, 2015, 04:28:51 pm
Could you not, check for a player jumping, then use setVelocity when they are in the area you want to have low gravity.

Not too sure, but thought it may work  :poker:

Shh..., everyone tries to keep that a secret, lol. With some finesse it will work. By finesse I'm talking a while loop and some vector math.

Some of these functions may help if that is what you want to do:

Vector related (http://wiki.modsrepository.com/index.php?title=Call_of_Duty_4:_Scripting_Reference_-_Vector)
Player velocity Related (http://wiki.modsrepository.com/index.php?title=Call_of_Duty_4:_Scripting_Reference_-_Player)
Title: Re: Gravity Change
Post by: GerardS0406 on July 30, 2015, 05:09:28 pm
couldn't you do
Code Snippet
Plaintext
setDvar(jump_height, <value>)
setDvar(g_gravity, <value>)
and change it back when the players come back?
Title: Re: Gravity Change
Post by: MakeCents on July 30, 2015, 05:16:42 pm
couldn't you do
Code Snippet
Plaintext
setDvar(jump_height, <value>)
setDvar(g_gravity, <value>)
and change it back when the players come back?

Well you said setDvar, not setclientDvar. Wouldn't a dvar affect everyone?
Title: Re: Gravity Change
Post by: BluntStuffy on July 30, 2015, 05:17:10 pm
couldn't you do
Code Snippet
Plaintext
setDvar(jump_height, <value>)
setDvar(g_gravity, <value>)
and change it back when the players come back?

Yes you could, but it Always affects all-players at the same time. You cant have player-1 have low-gravity and player-2 have normal gravity.


The way mc mentioned will allow you to do it for each player seperate, but it's more just high-jumping then low-gravity obv..


EDIT:

Well you said setDvar, not setclientDvar. Wouldn't a dvar affect everyone?

g_gravity is not a clientdvar, so using setclientdvar will not work ( or at least have the same outcome as setdvar )
Title: Re: Gravity Change
Post by: MakeCents on July 30, 2015, 05:27:31 pm
but it's more just high-jumping then low-gravity obv..


agreed on this one...



g_gravity is not a clientdvar, so using setclientdvar will not work ( or at least have the same outcome as setdvar )

That was my point I was going to walk them through...

Sorry for any confusion on that... I was trying baby steps since radi kind of said that.
Title: Re: Gravity Change
Post by: GerardS0406 on July 30, 2015, 05:34:48 pm
okay thanks for the help.
Title: Re: Gravity Change
Post by: BluntStuffy on July 30, 2015, 05:37:58 pm
That was my point I was going to walk them through...

Sorry for any confusion on that... I was trying baby steps since radi kind of said that.

 :D my bad, i missed the point there..
Title: Re: Gravity Change
Post by: MakeCents on July 30, 2015, 05:40:01 pm
:D my bad, i missed the point there..

Lol, no my bad. You prob were not alone, lol. Why can't every one see my thoughts?  :D
Title: Re: Gravity Change
Post by: RadimaX on August 01, 2015, 02:09:46 pm
as i said: you can change gravity for EVERYBODY or NOBODY in cod WaW
topic is called GRAVITY CHANGE, some people fail to see that...
Title: Re: Gravity Change
Post by: Ege115 on August 01, 2015, 03:32:16 pm
Here's a low gravity script I made a long long time ago. It may be not the best script but it works decently as far as I know.
Code Snippet
Plaintext
#include maps\_utility;
#include common_scripts\utility;
#include maps\_zombiemode_utility;

init()
{
level thread connect_gravity_on_player();
}

connect_gravity_on_player()
{
for(;;)
{
level waittill( "connecting", player );
player thread onPlayerSpawned();
}
}

onPlayerSpawned()
{
self endon("disconnect");
for(;;)
{
self waittill("spawned_player");
self thread gravity_jump_height();
self thread gravity_watch();
}
}

gravity_watch()
{
        self endon("disconnect");

low_gravity_area = getEntArray("low_gravity_area", "targetname");

while(1)
{
for(i=0;i<low_gravity_area.size;i++)
{
if(low_gravity_area[i].gravity_active && !self isOnGround() && (self getVelocity()[2] > 0 || self getVelocity()[2] < 0))
{
while(!self isOnGround())
{
angles = self getplayerangles();
angles = (0, angles[1], 0);
self SetVelocity( self getVelocity() + AnglesToUp(angles) * 34 );

if(!low_gravity_area[i].gravity_active)
break;

wait .05;
}
}
}

wait .05;
}
}

gravity_jump_height()
{
        self endon("disconnect");

low_gravity_area = getEntArray("low_gravity_area", "targetname");
for(i=0;i<low_gravity_area.size;i++)
low_gravity_area[i].gravity_active = false;

while(1)
{
for(i=0;i<low_gravity_area.size;i++)
{
if(self isTouching(low_gravity_area[i]) && !low_gravity_area[i].gravity_active)
{
low_gravity_area[i].gravity_active = true;
self setClientDvar("jump_height", 12);
}
else if(!self isTouching(low_gravity_area[i]) && low_gravity_area[i].gravity_active)
{
low_gravity_area[i].gravity_active = false;
self setClientDvar("jump_height", 39);
}
}

wait .05;
}
}
You make trigger multiples in the map with the KVP,
Code Snippet
Plaintext
targetname - low_gravity_area
If you touch those, you should have lower gravity when jumping.

If anyone wants this, feel free to edit.

EDIT: Also tell me if any glitches happens with this, or if any other scripter sees something stupid. Note this was a long time ago so I know I should improve it with what I know now. :P
Title: Re: Gravity Change
Post by: MakeCents on August 01, 2015, 05:32:15 pm
EDIT: Also tell me if any glitches happens with this, or if any other scripter sees something stupid. Note this was a long time ago so I know I should improve it with what I know now. :P

I had a few concerns, even questions, maybe some suggestions. I personally thread as little on the player as possible, cause you get into the, did I end it on death, do I got to start it again, shit, is it running twice? kind of stuff. Like here it doesn't appear you end it on death but you do start it on spawn each spawn. So, since you are using trigger multiples, I would rather use the triggers, then the players to thread things on for the most part. I didn't test any of this, just took your script and tweaked it. What you think?

Code Snippet
Plaintext
#include maps\_utility;
#include common_scripts\utility;
#include maps\_zombiemode_utility;

init()
{
low_gravity_area = getEntArray("low_gravity_area", "targetname");
array_thread(low_gravity_area,::WatchMe);// common_scripts\utility.gsc:
}

WatchMe(){
while(1){
waittill("trigger", player);
if(!isDefined(player.gravAffect)) player thread gravity_affect(self);
wait(.01);
}
}

gravity_affect(grav)
{
self.gravAffect = true;
self setClientDvar("jump_height", 39);
self endon("disconnect");
while(self isTouching(grav))
{
if(!self isOnGround() && (self getVelocity()[2] > 0 || self getVelocity()[2] < 0))
{
while(!self isOnGround())
{
angles = self getplayerangles();
angles = (0, angles[1], 0);
self SetVelocity( self getVelocity() + AnglesToUp(angles) * 34 );
wait .05;
}
}
wait .05;
}
self.gravAffect = undefined;
self setClientDvar("jump_height", 12);
}

Title: Re: Gravity Change
Post by: Ege115 on August 01, 2015, 07:10:17 pm
I had a few concerns, even questions, maybe some suggestions. I personally thread as little on the player as possible, cause you get into the, did I end it on death, do I got to start it again, shit, is it running twice? kind of stuff. Like here it doesn't appear you end it on death but you do start it on spawn each spawn. So, since you are using trigger multiples, I would rather use the triggers, then the players to thread things on for the most part. I didn't test any of this, just took your script and tweaked it. What you think?

Code Snippet
Plaintext
#include maps\_utility;
#include common_scripts\utility;
#include maps\_zombiemode_utility;

init()
{
low_gravity_area = getEntArray("low_gravity_area", "targetname");
array_thread(low_gravity_area,::WatchMe);// common_scripts\utility.gsc:
}

WatchMe(){
while(1){
waittill("trigger", player);
if(!isDefined(player.gravAffect)) player thread gravity_affect(self);
wait(.01);
}
}

gravity_affect(grav)
{
self.gravAffect = true;
self setClientDvar("jump_height", 39);
self endon("disconnect");
while(self isTouching(grav))
{
if(!self isOnGround() && (self getVelocity()[2] > 0 || self getVelocity()[2] < 0))
{
while(!self isOnGround())
{
angles = self getplayerangles();
angles = (0, angles[1], 0);
self SetVelocity( self getVelocity() + AnglesToUp(angles) * 34 );
wait .05;
}
}
wait .05;
}
self.gravAffect = undefined;
self setClientDvar("jump_height", 12);
}

Oh shit, didn't mean to make it end on death, fixed on mine now. :-X

Yea yours is much more effective, I usually make player threads on most of my scripts, but I admit that trigger waits are better in this case.
Title: Re: Gravity Change
Post by: DidUknowiPwn on August 01, 2015, 07:36:56 pm
jump_height is a global var it won't affect anyone but host.