PDA

View Full Version : setmodel



Loveboy
4th May 2013, 21:21
hello guys, i want to ask, how you can precache a model, give it a origin and give it a position and an angle and then set the model.

I already know precacheModel("xmodel/example");

but i must give the model now a position and angle and origin where it will be set the model.

somebody know the script?

kung foo man
4th May 2013, 21:43
spawnModel(name, origin, angles)
{
model = spawn("script_model", origin);
model.angles = angles;
model setModel(name);
return model;
}


You can change the origin later with:



model moveTo(someNewOrigin, 1); // moves to someNewOrigin in 1 seconds
model.origin = (1,2,3); // moves model instantly to new origin

Loveboy
4th May 2013, 22:11
The script is wrong ;(

kung foo man
4th May 2013, 22:47
270............

Loveboy
4th May 2013, 22:59
error:

******* script compile error *******
bad syntax: (file 'maps/mp/gametypes/_nuke.gsc', line 170)
{
*
************************************

script:

loveboy()
{
spawnModel(name, origin, angles)
{ // line 171
model = spawn("script_model", origin);
model.angles = angles;
model setModel(vehicle_stuka_flying);
return model;
}
}

sorry i mean line 170*

kung foo man
4th May 2013, 23:06
You need to write that function next to other functions and call it like: spawnModel("xmodel/...", (1,2,3), (3,2,1));

Loveboy
4th May 2013, 23:19
next error:

******* script compile error *******
uninitialised variable 'origin': (file 'maps/mp/gametypes/_nuke.gsc', line 171)
model = spawn("script_model", origin);
*
************************************

script:

loveboy()
{
spawnModel("xmodel/vehicle_stuka_flying", (1,2,3), (0,90,0));
{
model = spawn("script_model", origin);
model.angles = angles;
model setModel(vehicle_stuka_flying);
return model;
}
}

serthy
4th May 2013, 23:37
loveboy()
{
spawnModel("xmodel/vehicle_stuka_flying", (1,2,3), (0,90,0));
{
model = spawn("script_model", origin);
model.angles = angles;
model setModel(vehicle_stuka_flying);
return model;
}
}

WTF dude, you should really start with the basics of coding...



spawnModel( name , pos , angles );
{
model = spawn( "script_model" , pos );
model.angles = angles;
model setModel( name );
return model;
}

loveboy()
{
precacheModel( "xmodel/vehicle_stuka_flying" );

model = spawnModel( "xmodel/vehicle_stuka_flying" , ( 1 , 2 , 3 ) , ( 0 , 90 , 0 ) );
}

Loveboy
4th May 2013, 23:57
******* script compile error *******
bad syntax: (file 'maps/mp/gametypes/_nuke.gsc', line 166)
spawnModel( name , pos , angles );
*
************************************

Tally
5th May 2013, 08:57
WTF dude, you should really start with the basics of coding...



spawnModel( name , pos , angles );
{
model = spawn( "script_model" , pos );
model.angles = angles;
model setModel( name );
return model;
}

loveboy()
{
precacheModel( "xmodel/vehicle_stuka_flying" );

model = spawnModel( "xmodel/vehicle_stuka_flying" , ( 1 , 2 , 3 ) , ( 0 , 90 , 0 ) );
}

LMAO @serthy. You've made the kind of mistake I usually make - you've told LoveBoy to start with the basics and you then went and put a semi-colon (;) on your function bracket.

Tally
5th May 2013, 09:01
******* script compile error *******
bad syntax: (file 'maps/mp/gametypes/_nuke.gsc', line 166)
spawnModel( name , pos , angles );
*
************************************

Let me correct serthy:


spawnModel( name , pos , angles )
{
model = spawn( "script_model" , pos );
model.angles = angles;
model setModel( name );
return model;
}

loveboy()
{
precacheModel( "xmodel/vehicle_stuka_flying" );

model = spawnModel( "xmodel/vehicle_stuka_flying" , ( 1 , 2 , 3 ) , ( 0 , 90 , 0 ) );
}


Basically, DON'T try to call the spawnModel() function without filling in the details: 1. the model, 2, the origin, and 3. the angles. To stop that happening, I would add some checks for such details:


spawnModel( model, origin, angles )
{
if( !isdefined(model) || !isdefined(origin) )
return undefined;

if( !isdefined(angles) )
angles = (0,0,0);

spawn = spawn ("script_model",(0,0,0));
spawn.origin = origin;
spawn setmodel (model);
spawn.angles = angles;

return spawn;
}

That will stop the runtime error if you miss out the details, but the model wont spawn.

HISTORICAL NOTE -

The spawnModel() was first used in a Call of Duty mod by PoolMaster in his "PoolMaster Mod ver 1.3" for COD1 circa December 2003. But it was made famous by Bell in his AWE mod for COD1 and COD: UO circa 2004 and subsequent years. But Bell got the function from PoolMaster with permission, so correctly speaking, it was PoolMaster who came up with the function in the form it took in AWE. All that was done before the COD1 mod tools came out. We had no help from the developers and pretty much all modding was done by discovering what was possible and passing on the info on the IWNation modding forums. Golden Days of Modding! I miss them.

serthy
5th May 2013, 10:32
LMAO @serthy. You've made the kind of mistake I usually make - you've told LoveBoy to start with the basics and you then went and put a semi-colon (;) on your function bracket.

;D you are right, i sent the code not from my pc, but no excuses

271

Loveboy
5th May 2013, 12:03
let me try too:


loveboy()
{
bombmodel = "xmodel/prop_stuka_bomb";
angles = (0, 45, 0);
origin = (-3000, 1500, 1536); // hinten - vorne , links - rechts , höhe wurf: (1500, 1500, 1536)
bomb = spawn( "script_model" , origin );
bomb setModel(bombmodel);
}

guiismiti
5th June 2015, 22:10
Hey guys

I'm firing a projectile from the gunship, from self.origin to trace["position"].
How can I set the projectile.angles? It should be pointing to the target (trace["position"]).
I know I could determine the three angles as the inclinations between the origin and the target, but I'm not sure if trigonometric functions are supported...


Thanks again


Editted: This is good enough

projectile.angles = self getplayerangles();

Mitch
5th June 2015, 23:21
Hey guys

I'm firing a projectile from the gunship, from self.origin to trace["position"].
How can I set the projectile.angles? It should be pointing to the target (trace["position"]).

There is a default function available for that.

https://znation.nl/cod4script/vectortoangles.htm

angles = VectorToAngles( end - start );

Tally
6th June 2015, 08:51
Well, you should normalize the angles as well:


angles = VectorToAngles( vectorNormalize( end - start ) );