Healing Weapon/item; Self Heal weapon/item

Users who are viewing this thread

spiritwind

Squire
Is there any way to make an item or weapon to where it heals you or the other person when you use it? 
The best way, that im pretty sure is possible, is through mission_templates, to where you have a key configured such as "I" that you can bind to heal all of your health, or better yet, a certain amount of health, that is binded to the amount of a certain item you have in your inventory.  Once you run out, you obviously cannot use any more. 
Anyways, to go deeper, do you think it would be possible to make it to where you can have a little image, like the arrow counter, that shows how many of these items you have?  How about making it to where the bots can use them *doubt that one*. 
Any and all help is well needed!
 
store_agent_hit_points
agent_set_hit_points

Use these two commands.

Here's an example:

(get_player_agent_no, ":player",),
(store_agent_hit_points, ":hp", ":player",1),
(val_add, ":hp", 10),
(agent_set_hit_points, ":player", ":hp",1)

If you want to create some sort of healing command, you can have this little section applied either by key press, or by item trigger.

ti_on_weapon_attack - for ranged weapons
key_clicked - will execute the trigger when the key is clicked.

I'll leave it to you to figure out the rest. It's really not hard.
 
Ok, I'll see what I can do, thanks for the input though!  I take it this will also heal enemy troops if they receive it. 
---
If there is indeed someone out there that wants to help me write the code I would appreciate it.  My knowledge of coding in the missions side is very minimal! 
I might be able to put it together tho....
Thanks again!
 
you can also run a trigger that checks if an item is wielded.  If this is a "healing" object you can handle it various ways.  You could have it start to be "used" once the trigger sees it.  For every second it's wielded (or what ever timer) you can used up one of the object, and grant x amount of health.  I think this only works with percentages, so you would have to do some math to get the right percentage added.

You can test that when the attack key is pressed if this item is wielded, then use it up and grant health (similar to what SW is doing).

You can add a hoy key that when pressed checks your inventory for a healing object, if it is there, it uses one and grants x HP.

It all depends on how you want to "implement it.

(BTW: got a bit side tracked, but still working on that code bit)
 
Code:
(0, 0, 0, [(key_is_down, key_i)],
[(get_player_agent_no, ":player_agent"),
 (agent_is_alive, ":player_agent"),
 (store_agent_hit_points, ":player_hp", ":player_agent"),
 (lt, ":player_hp", 100),  
 (troop_get_inventory_capacity, ":inv_cap", "trp_player"),
 (try_for_range, ":slot_no", 0, ":inv_cap"),
     (troop_get_inventory_slot,":item_id","trp_player",":slot_no"),
     (eq, ":item_id", "itm_healing_item"),
     (assign, ":healing_item_slot", "slot_no"),
 (try_end),
 (try_begin), 
    (eq, ":healing_item_slot", -1),
    (display_message, "@No healthpacks!"),
 (else_try),
    (store_agent_hit_points, ":player_hp", ":player_agent", 1),
    (val_add, ":player_hp", 20), #hp to add
    (agent_set_hit_points, ":player_agent", ":player_hp", 1),
    (troop_set_inventory_slot,"trp_player",":healing_item_slot", -1),
    (display_message, "@You were healed for 20 hp"),
(try_end)]),

If player has "itm_healing_item" in inventory and his health is lower than 100%, he'll be healed for 20 points and the healing item will perish. Untested. The code might contain errors or\and misspellings.

Well, if you want to create a permanent item with healing ability, you can create a new item constant (item_healing_power) and modify it instead of deleting the item.

Hope it helps.
 
Ok, I understand the system, however it gets a tuple error.... 
I've tried rewriting it, tried to change some things around, and it always gets this error ...  Seems to be the
(val_add, ":player_hp", 20) #hp to add
But it says the tuple error is the one below it.  This is the error I get
    from module_mission_templates import *
  File "C:\Documents and Settings\Brian\Desktop\Fallout Mod\Fallout Py\module_m
ssion_templates.py", line 51, in <module>
    (agent_set_hit_points, ":player_agent", ":player_hp", 1),
TypeError: 'tuple' object is not callable
___
When I delete the Val add one everything runs through 100% no problems, but obviosuly thats one of the most important lines =p.  Any help would be well appreciated! 

---
This goes in Mission Temps right?  Any specific place or can it go just in the begging? 
___
Thanks a ton!
 
