Deleted member 219079
D
Deleted member 219079
SORRY MODS I'M NOT POSTING IT HERE ON OFF-TOPIC TO BE RUDE OR SOMETHING, I just.. World Editor Help Zone, no... JASS Class, h*ll no... Map Development, uh no... Triggers & Scripts, oh yes, wait, "In this forum you may ask for help on fixing a trigger or script." k not then... yeah..? Where's the WE Discussion Sub-Forum?
jondrean's Below 100-line useful code challenge
Example GUI usage trigger:
Video of 1.0.1 in action, running ~400 instances constantly:
Triggers for looping action:
Rules:
Rewards:
Edit: Updated my own mini system to 1.0.1 (some bug fixes and on death function feature added, 100 rows)
jondrean's Below 100-line useful code challenge
JASS:
//! textmacro NewMotion takes TYPE, DYNAMIC, PARAMETERS, PREFIX
function $TYPE$Motion takes $PARAMETERS$ returns nothing
local motiondata data
local timer t
if TAKEN[GetUnitIndex($PREFIX$u)] then
return
endif
set data = motiondata.create()
set t = NewTimer()
call SetTimerData(t,data)
call UnitAddAbility($PREFIX$u, FLY_ID)
call UnitRemoveAbility($PREFIX$u, FLY_ID)
set TAKEN[GetUnitIndex($PREFIX$u)] = true
set data.d = $DYNAMIC$
set data.ef = $PREFIX$endfunc
set data.g = 0
set data.uX = GetUnitX($PREFIX$u)
set data.uY = GetUnitY($PREFIX$u)
set data.uZ = GetUnitZ($PREFIX$u)
set data.u = $PREFIX$u
set data.x = $PREFIX$x
set data.y = $PREFIX$y
set data.z = $PREFIX$z
set data.b = $PREFIX$bounce
call TimerStart(t, 0.03125, true, function Step)
endfunction
//! endtextmacro
//! textmacro InsertEnd
set TAKEN[GetUnitIndex(data.u)]=false
call SetUnitZ(data.u, 0)
if data.ef != "" then
set udg_MS_u = data.u
call ExecuteFunc(data.ef)
endif
set data.u = null
call data.destroy()
call ReleaseTimer(t)
//! endtextmacro
library MotionSystem /*v.1.0.1*/ requires TimerUtils, PUI //or other unit indexer
globals
private constant location L = Location(0,0)
private constant integer FLY_ID = 'Arav'
private boolean array TAKEN
endglobals
struct motiondata
unit u
string ef
real uX
real uY
real uZ
real x
real y
real z
real b
real g
boolean d
endstruct
private function GetUnitZ takes unit u returns real
if GetUnitFlyHeight(u) <= 1 then
return 0.
endif
call MoveLocation(L, GetUnitX(u), GetUnitY(u))
return GetLocationZ(L) + GetUnitFlyHeight(u)
endfunction
private function SetUnitZ takes unit u, real height returns nothing
call MoveLocation(L, GetUnitX(u), GetUnitY(u)) //z height of terrain belove u
call SetUnitFlyHeight(u, height-GetLocationZ(L), 0) //minus the height of terrain, it automatically raises the unit z already
endfunction
private function Step takes nothing returns nothing
local timer t = GetExpiredTimer()
local motiondata data = GetTimerData(t)
set data.g = data.g + 0.5
if not data.d then
set data.uX = data.uX + data.x
set data.uY = data.uY + data.y
endif
set data.uZ = data.uZ + data.z - data.g
if data.uZ > 0 then
if data.d then
call SetUnitX(data.u, GetUnitX(data.u)+data.x)
call SetUnitY(data.u, GetUnitY(data.u)+data.y)
else
call SetUnitX(data.u, data.uX)
call SetUnitY(data.u, data.uY)
endif
call SetUnitZ(data.u, data.uZ)
else
set data.x = data.x * data.b
set data.y = data.y * data.b
set data.z = data.z * data.b
set data.g = 0
if data.z < 2 then
//! runtextmacro InsertEnd()
endif
endif
endfunction
//! runtextmacro NewMotion ("", "false","unit u, real x, real y, real z, real bounce, string endfunc","")
//! runtextmacro NewMotion ("Free", "false","unit u, real x, real y, real z, real bounce, string endfunc","")
//! runtextmacro NewMotion ("GUI", "udg_MS_free","nothing","udg_MS_")
endlibrary
Example GUI usage trigger:
-
ASD
-
Events
- Player - Player 1 (Red) types a chat message containing asd as An exact match
- Conditions
-
Actions
- Custom script: local real angle = 0
- Custom script: local real speed
- Custom script: set udg_count = GetRandomInt(15,20)
-
For each (Integer i) from 1 to count, do (Actions)
-
Loop - Actions
- Custom script: set speed = GetRandomReal(4.6,6.0)
- Custom script: set angle = angle + (360/udg_count) + GetRandomReal(-15.,15.)
- Custom script: set udg_MS_u = CreateUnit(Player(0),'h000',0,0,angle)
- Custom script: //! runtextmacro InsertCoordCalculation("Cos","udg_MS_x")
- Custom script: //! runtextmacro InsertCoordCalculation("Sin","udg_MS_y")
- Set MS_endfunc = Trig_END_Actions
- Set MS_bounce = 0.60
- Set MS_free = False
- Set MS_z = (Random real number between 10.00 and 15.00)
- Custom script: call GUIMotion()
-
Loop - Actions
-
Events
Video of 1.0.1 in action, running ~400 instances constantly:
-
LOOP
-
Events
- Time - Elapsed game time is 2.00 seconds
- Conditions
-
Actions
- -------- (text macro's in the header code) --------
- -------- //! textmacro InsertCoordCalculation takes TYPE, VARIABLE --------
- -------- set $VARIABLE$ = speed * $TYPE$(angle * bj_DEGTORAD) --------
- -------- //! endtextmacro --------
- Custom script: local real angle = GetRandomReal(0,360)
- Custom script: local real speed
- Custom script: set speed = GetRandomReal(4.6,6.0)
- Custom script: set udg_MS_u = CreateUnit(Player(0),'h000',0,0,angle)
- Custom script: //! runtextmacro InsertCoordCalculation("Cos","udg_MS_x")
- Custom script: //! runtextmacro InsertCoordCalculation("Sin","udg_MS_y")
- Set MS_endfunc = Trig_END_Actions
- Set MS_bounce = 0.60
- Set MS_free = False
- Set MS_z = (Random real number between 10.00 and 15.00)
- Custom script: call GUIMotion()
- Custom script: if GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_FOOD_USED) < 400 then
- Trigger - Run (This trigger) (ignoring conditions)
- Custom script: endif
-
Events
-
END
- Events
- Conditions
-
Actions
- Unit - Kill MS_u
- Custom script: if GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_FOOD_USED) < 400 then
- Trigger - Run LOOP <gen> (ignoring conditions)
- Custom script: endif
Rules:
- You can use known libraries/Utils for your help
- Just for fun, if you're as enthuastic coder as me you may like it
- Try to make something which can be used for useful purposes on a map
- It must work
- It can be GUI, you just need to count it from start of events block to the last function row
Rewards:
A compliment
Edit: Updated my own mini system to 1.0.1 (some bug fixes and on death function feature added, 100 rows)
Last edited by a moderator: