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

Halo Shielding System with MP compatibility.

Recommended Posts

I've given this code out kinda under the radar, and after giving it out last time, I said I'd release a public version. Out of any script I've made, this one gets used more, next to the HP Bar. So, here it is, the Halo shielding system. Complete with MP compatibility in ZDoom and Skulltag. You are also able to customize it a bit and put in your own custom armor types etc for any other special effects you'd like to try. You are free to use this, but please credit those who deserve it.


http://www.megaupload.com/?d=EBPD52DA

code:

#include "zcommon.acs"
#define RECHARGEDELAYTIME 105 //delay before the recharge takes place.
#define RECHARGETIME 1 //delay between each addition of shield hit points 
#define MAXPLAYERS 32

#define SHLDREGEN 600
#define SHIELDING 601

int isrecharging[MAXPLAYERS];
script SHLDREGEN (int pnum) //Recharging script.
{
	 if (getactorproperty(activatortid(), APROP_Health) <= 0)
	 {
		 terminate;
	 }
	int oldval = getactorproperty(activatortid(), APROP_health);
 	if (isrecharging[playernumber()] == 0)
 	{
	 	localambientsound("recharge", 127);
	 	isrecharging[playernumber()]++;
	 }
	for (int a = checkinventory("armor"); a < 100; a++)
		{
			if (checkinventory("armor") < a || getactorproperty(activatortid(), APROP_health) < oldval || getactorproperty(activatortid(), APROP_Health) <= 0)
			{
				isrecharging[playernumber()] = 0;
				terminate;
			}
				if (getactorproperty(activatortid(), APROP_health) > oldval)
			{
				 oldval =getactorproperty(activatortid(), APROP_health);
			}
		
			oldval = getactorproperty(activatortid(), APROP_health);
			giveactorinventory(activatortid(), "shieldlvl1", 1);
			delay(rechargetime);
		}
		isrecharging[playernumber()] = 0;
		
}

function str chkshield (int pnum) //this function is to be used for custom shielding values - mostly for the APS
{
	return "shieldlvl1"; //if you want to adjust the armor resilience or anything, just change this to your custom armor bonus.
						//if you wanted to check for other conditions as well, this would be the best place to put your checks.
}


script SHIELDING (int pnum) //status check script
{
	int acounter;
	int oldhp = getactorproperty(activatortid(), APROP_health);
	int oldval = checkinventory("armor");
	
	While (checkinventory("armor") == oldval)  //counter loop to make sure the charging process isn't interupted.
	{
		acounter++;
		delay(1);
		if (acounter == RECHARGEDELAYTIME && checkinventory("armor") < 100) //if the loop has reached it's proper delay time (in tics)
		{
			acs_executealways(SHLDREGEN,0,playernumber(),0,0);
			break;
		}
		
	/*	if(checkinventory("armor") == 0)    //failed attempt at trying for the dead beep. Try again next time charlie.
		{
			delay (4);
			localambientsound("deadbeep",127);
			acounter += 4;
		}*/
		
		if (checkinventory("armor") < oldval || getactorproperty(activatortid(), APROP_health) < oldhp) //if the armor or health changes it resets the countdown
		{
			if( checkinventory("armor") < oldval && getactorproperty(activatortid(), APROP_health) == oldhp)
			localambientsound("ohshit", 127);
			acounter = 0;
			oldval = checkinventory("armor");
			oldhp = getactorproperty(activatortid(), APROP_health);
		}
		if (getactorproperty(activatortid(), APROP_health) > oldhp)
		{
			oldhp = getactorproperty(activatortid(), APROP_health);
		}
		if (checkinventory("armor") > oldval)
		{
			oldval = checkinventory("armor");
		}

		if (getactorproperty(activatortid(), APROP_Health) <= 0)
    	{
			break;
		}
	}
	if (getactorproperty(activatortid(), APROP_Health) >= 1) 
    {
		delay(1);
		restart;
	}
}


Script 1 ENTER //This script is just meant to initialize the system.
{
thing_changetid(0,1000 + playernumber());
acs_executealways(SHIELDING,0,0,0,0);
}

Script 601 RESPAWN
{
thing_changetid(0,1000 + playernumber());
acs_executealways(SHIELDING,0,0,0,0);
}

Share this post


Link to post

I appreciate it. I tried to make it as flexible as possible. With this model, you could potentially apply it to monsters too. Would make for one heck of a boss or elite unit or something.

Share this post


Link to post

Interesting, but why do people keep trying to make DooM play like something else?

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
×