(val_add, ":player_hp", 20),
:grin:

Yes, this goes in mission_templates.
You can place it at the beginning, like

use_healthpack = (code)
(note, the code without the final comma)

and then place "use_healthpack," in any mission template you want.
 
Wow, I cannot believe that I seriously worked on that and tried to analyzed it for about 2 hours and never figured that out... 
THANKS A TON!!!!!! 
---
EDIT:
One problem, For some reason it isnt working in game =p.  Here is the item information,
["healthpack", "healthpack", [("rabati",0)], itp_merchandise|itp_type_goods|itp_consumable|itp_food,  ,0, 278 ,
weight(0)|abundance(100),imodbits_none ],
For some reason it also will not show the text on the side of the bar, I added some to where if the players health is full it will say so, but it isnt displaing any.  I cahnged the key to trigger it to O since I is assigned to inventory and already does something in battle.
---
Do I have to change anything?  Does the item have to be in the players hands or actual battle inventory?  How would I complete the process of getting healthpacks a special little like 5 bar screen for the player to add them into?  Could I make it to where each healthpack contains three charges and each time you use one that charge is permanently gone and wont restore once you exit the battle if you didnt use all three? 
 
Not itm_healthpack, itm_healing_item. You can change the items definition, or change the line (eq, ":item_id", "itm_healing_item"), to (eq, ":item_id", "itm_healthpack"),
 
I changed the healing item to healthpack, still does not work.  Perhaps you could test yourself and do some debugging?  I know its asking a lot but I would really appreciate it!
 
This goes in the beginning of mission_templates.
Code:
use_healthpack = (0, 0, 0, [(key_clicked, key_h)],
[(get_player_agent_no, ":player_agent"),
 (agent_is_alive, ":player_agent"),
 (store_agent_hit_points, ":player_hp", ":player_agent"),
 (lt, ":player_hp", 100),  
 (troop_get_inventory_capacity, ":inv_cap", "trp_player"),
 (assign, ":healing_item_slot", -1),
 (try_for_range, ":slot_no", 0, ":inv_cap"),
     (troop_get_inventory_slot,":item_id","trp_player",":slot_no"),
     (eq, ":item_id", "itm_healthpack"),
     (assign, ":healing_item_slot", ":slot_no"),
 (try_end),
 (try_begin), 
    (eq, ":healing_item_slot", -1),
    (display_message, "@No healthpacks!"),
 (else_try),
    (store_agent_hit_points, ":player_hp", ":player_agent", 1),
    (val_add, ":player_hp", 20), #hp to add
    (agent_set_hit_points, ":player_agent", ":player_hp", 1),
    (troop_set_inventory_slot,"trp_player",":healing_item_slot", -1),
    (display_message, "@You were healed for 20 hp"),
(try_end),])

This goes to the desired mission template
Code:
use_healthpack,

This is the healthpack.
Code:
["healthpack","Test", [("apple_basket",0)], itp_type_goods, 0, 44,weight(20)|abundance(110)|max_ammo(50),imodbits_none],

The code is tested, it works like it should.
 
What do you mean by desired mission template?
EDIT
I think I understand now, Like when you go way down and you come upon
[
      common_battle_mission_start,

      (0, 0, ti_once,
      [
        (assign, "$defender_team", 0),
        (assign, "$attacker_team", 1),
        (assign, "$defender_team_2", 2),
        (assign, "$attacker_team_2", 3),
        ], []),

      common_custom_battle_tab_press,
      common_custom_battle_question_answered,
      common_inventory_not_available,
      common_custom_siege_init,
--
It tells it when to use this, so I would just go througha nd find everything I iwant it to read this code in. 
I'll get back if it works or if it dosent when I can test it!
Thanks again
 
ConstantA - this looks great, I'll test it out soon, thx.

Is there anyway to have the healing item have multiple ammo (like the food), and it just gets decreased each time its used?
 
HokieBT said:
ConstantA - this looks great, I'll test it out soon, thx.

Is there anyway to have the healing item have multiple ammo (like the food), and it just gets decreased each time its used?

Code:
use_healthpack = (0, 0, 0, [(key_clicked, key_h)],
[(get_player_agent_no, ":player_agent"),
 (agent_is_alive, ":player_agent"),
 (store_agent_hit_points, ":player_hp", ":player_agent"),
 (lt, ":player_hp", 100),  
 (troop_get_inventory_capacity, ":inv_cap", "trp_player"),
 (assign, ":healing_item_slot", -1),
 (try_for_range, ":slot_no", 0, ":inv_cap"),
     (troop_get_inventory_slot,":item_id","trp_player",":slot_no"),
     (eq, ":item_id", "itm_healthpack"),
     (assign, ":healing_item_slot", ":slot_no"),
 (try_end),
 (try_begin), 
    (eq, ":healing_item_slot", -1),
    (display_message, "@No healthpacks!"),
 (else_try),
    (troop_inventory_slot_get_item_amount, ":cur_amount", "trp_player", ":healing_item_slot"),
    (assign, ":heal_amount", ":cur_amount"),
    (val_max, ":heal_amount", 20), #no more than 20 hp
    (val_sub, ":cur_amount", ":heal_amount"),
    (store_agent_hit_points, ":player_hp", ":player_agent", 1),
    (val_add, ":player_hp", ":heal_amount"),
    (agent_set_hit_points, ":player_agent", ":player_hp", 1),
    (troop_inventory_slot_set_item_amount, "trp_player", ":healing_item_slot", ":cur_amount"),
    (display_message, "@You were healed for 20 hp"),
(try_end),])

Again, untested. Not sure val_max does what I think it does.
 
ConstantA - thanks very much, I still need to test your bottom code, but the original use_healthpack worked great.  This will definetely be added to the next release of the star wars mod and I'll add you to the credits.    :smile:

edit:

In case anybody is interested, I modified the code a bit so it now uses an injector and capsules.



Code:
common_use_healthpack = (0, 0, 0, [
	(key_clicked, key_h)
	],
	[
		(get_player_agent_no, ":player_agent"),
		(agent_is_alive, ":player_agent"),
		(store_agent_hit_points, ":player_hp", ":player_agent"),
		(try_begin),
			(lt, ":player_hp", 100), 
			#(troop_get_inventory_capacity, ":inv_cap", "trp_player"),
			(troop_get_inventory_capacity, ":inv_cap", "$g_player_troop"),	#since custom commander is integrated
			(assign, ":healing_item_injector_slot", -1),
			(assign, ":healing_item_capsule_slot", -1),
			(assign, reg1, 0),
			(try_for_range, ":slot_no", 0, ":inv_cap"),
				#(troop_get_inventory_slot,":item_id","trp_player",":slot_no"),
				(troop_get_inventory_slot,":item_id","$g_player_troop",":slot_no"),	#since custom commander is integrated
				(try_begin),
					(eq, ":item_id", "itm_bacta_injector"),
						(assign, ":healing_item_injector_slot", ":slot_no"),
				(else_try),
					(eq, ":item_id", "itm_bacta_capsule"),
						(assign, ":healing_item_capsule_slot", ":slot_no"),
						(val_add, reg1, 1),
				(try_end),
			(try_end),
			(try_begin),
				(eq, ":healing_item_injector_slot", -1),
					(display_message, "@You don't have a Bacta Injector in inventory!"),
			(else_try),
				(le, reg1, 0),
					(display_message, "@You don't have any Bacta Capsules in inventory!"),
			(else_try),
					(store_agent_hit_points, ":player_hp", ":player_agent", 1),
					(val_add, ":player_hp", 20), #hp to add
					(agent_set_hit_points, ":player_agent", ":player_hp", 1),
					#(troop_set_inventory_slot,"trp_player",":healing_item_capsule_slot", -1),
					(troop_set_inventory_slot,"$g_player_troop",":healing_item_capsule_slot", -1),	#since custom commander is integrated
					(val_sub, reg1,1),
					(display_message, "@You were healed for 20 hp and have {reg1} bacta capsules left."),
			(try_end),
		(else_try),
			(display_message, "@You are not hurt."),
		(try_end),
	])
 
I am sorry to raise this from the dead, as I know it is quite old and I am unsure if Hokie is around anymore.

Can the owner of this code mode grant me permission to use it in my mod?  Since it is not explicitly in the OSP thread, I want to ask for permission and will of course credit its use to the appropriate parties.
 
Great thank you very much!  I just wanted to make sure not to overstep or assume I could benefit from someone elses work without asking.  Thanks much for the speedy clarification!
 
Back
Top Bottom