Jump to content
The Dark Mod Forums


  • Posts

  • Joined

  • Last visited

  • Days Won


Posts posted by joebarnin

  1. On 9/21/2021 at 8:49 AM, Dragofer said:

    The script method to remove a weapon would be:

    $player1.replaceInvItem($blackjack1, $null_entity);

    Unfortunately that didn't work. It can't find the inventory item, no matter what name I use for it. I think the engine does some special processing when you pick up melee weapons. I also tried code to delete the blackjack weapon:

    entity weap = $player1.getWeaponEntity();

    but that crashed the game.

    Is there any way to temporarily override the key bindings, so that '1' and '2' are inactive?

  2. Why not add the counter increment as a spawn arg on the button? So each button has

    ”counterIncrement” “13”

    or whatever. Then your script gets the value of the “counterIncrement” spawn arg from the button passed into the script function, and uses that to increment the counter. No need for if/then ugliness. 

    • Like 1
  3. In my mission, I want to "take away" the melee weapons (blackjack, sword) from the player, and then later give them back. So the game progression is:

    1. Player starts with blackjack/sword/arrows (typical situation)
    2. Some event takes away the blackjack and sword. He still has his bow, and can shoot arrows.
    3. Later, another event gives him a blackjack and sword. Preferably, he would just pick them up and that would re-enable them.

    I read this thread but I can't figure out if it has any suggestions for my situation: 

    I tried $player1.disableWeapon(), but this disables ALL weapons - I want the bow/arrows to still be available. I messed around with cloning and modifying the tdm_weapon_blackjack.script and tdm_weapon_shortsword.script files, and I got it to mostly work. The player can still hit the "1" and "2" keys - my modifications to those two scripts prevent the weapons from getting raised. But, the lightgem changes (for the sword at least). It would be best of those two keys were totally inactive, but I can't figure out how to do that.

    I also am playing with some scripting that @Geep kindly gave me. But, that involves redefining the 'player' object (from tdm_player.script), which I would rather not do. Does anyone have other ideas?


    • Like 1
  4. In my map under development, I see the following message in the DM console log:

    DepthStage: missing vertex or index cache

    What does this mean? Should I be concerned? I found the code that generates it (DepthStage::ShouldDrawSurf), but I'm not smart enough to know what it means.


  5. @DragoferThanks. I just tried your suggestion, and it looks like clearing immobilization is necessary, but not sufficient. Without a way to set m_bOnClimb=false (or m_bOnRope = false in the case of climbing a rope), the game still thinks the user is climbing on the ladder/rope. There doesn't appear to be a way to call ClimbDetach() or RopeDetach() from a script. The only way I can find to cause RopeDetach() to get called indirectly is to remove the rope, which I'd rather not do.

    I'll submit a ticket.

  6. Not sure if this counts as a newbie question. I'm using a func_teleporter. The teleporter fires at an unpredictable time; as an example, presume that I've got a script that invokes the teleporter every 5 minutes (that's not exactly what I'm doing, but it works as an example). It works fine normally, but if the player happens to be climbing a rope (from a rope arrow) when the teleporter fires, the teleporting doesn't work as I expect. The player is teleported to an incorrect location, and the physics engine seems to think that he is still climbing a rope (i.e., the player can still climb up and down as if they were on a rope, but there is no rope at the new location). It looks like the teleport code doesn't cause the user to "let go" of the rope, or something? Is this a bug, or ...? In scripting, is there a way to force the player to let go of a rope? I've experimented with removing the deployed rope, and that does cause the player to let go and the teleport works as expected, but that's suboptimal (now the rope is missing).


    On 7/14/2021 at 8:29 AM, JackFarmer said:

    However, I was already wondering how you can get the effect that lights activate when you approach and deactivate when you move away:

    With S / R that is probably not possible, since only one-time actions are triggered. Hm....

    I think there's probably a way to make this happen with a custom s/r and some scripting. I'll think about it.

    Edit: here's how. Set up a custom stim near the light, with an appropriate stim radius. The stim fires every 200 ms. Add a corresponding response to the player object. Custom responses call a script. That script looks like this:

    if (!light_already_on)
    	light_already_on = true;
    	lightTime = sys.getTime();
    	thread checkLight();
    lightTime = sys.getTime();

    light_ready_on is a global boolean, lightTime is a global float. Basically, the response script stores the latest systime that player was near the stim.

    The checkLight thread is this:

    void checkLight()
    	if (sys.getTime() - lightTime > 0.5)
    		light_already_on = off;

    Once the light is on, the checkLight thread wakes every 100 ms and compares the current time with the "last time the stim was fired". If it's more than a certain value, the user has moved away and the light is turned off.

    Completely untested. Also, the various timing parameters might have to be changed. But it's an idea.

    • Like 1
    • Thanks 1
  8. 7 hours ago, Destined said:

    Why are you opposed to changing the player's definition? As long as you have your def-file in the FM-folder it will not affect anything other than the FM itself. If I understand your workaround correctly, you are also creating a player entitiy that inherits its properties from the original. I cannot really see any benefit. You only have an additional step.

    In general, I feel it's best practice to extend an existing definition, rather than copying it and modifying it. Say, for example, in a future release of DM, the developers make a change to the tdm_player_thief.def file. With my original technique, anyone playing my mission won't see that change (because my mission is using a cloned version of the old tdm_player_thief.def file). With my preferred technique, that change will be maintained, because I'm just extending the existing definition.

  9. @JackFarmer For this mission I have a unique projectile (something like a fireball) that doesn't actually damage the player when it hits them, it has some other effect. I decided to implement this using stim/response. So my fireball has a stim attached to it (more accurately, the stim is attached to the "def_result" associated with the fireball). When the fireball 'hits' the player, I want a certain effect - this is implemented by a response. So the response has to be defined on the player object. The technique I describe above enables you to add responses to the player object. (It also enables you to change other player parameters, like walking speed or starting health, by the way).

    Maybe there's a better way to do this, but the technique I describe seems to work. Hope this makes sense.

  10. 13 hours ago, joebarnin said:

    I have some user-defined stims (sr_type >= 1000), and I want the response to be attached to the player object. How is this done? The only way I could figure out is to clone the default tdm_player_thief.def file into my mission folder, and modify it by adding my responses to the atdm:player_base object. This works, but it seems suboptimal (and maybe risky?). Is there a better way?

    Never mind, I figured out a better way. In a .def file, define a custom 'player' that inherits from the default and includes the custom responses. Something like:

    entityDef my_player_thief
        "inherit"                            "atdm:player_thief"
        // add custom responses
        "sr_class_5"                    "R"
        "sr_type_5"                        "1000"

    Then, on any worldspawn, define a spawnarg, "player_classname", with a value of your custom player entity (in this case, "my_player_thief"). When TDM starts it looks for that spawnarg on the worldspawn, and spawns that entity instead of the default one. Since my_player_thief inherits from atdm:player_thief, it behaves just like the default player, except for the changes you add/override.

    • Like 1
    • Thanks 1
  11. I have some user-defined stims (sr_type >= 1000), and I want the response to be attached to the player object. How is this done? The only way I could figure out is to clone the default tdm_player_thief.def file into my mission folder, and modify it by adding my responses to the atdm:player_base object. This works, but it seems suboptimal (and maybe risky?). Is there a better way?

  12. ai_type of "human" wont work. I think it's looking for a number, and it looks like humans are 0 (zero). So try "0" instead of "human" for both of those.

    Hmm, I just noticed that later in that wiki entry, it says "ai_type  Type of AI: human, beast, undead, steambot, etc. (reads m_AIType in the SDK, which is set by the "type" spawnarg on idActors. Not sure if this is implemented yet)."

    Hopefully, 0 will work for humans.

  13. Is there a script call that will tell me if an entity is in the player's inventory? Or, a call that enumerates all of the items in the inventory? getNextInvItem() isn't appropriate, as it actually modifies which inventory item is active to the player.

  14. My trigger_hurt can be toggled. I've got a brazier post that you can climb up on. The flame starts out lit, so the trigger_hurt is on. If you douse the flame, the trigger_hurt turns off, and if you relight it, it turns off (this is accomplished by adding "target=trigger_hurt_1" spawn arg to the flame). I can douse and light the flame back and forth several times, and it works.

    What are the details of what you are trying to do? How do you activate the trigger_hurt?

  15. Clever idea. How does it attach on the player's side? I can see how it sticks into the other side, just like a regular rope arrow. But what happens to the 'end' of the rope near the player? Does it magically attach to something?

    Maybe you have to be standing next to some sort of attachment object, and then the end of the rope attaches to it once the arrow is shot.

    Or maybe after you shoot the Tight Rope arrow, the end is 'attached' to you, and you have to walk over to the attachment object and interact with it to make it stick. 

    Also, I think the rope will have to sag a bit or it may look cheesy?

  16. 36 minutes ago, Bienie said:

    Well since the objective completes but mission simply doesn't end I don't that code is the problem. Hopefully it's not a bug like JackFarmer is describing... Maybe deleting and remaking the objectives could help, haven't tried that.

    I can upload just the map file I guess, if you would like to take a look for me: dropbox

    I think I see the problem. The "don't kill" objectives need the "Ongoing" flag set on them. The wiki says: "Important: No kill objectives need be set as "Satisfied at Game Start" and "ongoing" or they will not work!". You've got the "satisfied" checked, but not "ongoing". See if that helps.

  17. 3 hours ago, Bienie said:

    I didn't realize that was a thing. It's completely empty though so I'm guessing that's not the problem.

    The logic in the code is:

    Check each objective that is visible and that applies to this difficulty level:
      For each of these objectives, do the following four checks:
         objective state is Complete
         objective state is Invalid
         objective is not Mandatory
         objective is Ongoing
      If, for a given objective, any of those four tests are true, then that objective is "done", from the point of view of completing the mission.
      If, for a given objective, all four of those tests are false, then the mission can't be completed.
    If all of the checked objectives are "done", the mission is complete.

    I hope this makes sense. If you want to attach your map I can take a look at the objectives section. Or just the atdm:target_addobjectives section from the map.

  18. 1 hour ago, Bienie said:

    I'm running in to a weird problem where my map doesn't end when all mandatory objectives are complete. I've never seen this bug before... When I playtest it and go to the exfil area it says "objective complete" and continues on instead of getting the "mission complete" screen. I've triple checked all my objectives to make sure none have the mandatory flag that shouldn't have it. Any one have other ideas of what might be happening?

    Wild guess here. In DR, the Mission Objectives dialog, at the bottom there's an Edit Mission Success Logic button. Is there anything specified in that dialog? Anything in there overrides the "normal" mission complete logic.

  • Create New...