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

[ZScript] Passing a string to a script called from ZScript

Question

Hi everyone,

 

is it possible to pass a string to an ACS script? I have these two pieces of code and they work nicely together:
 

Spoiler

ZScript:

 


override void Tick()
	{
		super.Tick();
		FLineTraceData RemoteRay;
		double pz = height * 0.5 - floorclip + player.mo.AttackZOffset*player.crouchFactor;
		bool hit = LineTrace(
				angle,
				1000,
				pitch,
				offsetz: pz,
				data: RemoteRay
			);
		if(hit && RemoteRay.HitType == TRACE_HitActor && RemoteRay.HitActor.bISMONSTER == TRUE)
		{
			ACS_NamedExecute("EnemyHealthCheck", 0, RemoteRay.HitActor.health, RemoteRay.HitActor.SpawnHealth());
		}
		else
		{
			ACS_NamedTerminate("EnemyHealthCheck", 0);
		}
	}

 

ACS:

 


script "EnemyHealthCheck" (int currentHealth, int spawnHealth)
{
	str colour = "GREEN";
	if(currentHealth < (spawnHealth / 3) * 2)
		colour = "YELLOW";
	if(currentHealth < spawnHealth / 3)
		colour = "RED";
	SetFont("BIGFONT");
	HudMessage(d:currentHealth, s:" / ", d:spawnHealth; HUDMSG_PLAIN | HUDMSG_COLORSTRING, 0, colour, 0.5, 0.075, 0.1);
	SetFont("SMALLFONT");
	HudMessage(s:"Enemy health:"; HUDMSG_PLAIN, 1, CR_WHITE, 0.5, 0.05, 0.1);
}

 

 

But I would like to replace the 'enemy health' string with monster name, but AFAIK A_NamedExecute() only accepts integers as arguments; is there a way? Or way around it?

 

Thanks!

Share this post


Link to post

3 answers to this question

Recommended Posts

  • 1

You make an event handler and register it in Mapinfo's Gameinfo definition. (more on https://zdoom.org/wiki/Events_and_handlers)

 

In the event handler you can override the RenderOverlay method, and from this method you can call functions of Screen, such as DrawText or DrawTexture, which... draw things like text or images on screen.

Share this post


Link to post
  • 1

I don't think there is, unfortunately.

The only way to do what you want is probably by doing everything in ZSCRIPT, which it should be easily possible, with Events

Share this post


Link to post
  • 0

Well, I dunno how to do it with events, so I would be grateful for pointers/guide/WAD to learn from. I tried playing around with ZScript Status bar but can't crack it.

 

In the meantime, I managed to partially resolve it by having the LineTrace HitActor call the script and then I use GetActorClass().

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
×