Jump to content
The Dark Mod Forums

Use action scripts in inventory


kingsal

Recommended Posts

Hey All,

 

Are there any used_action_scripts for dropping an item from the inventory (similar to hitting the drop item key)? Something like frob_drop or use_drop? How about dropping an item to the players hands vs dropping it directly to the ground?

 

Thanks in advance!

  • Like 1
Link to comment
Share on other sites

Hey All,

 

Are there any used_action_scripts for dropping an item from the inventory (similar to hitting the drop item key)? Something like frob_drop or use_drop? How about dropping an item to the players hands vs dropping it directly to the ground?

 

Thanks in advance!

I don't quite understand what you're looking for, could you give an example situation? There are scripts to remove the item from the player inventory (and then just spawn another to the players location) which could simulate an item falling out their pocket. If The situation is that the player walks to an area and drops an item, that would be pretty simple to do.
  • Like 1
Link to comment
Share on other sites

If I understand him correctly he wants the inventory item to either be dropped to the players hands or on the floor. This is doable, although I think that there is no such script shipped with TDM. However, used_action_script is normally intented for a situation where you frob an entity with the inventory item selected to let them interact, like a key for example.

 

What you want is similar to the drop of a flashbomb, so it makes sense to look how this is done to mimic the effect.

 

object playertools_flashbomb : player_tools {
    /**
    * greebo: This is the method that gets called from within the SDK
    *          when the player "uses" this tool as inventory item.
    *
    * @userEntity: the entity that is using this item, usually $player1
    * @frobbedEntity: the entity the player is currently frobbing, may be $null_entity
    * @buttonState: a float telling about the current button state (pressed, released)
    */
    void inventoryUse(entity userEntity, entity frobbedEntity, float buttonState);

    /**
    * greebo: This is the method that gets called from within the SDK
    *          when the player releases the inventory use key
    *
    * @userEntity: the entity that is using this item, usually $player1
    * @holdTime: The time the key has been held down in ms.
    */
    void inventoryUseKeyRelease(entity userEntity, entity eFrobbed, float holdTime);
};

This is the object declaration of the script object used by the flashbomb. As you can see there are two functions. One gets called when the player presses the use button, the other one gets called once the player releases said button. The flash bomb makes use of the latter one as the amount of time passed between the button push and release determines the throwing strength. Unless you want such a behaviour, too, we will only need the first function. So the script object could look like this (note the semicolon at the end, don't forget it ;) )

 

object myObject : player_tools 
/* not sure whether the inheritance from player_tools is needed, but the functions may be restricted to them */
{
    void inventoryUse(entity userEntity, entity frobbedEntity, float buttonState);
};

Now all we need to do is to define what should be done once the player presses the use key. These are just the genral steps, as they depend on the type of item.

 

void myObject::inventoryUse(entity userEntity, entity frobbedEntity, float buttonState)
{
    // reduce the inventory count by one
    userEntity.changeInvItemCount(...);
    // put us in the players hands, this may not work like this and you have to create a copy of this entity to put in the players hands, try it out
    userEntity.holdEntity(self);
}

If you want to drop it to the floor you make it similar. You can for example drop it to the players hands first and then reuse the holdEntity function with $null_entity as an argument to let the player drop it. See the script reference on details how to use that function.

  • Like 1

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

Goldwell- I am trying to simulate dropping an object out of the inventory such as a key, but being able to do it by pressing the inventory use button. By default, custom items fire their triggers when used, so Im just looking for some code to drop them rather than trigger their targets.

 

Obs- This looks like it should work! I'll give it a try. I considered just modding the flashbomb as it is, but I didn't want to deal with turning this object into a projectile.

Edited by kingsal
Link to comment
Share on other sites

Bikerdude- The object I am using isn't it a key. Its movable that you can pick up in the inventory and drop by using it, sort of how flashbombs work.

 

Obs- I hooked up the script and it works! I am able to drop the item from the inventory by using it. However, I am able to drop the item through walls. Is there a way to add the collision check into the script? (similar to the check done when there isnt enough room to drop bodies or other inv items)

Link to comment
Share on other sites

I guess the flashbomb / mine scripts are performing such checks. You can check them to see how it is done. I don't know it by heart.

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

Hmmm, looks like flashbombs / mines do not check collision! I've been able to toss them through walls and out of the game world. I'll do some more investigation and file a bug for that.

Edited by kingsal
Link to comment
Share on other sites

Hmmm, looks like flashbombs / mines do not check collision! I've been able to toss them through walls and out of the game world. I'll do some more investigation and file a bug for that.

 

Be very specific.

 

2.05 or SVN 32-bit or SVN 64-bit?

 

Windows or Linux?

 

Particular mission, or several missions?

 

Player in open space or pushing up against a crate or wall?

Link to comment
Share on other sites

 

Be very specific.

 

2.05 or SVN 32-bit or SVN 64-bit?

 

Windows or Linux?

 

Particular mission, or several missions?

 

Player in open space or pushing up against a crate or wall?

 

2.05. Windows. All missions that use the flashbomb or mines? Up against a wall.

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

    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 6 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...