Author Topic: Health regeneration  (Read 3369 times)

0 Members and 1 Guest are viewing this topic.

Rize

  • Sergeant Knight at Arms
  • *
  • It's a monkey, no matter what you say!
    • View Profile
  • Faction: Neutral
Health regeneration
« on: July 27, 2009, 07:03:53 PM »
 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
  • *
  • may the force be with you
    • View Profile
  • Faction: Neutral
  • M&B
Re: Health regeneration
« Reply #1 on: July 27, 2009, 09:14:39 PM »

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
 

Rize

  • Sergeant Knight at Arms
  • *
  • It's a monkey, no matter what you say!
    • View Profile
  • Faction: Neutral
Re: Health regeneration
« Reply #2 on: July 28, 2009, 08:21:17 AM »
 Too bad he hasn't logged in since May 1st...

HokieBT

  • Grandmaster Knight
  • *
  • may the force be with you
    • View Profile
  • Faction: Neutral
  • M&B
Re: Health regeneration
« Reply #3 on: July 28, 2009, 02:18:12 PM »
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
(click to show/hide)

then add to the mission templates you want it to work in
(click to show/hide)

edit:

add a slot in module_constants.py
(click to show/hide)
« Last Edit: July 28, 2009, 03:21:01 PM by HokieBT »
 

Rize

  • Sergeant Knight at Arms
  • *
  • It's a monkey, no matter what you say!
    • View Profile
  • Faction: Neutral
Re: Health regeneration
« Reply #4 on: July 28, 2009, 03:09:55 PM »
 NameError: name 'slot_agent_regen_rate' is not defined

How do i get past this error?  :mrgreen:

HokieBT

  • Grandmaster Knight
  • *
  • may the force be with you
    • View Profile
  • Faction: Neutral
  • M&B
Re: Health regeneration
« Reply #5 on: July 28, 2009, 03:20:45 PM »

looks like I missed one part

add a slot in module_constants.py
(click to show/hide)
 

Rize

  • Sergeant Knight at Arms
  • *
  • It's a monkey, no matter what you say!
    • View Profile
  • Faction: Neutral
Re: Health regeneration
« Reply #6 on: July 28, 2009, 04:32:50 PM »
Thanks a lot! I managed to get a somewhat CoD-ish health regen script by modifying the one you gave me:

(click to show/hide)

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
  • *
    • View Profile
  • Faction: Nord
Re: Health regeneration
« Reply #7 on: April 22, 2011, 09:21:09 PM »
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

(click to show/hide)


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.
« Last Edit: April 22, 2011, 09:28:23 PM by Onitenshi »

Caba`drin

  • Administrator
  • *
  • It's time to toss the dice.
    • View Profile
  • Faction: Nord
  • MP nick: Caba_drin
  • M&BWBWF&SNW
Re: Health regeneration
« Reply #8 on: April 22, 2011, 09:48:54 PM »
@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

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: Health regeneration
« Reply #9 on: April 22, 2011, 09:49:34 PM »
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) [Select]
  (
    "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
  • *
    • View Profile
  • Faction: Nord
Re: Health regeneration
« Reply #10 on: April 23, 2011, 09:03:26 AM »
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

  • Administrator
  • *
  • It's time to toss the dice.
    • View Profile
  • Faction: Nord
  • MP nick: Caba_drin
  • M&BWBWF&SNW
Re: Health regeneration
« Reply #11 on: April 23, 2011, 03:20:35 PM »
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
  • *
    • View Profile
  • Faction: Nord
Re: Health regeneration
« Reply #12 on: April 24, 2011, 11:56:10 AM »
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:

(click to show/hide)

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:

(click to show/hide)

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

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: Health regeneration
« Reply #13 on: April 24, 2011, 06:11:54 PM »
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
  • *
    • View Profile
  • Faction: Nord
Re: Health regeneration
« Reply #14 on: April 24, 2011, 07:08:52 PM »
Well it nails the error down a bit

(click to show/hide)


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:

(click to show/hide)

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

 
(click to show/hide)

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 -.-;;
« Last Edit: April 24, 2011, 07:35:57 PM by Onitenshi »