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.


Messages - argoon

Pages: [1] 2 3 ... 18
1
id Tech 4 Needs Help / Re: how i can spawn models in map ?
« on: September 08, 2017, 03:56:54 PM »

2
id Tech 4 Scripting / Re: Zooming by run loop script
« on: September 03, 2017, 11:14:48 AM »
A while (1) loop is in it self a infinite loop unless you break from it, so be free to use sys.wait(1), btw a frame takes less than a second to run, if you open the doom_defs.script you will see that id software defined a frame time as 0.016 seconds (16 milliseconds), and i seam to recall that if you make a sys.wait() with less than 0.016 your loop will stop working.

About performance by using "thread" keyword before the function name you are making sure the loop doesn't clog the pipeline, also unless your loop is made of very complex chain's of if else's and many entity spawn arguments queries, like using many getkey() etc, than performance eating imo is not that bad, plus you should try to break from a while(1) loop ( break; ) if possible, unless it is required to run for the entirety of the game or map.

3
id Tech 4 Textures / Re: Another Material Question
« on: September 03, 2017, 10:44:33 AM »
models/mapobjects/tablecart1ball

This is the object that I want it to apply to. When you say player script, you mean doom_main.script? There's no player.script. Is this all 1 set of instructions or 2 ways of doing it?

That isn't a object, its a material. That script won't help you without one.

So much for that...

Materials are attached to objects, deform sprite also rotates the object not the material itself plus deform sprite requires models made of a single flat face (a plane), wheres my script works with any object.
You need to find, using the editor, all the objects using that material, Dark Radiant (from the DarkMod) has a option where it will select all objects using the same material, with all selected you can assign the key value, i suggested, to all of them at the same time.

4
id Tech 4 Scripting / Re: Zooming by run loop script
« on: September 02, 2017, 05:14:41 PM »
I trying to achieve a sniper zooming effect via 'g_fov' CVar.

It's realized via level script but as I think same algorithm can be used in weapon script.

The example below is works but from time to time g_fov is not set correct (stays in previous state or sets several times in one pass).

I thing it's because cycle checks is too fast.

Has anyone idea how to fix it?

Thanks.

Code: [Select]
void    debug_print()
        {
        sys.println( "^3g_fov set to: " + sys.getcvar( "g_fov" ) + " ^5at:" + sys.getTime() + "sec" );
        }

void    pressed_fov()
        {
        float userbuttons, btn2;                      // inspired by modwiki

        boolean already_set = ( false );              // each second "Z"-press will reverse this flag and reset g_fov

            while(1)
            {
            userbuttons = $player1.getButtons();
            btn2 = 4 & userbuttons;                   // 0000 0100 & 0000 0100 = true

              if(btn2)                                // 'Zoom' was pressed
                {
                     if( already_set )                // is it second press?
                     {
                        sys.setcvar( "g_fov", "90" );
                        already_set = !already_set;
                        debug_print();
                        sys.waitFrame();
                     }
                     else
                     {
                        sys.setcvar( "g_fov", "10" );
                        already_set = !already_set;
                        debug_print();
                     }
                }
            sys.waitFrame();
            }
        }

void main()
        {
        thread pressed_fov();       // always run when level is loaded
        }

I don't know but it could be because getbuttons runs more than one time at button press(was made for continuous pressing like shooting), no matter how fast you press it, so that perhaps is messing things up, before i add full access to impulses (they run only one time) this also caused many problems to me, you need to find a way to make the code run only one time at button press, unfortunately that is easier said than done.

5
id Tech 4 Textures / Re: Another Material Question
« on: September 02, 2017, 09:44:19 AM »
Btw when I try to replace 'while(1)' to 'eachFrame' (for level script) I get an error "Built-in function can't be used without an object".

Hum I didn't knew that was locked to objects only, need to study why, I'm working on engine c++ so have not scripted any level for a while now.
I'm not near my computer tho so will see later, for now continue using while loop for level scripting as always, sorry.

