Jump to content
The Dark Mod Forums

Newbie DarkRadiant Questions


demagogue

Recommended Posts

Not sure if I've already asked this, but is there a way to pass an argument to a script function called by an entity as a response to a stim.

 

So the response is "run script" and my script is like void functionname(entity e). The script, however, get called, but there seem to be no entity passed, as I can't retrieve any information from it.

 

My goal is to find out which entity actually called the script.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

No.

 

The code only reads these two spawnargs:

 

"sr_effect_1_N" "effect_script"

"sr_effect_1_N_arg1" "MyScriptFunctionName"

 

Where "N" is 1,2,3,4, ...

 

There's nothing in the code that supports more than one argument (*_arg1), the script name.

 

You'd have to put a unique script name on each entity you want to run this script.

 

Then the unique scripts would know what called them.

 

Of course, the body of each uniquely-named script could be nothing more than a call to a common script function that does all the work. At that point you can pass an argument to the common function so it knows who called it.

Link to comment
Share on other sites

Does anyone know the way to relit or extinguish TDM light entities (light source, like "light_bonfire") via a script command.

lightname.On(); does not work. I think it does not touch particles or sounds.

lightname.LightsOn(); does not work.

lightname.response_extinguished(); does not work (this I found from the lights.script file...)

Clipper

-The mapper's best friend.

Link to comment
Share on other sites

Fires like torches are controlled by the script object tdm_light_holder. In this case it is lightname.LightsOn() and lightname.LightsOff().

 

The bonfire uses light_moving ext. In this case it is lightname.response_extinguish(entity stim,float threadnum) and lightname.response_ignite(entity stim, float threadnum). You can call them like lightname.response_ignite($null,0) I guess.

 

On() and Off() are used by electric lamps.

 

I hope that helps.

 

Btw: If you wanna find out how some things can be manipulated via script, check out which script object it uses and look it up in the tdm_base.pk4.

 

Edit: You can also use frob_extinguish() and frob_ignite(). The reason why response_extinguished() doesn't work is that such a function (without arguments!) doesn't exist. Don't forget the arguments when using script functions. ;)

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Only if they share the same skeleton.

 

Our new zombies do share the same skeleton as other humanoids, but there are limited zombie animations so far (Arcturus has made an idle and a walk but I think that's it).

Link to comment
Share on other sites

What script function is called if the player frobs a door with his lockpicks selected? First I thought that the used_action_script on the lockpicks is used (which is frob_trigger by default). But when I change it nothing happens. Than I thought it may be the frob_action_script on the door (frob_door by default). Well, it gets called if you frob the door with no lockpicks selected, but not if you have them selected.

 

It's a bit weird as I don't know where else to look.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Nevermind, I've found a workaround. :smile:

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Is there a way to call a function of a basic object (not sure if this is the right word).

 

So if I have object A and derive an object B via

object B : A {
};

and I overload a function of A, let's assume it is called void func(), which I want to do some little extras to the things done in the basic function.

 

Instead of copying the whole code from A to B I normally would write

void B::func() {
A::func();
//do some extra stuff here
}

However, this syntax is not understood by the game. How does the correct syntax look like?

 

Thanks in advance.

 

EDIT: The function which I call func here has a specific name which I cannot change.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Another question. How does void ResponseSetAction(float stim,string action) actually work? I want to use it in an custom script object to make the entities using these script object caling an object function when they gt stimmed by a custom stim (so the float stim must be 1000, that's clear).

 

But I don't know what kind of string argument I must pass and how the function must look like.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Another question. How does void ResponseSetAction(float stim,string action) actually work? I want to use it in an custom script object to make the entities using these script object caling an object function when they gt stimmed by a custom stim (so the float stim must be 1000, that's clear).

 

But I don't know what kind of string argument I must pass and how the function must look like.

 

When you see a line like this in the *.def files:

 

"sr_script_STIM_VISUAL" "response_visualStim"

 

It means that when the entity responds to a visual stim, it calls a script function named "response_visualStim".

 

When you use ResponseSetAction(), the syntax is:

 

ResponseSetAction(STIM_VISUAL,"MyScriptFunction")

 

which means that from that point on, when the entity responds to a visual stim, it calls the script function named "MyScriptFunction".

 

It has the same effect as originally placing the following spawnarg on the entity in its definition:

 

"sr_script_STIM_VISUAL" "MyScriptFunction"

Link to comment
Share on other sites

Instead of copying the whole code from A to B I normally would write

void B::func() {
A::func();
//do some extra stuff here
}

However, this syntax is not understood by the game. How does the correct syntax look like?

 

This will work, as long as the header for object A declares func() using this syntax:

 

virtual void func();

 

And the header for object B declares func() the same way:

 

virtual void func();

 

This allows A::func() to be overridden by B::func(). Having B::func() start by calling A::func() is acceptable.

Link to comment
Share on other sites

Any suggestions regarding my first question?

 

Too late. My question referred to the object function inventoryUseKeyRelease of the flashbomb, which is not virtual.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Another question to the response function. It seems that the entity causing the response (so the stimming entity) is passed as self to the function, not the entity that responses (the stimmed entity). How can I access the stimmed entity?

 

Solved. Wrong arguments. :blush:

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Here's the default response for a visual stim, found in tdm_ai_base.script:

 

void ai_darkmod_base::response_visualStim(entity stimSource, float ThreadNum)
{
 // greebo: Pass the call back into the SDK
 // If the standard SDK algorithms should be overridden, do this here

 processVisualStim(stimSource);
 return;
}

 

So the stimming entity (stimSource) is provided to the script, at which point you can do anything you want with it.

Link to comment
Share on other sites

I get an error message which I don't understand. I created a custom object using a script object. However, the init() method is called correctly. This than should call another member function of the script object, but this fails. I get the error message

"Tried to call function on entity <name of entity I applied the script object to>, but entity has no script object"

 

What does that mean?

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

How can I get a linebreak in a readable when adding the text via the pageN_body spawnarg? "\n" doesn't work (instead it gets part of the text displayed).

 

Thanks in advance.

 

EDIT: I've found another way. But I'm still interested if someone knows the answer.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

This doesn't work if you use spawnargs instead of xdata files.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Don't know if anyone ever asked for this, but who cares. For the map I'm currently working on I needed some swinging lights. What I've done was to create a brush, texture it nodraw and created a func_pendulum out of it. Then I've bound the light entity to it. There are spawnargs on the pendulum to calibrate the swinging direction, the frequenzy and the amplitude. (They are not named pretty well, so you have to find out what they do by reading the descriptions).

 

By bounding a light entity on a func_pendulum that is bound on a func_pendulum you can get more chaotic behaviour, especially if you use different frequencies for both.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recent Status Updates

    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
×
×
  • Create New...