- Joined
- Mar 11, 2017
- Messages
- 587
Script
Mission Description
Changelog
InitTrig_CrashCourse() is the initializer: It will call the single function required for Crash Course 5 ( cc5() ), then will go on setting up the global variables required for crash course 7.
cc7 task was accomplished with several triggers that count 3 kinds of order separately( cc7pointorder(), cc7targetorder(), cc7order() ), output the three counts upon hero selection (cc7select() ) , and clear the data upon pressing Esc ( cc7part2() )
cc7 task was accomplished with several triggers that count 3 kinds of order separately( cc7pointorder(), cc7targetorder(), cc7order() ), output the three counts upon hero selection (cc7select() ) , and clear the data upon pressing Esc ( cc7part2() )
JASS:
globals
hashtable Hash = null //cc5
unit Hero //for cc7
endglobals
function cc5 takes nothing returns nothing
call SaveUnitHandle(Hash,123456789,0,CreateUnit(Player(0),'hfoo',0.,0.,270.0))
call DisplayTimedTextToPlayer(Player(0),0.,0.,30.,GetUnitName(LoadUnitHandle(Hash,123456789,0)))
call RemoveSavedHandle(Hash,123456789,0)
endfunction
function cc7pointorder takes nothing returns boolean
local integer n
set n = ( LoadInteger(Hash,GetHandleId(GetTriggerUnit()),76) ) + 1
call SaveInteger(Hash,GetHandleId(GetTriggerUnit()),76,n)
return false
endfunction
function cc7targetorder takes nothing returns boolean
local integer n
set n = ( LoadInteger(Hash,GetHandleId(GetTriggerUnit()),77) ) + 1
call SaveInteger(Hash,GetHandleId(GetTriggerUnit()),77,n)
return false
endfunction
function cc7order takes nothing returns boolean
local integer n
set n = ( LoadInteger(Hash,GetHandleId(GetTriggerUnit()),75) ) + 1
call SaveInteger(Hash,GetHandleId(GetTriggerUnit()),75,n)
return false
endfunction
function cc7select takes nothing returns boolean
local string p //for point-orders
local string t //for targeted-orders
local string u //for untargeted-orders
set p = ( "amount of point orders issued: " + I2S(LoadInteger(Hash,GetHandleId(GetTriggerUnit()),76)) + "\n" )
call DisplayTimedTextToPlayer(Player(0),0.,0.,6.,p)
set t = ( "amount of targeted orders issued: " + I2S(LoadInteger(Hash,GetHandleId(GetTriggerUnit()),77)) + "\n" )
call DisplayTimedTextToPlayer(Player(0),0.,0.,6.,t)
set u = ( "amount of untargeted orders issued: " + I2S(LoadInteger(Hash,GetHandleId(GetTriggerUnit()),75)) + "\n" )
call DisplayTimedTextToPlayer(Player(0),0.,0.,6.,u)
set p = null
set t = null
set u = null
return false
endfunction
function cc7part2 takes nothing returns boolean
call FlushChildHashtable(Hash, GetHandleId(Hero))
call DisplayTimedTextToPlayer(Player(0),0.,0.,6.,"Counts reset.")
return false
endfunction
//===========================================================================
function InitTrig_CrashCourse takes nothing returns nothing
local trigger t = CreateTrigger()
set Hash = InitHashtable() //initializing a global variable with a function here
call cc5() //crash course 5. simplest use of a hashtable like a 2-keys array storage
set Hero = CreateUnit(Player(0),'Opgh',100.,100.,270.0) //crash course 7. creating a Hero
call SaveInteger(Hash,GetHandleId(Hero),76,0) //initialize the specific order-type counter to 0 (point)
call SaveInteger(Hash,GetHandleId(Hero),77,0) //initialize the specific order-type counter to 0 (targeted)
call SaveInteger(Hash,GetHandleId(Hero),75,0) //initialize the specific order-type counter to 0 (orders that use no point nor target)
call TriggerRegisterUnitEvent(t,Hero,ConvertUnitEvent(76)) //cc7. point order
call TriggerAddCondition(t, Condition(function cc7pointorder))
set t = CreateTrigger()//cc7. target order
call TriggerRegisterUnitEvent(t,Hero,ConvertUnitEvent(77))
call TriggerAddCondition(t, Condition(function cc7targetorder))
set t = CreateTrigger()//cc7. no-target, no-point order
call TriggerRegisterUnitEvent(t,Hero,ConvertUnitEvent(75))
call TriggerAddCondition(t, Condition(function cc7order))
set t = CreateTrigger() //cc7 upon hero selection
call TriggerRegisterUnitEvent(t,Hero,ConvertUnitEvent(57))
call TriggerAddCondition(t, Condition(function cc7select))
set t = CreateTrigger() //cc7 part 2. flush the hash
call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_END_CINEMATIC)
call TriggerAddCondition(t, Condition(function cc7part2))
set t = null
endfunction
Code:
function InitTrig_CrashCourse takes nothing returns nothing
local trigger t = CreateTrigger()
set Hash = InitHashtable() //initializing a global variable with a function here
call cc5() //crash course 5. simplest use of a hashtable like a 2-keys array storage
set Hero = CreateUnit(Player(0),'Opgh',100.,100.,270.0) //crash course 7. creating a Hero
call SaveInteger(Hash,GetHandleId(Hero),76,0) //initialize the specific order-type counter to 0 (point)
call SaveInteger(Hash,GetHandleId(Hero),77,0) //initialize the specific order-type counter to 0 (targeted)
call SaveInteger(Hash,GetHandleId(Hero),75,0) //initialize the specific order-type counter to 0 (orders that use no point nor target)
call TriggerRegisterUnitEvent(t,Hero,ConvertUnitEvent(76)) //cc7. point order
call TriggerAddCondition(t, Condition(function cc7pointorder))
set t = CreateTrigger()//cc7. target order
call TriggerRegisterUnitEvent(t,Hero,ConvertUnitEvent(77))
call TriggerAddCondition(t, Condition(function cc7targetorder))
set t = CreateTrigger()//cc7. no-target, no-point order
call TriggerRegisterUnitEvent(t,Hero,ConvertUnitEvent(75))
call TriggerAddCondition(t, Condition(function cc7order))
set t = CreateTrigger() //cc7 upon hero selection
call TriggerRegisterUnitEvent(t,Hero,ConvertUnitEvent(57))
call TriggerAddCondition(t, Condition(function cc7select))
set t = CreateTrigger() //cc7 part 2. flush the hash
call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_END_CINEMATIC)
call TriggerAddCondition(t, Condition(function cc7part2))
set t = null
endfunction
JASS:
function cc5 takes nothing returns nothing
call SaveUnitHandle(Hash,123456789,0,CreateUnit(Player(0),'hfoo',0.,0.,270.0))
call DisplayTimedTextToPlayer(Player(0),0.,0.,30.,GetUnitName(LoadUnitHandle(Hash,123456789,0)))
call RemoveSavedHandle(Hash,123456789,0)
endfunction
JASS:
function cc7pointorder takes nothing returns boolean
local integer n
set n = ( LoadInteger(Hash,GetHandleId(GetTriggerUnit()),76) ) + 1
call SaveInteger(Hash,GetHandleId(GetTriggerUnit()),76,n)
return false
endfunction
function cc7targetorder takes nothing returns boolean
local integer n
set n = ( LoadInteger(Hash,GetHandleId(GetTriggerUnit()),77) ) + 1
call SaveInteger(Hash,GetHandleId(GetTriggerUnit()),77,n)
return false
endfunction
function cc7order takes nothing returns boolean
local integer n
set n = ( LoadInteger(Hash,GetHandleId(GetTriggerUnit()),75) ) + 1
call SaveInteger(Hash,GetHandleId(GetTriggerUnit()),75,n)
return false
endfunction
JASS:
function cc7select takes nothing returns boolean
local string p //for point-orders
local string t //for targeted-orders
local string u //for untargeted-orders
set p = ( "amount of point orders issued: " + I2S(LoadInteger(Hash,GetHandleId(GetTriggerUnit()),76)) + "\n" )
call DisplayTimedTextToPlayer(Player(0),0.,0.,6.,p)
set t = ( "amount of targeted orders issued: " + I2S(LoadInteger(Hash,GetHandleId(GetTriggerUnit()),77)) + "\n" )
call DisplayTimedTextToPlayer(Player(0),0.,0.,6.,t)
set u = ( "amount of untargeted orders issued: " + I2S(LoadInteger(Hash,GetHandleId(GetTriggerUnit()),75)) + "\n" )
call DisplayTimedTextToPlayer(Player(0),0.,0.,6.,u)
set p = null
set t = null
set u = null
return false
endfunction
JASS:
function cc7part2 takes nothing returns boolean
call FlushChildHashtable(Hash, GetHandleId(Hero))
call DisplayTimedTextToPlayer(Player(0),0.,0.,6.,"Counts reset.")
return false
endfunction
Preparation
Following global variables must be declared and used (<type> , <name>):
Create a unit and save it into hashatble. ParentKey = 123456789 ; ChildKey = 0
Part 2
Print the name of the saved unit using the loaded value from hashtable. (you can do it in same function)
Following global variables must be declared and used (<type> , <name>):
- hashtable Hash
Create a unit and save it into hashatble. ParentKey = 123456789 ; ChildKey = 0
Part 2
Print the name of the saved unit using the loaded value from hashtable. (you can do it in same function)
Prepration
Following global variables must be declared and used (<type> , <name>):
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.
Following global variables must be declared and used (<type> , <name>):
- hashtable Hash
- unit Hero
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.
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.
v0 - exercise submission
Seemed simple at first. I beg reviewers to point out to me the (inevitable) errors within.
Attachments
Last edited: