Difference between revisions of "Tint projectiles based on player"

From HIVE
Jump to navigation Jump to search
 
m (1 revision: StarEdit.net Wiki)
 
(No difference)

Latest revision as of 06:16, 21 November 2010

If you want the missiles of your unit to be colored based on the player that casts it, this tutorial is for you!

The fact that I am using 4 upgrades, requirements, validators, events, etc. is because I'm going to make the game tint the projectiles of 4 different players.

General concept

We'll use Validators to detect which Custom Upgrade a player's caster-unit has. We'll also have to give this upgrade to the players via triggers.

Upgrades

Create 4 blank upgrades and you're done for this part!

Requirements

Create 4 requirements of Tech Type "Upgrade".

In the Requirements + field, remove anything you see. From there, add a new value (right click -> Add Node) to the Use field and select "Equals".

Now, add a new value to the Equals: "Count Upgrade". From there, choose the corresponding upgrade as the Alias and select Completed as the State.

You'll also need to create a new Node that will correspond to the Upgrade Count. Do as follow: create a new value to the Equals, select Constant and set it to 1.

You'll do this for the 4 requirements, one different upgrade per requirement, but always setting the Constant to 1.

Validators

Create 4 Validators of type Player Requirement.

Make sure the field Validator - Player + is set to "Caster Origin".

Change the field Validator - Value to the corresponding Requirement.

Actors

Go to your missile unit (Ammo Unit)'s Actor tab and change the Event - Events +: right-click to make a new Event. The Event's type should be Actor Creation (since we always want the actor to be tinted).

Now, right-click on the Event and click on "Add Term". Change the Term type to ValidatePlayer and change the Validator to one of the 4 you've created.

Next step is to set the Action's "Msg Type" to Set Tint Color. All you'll want to change in this is the "Color" field.

Repeat this 3 more times, adding a new Event for each player (remember we're making this for four players, hence the fact that we're doing 4 times everything).

Triggers

Now, using a Map Initialization event, you'll want to create a "Set Upgrade Level For Player" action and give a level 1 upgrade for all the 4 players (remember you've created 4 different upgrades, one for each player).

Other techniques

There are multiple ways to achieve this. Some are easier, but may not fit most of the situations.

Alternative #1

We could use 1 upgrade and 4 constants (the difference would be in the triggers: you'd set a level value to the upgrade instead of different upgrades of level 1).

Alternative #2

We could use resources.

The only thing this technique requires is 4 different Validators of type "Player Compare Resource". From there, you change the fields Validator - Compare, Validator - Resource and Validator - Value. Don't forget to verify that the Validator - Player + field is set to "Player Origin".

As for the triggers, we'd have to use a "Modify Player Property" action.

IMPORTANT NOTE: You shouldn't use this technique if the resource amount a player has might change during the game.

Thanks

This is mostly a put-together form, resulting from a discussion between Temp and shmeeps.