Try sys.eachFrame

sys is indeed a object but eachframe that I recommend is not a c++ function, callable by sys, is just a script macro made using #define, it is written at the bottom of the doom_defs.script if I'm recalling correctly.


models/mapobjects/tablecart1ball

This is the object that I want it to apply to. When you say player script, you mean doom_main.script? There's no player.script. Is this all 1 set of instructions or 2 ways of doing it?

That isn't a object, its a material. That script won't help you without one.

Exactly my script needs to be assigned to a entity in the editor or on a def file, it has no knowledge of materials it will only change the yaw (rotation) of a object no matter the materials on its surface.



bitterman add a thought, I assume you're calling your map script from within the map folder, using the script with the map name next to the map file,  perhaps that is why it doesn't work, if you open the script folder you see Id software put map scripts there as well, and call them from the doom_main.script just like with objects. The difference with this method is that you need to enclose your script code inside a "use namespace mapname" or all function/variables names will conflict with each other.

6
id Tech 4 Textures / Re: Another Material Question
« on: August 31, 2017, 09:27:19 PM »
argoon thanks for your posts.

Сan I ask a few questions about example above?

1. What is the expression '#ifndef' (it's not about general purpose, it's about D3 scripting)?

2. If entity on the map have a scriptobject and init() as described above then it (init) will be start at start of level? IMO this is not typical behavior for level script wich must be placed in /maps, not in /script.

Those are called pre-processor keywords on c and c++, they are special keywords that are run before the script compiler, they are used by script engine to create macros and Global variables, etc. In this case i'm defining _LOOK_AT_  before compilation so any variable i put inside this script doesn't conflits with variables with the same name on other script files.  Is akin to using the:  "using namespace mapname" keyword for map scripts.

About the second question, this is not a map script, this is a object script and those go on the script folder, init() in a object script is just like constructors in c++, so any function inside init() will run at the exact moment the entity (object) spawns in the game, it can be at level start or not.

Quote
You mention the entity and the map, but it's not a single entity but rather all instances of a material I need it to work on, and that's on any map.

object scripts run on any map the object exists, because they are called by the entities them self's at spawn time.

To know more about this i recommend that you guys read about OOP programming (Object Oriented Programming).   

7
id Tech 4 Textures / Re: Another Material Question
« on: August 31, 2017, 08:21:21 AM »
There is a player script, look carefully, is not called player.script but has player written on its file name. ;)

Imo what i wrote is very explicit, but maybe is because i wrote it, and others maybe have problems reading it, i don't know, ok what i posted was two ways for doing this, one (bad way) from the player script side and one where you make a new script.

8
id Tech 4 Textures / Re: Another Material Question
« on: August 30, 2017, 05:34:37 PM »
For this particular function you need to put it on the player script.

Like this.

on the player script inside the player object write:

void lookAtPlayer( entity ent );

then outside the player object, below the Init() function write the function i posted, btw put the code inside the lookAtPlayer function, the one inside the {},
inside the following code:

eachFrame { past the code here }

then inside the player Init() function write this:

thread lookAtPlayer($entityName);    // entityname is the name of the object you want to always look at the player;

and that's it.

There's a serious problem with this code tho, because it runs from the player script side, unfortunately makes it very complex for multiple objects, this way you need to write "thread lookAtPlayer($entityName);" for every single object you want to always look at the player! Not pretty.

But if you make it run from the object script instead (if it has one), then you just need to pass in the player ($player1) to a single look at function and multiple objects (of that type) will then look at the player just fine.

I recommend that you learn how to script is very important if you want to make more complex modifications to the game.
But for now, here is a small tutorial in how to create a new BASIC game object script, hope this make you want to learn more:

1 - inside the scripts folder create a new txt file

2 - rename it to lookAt and change the .txt extension to .script

3 - inside the script file past the following code:

