- Joined
- Sep 12, 2011
- Messages
- 47
Idea is nice, but is this really needed.Warning!
The declaration of variables like that is supported only for this types:
timer
group
force
region
trigger
dialog
leaderboard
multiboard
quest
texttag
camerasetup
hashtable
Awesome idea, dunno why something like this wasn't included by Blizzard.Multiple global variable declaration
Sometimes we don't want loop to happen even once if conditions aren't true.Loops 'repeat until'
Nice job, cool idea.Untypified variables
library Test
private pointer GetTriggerUnitReal replace GetTriggerUnit
// if this function is not a private one, it will show an error :D
// since the pointer replacement is private
private function GetTriggerUnit takes nothing returns unit
return GetTriggerUnitReal() // this call the native
endfunction
function Test takes nothing returns nothing
local unit u = GetTriggerUnit() // will call the function above
// not the native
// . . . . .
endfunction
endlibrary
You can use cJass defines and macros. Example:
JASS:define { <GetTriggerUnit> = GetTriggerUnitReal } void test() { unit u = GetTriggerUnit() }
library Test
// setreal = sets the real variable of ones taken as arguments
// commands can be used like set/call
// multitakes must only have one argument taken
// using format:
// free YourVar1, YourVar2, YourVar3, . . .
private command free multitakes var v
if var.type == handle then
setreal v = null
elseif var.type == boolean then
setreal v = false
elseif var.type == string then
setreal v = ""
else
setreal v = 0
endif
endcommand
// using format:
// swap YourVar1, YourVar2 (no more, no less)
private command swap takes var v1, var v2
local var s = v1
setreal v1 = v2
setreal v2 = s
free s
endcommand
// commandchar(s) are characters that must be inserted for a requirement of the command
// using format:
// make UnitVariable = UnitId [X, Y]
private command make takes unit u, commandchar =, integer id, commandchar [, real x, real y, commandchar ]
setreal u = CreateUnit(Player(15), id, x, y, 270)
endcommand
// Testing function
function Test takes unit u returns nothing
local unit u1 = GetTriggerUnit()
local unit u2 = GetSpellTargetUnit()
swap u1, u2 // swap values
free u1, u2 // null variables
// these two will be merged above with u1 and u2
local real x = 999
local real y = 111
make u1 = 'hpea' [x, y]
swap x, y
swap u1, u2
make u1 = 'Hblm' [x, y]
free u1, u2
call RemoveUnit(u)
endfunction
returnhook CreateUnit Test // Test will be run everytime CreateUnit is called
// Test must takes one argument with the same type
// as the hooked function returns
endlibrary
integer Example(integer i, real z, unit v) {
handle h
GetTriggerUnit()
h = null
}
// For encapsulation, this would seem nice:
// Exactly what vJass offers:
private function
public function
readonly integer
readonly handle
// Accessible everywhere:
function
// For globals, free declarations just like C++ would be nice.
JASP isn't vJass expansion but is separate preprocessor. He is generally not using vJass features so I think I won't implement any vJass-expanding features.
globals
hashtable hash = InitHashtable()
endglobals
function someFunc takes nothing returns nothing
global hashtable hash = InitHashtable()
endfunction
new global hashtable hash
mount GetTriggerUnit to GetSpellTargetUnit
var u = GetTriggerUnit()
unmount GetTriggerUnit from GetSpellTargetUnit
var us = GetTriggerUnit()
local unit u = GetSpellTargetUnit()
local unit us = GetTriggerUnit()
function Trig_Freezing_Shot_Timer takes nothing returns nothing
//===========================================================================================================================//
// Local variables //
//===========================================================================================================================//
var t = GetExpiredTimer()
var hid = GetHandleId(t)
var caster = LoadUnitHandle(hash, hid, 0)
var dist = LoadReal(hash, hid, 4)
var count = LoadInteger(hash, hid, -1)
var dummy, target, angle, x, y, i = 1
//===========================================================================================================================//
// Timer actions //
//===========================================================================================================================//
if dist <= 750. then
repeat
set dummy = LoadUnitHandle(hash, hid, i)
set angle = GetUnitFacing(dummy) * .017
set x = GetWidgetX(dummy) + 25. * Cos(angle)
set y = GetWidgetY(dummy) +25. * Sin(angle)
call SetUnitPosition(dummy, x, y)
call GroupEnumUnitsInRange(temp, x, y, 75., null)
loop
set target = FirstOfGroup(temp)
exitwhen target == null
if IsUnitEnemy(target, GetOwningPlayer(caster)) and not IsUnitType(target, UNIT_TYPE_STRUCTURE) and not IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) and GetWidgetLife(target) > .405 then
call UnitDamageTarget(caster, target, 100., true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call FastEffect("Abilities\\Weapons\\FrostWyrmMissile\\FrostWyrmMissile.mdl", x, y)
call DummycastToTarget(caster, target, 'A001', 852075)
call SaveInteger(hash, hid, -1, count - 1)
free dummy
endif
call GroupRemoveUnit(temp, target)
endloop
set i = i + 1
until i > 3
call SaveReal(hash, hid, 4, dist + 25.)
elseif dist > 750. or count <= 0 then
repeat
free LoadUnitHandle(hash, hid, i)
set i = i + 1
until i > 3
call FlushChildHashtable(hash, hid)
call PauseTimer(t)
free t
endif
//===========================================================================================================================//
// Flushing variables //
//===========================================================================================================================//
flush t, caster, dummy
endfunction
function Trig_Freezing_Shot_Actions takes nothing returns boolean
//===========================================================================================================================//
// Local variables //
//===========================================================================================================================//
var t, caster, dummy, angle, hid, x, y, i = 1
//===========================================================================================================================//
// Trigger actions //
//===========================================================================================================================//
if GetSpellAbilityId() == 'A000' or GetSpellAbilityId() == 'A002' then
set t = CreateTimer()
set hid = GetHandleId(t)
set caster = GetTriggerUnit()
set x = GetWidgetX(caster)
set y = GetWidgetY(caster)
set angle = Atan2(GetSpellTargetY() - y, GetSpellTargetX() - x) * 57.295 + 25.
call SaveInteger(hash, hid, -1, 3)
call SaveAgentHandle(hash, hid, 0, caster)
call SaveReal(hash, hid, 5, angle)
repeat
set dummy = CreateDummy(GetTriggerPlayer(), "Abilities\\Spells\\Other\\FrostBolt\\FrostBoltMissile.mdl", .3, x, y, 100., angle)
call SaveAgentHandle(hash, hid, i, dummy)
set angle = angle - 25.
set i = i + 1
until i > 3
call TimerStart(t, .04, true, function Trig_Freezing_Shot_Timer)
endif
//===========================================================================================================================//
// Flushing variables //
//===========================================================================================================================//
flush t, caster, dummy
return false
endfunction
//===========================================================================================================================//
// Trigger Initialization //
//===========================================================================================================================//
function InitTrig_Freezing_Shot takes nothing returns nothing
call FogMaskEnable(false)
call FogEnable(false)
set gg_trg_Freezing_Shot = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Freezing_Shot, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Freezing_Shot, Condition(function Trig_Freezing_Shot_Actions))
endfunction
//pardon my c++
int hi(A &a);
----------------------------
int boo = 6;
hi(boo);
function foo takes boolean b
var a
if b
a = 1.
else
a = GetSpellAbilityUnit()
class handle
{
public integer getId();
}
class agent : handle
{
}
class widget : agent
{
public real getX();
public real getY();
public real getLife();
public void setLife(real value);
}
class unit : widget
{
public unit(player p, integer id, real x, real y, real facing);
public void remove();
public void setX(real value);
public void setY(real value);
public real getX();
public real getY();
// etc...
}