Custom health, deathmatch / SP

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
DBThanatos
Posts: 3101
Joined: Fri Apr 14, 2006 3:17 pm
Location: in "the darkness that lurks in our mind"

Custom health, deathmatch / SP

Post by DBThanatos »

Basically Im trying to achieve a health pickup that gives a certain amount of health in SP/Coop, but a different amount in Deathmatch. And that it also looks different

At the moment I have a hackish way of doing it: A health item that's invisible, always pickup-able, silent, that upon spawning in the map, it checks via ACS if the game is Deathmatch. If so, spawns the +50. If not DM, it spawns a regular medkit of +25.

The reason I made it so hackish, was to ensure it will follow the rules of health spawning in DM. I had to make it ALWAYSPICKUP so that if the player picks up the spawned health (the +50), will walk over the hacky thing, picking it up, telling the game to start the counter to respawn health. That part works fine, but the hack-item can be picked up even if the spawned health wasnt, meaning that it might spawn a 2nd health bubble where the unpicked one is. And so on.

Anybody has a better idea how to do this? Im really new at all this MP stuff, so any help is greatly appreciated.

EDIT: And it's supposed to work with Zandronum, so no fancy new features :(
User avatar
DavidN
 
 
Posts: 266
Joined: Mon Dec 28, 2015 6:22 pm

Re: Custom health, deathmatch / SP

Post by DavidN »

I'm not sure if there's an easier way to do it - what are the specific health-spawning rules that you want the item to follow? - but as another suggestion, how about this?

You have a single CustomInventory object in gameplay that calls an ACS script on spawn to check the game type, as you have now - but instead of spawning a different object, it just jumps to one of two states depending on the result of that (so that you can have different apperances depending on the game type). On pickup, the game type is checked again, and you award the amount of health needed by calling A_GiveInventory with one of two custom health items.
User avatar
ChronoSeth
Posts: 1631
Joined: Mon Jul 05, 2010 2:04 pm
Location: British Columbia

Re: Custom health, deathmatch / SP

Post by ChronoSeth »

What I came up with is very similar to what DavidN suggested. I haven't tested it, so I probably messed up the syntax somewhere, but something like this should work. I think these features are old enough that Zandronum supports them by now.

The only obvious problem I can think of with this idea is that the item will always have the same pickup message. I don't know if that can be worked around with ACS somehow.

Code: Select all

Actor HealthPickup : CustomInventory
{
	[properties go here]
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIf (CallACS("DeathmatchCheck") == 1, "Deathmatch")
			HLTH A 1
			Wait
		Deathmatch:
			HLTH B 1
			Loop
		Pickup:
			TNT1 A 0 A_JumpIf (health >= 100, "Full")	// Cannot pick up if health is full.
			TNT1 A 0 A_JumpIf (CallACS("DeathmatchCheck") == 1, "DeathmatchPickup")
			TNT1 A 0 HealThing (25)
			Stop
		DeathmatchPickup:
			TNT1 A 0 HealThing (50)
			Stop
		Full:
			TNT1 A 0
			Fail
	}
}

Script "DeathmatchCheck" (void)	// Returns 1 if deathmatch, 0 if other game mode.
{
	If (GameType() != GAME_NET_DEATHMATCH)
	{
		SetResultValue (0);
	}
	Else
	{
		SetResultValue (1);
	}
}
User avatar
DBThanatos
Posts: 3101
Joined: Fri Apr 14, 2006 3:17 pm
Location: in "the darkness that lurks in our mind"

Re: Custom health, deathmatch / SP

Post by DBThanatos »

Thank you very much guys. That indeed was the solution!

Here's the final code used.

Code: Select all

ACTOR MedikitReplacer : CustomInventory replaces Medikit
{
    Inventory.PickupMessage "Large Health"
    Inventory.PickupSound "quake4/Misc/PickLargeHealth"
    Inventory.RespawnTics 700
    States
    {
    Spawn:
        TNT1 A 0
        TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("DMCheck",0,0,0,0)==1,"DMSpawn")
        Goto SPSpawn
    SPSpawn:
        TNT1 A 0 A_SetScale(0.15)
        Q4HE A -1
        Stop
    DMSpawn:
        TNT1 A 0 A_SetScale(0.16)
        TNT1 A 0 A_SetTranslucent(1,1)
        TNT1 A 0 A_ChangeFlag("FLOATBOB",1)
        MGHL ABCDEFGHIJKLMNOP 2 Bright
        Goto DMSpawn+3
    Pickup:
        TNT1 A 0 A_JumpIf(health >= 100, "Full")   // Cannot pick up if health is full.
        TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("DMCheck",0,0,0,0)==1, "DeathmatchPickup")
        TNT1 A 0 HealThing (25)
        Stop
    DeathmatchPickup:
        TNT1 A 0 HealThing (50)
        Stop
    Full:
        TNT1 A 0
        Fail
    }
} 
The only "issue" I found is that I cannot change the translation of the "MGHL" sprites, since I used a common set of sprites to translate to green, orange, blue health bubbles in different actors. But that can be easily fixed by simply adding pre-colored sprites, instead of using translations.

Once again, thanks a lot! :cheers:
User avatar
DavidN
 
 
Posts: 266
Joined: Mon Dec 28, 2015 6:22 pm

Re: Custom health, deathmatch / SP

Post by DavidN »

Excellent :) I'd forgotten about HealThing() - that saves a step!
Locked

Return to “Editing (Archive)”