Extra global variables are not allowed.
Part 1
Create a (JASS) trigger that runs (only) when Hero makes a point order.
Create a (JASS) trigger that runs (only) when Hero makes a target order.
Create a (JASS) trigger that runs (only) when Hero makes an order without target.
Create a (JASS) trigger that runs when you select the Hero.
The trigger's goal is to print following values on screen:
Tip: You must use the first three triggers to count the different orders, and use hashtable to bind the values to the unit.
Part 2
Create a (JASS) trigger that runs when a player presses the 'Esc' button.
The trigger's goal is to clean the hashtable of all it's entries.
Part 1
Create a (JASS) trigger that runs (only) when Hero makes a point order.
Create a (JASS) trigger that runs (only) when Hero makes a target order.
Create a (JASS) trigger that runs (only) when Hero makes an order without target.
Create a (JASS) trigger that runs when you select the Hero.
The trigger's goal is to print following values on screen:
- PointOrders: X
- TargetOrders: Y
- NontargetOrders: Z
Tip: You must use the first three triggers to count the different orders, and use hashtable to bind the values to the unit.
vJASS:
//! zinc
library Hashtable2 {
private {
hashtable hash = InitHashtable();
unit hero;
function onInit() {
trigger trgPointOrder = CreateTrigger();
trigger trgTargetOrder = CreateTrigger();
trigger trgIssuedOrder = CreateTrigger();
trigger trgSelectUnit = CreateTrigger();
integer Index = 0;
hero = CreateUnit( Player(0), 'Utic', 0, 0, 0 );
while( Index < bj_MAX_PLAYERS ) {
TriggerRegisterPlayerUnitEvent( trgPointOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null );
TriggerRegisterPlayerUnitEvent( trgTargetOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null );
TriggerRegisterPlayerUnitEvent( trgIssuedOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_ORDER, null );
TriggerRegisterPlayerUnitEvent( trgSelectUnit, Player( Index ), EVENT_PLAYER_UNIT_SELECTED, null );
Index = Index + 1;
}
TriggerAddAction( trgPointOrder, function(){
if( GetOrderedUnit() == hero ) {
SaveInteger( hash, 0, 0, LoadInteger( hash, 0, 0 ) + 1 );
}
});
TriggerAddAction( trgTargetOrder, function(){
if( GetOrderedUnit() == hero ) {
SaveInteger( hash, 0, 1, LoadInteger( hash, 0, 1 ) + 1 );
}
});
TriggerAddAction( trgIssuedOrder, function(){
if( GetOrderedUnit() == hero ) {
SaveInteger( hash, 0, 2, LoadInteger( hash, 0, 2 ) + 1 );
}
});
TriggerAddAction( trgSelectUnit, function(){
if( GetTriggerUnit() == hero ) {
ClearTextMessages();
DisplayTextToPlayer( GetLocalPlayer(), 0, 0,
"PointOrders: " + I2S( LoadInteger( hash, 0, 0 ) ) + "\n" +
"TargetOrders: " + I2S( LoadInteger( hash, 0, 1 ) ) + "\n" +
"NontargetOrders: " + I2S( LoadInteger( hash, 0, 2 ) )
);
}
});
trgPointOrder = null;
trgTargetOrder = null;
trgIssuedOrder = null;
trgSelectUnit = null;
}
}
}//! endzinc
Part 2
Create a (JASS) trigger that runs when a player presses the 'Esc' button.
The trigger's goal is to clean the hashtable of all it's entries.
vJASS:
//! zinc
library Hashtable2 {
private {
hashtable hash = InitHashtable();
unit hero;
function onInit() {
trigger trgPointOrder = CreateTrigger();
trigger trgTargetOrder = CreateTrigger();
trigger trgIssuedOrder = CreateTrigger();
trigger trgSelectUnit = CreateTrigger();
trigger trgESC = CreateTrigger();
integer Index = 0;
hero = CreateUnit( Player(0), 'Utic', 0, 0, 0 );
while( Index < bj_MAX_PLAYERS ) {
TriggerRegisterPlayerUnitEvent( trgPointOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null );
TriggerRegisterPlayerUnitEvent( trgTargetOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null );
TriggerRegisterPlayerUnitEvent( trgIssuedOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_ORDER, null );
TriggerRegisterPlayerUnitEvent( trgSelectUnit, Player( Index ), EVENT_PLAYER_UNIT_SELECTED, null );
TriggerRegisterPlayerEvent( trgESC, Player( Index ), EVENT_PLAYER_END_CINEMATIC );
Index = Index + 1;
}
TriggerAddAction( trgPointOrder, function(){
if( GetOrderedUnit() == hero ) {
SaveInteger( hash, 0, 0, LoadInteger( hash, 0, 0 ) + 1 );
}
});
TriggerAddAction( trgTargetOrder, function(){
if( GetOrderedUnit() == hero ) {
SaveInteger( hash, 0, 1, LoadInteger( hash, 0, 1 ) + 1 );
}
});
TriggerAddAction( trgIssuedOrder, function(){
if( GetOrderedUnit() == hero ) {
SaveInteger( hash, 0, 2, LoadInteger( hash, 0, 2 ) + 1 );
}
});
TriggerAddAction( trgSelectUnit, function(){
if( GetTriggerUnit() == hero ) {
ClearTextMessages();
DisplayTextToPlayer( GetLocalPlayer(), 0, 0,
"PointOrders: " + I2S( LoadInteger( hash, 0, 0 ) ) + "\n" +
"TargetOrders: " + I2S( LoadInteger( hash, 0, 1 ) ) + "\n" +
"NontargetOrders: " + I2S( LoadInteger( hash, 0, 2 ) )
);
}
});
TriggerAddAction( trgESC, function(){
FlushChildHashtable( hash, 0 );
});
trgPointOrder = null;
trgTargetOrder = null;
trgIssuedOrder = null;
trgSelectUnit = null;
trgESC = null;
}
}
}//! endzinc