Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
linuxfree1

How can create a Script Health regen?

Recommended Posts

I,m trying create a health regen script for player in doom 3 but can find reference to player entity with health and max heath to work with systime like sys.getTime()

Share this post


Link to post

I'm not sure, I don't know any real scripting of sorts. But you could look into how the health decreases in Nightmare mode. I'm not sure if it's in the scripts file or in the player.cpp file (SDK).

Share this post


Link to post
On 5/14/2019 at 9:43 PM, xyzz said:

I'm not sure, I don't know any real scripting of sorts. But you could look into how the health decreases in Nightmare mode. I'm not sure if it's in the scripts file or in the player.cpp file (SDK).

yes i dont find too :( the idea is increment player_health 5 by delta_time machine or delay time by script

Share this post


Link to post

Here's an example very raw I recently made for you: https://www.mediafire.com/file/hghpdo91hwcemo6/sRegenByStradex.pk4/file

 

How it works?

 

In a dirty way because it's all done via scripting, no SDK work here. (This is not going to work in MP)

 

1. When you load a map the doom_main function is called

2. I created a function (thread) called in that function for this regeneration system.

3. The regen function just spawn a health item (like a item_medkit_small but this one just gives you 5 health) every 15 seconds and give it to the player ($player1) .

 

def/regenAddon.def

entityDef item_regen_giver {
	"inherit"				"item_default"
	"editor_color"			".3 .3 1"
	"editor_mins"			"-16 -16 0"
	"editor_maxs"			"16 16 32"

	"editor_usage"			"Used by Regen system"

	"spawnclass"			"idItem"
	"model" 				"models/items/medkit/medkit_small.lwo"
	"size"					"32 32 32"
	"inv_name"				"Regeneration Life"
	"inv_health"			"5"
	"inv_item"				"2"
	"snd_acquire"			"guisounds_health"
}

 

script/stradexRegen.script

 


/*
=====================
stradexRegenMain

Give health to player every 15 secs
=====================
*/
void stradexRegenMain() {
  entity regenGiver;

  while(1)
  {
  
  	if ($player1) {
   	  regenGiver = sys.spawn("item_regen_giver");
   	  regenGiver.activate($player1);
   	  regenGiver.remove();
   	}

     sys.wait(15.0);
   }
}

 

script/doom_main.script

 

...
...
...
// test scripts
#include "script/ai_follower.script"

//Regeneration script
#include "script/stradexRegen.script"

void doom_main() {
	sys.print( "Entering doom_main()\n");

	thread stradexRegenMain();

	sys.print( "Exiting doom_main()\n" );
}

 

Share this post


Link to post
On 5/17/2019 at 10:56 PM, Doommarine_maxi said:

Here's an example very raw I recently made for you: https://www.mediafire.com/file/hghpdo91hwcemo6/sRegenByStradex.pk4/file

 

How it works?

 

In a dirty way because it's all done via scripting, no SDK work here. (This is not going to work in MP)

 

1. When you load a map the doom_main function is called

2. I created a function (thread) called in that function for this regeneration system.

3. The regen function just spawn a health item (like a item_medkit_small but this one just gives you 5 health) every 15 seconds and give it to the player ($player1) .

 

def/regenAddon.def


entityDef item_regen_giver {
	"inherit"				"item_default"
	"editor_color"			".3 .3 1"
	"editor_mins"			"-16 -16 0"
	"editor_maxs"			"16 16 32"

	"editor_usage"			"Used by Regen system"

	"spawnclass"			"idItem"
	"model" 				"models/items/medkit/medkit_small.lwo"
	"size"					"32 32 32"
	"inv_name"				"Regeneration Life"
	"inv_health"			"5"
	"inv_item"				"2"
	"snd_acquire"			"guisounds_health"
}

 

script/stradexRegen.script

 



/*
=====================
stradexRegenMain

Give health to player every 15 secs
=====================
*/
void stradexRegenMain() {
  entity regenGiver;

  while(1)
  {
  
  	if ($player1) {
   	  regenGiver = sys.spawn("item_regen_giver");
   	  regenGiver.activate($player1);
   	  regenGiver.remove();
   	}

     sys.wait(15.0);
   }
}

 

script/doom_main.script

 


...
...
...
// test scripts
#include "script/ai_follower.script"

//Regeneration script
#include "script/stradexRegen.script"

void doom_main() {
	sys.print( "Entering doom_main()\n");

	thread stradexRegenMain();

	sys.print( "Exiting doom_main()\n" );
}

 

thanks a lot i would create one map for play like ARCADE style example you need find points in map where go spawn enemies and you have a time for kill this enemies this i create but dont know how show in HUD gui when this map is loaded the time and if pass to gui WIN and gui loose for then go to restart gui 

 

Can you help me in this project? i can send you my map for you see like working 

Share this post


Link to post

I try run your .pk4 but give error in doom_main.script

 

in line of thread stradexRegenMain();  // Erro Unknown value stra

 

Strange I just rename function stradexRegenMain(); for Main(); then work is normal that? after rename again and it worked i think is conflict C++ open change anything then save then work

Edited by linuxfree1

Share this post


Link to post
3 hours ago, linuxfree1 said:

thanks a lot i would create one map for play like ARCADE style example you need find points in map where go spawn enemies and you have a time for kill this enemies this i create but dont know how show in HUD gui when this map is loaded the time and if pass to gui WIN and gui loose for then go to restart gui 

 

Can you help me in this project? i can send you my map for you see like working 

 

Nice I got your idea then change anythings and got condition when time 300 5 minutos and you dont kill all enemies on the map you loose then go to restart level of game. But this for work regen only in my map arcade mode game i need write a code inside map only? the function regen put inside map will work only inside map?

Share this post


Link to post

I just put the thread function inside main function on my map and

#include script/my_file.script and worked now work only in my map like Arcade Doom 3 and your regen work like a mod i go put for you the credits friend =D .Very clean and nice your code help me a lot.

Share this post


Link to post
On 5/23/2019 at 9:56 PM, linuxfree1 said:

I just put the thread function inside main function on my map and

#include script/my_file.script and worked now work only in my map like Arcade Doom 3 and your regen work like a mod i go put for you the credits friend =D .Very clean and nice your code help me a lot.

 

 

Happy to help a fellow Doom 3 modder.

 

I hope to see your project and being able to play it.

Share this post


Link to post
3 hours ago, Doommarine_maxi said:

 

 

Happy to help a fellow Doom 3 modder.

 

I hope to see your project and being able to play it.

thanks i wish now can write the health of monsters when hited may can use your idea with scriptEvent entity getAttacker() ?

 

but in my doubt in entityDef can be write the params in runtime? example is "inv_name"       "Hited! cb_demon health is monster_boss_cyber_demon_1.getHealth()"

 

or any idea how can i write on the screen the message?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×