Health regeneration

Rize

Sergeant Knight at Arms
Best answers
0
I know there's a way to fully regenerate the player's health, but is there a way to do it, like 5 health per second?
 

HokieBT

Grandmaster Knight
M&BWB
Best answers
0
Kardiophylax had some nice code to do this in the CoT mod, you might want to PM him
http://forums.taleworlds.com/index.php?action=profile;u=32629
 

HokieBT

Grandmaster Knight
M&BWB
Best answers
0
ahh, too bad.  He was always helpful answering questions for me, so I don't think he would mind me sharing this part of his code.

His code allowed kings to regen at 4hp a second and knights do 3hp.  But you should be able to modify this concept to work on healing the player, etc.

put in module_mission_templates.py
Code:
#SW - Chronicles of Talera regen rate script by Kardiophylax START
common_regeneration_store_info = (
  0, 0, ti_once, [], [                      # run this only once at the start of battle
   (get_player_agent_no, "$agent_for_player"), 						# these aren't required, I use them for other things
   #(agent_get_team, "$agent_for_player_team", "$agent_for_player"),  # these aren't required, I use them for other things
 
   (try_for_agents, "$talera_agent"),
      #(agent_set_slot, "$talera_agent", slot_agent_regen_rate, 0),  # this is probably redundant, I think all agents have new, fresh ids when created
   (try_end),

   (try_for_agents, "$talera_agent"),
       (agent_get_troop_id, "$agent_troop_type", "$talera_agent"),
       (try_begin),
          (is_between, "$agent_troop_type", kings_begin, kings_end),
          (agent_set_slot, "$talera_agent", slot_agent_regen_rate, 4),
       (else_try),
          (is_between, "$agent_troop_type", kingdom_heroes_begin, kingdom_heroes_end),
          (agent_set_slot, "$talera_agent", slot_agent_regen_rate, 3),
       (try_end),
   (try_end),
   
   # for testing
   (agent_set_slot, "$agent_for_player", slot_agent_regen_rate, 4),
  ]
)

common_regeneration = (
1, 0, 0, [], [
    (try_for_agents, "$talera_agent"),
       (agent_is_alive, "$talera_agent"),
       (agent_get_slot, ":regen_rate", "$talera_agent", slot_agent_regen_rate),
       (ge, ":regen_rate", 1),
       (store_agent_hit_points, ":agent_health", "$talera_agent", 1),
       (val_add, ":agent_health", ":regen_rate"),
       (agent_set_hit_points, "$talera_agent", ":agent_health", 1),
    (try_end),
  ]
)
#SW - Chronicles of Talera regen rate script by Kardiophylax END

then add to the mission templates you want it to work in
Code:
   #SW - added regen for certain agents
   common_regeneration_store_info,
   common_regeneration,

edit:

add a slot in module_constants.py
Code:
#SW - Chronicles of Talera regen rate script by Kardiophylax START
slot_agent_regen_rate = 145
#SW - Chronicles of Talera regen rate script by Kardiophylax END
 

Rize

Sergeant Knight at Arms
Best answers
0
NameError: name 'slot_agent_regen_rate' is not defined

How do i get past this error?  :mrgreen:
 

HokieBT

Grandmaster Knight
M&BWB
Best answers
0
looks like I missed one part

add a slot in module_constants.py
Code:
#SW - Chronicles of Talera regen rate script by Kardiophylax START
slot_agent_regen_rate = 145
#SW - Chronicles of Talera regen rate script by Kardiophylax END
 

Rize

Sergeant Knight at Arms
Best answers
0
Thanks a lot! I managed to get a somewhat CoD-ish health regen script by modifying the one you gave me:

Code:
#TLW - Chronicles of Talera modified regen rate script by Kardiophylax START
common_regeneration_store_info = (
  0, 0, 14, [], [                      
   (get_player_agent_no, "$players_agent"),                   
   (agent_is_alive, "$players_agent"),
   (store_agent_hit_points, ":agent_health", "$players_agent", 1),
   (try_begin),
       (is_between, ":agent_health", 1, 5),
       (agent_set_slot, "$players_agent", slot_agent_regen_rate, 2),
   (else_try),
       (is_between, ":agent_health", 5, 25),
       (agent_set_slot, "$players_agent", slot_agent_regen_rate, 1),
   (else_try),
       (is_between, ":agent_health", 25, 9999),
       (agent_set_slot, "$players_agent", slot_agent_regen_rate, 0),
   (try_end),
 
   ]
)

