Jump to content


Photo

Use action scripts in inventory


9 replies to this topic

#1 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 190 posts

Posted 20 August 2017 - 05:19 PM

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!


  • Anderson likes this

#2 Goldwell

Goldwell

    Team Member

  • Active Developer
  • PipPipPipPip
  • 2197 posts

Posted 21 August 2017 - 12:00 AM

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.
  • Anderson likes this

The Accountant Series
Part 1: Thieves and Heirs | Part 2: New In town


Lord Edgar Trilogy
Lord Edgar's Bathhouse
 
Stand Alone Missions
Spring Cleaning


#3 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPipPip
  • 5300 posts

Posted 21 August 2017 - 02:39 AM

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.


  • Anderson likes this
FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#4 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 190 posts

Posted 21 August 2017 - 10:59 AM

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, 21 August 2017 - 11:00 AM.


#5 Bikerdude

Bikerdude

    Mod hero

  • Member
  • PipPipPipPipPip
  • 18894 posts

Posted 21 August 2017 - 01:29 PM

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.

You can set non-spawned keys to be inv_droppable arg.



#6 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 190 posts

Posted 21 August 2017 - 04:43 PM

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)



#7 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPipPip
  • 5300 posts

Posted 22 August 2017 - 02:39 AM

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
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#8 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 190 posts

Posted 23 August 2017 - 01:27 PM

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, 23 August 2017 - 01:28 PM.


#9 grayman

grayman

    Master Builder, Coder

  • Active Developer
  • PipPipPipPipPip
  • 11988 posts

Posted 23 August 2017 - 03:50 PM

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?



#10 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 190 posts

Posted 24 August 2017 - 11:48 AM

 

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.





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users