.gsc Scripting help needed

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: .gsc Scripting help needed

Post by F |Madness| U » June 6th, 2011, 12:09 pm

I've seen custom maps with something similar, where they have patched exploits without re-compiling whole map in radiant. They add something into .gsc, but rather than a solid object like this spawn collision is, its more like a repulsion when you try to walk there. Eg. if they put it into a door way, if you tried to walk through the door you would get about half way through, and be `repelled` back to infront of the door.

Also I know there must be a way to, but how could I get the co-ordinates of certain places on the map without guessing/using radiant? And in the spawn collision code they have 2 sets of information, eg (1558, -179, -362) and (0, 225, 0). I'm guessing the first set of numbers are the x y and z co-ordinates of where it should be placed, what could the second values be, angles?
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: .gsc Scripting help needed

Post by Drofder2004 » June 6th, 2011, 12:19 pm

viewpos returns the origin and angles of your current position.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: .gsc Scripting help needed

Post by F |Madness| U » June 6th, 2011, 7:49 pm

Drofder I found something else, you can also spawn models within the .gsc, and then add a spawncollision to it as if it was already in the map. Example:

Code: Select all

// spawn collision to keep the player out the corner by the stairs. 
        spawncollision("collision_geo_128x128x128","collider",(-486, -1115, -181), (0, 0, 0));
        spawncollision("collision_geo_128x128x128","collider",(-514, -1115, -128), (40, 0, 0));
        spawncollision("collision_geo_128x128x128","collider",(-571, -998, -129), (0, 270, 0));
        spawncollision("collision_wall_128x128x10","collider",(-514, -998, -17), (0, 270, 0));
 
        // spawn a barrel in the corner by the stairs to account for the collision.
        /*wetBarrel1 = Spawn("script_model", (-442, -1038, -193) );
        if ( IsDefined(wetBarrel1) )
        {
                wetBarrel1.angles = (0, 0, 0);
                wetBarrel1 SetModel("p_jun_woodbarrel_asian_lid_wet");
        }*/

Code: Select all

        precachemodel("collision_wall_128x128x10");
        precachemodel("collision_geo_128x128x128");
        precachemodel("p_jun_woodbarrel_asian_lid_wet");
Just tested it and you can indeed spawn models with it, I spawned some random poles around a map each with their own collision barrier aswell. I think you can only spawn models which are found inside the map you have loaded, might there be anyway to load models used in other maps?

There isn't any chance there may be a function where you can remove collisions or models? I'm guessing not because the collision/model would be in the actual radiant map file.

And you can spawn killtriggers:

Code: Select all

        // Start a killtrigger to keep players from standing on thier carepackages outside the map.
        thread trigger_killer((920, -336, -592), 1725, 128);
        thread trigger_killer((1440, 1848, -592), 1725, 128);
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: .gsc Scripting help needed

Post by Drofder2004 » June 7th, 2011, 11:20 am

By the look of it, they have simply spawned a normal collision barrier and then a barrel to give illusion the barrier is made by the barrel.

Spawn the same barrel in another spot on the map, and I would guess you cannot jump on it.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: .gsc Scripting help needed

Post by F |Madness| U » June 7th, 2011, 12:33 pm

That's correct, unless you spawn a collision where that barrel is aswell. One thing that questions me though, most maps where they have an item spawned in the gsc, they don't have to precache the model (since it's already been used in the map I assume). However on some maps, they have had to precache the model ie. precache("p_kow_plane_747"), meaning it hasn't been already loaded in the map. I want to know how they have done this, as I have tried precaching and placing models not used on a map, and it is unable to load that xmodel.
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: .gsc Scripting help needed

Post by Drofder2004 » June 7th, 2011, 12:45 pm

To my knowledge it is possible to load any model after preloading, as long as you precache before any wait command is issued.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: .gsc Scripting help needed

Post by F |Madness| U » June 7th, 2011, 5:10 pm

Still cannot load the xmodel :s I am totally confused after examing a few of their ma .gscs. Look below if you have the time.
Code where they load object already in map (I think it's already in the map, tehre are various other barriers which look identicle to the ones specified in the origin below):

Code: Select all

main()
{
        //needs to be first for create fx
        maps\mp\mp_array_fx::main();
 
        precachemodel("collision_geo_10x10x512");
        precachemodel("collision_geo_64x64x64");
        precachemodel("collision_wall_64x64x10");
        precachemodel("collision_wall_512x512x10");
        precachemodel("collision_geo_64x64x256");
        precachemodel("p_glo_concrete_barrier_damaged");
// spawn a couple of K Rails to make sense of the collision spawned under the center building.
        kRail1 = Spawn("script_model", (-824, 672, 480) );
        if ( IsDefined(kRail1) )
        {
                kRail1.angles = (0, 105, 0);
                kRail1 SetModel("p_glo_concrete_barrier_damaged");
        }
        
        kRail2 = Spawn("script_model", (-804, 600, 468) );
        if ( IsDefined(kRail2) )
        {
                kRail2.angles = (15, 285, 0);
                kRail2 SetModel("p_glo_concrete_barrier_damaged");
        }
Another code where they load an object already in the map, note: this time they don't precache it.

Code: Select all

main()
{
        //needs to be first for create fx
        maps\mp\mp_russianbase_fx::main();
 
        precachemodel("collision_geo_32x32x128");
        precachemodel("collision_wall_256x256x10");
        precachemodel("collision_wall_500x320x9");
//spawn a new telephone pole
        
        pole1 = Spawn("script_model", (-114.081, 1821.35, -10) );
        if ( IsDefined(pole1) )
        {
                pole1.angles = (0, 15.2, 0);
                pole1 SetModel("p_rus_electricpole");
        }
Code where they spawn an object not already in map (I assume it's not already in the map, also whats with the precaching before and after the fx line).

Code: Select all

main()
{
 
        PrecacheModel("p_kow_airplane_747");
        PrecacheItem( "zipline_mp" );
        PrecacheString( &"MP_ZIPLINE" );
        
        //needs to be first for create fx
        maps\mp\mp_kowloon_fx::main();
 
        precachemodel("collision_wall_128x128x10");
        precachemodel("collision_geo_128x128x128");
        precachemodel("p_jun_woodbarrel_asian_lid_wet");
 
// spawn a barrel in the corner by the stairs to account for the collision.
        /*wetBarrel1 = Spawn("script_model", (-442, -1038, -193) );
        if ( IsDefined(wetBarrel1) )
        {
                wetBarrel1.angles = (0, 0, 0);
                wetBarrel1 SetModel("p_jun_woodbarrel_asian_lid_wet");
        }*/
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: .gsc Scripting help needed

Post by Drofder2004 » June 7th, 2011, 5:44 pm

Post your code.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: .gsc Scripting help needed

Post by F |Madness| U » June 7th, 2011, 5:47 pm

Code: Select all

main()
{
        PrecacheModel("p_rus_electricpole");
        precachemodel("tag_origin");
 
        level.onSpawnIntermission = ::cosmodrome_intermission;
 
        /#
                level thread devgui_cosmodrome();
                execdevgui( "devgui_mp_cosmodrome" );
        #/
        
        //needs to be first for create fx
        maps\mp\mp_cosmodrome_fx::main();
 
        //precachemodel("collision_wall_128x128x10");
        //precachemodel("collision_geo_128x128x128");
        //precachemodel("collision_wall_512x512x10");
  //precachemodel("collision_geo_mc_8x560x190");
  //precachemodel("collision_geo_mc_4x52x190");
  //precachemodel("collision_geo_mc_4x156x190");
 
....
 
//spawn a new telephone pole
        
        pole1 = Spawn("script_model", (1348, -160, 240) );
        if ( IsDefined(pole1) )
        {
                pole1.angles = (0, 15.2, 0);
                pole1 SetModel("p_rus_electricpole");
        }
 
Also tried putting the precache("p_rus_electricpole"); with the spawncollision precaches. Either way I get "Error: Could not load xmodel "p_rus_electricpole")."
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: .gsc Scripting help needed

Post by Drofder2004 » June 7th, 2011, 6:30 pm

I assume the model is correct and exists (spelling correct?).

I honestly do not know, it is certainly possible in CoD4 :S
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: .gsc Scripting help needed

Post by IzNoGoD » June 7th, 2011, 7:49 pm

Are you sure you dont need "xmodel\model" or smthing?
LMGTFY!

Its not a glitch... Its the future!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: .gsc Scripting help needed

Post by Drofder2004 » June 7th, 2011, 10:09 pm

IzNoGoD wrote:Are you sure you dont need "xmodel\model" or smthing?
In CoD2 I think so, but not in CoD4, and looking at the stock values in the posts above, I would assume not.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: .gsc Scripting help needed

Post by F |Madness| U » June 11th, 2011, 8:29 pm

Yeah I've given up on that spwaning models, oh well.

One thing I'm trying to do (I think it's pretty simple) but I cannot find out how to..is use a function to get a value. Then print that value in the middle of the screen.

My code:

Code: Select all

onPlayerConnect()
{
        for(;;)
        {
                level waittill( "connected", player );
                
                name = self.getxuid;
                
        
                xuidText = createServerFontString( "extrabig", 1.5 );
                xuidText setPoint( "CENTER", "CENTER", 0, -80 );
                xuidText.sort = 1001;
                xuidText setText(name);
Obviously I'm doing something wrong, any help would be appreciated.

Also, what are the advantages of creating a mod as a new gametype (rather than running it as TDM etc), and how would you go about this?

Lastly, how do you `make` dvars (to put in your mod's cfg file) specific to your mod? I tryed googling for all of these and found nothing!
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: .gsc Scripting help needed

Post by Drofder2004 » June 11th, 2011, 11:01 pm

Code: Select all

playerKDRatio()
{
   kills = self.kills;
   deaths = self.deaths;
 
   return (kills / deaths); /* The return is the data that is sent back to the thread where the function was called */
}
 
displayKDRatio()
{
   ratio = self playerKDRatio(); /* This is where the function is called. Any function you call with an expected return, is setup like a variable. variable = function(); */
   self iprintlnbold(ratio);
}
That is the basics of retrieving a value from a different function and also printing to the centre screen.

(there are several potnetial problems with the code, such as 'divide by zero' errors, no defined 'self', this code is just example work)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: .gsc Scripting help needed

Post by F |Madness| U » June 11th, 2011, 11:35 pm

Okay thanks, I understand your code, and tryed doing it with my own, but am still getting the error that nameshow is an undefined string. My code:

Code: Select all

myxuid()
{
        name = self.getxuid;
        return (name);
}
 
showme()
{
        nameshow = self myxuid();
        
        xuidText = createServerFontString( "extrabig", 1.5 );
        xuidText setPoint( "CENTER", "CENTER", 0, -80 );
        xuidText.sort = 1001;
        xuidText setText(nameshow);
        //self iprintlnbold(nameshow);
        
}
-

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests