Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - argoon

Pages: [1] 2
After many hours of trying to prevent a sound from playing over itself, when pressing a key continuously and inside the player think loop, after going trough the engine code i found some ways to solve this.


Code: [Select]
const idSoundShader *sound = declManager->FindSound( "sound_name" );
// this above is not really necessary you can do the following instead if you want.
//...StartSound( declManager->FindSound( "sound_name" ), SND_CHANNEL_BODY );

// get the sound emitter (speaker) binded to the ingame entity, btw i tried to get a emitter directly from the master entity but it didn't found any and crashed the engine, why i don't know,
// is strange because afaik all entities can be "speakers"...
idSoundEmitter *emit = gameLocal.FindEntity( "some_speaker" )->GetSoundEmitter( );
if (!( emit->CurrentlyPlaying( ) )) // if sound is not playing
        // play it
emit->StartSound( sound, SND_CHANNEL_BODY);


Code: [Select]
const idSoundShader *sound = declManager->FindSound( "sound_name" );
idSoundEmitter *emit = gameLocal.FindEntity( "some_speaker" )->GetSoundEmitter( );
emit->StartSound( sound, SND_CHANNEL_BODY, 0, SSF_PLAY_ONCE ); // SSF_PLAY_ONCE prevents the sound from playing again if it is already playing

Three:  If you don't create a emiter object like above and call the sound directly from a entity it also works. :)

Code: [Select]
const idSoundShader *sound = declManager->FindSound( "sound_name" );
Entity->StartSoundShader( sound, SND_CHANNEL_BODY, SSF_PLAY_ONCE, false, NULL );

id Tech 4 Engine Coding / Getting var values from GUis?
« on: September 28, 2017, 04:07:16 PM »
Hello guys i know that i can set a variable value in a GUI from the engine code using for example somegui->SetStateInt("varName"); and it works fine, but i can't seem to do the inverse, get a value from a gui variable to the game code, i tried using the somegui->GetStateInt("varName"); but it returns zero every time, no matter to what value i set the GUI variable.

what i'm trying to do is create a grid based inventory system, and when i click in a "slot" i tell the c++ code what slot i interacted with.

id Tech 4 Engine Coding / working with idStrg class
« on: August 27, 2017, 04:32:26 PM »
Hello guys and gals :)

I need help from some idtech 4 coder that has experience working with the idStrg class, it has many functions ( or members )  to mess around with, but because i don't know what half of them do i'm really going blind here, what i'm trying to do is take a file path, like a icon path, get a particular string from it (like a file name) compared that to some other string and if true or false run some code. Anyone here know anything about this? 

id Tech 4 Discussion / why is this not news here!?
« on: August 11, 2017, 03:57:43 PM »
At lest i don't see any thread about it...  :P

Doom 3 BFG got a Vulkan render! written by a id Software coder, so in a sense a official render!

id Tech 4 Discussion / Fantastic BFG VR mod!
« on: July 30, 2017, 08:09:32 PM »
Can someone explain to me how were they able to modify the BFG flash GUI's so deeply without the source files?

Hello guys and gals,  i'm trying to call functions from the c++ code, like i used to do using DoomScript but obviously is different on the c++ side, studying the engine code i see id calls scripts like so:

Code: [Select]
const function_t *func;

func = Entity->scriptObject.GetFunction("somefuncname");
Thread->CallFunction(frobableEntity, func, true);

but this just crash's the engine for me and i'm totally clueless why.

Any help is welcome.

 Edit: before posting this i spend more than a hour trying to make this work, after making this thread and going away to try to solve again i did it: :P  :D

This is the necessary code to successfully call object script functions from withing the c++ code:

Code: [Select]
const function_t *func;
idThread *Thread;

func = Entity->scriptObject.GetFunction("signalOn");
Thread = new idThread();
Thread->CallFunction(Entity, func, true);

id Tech 4 Discussion / modwiki problems
« on: April 07, 2017, 06:16:36 PM »
Hello guys i'm getting a "your connection is not private - NET::ERR_CERT_AUTHORITY_INVALID" error when trying to read the idtech4 modwiki, i'm using Vivaldi (is based on chrome), i'm the only one with this error? 

id Tech 4 Engine Coding / Nice PBR opengl tutorial
« on: March 20, 2017, 09:07:16 PM »
If some day someone wants to implement PBR in idtech 4 here is a tutorial that could help.!PBR/Theory

id Tech 4 Scripting / LOD system
« on: November 23, 2016, 10:08:21 PM »
Hello guys i made a LOD system for my mod using script and it works, more or less, the lod change works the problem i'm getting is that when the model changes it shivers for a moment and is very obvious, do you guys have any idea on how to smooth that transition?

here is the script code

Code: [Select]


self script contains any LOD's specific code.

revision = 0.1


#define LOD_LEVEL_0 1
#define LOD_LEVEL_1 2
#define LOD_LEVEL_2 3

object lod_object_base {
// bool to control the while loop
    boolean isON;

// lod0 position for the other lod's
vector currObjPos;

float currentLOD;

string lod0_model;
string lod1_model;
string lod2_model;

// player entity
entity lod_player;

// enable or disable the LOD check, no need to do it on objects with no lod's
float lod_enabled;

// show distances
float lod1_dis;
float lod2_dis;
// player distance from lod object
float pldistance;

void init();

void lodUpdate();
void checkLOD();


void lod_object_base::checkLOD() {

pldistance = self.distanceTo(lod_player); // check lod obj pos distance to player1 pos

if( pldistance < lod1_dis && currentLOD != LOD_LEVEL_0 ){
currentLOD = LOD_LEVEL_0;
else if ( pldistance >= lod1_dis && pldistance < lod2_dis && currentLOD != LOD_LEVEL_1 ){
currentLOD = LOD_LEVEL_1;
else if ( pldistance >= lod2_dis && currentLOD != LOD_LEVEL_2 ){
currentLOD = LOD_LEVEL_2;
//self.setKey("noShadows", "1"); doesn't work at runtime :(

void lod_object_base::lodUpdate() {

lod_enabled = self.getIntKey("lod"); // get the spawn lod value

// if spawnarg lod is 0 disable the while loop
if(lod_enabled == 0){
isON = false;

// gets the lod0 world position
currObjPos = self.getWorldOrigin();

// not run this on the loop or it will not work.
currentLOD = LOD_LEVEL_2;

// get the models can be set on the editor if using the def key "editor_model"
lod0_model = self.getKey("model");
lod1_model = self.getKey("model_lod1");
lod2_model = self.getKey("model_lod2");
// then get lod distance values
lod1_dis = self.getIntKey("lod1_distance");
lod2_dis = self.getIntKey("lod2_distance");

// this gets the player entity
    lod_player = sys.getEntity("player1");

// runtime loop to check for the player position and set the lod objs
while ( isON ){ // while isON == true
if( lod_enabled ){ // if lod0 has the spawnarg lod_enabled with value 1 then run if not stop


void lod_object_base::init()
isON = true;
thread lodUpdate();

id Tech 4 Scripting / Unity enum equivalent on doom 3 script?
« on: November 23, 2016, 04:08:03 PM »
Hey guys does idtech 4 script has something like unity enum?

In unity you use - enum NAME { VALUE, VALUE_1, VALUE_2} almost like an array then you access that with - private var name : NAME= NAME.VALUE_2;

This in Unity script looks very similar to the idtech 4 script #define NAME VALUE  directive, i'm i right? If yes how could i implement that using #define?

edit - Was able to do the same using 3 different #defines but would still like to know if something like enum was possible. 

Content for Games/etc. / Node editor
« on: November 22, 2016, 01:59:50 PM »
For someone wanting to make a node editor for idtech 4 (i can dream) here is a nice one with open source and all.

id Tech 4 Scripting / idtech 4 Vectors?
« on: November 16, 2016, 12:51:54 PM »
Cheers people can anyone explain how to use vectors on idtech 4? As always before asking i tried doing it my self and even reading other people code to learn but i'm just not getting anywhere, math was never my strong point,  i'm trying to make a grass system (using script not c++ code) where every grass model shoots a trace downwards and detects the surface below at init() so it gets on the ground and follows the terrain bumps, without the need for me to manually do that, problem i'm totally failing, because i can't seam to shoot a trace straight down for all models using only code, i tried to learn vector math, it seams easy but when i try to implement it in code i fail, all models just shoot the trace in random directions, can anyone with sufficient knowledge about idtech 4 vectors give me some hints?

here is the code that i have for that, is ugly and just me messing around trying everything so have petty.

Code: [Select]
void grass_sys::alignToFloor(){
vector traceStart;
vector tracEnd;
vector  downVec;
vector  normVec;
vector  traceNormal;
vector traceStartAng;

traceStart = self.getWorldOrigin();

//traceStart = traceStart - getWorldOrigin();

sys.println("tracStart is: " + traceStart);

traceStartAng = sys.VecToAngles(traceStart);
sys.println("tracStartAng is: " + traceStartAng);

normVec = sys.vecNormalize(traceStart);
sys.println("normVec is: " + normVec);

downVec = sys.angToForward(traceStart);
sys.println("downVec is: " + downVec);

tracEnd = traceStart + downVec * 50;
sys.println("tracEnd is: " + tracEnd);

sys.debugArrow('0 1 0', traceStart, tracEnd, 4, 100 );

Also vectors from where i read seam to be
A Vector is a quantity which has both magnitude (size) and direction, but no position
so how does in idtech 4 they do seam to have a position in space? By using getWorldOrigin() or getOrigin() i get a position this tell me they are points in space but that quote implies otherwise, I'm just not comprehending this well or they are different vectors?

How can you visualize a single vector in idtech 4 script? By using debugLine or debugArrow you need two vectors, a start and a end vector, but isn't a single vector already a "arrow"?

Sorry if this are really dumb questions but i'm just ignorant on this stuff and i'm stuck and would like to learn this. 


id Tech 4 Scripting / help with func_animate
« on: September 24, 2016, 06:34:29 PM »
Hello again guys like i referred in the "help with script thread" the func_animate object hides it self after playing the "anim1" "anim2" animations how can i disable that? Is it even possible without messing with the engine or game source code?

here is the entity definition.

Code: [Select]
model env_smwoodTable {
mesh models/md5/furniture/smwoodTable.md5mesh
anim idle models/md5/furniture/smwoodTable_idle.md5anim
anim open models/md5/furniture/smwoodTable.md5anim {
frame 1 sound storagecabinet_open
anim close                      models/md5/furniture/smwoodTable_close.md5anim {
frame 1 sound storagecabinet_close

entityDef env_smwoodTable {
"editor_color" "1 .5 0"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 64"

"inhrit"             "func_animate"
"spawnclass" "idAnimated"
"model" "env_smwoodTable"
"frob"                  "1"
"start_anim"            "idle"
"num_anims"             "2"
"wait"                   "-1" //how long to wait before auto activating.  -1 means only activate when triggered.
"anim1" "open"
"anim2" "close"

"combatModel" "1" // collision based on the md5 mesh (bad for performace use AF's when possible)
//"bleed" "0"
//"mtr_wound_metal" "textures/decals/bullethurt"
//"snd_metal" "bullet_impact_flesh"
"sound_bone" "origin"

id Tech 4 Scripting / help with a script
« on: September 24, 2016, 05:15:28 PM »
Hello guys can anyone that knows coding and specially doom 3 scripting see why this script of mine is not working? Is a experience of mine about making a mouse over functionality without the need to mess with the source c++ (that i don't really know at all).

First a disclamer i'm not a coder i'm just a noob at c++ coding and at Doom 3 scripting, what you see below is what i came up with, by trial&error, by reading and copypasting from various sources.
Now the important part, the code that doesn't work as i want it, is the entity.setShaderParm() bit, it highlights the object like i want it too, when i mouse over the "frob" object (inspiration from TDM ;p), but when i stop "mouse overing" the object it stays highlighted still, i tried everything some of my tries made me turn on and off the highlight but only when i mouse overed the object again, what i'm i  missing here?

The funny thing is that the code that turns off the test light (that i put for debugging) and the code to activate the func_animate works just fine. Only problem the func_animate hides it self after playing all the animations.

Sorry for the messy code...

Code: [Select]
//    global vars

#define FROB_NONE  0
#define FROB_OVER  1

entity frobEntity; // detected entity with frob enabled
float isOver_obj = false; // Is the player looking to frob object ?
float   command     = FROB_NONE;
vector traceStart, tracEnd;
float useBtn, btn0; // use button for frob, same as attack
//float highlight_on = false;
float parm11_state;
float isPressed = false;
float isFrobable; // check for the frob spwn arg value

void trace_objs() {

// bind objs to player head position
$ml_start.bindToJoint( $player1, "headcontrol", 1 );


void draw_ent_text_type(){
if(isOver_obj == true){
vector bbox_size = frobEntity.getSize();
vector frob_ent_origin = frobEntity.getWorldOrigin();
vector text_origin = frob_ent_origin;
text_origin_z = text_origin_z + bbox_size_z + 30.0f;
string ent_type = frobEntity.getKey("type");
frobObjText = sys.drawText(ent_type, text_origin,0.5,'0 1 0', 1, 1);

void obj_higlight(){

parm11_state = frobEntity.getShaderParm(SHADERPARM_FROB);
sys.println("\n\nInit parm11 value is: " + parm11_state);

if( parm11_state == 0 ){
//highlight_on = false;
frobEntity.setShaderParm(SHADERPARM_FROB, 1);
sys.println("\n\nOff parm11 value is: " + parm11_state);
if( parm11_state == 1 ){
//highlight_on = true;
frobEntity.setShaderParm(SHADERPARM_FROB, 0);
sys.println("\n\nON parm11 value is: " + parm11_state);


void mouseOver()
traceStart = $ml_start.getWorldOrigin();
//sys.println("\n\ntraceStart value is: " + traceStart);

tracEnd = $ml_end.getWorldOrigin();
//sys.println("\n\ntraceEnd value is: " + tracEnd);

//sys.drawText("end",tracEnd,1,'0 1 0', 1, 1);

useBtn = $player1.getButtons();
btn0 = 1 & useBtn;

sys.trace( traceStart, tracEnd, '0 0 0','0 0 0', MASK_SOLID|CONTENTS_RENDERMODEL, $player1 );

sys.debugLine('0 1 0', traceStart, tracEnd, 1 );

frobEntity = sys.getTraceEntity();
isFrobable = frobEntity.getIntKey("frob");

parm11_state = frobEntity.getShaderParm(SHADERPARM_FROB);
sys.println("\n\nInit parm11 value is: " + parm11_state);

if( !(!frobEntity) && (frobEntity != $world ) ){
if(isFrobable && isOver_obj == false){
isOver_obj = true;
if(parm11_state == 0){
frobEntity.setShaderParm(SHADERPARM_FROB, 1);
isPressed = false;
if ( btn0 && isPressed == false ){
sys.println("use was pressed.");
isPressed = true;
} else {
if(parm11_state == 1){
frobEntity.setShaderParm(SHADERPARM_FROB, 0);
isOver_obj = false;


void MO_loop_control(){
while( true ){
command = FROB_NONE;
while( command == FROB_NONE){



void main ()
sys.waitFrame(); // wait for init() routines to finish
thread MO_loop_control();

The "SHADERPARM_FROB" is a custom #define in the doom_defs.script not one that exist in vanilla Doom 3.

here is the material of the "frob" object

Code: [Select]


qer_editorimage textures/boat/boat_woodtable.tga

diffusemap textures/boat/boat_woodtable.tga
bumpmap textures/boat/boat_woodtable_bump.tga
Specularmap textures/boat/boat_woodtable_s.tga

// This is the code required for frob highlighting this texture
        if ( parm11 > 0 )
        blend       blend
        map         _white
        color       0.99, 0.95, 0.62, 0.25

BTW is there a way to attach a object to the player camera (is it even a entity?) and have it follow all the movements of the player camera? looking up and down, sides to sides, etc.

In my script i attach the trace origin to the $player 1 joint (headcontrol) but it is the head of the invisible character (for shadows and mirrors) so it lags behind the cursor and doesn't follow it precisely, but it more or less works . Help on this would also be appreciated. 

welcome, you are from the TDM community aren't you? Btw before this happens, please don't care about the karma points, we add two new users go away because of the negative karma points they are useless, the comments is what matters.    :)

Pages: [1] 2