common_regeneration = (
1, 0, 0, [], [
    (try_for_agents, "$players_agent"),
       (agent_is_alive, "$players_agent"),
       (agent_get_slot, ":regen_rate", "$players_agent", slot_agent_regen_rate),
       (ge, ":regen_rate", 1),
       (store_agent_hit_points, ":agent_health", "$players_agent", 1),
       (val_add, ":agent_health", ":regen_rate"),
       (agent_set_hit_points, "$players_agent", ":agent_health", 1),
    (try_end),
  ]
)
#TLW - Chronicles of Talera modified regen rate script by Kardiophylax END

If the player's health drops below 25, it will regenerate back to 25 slowly after 7 secs or so, and if it falls below 5, it will regenerate quickly back to 5.
But i'm not sure if the time needed to pass in order for the regeneration to start is accurate, and i don't know if health can be represented as a percentage instead of a numerical value, or if regeneration can be interrupted if the player is hit again.
 

Onitenshi

Recruit
Best answers
0
Well I hope someone looks at this old thread, but i dont want to start a new one ^^;;

I don't understand the "then add to the mission templates you want it to work in" ... How do i know in which one i need them to have this effect in all battles? I don't get mission templates at all. the scripts.py file does what i want, but mission_templates.py wants to drive me crazy. (I cant get what numbers i have to change to get more reinforcement waves per battle too, but i will ask that question in the right thread, after some last tries)
So i really would love a lil help AND another related problem. there is one particular troop type i want to have regeneration too. trp_demigod
would

      (try_begin),
          (is, "$agent_troop_type", trp_demigod),
          (agent_set_slot, "$talera_agent", slot_agent_regen_rate, 4),
      (else_try),


work, or do  have to make a different line of code to insert my demigods??

Sorry, for my sucking at mision templates... and thanks alot for the help in advance.
 

Caba`drin

Count
M&BWBWF&SNWVC
Best answers
0
@Onitenshi, it looks like your questions would be better served in the general Q&A thread. It is stickied, above.
jik's tutorial doesn't get much into mission_templates, but do be sure you look at it if you haven't. Similarly, you'll want to see the syntax link in my signature.

As for this specific code, the "put in module_mission_templates.py" goes toward the top of the file. Those are mission template triggers and they are given names. They should go by the other named triggers, those that begin common_* or multiplayer_*

The part that says "then add to the mission templates you want it to work in" goes lower in the file, in actual mission templates. These templates are named "town_default" or "lead_charge", include information on how spawning should work, and then are simply a list of triggers. (These basic parts are explained in the tutorial.) You can add the names of these triggers into the listing of triggers, as they appear.

As for which templates to add it to: lead_charge governs all field battles. The rest are fairly self-explanatory...there are numerous templates for sieges, bandit attacks, village raiding, etc.

"Is" is not a valid operation. Use "eq".

As an aside, in general the base code you are looking at here is fairly out of date/mess due to its unnecessary use of global variables.
 

Somebody

Code Pope
Baron
WBWF&S
Best answers
1
mission templates are a common set of triggers code and which affect behaviour inside a scene. They are applied via set_jump_mission preceeding jump_to_scene. In regular field battles, you'll want "lead_charge" The first part (excluding the name and flags) deals with how visitors set up for the various entry points are affected. The triggers themselves in the block below may be encapsulated inside individual templates, or be included as a one-liner such as common_regeneration. Note, however that both are compiled in the same way - "common" triggers only shorten and unify code in the source files. To include such a trigger (which must first be placed above the list of mission templates with its name followed by the indented code without a comma), simply add a comma after its name inside any mission template.

Keep common_regeneration (but change $player_agent, to :agent so you don't use an extraneous global), and add the following:
Code:
  (
    "lead_charge",mtf_battle_mode,charge,
    "You lead your men to battle.",
    [
     (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
     (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
     (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
     (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
     ],
    [
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (call_script, "script_agent_reassign_team", ":agent_no"),

         (assign, ":initial_courage_score", 5000),
                  
         (agent_get_troop_id, ":troop_id", ":agent_no"),
         (try_begin), #add this
           (eq, ":troop_id", "trp_demigod"),
           (agent_set_slot, ":agent_no", slot_agent_regen_rate, 4),
         (try_end),
...
         (agent_set_slot, ":agent_no", slot_agent_courage_score, ":initial_courage_score"), 
         ]),

      common_battle_init_banner,
      common_regeneration, #and this
 

Onitenshi

Recruit
Best answers
0
Caba` drin
I am sorry, i didn't want to go on the nerves of the "wise" ones. I've seen youre name countless times on my researches. I think anyone desperately looking for regeneration will find this, because if u search the forum for regeneration theres only like 10 hits in The Forge forum. Atleast i read alot before i open just a new thread. I promise though, that i will try out the Q/A thread next time.

