- Joined
- Jul 12, 2010
- Messages
- 1,719
How to use Jass without Jass Class Core System?
Here is an example of a JASS Class code:
BUT in order for it to work we need this Core System:
How can i make a code that does the same thing exactly as the first one BUT without using that core system?
How can i choose WHEN i want the trigger to run?
GUI examples:
Here is an example of a JASS Class code:
JASS:
//! runtextmacro Variables()
unit u
integer i
real r
string s
//! runtextmacro Actions()
set u = CreateUnit(Player(0), 'hfoo', 0.00, 0.00, 270)
set i = 5+67+8*10
set r = GetRandomReal(1.00, 50.00)
set s = UnitId2String('u')
call PrintInteger(i)
call PrintReal(r)
call Print(s)
//! runtextmacro End_Code()
BUT in order for it to work we need this Core System:
JASS:
native GetPlayerUnitTypeCount takes player p, integer unitid returns integer
native GetUnitGoldCost takes integer unitid returns integer
native GetUnitWoodCost takes integer unitid returns integer
native GetUnitBuildTime takes integer unitid returns integer
native CreepsOnMap takes nothing returns boolean
native UnitAlive takes unit id returns boolean
library Core
function Print takes string msg returns nothing
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60000,msg)
endfunction
function PrintInteger takes integer i returns nothing
call Print(I2S(i))
endfunction
function PrintReal takes real r returns nothing
call Print(R2SW(r, 0, 9))
endfunction
endlibrary
//! textmacro Variables
globals
//! endtextmacro
//! textmacro Actions
endglobals
function Run takes nothing returns nothing
//! endtextmacro
//! textmacro End_Code
endfunction
struct Init extends array
private static method init takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
call Run.execute()
endmethod
private static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(),0,false,function thistype.init)
endmethod
endstruct
//! endtextmacro
//! textmacro Function
function Run takes nothing returns nothing
//! endtextmacro
//! textmacro Lesson2
local attacktype test
set hello = null
set test = hello
//! endtextmacro
//! textmacro Lesson6
function TheFunction takes nothing returns nothing
endfunction
function DisplayMessage takes nothing returns nothing
call Print("You have called Display Message")
endfunction
//! endtextmacro
//! textmacro Project1
struct Project1 extends array
private static method check takes nothing returns nothing
local integer unitCount = 0
local integer surviveCount = 0
local group g = CreateGroup()
local unit u
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
if (UnitAlive(u)) then
set unitCount = unitCount + 1
if (GetOwningPlayer(u) == Player(0)) then
set surviveCount = surviveCount + 1
endif
endif
endloop
if (surviveCount == unitCount) then
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
call Print("Congragulations "+GetPlayerName(Player(0))+", you won!")
endif
call DestroyGroup(g)
set g = null
endmethod
private static method onInit takes nothing returns nothing
set player0 = Player(0)
set player1 = Player(1)
set player2 = Player(2)
set player3 = Player(3)
set player4 = Player(4)
set player5 = Player(5)
set player6 = Player(6)
set player7 = Player(7)
set player8 = Player(8)
set player9 = Player(9)
set player10 = Player(10)
set player11 = Player(11)
call TimerStart(CreateTimer(),.03125,true,function thistype.check)
endmethod
endstruct
//! endtextmacro
//! textmacro Lesson14
struct Lesson14 extends array
private static method onInit takes nothing returns nothing
set i[4] = 2422
set i[23] = 14291
set i[931] = 14
set i[0] = 99
set i[93] = -4214
set i[999] = 999
endmethod
endstruct
//! endtextmacro
//! textmacro Lesson14P2
struct Lesson14P2 extends array
private static method init takes nothing returns nothing
local group g
local unit u
call SetUnitScale(riflez[1423], 5, 5, 5)
if (riflez[1423] == null) then
set g = CreateGroup()
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
call Print(GetUnitName(u) + " is set to the wrong position")
endloop
call DestroyGroup(g)
set g = null
return
else
call Print(GetUnitName(riflez[1423])+" is set to the correct position")
endif
if (GetOwningPlayer(riflez[1423]) != Player(2)) then
call Print("Unit owner is incorrect")
return
endif
call SetPlayerAlliance(Player(2), Player(0), ALLIANCE_SHARED_VISION_FORCED, true)
endmethod
private static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(),.1,false,function thistype.init)
endmethod
endstruct
//! endtextmacro
How can i choose WHEN i want the trigger to run?
GUI examples:
- Map initialization
- Unit - A unit Dies
- Player - Player 1 (Red) leaves the game
- Unit - A unit Begins channeling an ability
- Time - Elapsed game time is 5.00 seconds
- Player - Player 1 (Red) Presses the Left Arrow key
- Unit - Peasant 0001 <gen>'s life becomes Less than 100.00
- Player - Player 1 (Red) types a chat message containing test as An exact match