BlockThingsIterator confusion

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Silentdarkness12
Posts: 1555
Joined: Thu Aug 15, 2013 5:34 pm
Location: Plains of Pride

BlockThingsIterator confusion

Post by Silentdarkness12 »

I'm working on a Hideous Destructor addon, and there is this chunk of code I am struggling to make work. I want the actor in question(which is a weapon if that matters) to do a line of sight and proximity check for HDBarrel and BarrelGremlin(the actor that attacks from HDBarrel) and then sets state accordingly.

Code: Select all

ThinkerIterator GremlinIterator = ThinkerIterator.Create("BarrelGremlin");
	BlockThingsIterator BarrelIterator = BlockThingsIterator.Create(self,100.0);
	BarrelGremlin grem;
	HDBarrel gbar;
	HDBarrel barbar;
	while(grem = BarrelGremlin(GremlinIterator.Next()))
		{
		if(grem.master.GetClassName() == "HDBarrel")
			{
			gbar = HDBarrel(grem.master);
			}
			else
			{
			A_Log("Orphaned Gremlin?!");
			}
		}
		if(IsVisible(BarrelIterator.Actor("HDBarrel"),false,null)&& CheckProximity(BarrelIterator.Actor("HDBarrel"),100.0,1,CPXF_SETTARGET))
					{
					SetStateLabel("BarrelWarn");
					}
					else if(IsVisible(barbar,false,null)&& CheckProximity(barbar.GetClassName(),100.0,1,CPXF_SETTARGET))
					{
					SetStateLabel("BarrelSucc");
					}
	}
I've tried a number of different combinations but I can't make it work. It always throws a failure to convert error at me or some other if syntax nonsense. How exactly am I supposed to use BlockThingsIterator to pass the information I want to the else if here?
Post Reply

Return to “Scripting”