So thanks alot you two for explaining it to me. I will now try to get it running.

I wish you a nice easter, if you celebrate it ^^
 

Caba`drin

Count
M&BWBWF&SNWVC
Best answers
0
Onitenshi said:
Caba` drin
I am sorry, i didn't want to go on the nerves of the "wise" ones.
Apologies if my tone said otherwise, but I wasn't trying to appear short or as if my nerves were ruffled...just trying to point in a better direction. Better to have posted here than a new thread of course.

Cheers, happy scripting, and continue asking questions!
 

Onitenshi

Recruit
Best answers
0
Thanks alot so far. You even solved my other problem, thanks to you i found the way to increase the waves in open field battles ^^

But ... Gnarf... I need more help regarding this  :oops:

So far i am using this:

#----------------------------------------------------------------------------------------------------------

#SW - Chronicles of Talera regen rate script by Kardiophylax START editet by ERIK
common_regeneration_store_info = (
  0, 0, ti_once, [], [                      # run this only once at the start of battle

  (try_for_agents, ":agent_no"),
      #(agent_set_slot, "$talera_agent", slot_agent_regen_rate, 0),  # this is probably redundant, I think all agents have new, fresh ids when created
  (try_end),

  (try_for_agents, ":agent_no"),
      (store_skill_level, ":ironflesh_level", "skl_ironflesh", ":agent_no"),
      (store_skill_level, ":persuasion_level", "skl_persuasion", ":agent_no"),
        (val_sub, ":ironflesh_level", 1),
        (val_min, ":ironflesh_level", 0), #eliminate negative results
        (val_mul, ":ironflesh_level", 3),
        (val_sub, ":persuasion_level", 1),
        (val_min, ":persuasion_level", 0), #eliminate negative results
        (val_mul, ":persuasion_level", 10),
        (assign, ":regeneration", ":ironflesh_level"),
        (val_add, ":regeneration", ":persuasion_level"), 
          (agent_set_slot, ":agent_no", slot_agent_regen_rate, ":regeneration"),
  (try_end), 

  ]
)

common_regeneration = (       
1, 0, 0, [], [
    (try_for_agents, ":agent_no"),
      (agent_is_alive, ":agent_no"),
      (agent_get_slot, ":regen_rate", ":agent_no", slot_agent_regen_rate),
      (ge, ":regen_rate", 1),
      (store_agent_hit_points, ":agent_health", ":agent_no", 1),
      (val_add, ":agent_health", ":regen_rate"),
      (agent_set_hit_points, ":agent_no", ":agent_health", 1),
    (try_end),
  ]
)

#----------------------------------------------------------------------------------------------------------

Long tests show, that it works for (50% of the) troops, but not for the player... I just don't get it, why i need to adress the player in the first script directly like:

  (get_player_agent_no, ":agent_player"),
  (agent_set_slot, ":agent_player", slot_agent_regen_rate, 11),

I mean in the second script in the FIRST Spoiler (common_regeneration)
the player is not especially adressed....

But my main Problem is, that my script seems to be ineffective, cause even with regeneration 100 every 1 second and opponents that doesn't do much damage, some die, and some are nearly imortal (like they should be for test purpose).  So i guess my script is kinda crappy, but i dont know where. By the way, i subtract 1 and then set a possible -1 to 0, so that troop, who got ironskin level 1 by coincidence (the game gives troops who have "0" in there knowing place some skills on level 1) dont regenerate.

My biggest fail so far was using wound treatment instead of persuation. Because its an group skill, everyone in my troop got the level 10 my main char had....

Well i hope you have some ideas what i am doing wrong, cause i cant see my error. Thanks alot for your time in advance ^^;;
 

Somebody

Code Pope
Baron
WBWF&S
Best answers
1
First, if you're using Warband, you should use the ti_on_agent_spawn trigger.
Second, store_skill_level only words for troops, which are templates from which agents are formed. So you'll want to use agent_get_troop_id before performing those operations.
 

Onitenshi

Recruit
Best answers
0
Well it nails the error down a bit

