ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


new:inventory

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
new:inventory [2018/02/15 17:18] – created korshunnew:inventory [2018/02/18 18:13] (current) korshun
Line 1: Line 1:
-====== Unit conversion ======+====== Inventory functions ======
  
-**All** unit conversion function operate on ''fixed'' numbers, even if ZDoom only uses integers for some of these units.+===== SetInventory =====
  
-===== Angle units =====+  * ''void SetInventory(str itemname, int count)'' 
 +  * ''void SetActorInventory(int tid, str itemname, int count)''
  
-  * ZDoom ''fixed'' angles [0, 1] +Sets the number of items in actor's inventor to ''count''. This is useful when treating inventory items like variables stored in actors.
-  * Degrees [0, 360] +
-  * Radians [0, 6.28]+
  
-ZDoom ''fixed'' angles are the recommended angle unit in ZDoomused by almost all actor functionsand used by all ACSUtils functions.+This function is optimized to minimize bandwidth use. It computes the difference between the current item count and the requested countand gives or takes the needed number of items. If the actor already has the exact number of itemsthis function does nothing.
  
-Angle units can be converted using the following functions (ang ZDoom ''fixed'' angles, deg Degrees, rad Radians):+===== GiveMaxInventory/TakeMaxInventory =====
  
-  * ''fixed deg2ang(fixed degrees)'' -- converts degrees to ZDoom angle +  * ''void GiveMaxInventory(str itemname)'' 
-  * ''fixed rad2ang(fixed radians)'' -- converts radians to ZDoom angle +  * ''void GiveMaxActorInventory(int tid, str itemname)'' 
-  * ''fixed ang2deg(fixed angle)'' -- converts ZDoom angle to degrees +   
-  ''fixed ang2rad(fixed angle)'' -- converts ZDoom angle to radians +Give maximum possible number of ''itemname'' to actor. Shorthand for ''GiveInventory(itemname, INT_MAX)''.
-  * ''fixed deg2rad(fixed degrees)'' -- converts degrees to radians +
-  * ''fixed rad2deg(fixed radians)'' -- converts radians to degrees+
  
-===== Gravity units =====+  * ''void TakeMaxInventory(str itemname)'' 
 +  * ''void TakeMaxActorInventory(int tid, str itemname)''
  
-  * acceleration (default gravity is 1.0) +Take all items of type ''itemname'' from actor. Shorthand for ''TakeInventory(itemname, INT_MAX)''.
-  * ''sv_gravity'' units (default gravity is 800)+
  
-ZDoom uses ''sv_gravity'' units exclusively, but acceleration is the recommended unit, as it can be used in physical calculations without conversion.+===== ToggleInventory =====
  
-Gravity units can be converted using the following functions:+  * ''void ToggleInventory(str itemname)'' 
 +  * ''void ToggleActorInventory(str itemname)''
  
-  * ''fixed grav2accel(fixed sv_gravity)'' -- converts ''sv_gravity'' units to acceleration +If the actor has no ''itemname'', give one item of this type. If it has one or more item of ''itemname'', take them all.
-  * ''fixed accel2grav(fixed acceleration)'' -- converts acceleration to ''sv_gravity'' units+
  
-ACSUtils also provides utility functions for manipulating gravity: +This is shorter way of writing ''x = !x'' when using inventory items as boolean variables.
- +
-  * ''fixed GetGravityG()'' -- reads the value of ''sv_gravity'', converts it to acceleration and returns the result. Supports both very small and HUGE values of ''sv_gravity''+
-  * ''void SetGravityG(fixed accel)'' -- wrapper for [[zdoom>SetGravity]] that accepts acceleration instead of ''sv_gravity'' units. +
- +
-===== Jump height ===== +
- +
-  * ''fixed jumpz2height(fixed jumpz)'' -- converts decorate JumpZ to actual resulting jump height +
-  * ''fixed height2jumpz(fixed height)'' -- calculates JumpZ from actual jump height+
  
new/inventory.1518707925.txt.gz · Last modified: 2018/02/15 17:18 by korshun