Page 3 of 5
Re: .gsc Scripting help needed
Posted: June 6th, 2011, 12:09 pm
by F |Madness| U
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?
Re: .gsc Scripting help needed
Posted: June 6th, 2011, 12:19 pm
by Drofder2004
viewpos returns the origin and angles of your current position.
Re: .gsc Scripting help needed
Posted: June 6th, 2011, 7:49 pm
by F |Madness| U
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);
Re: .gsc Scripting help needed
Posted: June 7th, 2011, 11:20 am
by Drofder2004
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.
Re: .gsc Scripting help needed
Posted: June 7th, 2011, 12:33 pm
by F |Madness| U
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.
Re: .gsc Scripting help needed
Posted: June 7th, 2011, 12:45 pm
by Drofder2004
To my knowledge it is possible to load any model after preloading, as long as you precache before any wait command is issued.
Re: .gsc Scripting help needed
Posted: June 7th, 2011, 5:10 pm
by F |Madness| U
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");
    }*/
Re: .gsc Scripting help needed
Posted: June 7th, 2011, 5:44 pm
by Drofder2004
Post your code.
Re: .gsc Scripting help needed
Posted: June 7th, 2011, 5:47 pm
by F |Madness| U
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")."
Re: .gsc Scripting help needed
Posted: June 7th, 2011, 6:30 pm
by Drofder2004
I assume the model is correct and exists (spelling correct?).
I honestly do not know, it is certainly possible in CoD4 :S
Re: .gsc Scripting help needed
Posted: June 7th, 2011, 7:49 pm
by IzNoGoD
Are you sure you dont need "xmodel\model" or smthing?
Re: .gsc Scripting help needed
Posted: June 7th, 2011, 10:09 pm
by Drofder2004
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.
Re: .gsc Scripting help needed
Posted: June 11th, 2011, 8:29 pm
by F |Madness| U
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!
Re: .gsc Scripting help needed
Posted: June 11th, 2011, 11:01 pm
by Drofder2004
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)
Re: .gsc Scripting help needed
Posted: June 11th, 2011, 11:35 pm
by F |Madness| U
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);
}