Call of Duty 4: Bobbing Models: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
No edit summary
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Image:Nutshell.png]] This tutorial shows how to create 'bobbing' models in water to give a floating movement impression. I got the script from a COD2 tutorials by ''BR3NT''
[[Category:Call of Duty 4]]
[[Category:Modtools]]
[[Category:Radiant]]
[[Category:Advanced Editing]]
[[Category:Scripting]]
{{warning_forpro}}
[[Image:rgn_warning.png|right]]
[[Image:Nutshell.png]] This tutorial shows how to create 'bobbing' models in water to give a floating movement impression. I got the script from a COD2 tutorials by ''BR3NT''.<br>


'''<font color="blue">2 models are animated in this example:'''</font>
com_bottle4
me_plastic_crate1
[[Image:bobbing_1.png|600px|center]]


== In Radiant ==
== In Radiant ==
Place the 2 models how we want them with their top surface slightly (2/3 units) over the water patch.


[[Image:bobbing_4.png]]
Select the first model, right clic in the 2D window and select ''Script'' then ''Script_model''
[[Image:bobbing_5.png]]
Then witht the first model still selected press 'n' to bring up the entity window and enter the following key/values:
targetname bobbing_obj
Do the same steps for the second model using those:
targetname bobbing_obj2
The result should be:
[[Image:bobbing_2.png]]
and
[[Image:bobbing_3.png]]


== In Script ==
== In Script ==


* Create a new file under /raw/maps/mp/ called _bobbing_obj.gsc and have the following in:
* Create a new file under /raw/maps/mp/ called _bobbing_obj.gsc and insert the following:


<pre>
<pre>
main()
main()
{
{
  thread bobbing_think();
thread bobbing_think();
}


bobbing_think()
bobbing_think()
{
{
obj1 = getent("bobbing_obj","targetname"); // Get the name of the script_model
obj1 = getent("bobbing_obj","targetname"); //get the script_model entity
obj2 = getent("bobbing_obj2","targetname"); // Get the name of the script_model
obj2 = getent("bobbing_obj2","targetname"); //get the other script_model entity
 
wait (randomfloat (1.5)); // Generate a random Number of Seconds Between Bobbings
wait randomfloat(1.5); //generate a random number of seconds between bobs
 
org1 = (-83, -895, 688); // Define Origin or Location of Your Boat/script_model
org1 = (-83, -895, 688); //define origin or location of your boat/script_model
org2 = (29, -897.1, 683); // Define Origin or Location of Your Boat/script_model
org2 = (29, -897.1, 683); //define origin or location of your boat/script_model
timer = 1; // Speed of the Bobbing - Higer Number Slower Bobbing
timer = 1; //bobbing speed - higher number = slower bobbing
 
while (1)
for(;;)
{
{
obj1 moveto (org1 + (0,0,2), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Above Original Location
obj1 moveto (org1 + (0,0,2), timer, timer * 0.5, timer * 0.5); // 2 is num. of units to go over Orig.
obj2 moveto (org2 + (0,0,-1), timer, timer*0.5, timer*0.5);
obj2 moveto (org2 + (0,0,-1), timer, timer * 0.5, timer * 0.5);
wait (timer);
wait timer;
obj1 moveto (org1 + (0,0,-2), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Below Original Location
obj1 moveto (org1 + (0,0,-2), timer, timer * 0.5, timer * 0.5); // 2 is num. of units to go over Orig.
obj2 moveto (org2 + (0,0,1), timer, timer*0.5, timer*0.5);
obj2 moveto (org2 + (0,0,1), timer, timer * 0.5, timer * 0.5);
wait (timer);
wait timer;
}
}
}
}
</pre>
</pre>
<font color="red">'''NOTE: For CODWAW the (0,0,2) can be highered to (0,0,5) for effect to show'''</font>


In your main mp GSC, after ''maps\mp\_load::main();'' add this line:
In your main mp GSC, after ''maps\mp\_load::main();'' add this line:

Latest revision as of 19:48, 24 October 2016

This tutorial assumes that you already know how to create, compile & create GSCs,CSVs & FastFiles for your maps

This tutorial shows how to create 'bobbing' models in water to give a floating movement impression. I got the script from a COD2 tutorials by BR3NT.

2 models are animated in this example:

com_bottle4
me_plastic_crate1

In Radiant

Place the 2 models how we want them with their top surface slightly (2/3 units) over the water patch.



Select the first model, right clic in the 2D window and select Script then Script_model



Then witht the first model still selected press 'n' to bring up the entity window and enter the following key/values:

targetname bobbing_obj

Do the same steps for the second model using those:

targetname bobbing_obj2

The result should be:



and


In Script

  • Create a new file under /raw/maps/mp/ called _bobbing_obj.gsc and insert the following:
main()
{
	thread bobbing_think();
}

bobbing_think()
{
	obj1 = getent("bobbing_obj","targetname"); //get the script_model entity
	obj2 = getent("bobbing_obj2","targetname"); //get the other script_model entity
	
	wait randomfloat(1.5); //generate a random number of seconds between bobs
	
	org1 = (-83, -895, 688); //define origin or location of your boat/script_model
	org2 = (29, -897.1, 683); //define origin or location of your boat/script_model
	timer = 1; //bobbing speed - higher number = slower bobbing
	
	for(;;)
	{
		obj1 moveto (org1 + (0,0,2), timer, timer * 0.5, timer * 0.5); // 2 is num. of units to go over Orig.
		obj2 moveto (org2 + (0,0,-1), timer, timer * 0.5, timer * 0.5);
		wait timer;
		obj1 moveto (org1 + (0,0,-2), timer, timer * 0.5, timer * 0.5); // 2 is num. of units to go over Orig.
		obj2 moveto (org2 + (0,0,1), timer, timer * 0.5, timer * 0.5);
		wait timer;
	}
}

NOTE: For CODWAW the (0,0,2) can be highered to (0,0,5) for effect to show

In your main mp GSC, after maps\mp\_load::main(); add this line:

maps\mp\_bobbing_obj::main();

Now, add this to your Zone File:

rawfile,maps/mp/_bobbing_obj.gsc

Compile and test!


--Zeroy. 14:18, 16 October 2008 (UTC)