banimod / etpro / ettv forums Forum Index banimod / etpro / ettv forums
Bani's Discussion Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Scripting in ET Pro 3
Goto page 1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    banimod / etpro / ettv forums Forum Index -> ET Pro Documentation
View previous topic :: View next topic  
Author Message
duke'ku



Joined: 03 Nov 2002
Posts: 1317
Location: portland, oregon

PostPosted: Wed Apr 14, 2004 4:49 pm    Post subject: Scripting in ET Pro 3 Reply with quote

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:

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:



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:

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:

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:

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:

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 here. 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:

//bani
create
{
   scriptName "backdoor"
   classname "func_explosive"
   targetname "backdoor"
   origin "4608 -4594 1024"
   mins "-63 -10 0"
   maxs "63 10 128"
   spawnflags 1   // AXIS_OBJECTIVE(1)
   eflags 65536   // EF_FAKEBMODEL
   svflags 1   // SVF_NOCLIENT
}

//bani
create
{
   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(1) | CUSTOMIMAGE
   track "the Back Door"
   shortname "Back Door"
   customaxisimage "gfx/limbo/cm_radar_maindoor"
}

//bani - bug fixes
create
{
   scriptName "bugfix1"
   classname "func_fakebrush"
   origin "3632 -4313 881"
   contents 65536  // CONTENTS_PLAYERCLIP
   mins "-40 -1 -20"
   maxs "40 1 10"
}


Example 2: Fueldump and Spawning at the Command Post
Code:

create
{
   scriptName "fueldumphq_obj"
   classname "team_WOLF_objective"
   targetname "fueldumphq_obj"
   origin "-10853 -2036 6"   // z = CC_FILTER_ALLIES(2) | CC_FILTER_SPAWNS(4)
   spawnflags 2   // TEAM_ALLIES(2)
}

create
{
   scriptName "fueldumphq_spawn1"
   classname "team_CTF_bluespawn"
   targetname "fueldumphq_spawn"
   origin "11072 -2448 512"
   spawnflags 2   // TEAM_ALLIES
}

create
{
   scriptName "fueldumphq_spawn2"
   classname "team_CTF_bluespawn"
   targetname "fueldumphq_spawn"
   origin "-10995 -2448 512"
   spawnflags 2   // TEAM_ALLIES
}

create
{
   scriptName "fueldumphq_spawn3"
   classname "team_CTF_bluespawn"
   targetname "fueldumphq_spawn"
   origin "-10918 -2448 512"
   spawnflags 2   // TEAM_ALLIES
}

create
{
   scriptName "fueldumphq_spawn4"
   classname "team_CTF_bluespawn"
   targetname "fueldumphq_spawn"
   origin "-10841 -2448 512"
   spawnflags 2   // TEAM_ALLIES
}

create
{
   scriptName "fueldumphq_spawn5"
   classname "team_CTF_bluespawn"
   targetname "fueldumphq_spawn"
   origin "11072 -2288 512"
   spawnflags 2   // TEAM_ALLIES
}

create
{
   scriptName "fueldumphq_spawn6"
   classname "team_CTF_bluespawn"
   targetname "fueldumphq_spawn"
   origin "-10995 -2288 512"
   spawnflags 2   // TEAM_ALLIES
}

create
{      
   scriptName "fueldumphq_spawn7"      
   classname "team_CTF_bluespawn"
   targetname "fueldumphq_spawn"
   origin "-10918 -2288 512"
   spawnflags 2   // TEAM_ALLIES
}

create
{
   scriptName "fueldumphq_spawn8"
   classname "team_CTF_bluespawn"
   targetname "fueldumphq_spawn"
   origin "-10841 -2288 512"
   spawnflags 2   // TEAM_ALLIES
}


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 irc.freenode.net, #etpro.

Contents Flags


  • 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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Rain



Joined: 02 Aug 2003
Posts: 651
Location: Muffin Laboratories

PostPosted: Sun Apr 18, 2004 5:05 pm    Post subject: Reply with quote

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:
axis_garrison_wobj
{
        spawn
        {
                set
                {
                        origin "7089 4852 -415"
                }
        }
}


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:
water_tunnel
{
        spawn
        {
                // 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
                {
                        contents 32 // CONTENTS_WATER
                        clipmask 32 // CONTENTS_WATER
                }
        }
        [...]

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:

KeyDescription
minsA point describing the location of the lower corner of the bounding box. (ent->r.mins)
maxsA point describing the location of the upper corner of the bounding box. (ent->r.maxs)
contentsContents flags - description above (ent->r.contents)
svflagsServer flags (ent->r.svFlags)
clipmaskBrush content types to collide with. (ent->clipmask)
count2entity-specific (ent->count2)
eflagsEntity flags (ent->s.eFlags)
pos_trTypePosition trajectory type (ent->s.pos.trType)
pos_trDeltaPosition trajectory delta Δ (ent->s.pos.trType)
apos_trTypeAngle trajectory type (ent->s.apos.trType)
pos_trDeltaAngle trajectory delta Δ (ent->s.apos.trType)
classname_nospawnChanges the class name, but doesn't re-spawn the entity. (ent->classname)
customaxisimageCustom command map image for the Axis team
customalliesimage
customalliedimage
Custom command map image for the Allied team
allowteamsTeams allowed to use an entity (ent->allowteams)

(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.
_________________
Rain
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Noobie



Joined: 14 Jan 2004
Posts: 105

PostPosted: Wed Apr 21, 2004 4:15 am    Post subject: Reply with quote

Interesting guide, but I wonder if we can do something with textures this way? And what about creating lights?
Back to top
View user's profile Send private message
=FF=im2good4u



Joined: 05 Feb 2003
Posts: 3924
Location: The Netherlands, HOLLAND

PostPosted: Wed Apr 21, 2004 6:42 am    Post subject: Reply with quote

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
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
duke'ku



Joined: 03 Nov 2002
Posts: 1317
Location: portland, oregon

PostPosted: Wed Apr 21, 2004 6:50 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
=FF=im2good4u



Joined: 05 Feb 2003
Posts: 3924
Location: The Netherlands, HOLLAND

PostPosted: Wed Apr 21, 2004 7:09 am    Post subject: Reply with quote

yeh i though so but does it alllow to create any etinety ?
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Noobie



Joined: 14 Jan 2004
Posts: 105

PostPosted: Wed Apr 21, 2004 7:35 am    Post subject: Reply with quote

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).
Back to top
View user's profile Send private message
=FF=im2good4u



Joined: 05 Feb 2003
Posts: 3924
Location: The Netherlands, HOLLAND

PostPosted: Wed Apr 21, 2004 10:32 am    Post subject: Reply with quote

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
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
duke'ku



Joined: 03 Nov 2002
Posts: 1317
Location: portland, oregon

PostPosted: Wed Apr 21, 2004 2:40 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Rain



Joined: 02 Aug 2003
Posts: 651
Location: Muffin Laboratories

PostPosted: Wed Apr 21, 2004 6:09 pm    Post subject: Reply with quote

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

The normal lighting is done as part of the map compile (as mentioned), but spawning dlights does work.
_________________
Rain
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
=FF=im2good4u



Joined: 05 Feb 2003
Posts: 3924
Location: The Netherlands, HOLLAND

PostPosted: Thu May 20, 2004 4:47 am    Post subject: Reply with quote

how do i turn this
Code:
// brush 0
{
( 496 1948 492 ) ( 496 2988 492 ) ( 512 2988 492 ) common/ladder 0 0 0 0.500000 0.500000 0 0 0
( 496 2988 208 ) ( 496 1948 208 ) ( 512 1948 208 ) common/ladder 0 0 0 0.500000 0.500000 0 0 0
( 496 2052 492 ) ( 496 2052 8 ) ( 512 2052 8 ) common/ladder 0 0 0 0.500000 0.500000 0 0 0
( 512 1948 492 ) ( 512 1948 8 ) ( 496 1948 8 ) common/ladder 0 0 0 0.500000 0.500000 0 0 0
( 496 2012 492 ) ( 496 2012 8 ) ( 496 972 8 ) common/ladder 0 0 0 0.500000 0.500000 0 0 0
( 488 1988 492 ) ( 488 1988 8 ) ( 488 3028 8 ) common/ladder 0 0 0 0.500000 0.500000 0 0 0
}
into this
Code:
      //LADDERS
      create
      {
         scriptName "ladder1"
         classname "func_fakebrush"
         origin "? ? ?"
         contents 1073741824 // CONTENTS_LADDER
         mins "? ? ?"
         maxs "? ? ?"
      }
Rolling Eyes
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
duke'ku



Joined: 03 Nov 2002
Posts: 1317
Location: portland, oregon

PostPosted: Thu May 20, 2004 6:19 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
=FF=im2good4u



Joined: 05 Feb 2003
Posts: 3924
Location: The Netherlands, HOLLAND

PostPosted: Fri May 21, 2004 1:55 am    Post subject: Reply with quote

so i got the coords of the origin

and i got to guess the mins "? ? ?" maxs "? ? ?" ?
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
infinity



Joined: 06 Mar 2004
Posts: 12

PostPosted: Fri May 21, 2004 3:08 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
infinity



Joined: 06 Mar 2004
Posts: 12

PostPosted: Fri May 21, 2004 3:11 am    Post subject: Reply with quote

*my ET crashes
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    banimod / etpro / ettv forums Forum Index -> ET Pro Documentation All times are GMT - 8 Hours
Goto page 1, 2, 3, 4, 5, 6  Next
Page 1 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group