Code: [Select]
#ifndef _LOOK_AT_
#define _LOOK_AT_

object lookAT {


vector plAngles;

entity player;


void init();
void lookAtPlayer();
};

void lookAT::init()
{
player = $player1;

        thread lookAtPlayer();
}


void lookAT::lookAtPlayer()
{
      eachFrame
      {
           plAngles = player.getViewAngles();

   plAngles_x = 0;
   plAngles_y = plAngles_y + 90;
   plAngles_z = 0;
   self.setAngles(plAngles);
      }
}
#endif


5 - open the doom_main.script

and past the following code after the ai_base script

Code: [Select]
#include "script/lookAt.script"

6 - open the editor, select the entity you want the script to run on

8 - write the following key value par:

key - scriptobject
value - lookAT

9 - Run the map
 

9
id Tech 4 Textures / Re: Another Material Question
« on: August 30, 2017, 01:13:24 PM »
I don't work with materials for a very long time now, focusing on coding, so my memory is a little rusty about it but i seam to remember when i was playing with grass that deform sprite automatically uses translucency even if you don't write it explicitly, because of that it doesn't support normal maps or specular maps, there the black material error, afaik deform sprite was written by id for lights glow and the gun muzzleflash's, because of this i ended writing my own "always look to the player" script, is not very hard will see if i still have it somewhere.

ok here it is:

Code: [Select]
void player::lookAtPlayer( entity ent )
{
vector plAngles = self.getViewAngles();

plAngles_x = 0;
plAngles_y = plAngles_y + 90;
plAngles_z = 0;
ent.setAngles(plAngles);
}
   

10
id Tech 4 Engine Coding / Re: working with idStrg class
« on: August 28, 2017, 07:50:10 AM »
I don't have much experience with the idStr class but from what I can see you could try something like this.
Code: [Select]
    idStr filePath  = "C:/Doom3/mod_folder/icon.ico";
idStr compareTo = "icon.ico";
idStr fileName;

filePath.ExtractFileName( fileName );

if ( fileName == compareTo ) {
        // icon file found
  } else {
      // icon file not found!
  }

Sorry about the code formatting.

Thank you that helped. :)

No need to ask for sorry about that, i'm still learning to code so my code is pretty much a mess, i'm sure that one year from now i will look back and say, how dumb i was! :D


I also found out after your help that you can also remove the path and the extension from a file name very easily, in that way you also end with just the desired string:

Example:
Code: [Select]
idStr iconType;

iconType = item->GetString("inv_icon"); // "guis/assets/pda/inventory/inventory_battery.tga"
iconType.StripPath(); // inventory_battery.tga
iconType.StripFileExtension(); // inventory_battery

11
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? 

12
id Tech 4 Scripting / Re: getButtons
« on: August 27, 2017, 04:14:57 PM »
Yes to return impulses you just replicate the buttons code.

First you need to make a way for the script engine to read them by creating a script event

Code: [Select]
const idEventDef EV_Player_GetImpulses( "getImpulses", NULL, 'd' ); // "getImpulses" is the func name of your script event, NULL just tells we don't pass anything to the func, 'd' means we return a integer

EVENT( EV_Player_GetImpulses, idPlayer::Event_GetImpulses)

/*
==================
idPlayer::Event_GetImpulses
==================
*/
void idPlayer::Event_GetImpulses(void) {
idThread::ReturnInt(usercmd.impulse);
}


Then you create a script func on the doom_events.script file or your own file (you need to call your file on the doom_main.script for it to work).

scriptEvent    float   getImpulses();

To test the func and know what impulses you have active in what keys you can do the following:

call that on the player script
Code: [Select]
eachFrame
{
float impulse;

impulse = self.getImpulses();

sys.println("You used Impulse: " + impulse );
}



 




13
id Tech 4 Scripting / Re: getButtons
« on: August 27, 2017, 09:38:59 AM »
You should always include a sys.waitframe() or sys.wait(somenumber) in all loops or they will cause a loop error, btw there's a helper function included in Doom 3 called:

Code: [Select]
eachFrame{ some code }

Behind the scenes is in reality a while loop with a sys.waitframe already included.

Also all functions with a loop, meant to run for a long time, when called on init() or main() should use the thread keyword before the name, like so -  thread funcName();
This is so your loop runs on a different thread and lets other game code run at the same time, if not it can "clog the pipeline" and make stuff slow. 

14
id Tech 4 Scripting / Re: getButtons
« on: August 26, 2017, 02:36:17 PM »
But how to work with getButtons in script?

I need to do this: when key is pressed then some script function is running.

Now I try to realize it with level script, start thread func from main () & check into thred func some buttons via getButtons. But when I try to do this in while (1) it's causing an loop error.

How to listen key events?

Thanks.

Like i said before normal key usage in idtech 4 script is very limited, there's only a few keys available and there's no way in vanilla idtech 4 to get impulses by script (i changed all that for my version of fhdoom engine tho).

But here is how (before i was coding on the engine c++) i managed key/buttons events for scripts.

Code: [Select]

//Custom help function made by me to manage buttons - this was on a separate script file.
float giveButtons(float userbuttons, string buttonType)
{
float result;

/*
btn0 = 1 & userbuttons; // Attack
btn1 = 2 & userbuttons; // Run
btn2 = 4 & userbuttons; // Zoom
btn3 = 8 & userbuttons; // Scores only for MP
btn4 = 16 & userbuttons; // Mouse look
btn5 = 32 & userbuttons; // Button 5
btn6 = 64 & userbuttons; // Button 6
btn7 = 128 & userbuttons; // Button 7
*/

if (buttonType == "btn0")
{
result = 1 & userbuttons;
}
else if (buttonType == "btn1")
{
result = 2 & userbuttons;
}
else if (buttonType == "btn2")
{
result = 4 & userbuttons;
}
else if (buttonType == "btn3")
{
result = 8 & userbuttons;
}
else if (buttonType == "btn4")
{
result = 16 & userbuttons;
}
else if (buttonType == "btn5")
{
result = 32 & userbuttons;
}
else if (buttonType == "btn6")
{
result = 64 & userbuttons;
}
else if (buttonType == "btn7")
{
result = 128 & userbuttons;
}

return result;
}

// Code i used on the player script

#define USE_BTN  giveButtons(buttons, "btn0")

float buttons;


buttons = $player1.getButtons();


if ( USE_BTN ){
   entity.callFunction("someFunctionName");
}


That code above was inspired by the following documentation on modWiki.


If you want a specific key then bind that key to the command you want to run.  It can run any console command, including script functions.

IE
Code: [Select]
bind h "trigger scriptfunction"
Pretty sure "trigger" will activate a script function.

Hum i didn't knew about that! If it indeed work then it indicates that by using that trick you can use more than the 7 buttons (three really some are hardcoded in the c++ code) that the player getbuttons() func provides. :)

But now that i think about it, how does this trick knows what function in what script file i'm talking about? I assume i have to include the full path to the script file not only the function name? Because if i only need to include the name then that tells me that function needs to be uniquely named and that imo is a serious limitation, i'm wrong?

15
Strutt your stuff! / Re: fhDOOM (modernized idTech4)
« on: August 23, 2017, 06:09:48 PM »
the files were made 10 years ago ...so updating jpg , curl & ogg will only be a good idea..
i searched and then looked at the files...the libraries should be very easy to replace...same goes with zlib and bfg edition .
the sound system for me is as important as updating opengl to vulkan or even more... O0 O:-)
playing in stereo is not as great as 5.1 or 7.1 ...  :-\

You only think stereo is bad because HRTF is not used in most games, ;)  also Doom 3 and idtech4 is capable of 5.1 and 7.1 sound from the beginning.

Pages: [1] 2 3 ... 18