#SW - Chronicles of Talera regen rate script by Kardiophylax START editet by ERIK
common_regeneration_store_info = (
  0, 0, ti_on_agent_spawn, [], [                      # run this only once when troops spawn

  (try_for_agents, ":agent_no"),
        (agent_get_troop_id, ":troop_id", ":agent_no"),
      (store_skill_level, ":ironflesh_level", "skl_ironflesh", ":troop_id"),
      (store_skill_level, ":persuasion_level", "skl_persuasion", ":troop_id"),
        (val_sub, ":ironflesh_level", 1),
        (val_min, ":ironflesh_level", 0), #eliminate negative results
        (val_mul, ":ironflesh_level", 3),
        (val_sub, ":persuasion_level", 1),
        (val_min, ":persuasion_level", 0), #eliminate negative results
        (val_mul, ":persuasion_level", 11),
        (assign, ":regeneration", ":ironflesh_level"),
        (val_add, ":regeneration", ":persuasion_level"), 
          (agent_set_slot, ":agent_no", slot_agent_regen_rate, ":regeneration"),
  (try_end), 
  ]
)


if i replace the last ":regeneration" with a number like 11, then everyone (even the player) has regeneration 11. So i think ":regeneration", ":persuasion_level" or ":ironflesh_level" is no integer/number and thus no integer/number is stored in the slot_agent_regen_rate. But i dont know why. I mean in python i dont have to define it extra as an integer... or?

EDIT: I even nailed it down even more:
If i comment out these lines:

        (val_sub, ":ironflesh_level", 1),
        (val_min, ":ironflesh_level", 0),
        (val_sub, ":persuasion_level", 1),
        (val_min, ":persuasion_level", 0),

it works, but i guess i have to live with the risk of troops that get regeneration, by accident...

could it be that integers can't be -1 or any other negative number??, then

        (val_min, ":ironflesh_level", 1),
        (val_sub, ":ironflesh_level", 1),

        (val_min, ":persuasion_level", 1),
        (val_sub, ":persuasion_level", 1),

should do the same, without them ever getting to negative
Edit2:  Well it doesnt work even then, it just works when i comment thos lines out. I dont get it, why val_min or val_sub mess it up. I mean i work with whole numbers there ... and it can't possibly go lower then 0 -.-;;
 

Somebody

Code Pope
Baron
WBWF&S
Best answers
1
The script is wrong. val_min takes the lesser value, so it can be negative. Your trigger format is also wrong - ti_on_agent_spawn should be the first interval.
Code:
(ti_on_agent_spawn, 0, 0, []
[
(store_trigger_param_1, ":agent_no"),
(agent_get_troop_id, ":troop_id", ":agent_no"),
(store_skill_level, ":ironflesh_level", "skl_ironflesh", ":troop_id"),
(store_skill_level, ":persuasion_level", "skl_persuasion", ":troop_id"),
(val_sub, ":ironflesh_level", 1),
(val_max, ":ironflesh_level", 0), #eliminate negative results
(val_mul, ":ironflesh_level", 3),
(val_sub, ":persuasion_level", 1),
(val_max, ":persuasion_level", 0), #eliminate negative results
(val_mul, ":persuasion_level", 11),
(val_add, ":ironflesh_level", ":persuasion_level"),   
(agent_set_slot, ":agent_no", slot_agent_regen_rate, ":ironflesh_level"),
]
),
 

Onitenshi

Recruit
Best answers
0
Thanks alot Somebody. It's a wonder this script ever worked in the tests, seeing how many things you changed in the past hours.

I have to admit, i don't get val_max or val_min at all. I thought, val_min says, that for example :ironflesh_level can't be under this (0) and every value below will be set to 0, because i set a MINIMAL value and val_max does the opposite and if i set it for :ironflesh_level to (5) that for example a 9 will be reduced to a 5, beacuse i set a MAXIMAL value. Now u tell me it's the opposite and it works... that makes no sense (in my logic. not that u are right, but how they are named -.-;; )... or do i miss something?

On the long term, many many thanks for your hard work helping me ^^
I know it was not easy ^^;;
I think this could be interesting for some people, for example creating an independent regeneration skill in one of the reserved slots.
 

SPD_Phoenix

Master Knight
Best answers
0
Now u tell me it's the opposite and it works... that makes no sense (in my logic. not that u are right, but how they are named -.-;; )... or do i miss something?
val_min : compare 2 values/numbers and keep the smaller/smallest (min) value/number.

val_max : compare 2 values/numbers and keep the bigger/biggest (max) value/number
 

The Shadow

Recruit
Best answers
0
An integer can support anything from −2,147,483,648 up to  +2,147,483,647, if I remember correctly.  That shouldn't be the problem. 

EDIT:  Didn't read the second page :oops: