Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Scripting 16 - Fire

A smaller forum with a few tutorials how to get started with the ScriptAPI.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1676
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 29

Scripting 16 - Fire

Post by Gurt » Sun Aug 11, 2019 1:14 pm

Scripting 16 - Fire

Scripting in SFD assumes you have a fair knowledge of C#.

The following code demonstrates how to read and remove fire. Available in v.1.3.1.

This is a limited instruction set. All you can do is to read a limited set of data from current fire nodes and remove individual fire nodes in the game. The fire system is old and this is what can easily be done in the API without refactoring a huge set of code.

Code: Select all

// Example how to create a "no-fire zone" around the middle of the map
public void OnStartup()
{
	Events.UpdateCallback.Start(OnUpdate, 0);
}
	
public void OnUpdate(float ms)
{	
	// No fire zone
	Area area = new Area(new Vector2(-32f, -32f), new Vector2(32f, 32f));
	
	Game.DrawArea(area, Color.Yellow);

	FireNode[] fireNodes = Game.GetFireNodes(area);
	foreach(FireNode fireNode in fireNodes)
	{
		if (fireNode.AttachedToObjectID != 0)
		{
			Game.EndFireNode(fireNode.InstanceID);
		}
	}
	foreach(IObject obj in Game.GetBurningObjects())
	{
		if (area.Contains(obj.GetWorldPosition()))
		{
			obj.ClearFire();
		}
	}
}
ScriptAPI Implementation
► Show Spoiler
2 x
Gurt

NearHuscarl
Fighter
Fighter
Posts: 22
Joined: Thu Feb 07, 2019 4:36 am

Post by NearHuscarl » Mon Aug 12, 2019 2:38 am

Since you add FireNode. IGame.SpawnFireNode() and IGame.SpawnFireNodes() should return FireNode and FireNode[] respectively instead of void
2 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1676
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 29

Post by Gurt » Mon Aug 12, 2019 12:10 pm

NearHuscarl wrote:
Mon Aug 12, 2019 2:38 am
Since you add FireNode. IGame.SpawnFireNode() and IGame.SpawnFireNodes() should return FireNode and FireNode[] respectively instead of void
Good idea! Adding it to the next update.
1 x
Gurt

Post Reply