Patches for Sauerbraten/Eisenstern

These are some patches I made for Eisenstern (Sauerbraten engine). The primary goal is to make almost everything that's currently hardcoded scriptable with CubeScript.

They are based on Sauerbraten CVS as of 2008-05-29. Apply with "patch -p1" from within src directory.

rpg-eol.patch
Remove whitespace on end of line in rpggame/*.
r_get_name.patch
Add command r_get_name to get name of object on top of RPG stack.
itemflags-fix.patch
Fix itemflags for items changing owner (add to inventory). Fixes attribute accumulation.
invgui-only-trade-and-inv.patch
Only show IF_TRADE and IF_INVENTORY items in inventory GUI
autoclose-menus.patch
Auto-close GUI menus if player gets away from them
r_check_inv.patch
Add command r_check_inv to check if object on top of RPG stack has a given item in inventory
r_takegive_silent.patch
Add optional parameter silent to commands r_take and r_give to suppress console output
aigroups.patch
Add AI groups for defining asymmetric friend/neutral/foe relationships. Commands: r_{add,check,del}_{enemy,friend}. Used for attacking, needs changes to game_rpg.cfg (add "r_aigroup x" for each "r_ai x").
r_pop_param.patch
Add optional, potentially negative parameter to r_pop. Since the RPG stack isn't a real stack, but rather something like a ring buffer, we can "undo" r_pop.
neg_stats.patch
Add support for negative attribute/stats values (0 = 100%, so negative values indicate below 100%), with limit to 0%.
movespeed.patch
Use movespeed attribute (for NPCs and player).
droploot-pop.patch
Let droploot() pop the pushed object off the RPG stack so it won't disturb other code.
r_state.patch
Add commands r_state and r_get_state to get/set entity state (e.g. for reviving NPCs).
floatret.patch
Add floatret() to command interpreter to return float values to CubeScript.
r_xyz.patch
Add commands r_{x,y,z} and r_get_{x,y,z} to get/set entity coordinates (e.g. to ensure revived entities don't get stuck in their dropped loot).
r_sleep.patch
Quick hack to add RPG stack preserving sleep command. Duplicates code from command interpreter, better solution needed.
r_get_model.patch
Add command r_get_model to determine model for object on top of RPG stack.
player_model_support.patch
Add support for setting player model via r_model
r_push_player.patch
Add command r_push_player to push player object on top of RPG stack.
r_del_action.patch
Add command r_del_action to remove a given NPC action or quest from the GUI menu (but not from the quest log). Does not free memory, but most struct members are only references to the string pool anyway. Deliberate design decision, but good arguments might convince me otherwise.
intset.patch
Export intset() from command interpreter so RPG code can use it to set variables for CubeScript.
r_loop_inrange.patch
Add command r_loop_inrange to loop over entities within a given range. Current entity is pushed onto RPG stack (so it can be used from within CubeScript) and popped back (so the parent objects remain accesible) for each iteration.
r_attack.patch
Add command r_attack to let stack[1] attack stack[0], e.g. from within r_loop_inrange.
r_rotate.patch
Add command r_rotate to let object on top of RPG stack rotate towards a given angle (absolute).
r_turnto.patch
Add command r_turnto to let stack[1] turn to face stack[0], e.g. from within r_loop_inrange.
r_move.patch
Add command r_move to let object on top of RPG stack start/stop moving. Needs better AI type support to work properly (otherwise it's overridden by hardcoded NPC logic).
r_loop_inv.patch
Add command r_loop_inv to loop over inventory objects of given type (0 means everything). Works like r_loop_inrange.
r_use_for_NPCs.patch
Make r_use usable for NPCs. Changes (automatic) weapon selection for player slightly.
better_weapon_auto_selection.patch
Add better auto selection algorithm for weapons (both player and NPC). Used only if no weapon is selected (e.g. because limited-use weapon has worn out).
r_ai_bitfield.patch
Interpret r_ai as bitfield (instead of sequence). Flags: AI_CHAR=1, AI_NOGUI=2, AI_NOTAKE=4, AI_SCRIPT=8. Needs game_rpg.cfg changes to work properly (replace "r_ai 2" with "r_ai 1").
r_blocked.patch
Add commands r_get_blocked and r_blocked to get/reset attribute "blocked".
r_get_targetyaw.patch
Add command r_get_targetyaw (opposite of r_rotate).
r_enemy.patch
Add commands r_enemy (set top of stack as enemy of top-1) and r_push_enemy (put enemy of top of stack on top of stack)
r_push_weapon.patch
Add command r_push_weapon (put current weapon of top of stack on top of stack)
r_npcstate.patch
Add commands r_npcstate and r_get_npcstate to get/set npcstate attribute of top of stack.
r_dist.patch
Add command r_dist to determine distance between top of stack and top-1.
npc_attack_dead_fix.patch
Fix for NPCs continuing to attack dead entities.
r_dispname.patch
Add commands r_get_dispname and r_dispname to get/set name displayed in GUI (defaults to spawn name).
stat_armor.patch
Add stat "armor" for use by scripts (r_dodamage)
blood_vars.patch
Add variables blood and bloodfade to toggle blood resp. change blood fade speed. Useful for older graphics cards.
r_vecyaw.patch
Add command r_vecyaw to determine angle (yaw) to given position (e.g. home).
wrap_abovetext.patch
Interpret \n in abovetext (r_say) as end-of-line, i.e. add support for multi-line texts.