- Joined
- Jul 10, 2007
- Messages
- 6,306
[vJASS] The Map Framework
Guide Version- (v.02a)
Anyone who creates quick utilities for giving credits with this format and this usage
will have an Mfn version built for them with their credit type and they will be added to the helper list for that version.
Tired of only Quest Credits? Make your own layout and it will be put out : ).
Why don't I just let users define their own layouts? Obvious reasons ; P. They might be the type who "hates" to give credit : ), and I believe it is required ^^. If they want to remove it, they have to remove it from each thing they put into their map.
1. Must use all parameters, including the icon
2. If temporary, it must display it for 6 seconds
3. May use any preset values desired (Mfn (QUEST) uses a left side true/false setting)
Be sure to do all the formatting yourself and the creation works using this-
Utilities-
Virtual Grid and Math (these 2 are now merged)
Systems-
Graphic Effects (contorts stuff using math. Really specialized for 2D and 3D shapes created with math and structures of those shapes (things rotating around other things, etc)
Data Effects (effects data, can be like upgrades and can apply to any system ^_^)
Model (unsure about doing this)
Spawn + 3 lvl 2 Spawns (one class style spawning, one charge type, and another trainer type o-o)
Spell + lvl 2 spell (lvl 2 defines a type of spell system ^^, which uses nodes to create spells, very interesting and I find it to be an incredible model for spell creation)
Melee
Ranged
Frameworks-
Footmen Wars Framework
Starcraft Zone Control Framework
Level 1 defines basic types such as complex relationships (link between 3 thinks all sharing one thing, etc), combat types (spell- melee+ranged, bow- ranged, etc), etc.
Level 2 defines basic objects that plug into lvl 1's types.
Level 3 defines objects that extend upon lvl 2's basic objects.
Level 4 instantiates things and adds controls and events for them in the map.
Manipulation for a specific map
The Map Framework
Now With All Working AI Native Declarations!
Current Version- v3.10Now With All Working AI Native Declarations!
Guide Version- (v.02a)
Anyone who creates quick utilities for giving credits with this format and this usage
JASS:
//! textmacro Mfn_BUILD_CREDIT_INTERFACE takes name, title, description
public function createCredit$name$ takes string systemName, string versionNumber, string author, string helpers, string texturePath, string description returns nothing
will have an Mfn version built for them with their credit type and they will be added to the helper list for that version.
Tired of only Quest Credits? Make your own layout and it will be put out : ).
Why don't I just let users define their own layouts? Obvious reasons ; P. They might be the type who "hates" to give credit : ), and I believe it is required ^^. If they want to remove it, they have to remove it from each thing they put into their map.
1. Must use all parameters, including the icon
2. If temporary, it must display it for 6 seconds
3. May use any preset values desired (Mfn (QUEST) uses a left side true/false setting)
Be sure to do all the formatting yourself and the creation works using this-
JASS:
//! textmacro Mfn_BUILD_CREDIT_INTERFACE takes name, title, description
JASS:
//Level 2 design, defined basic types (level 1 is Mfn)
module Module
public method greet takes integer instance, string greet returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, .getH(instance) + greet + .getH2(instance))
endmethod
endmodule
//! textmacro CONTAINER takes name
scope Mfn$name$ initializer Mfn$name$Mfn
globals
Instance $name$
private integer array MFN$name$AAbbCCddMFN$name$
endglobals
private struct Mfn_$name$Instance$name$AABB
public string h
public string h2
public integer id
endstruct
struct Mfn$name$1122 extends Instance
public method getInstance takes integer id returns integer
return MFN$name$AAbbCCddMFN$name$[id]
endmethod
public method setInstance takes integer id, integer value returns nothing
set MFN$name$AAbbCCddMFN$name$[id] = value
endmethod
public method setIdInstance takes integer instance, integer value returns nothing
set Mfn_$name$Instance$name$AABB(instance).id = value
endmethod
public method getIdInstance takes integer instance returns integer
return Mfn_$name$Instance$name$AABB(instance).id
endmethod
public method getH takes integer instance returns string
return Mfn_$name$Instance$name$AABB(instance).h
endmethod
public method getH2 takes integer instance returns string
return Mfn_$name$Instance$name$AABB(instance).h2
endmethod
public method setH takes integer instance, string x returns nothing
set Mfn_$name$Instance$name$AABB(instance).h = x
endmethod
public method setH2 takes integer instance, string x returns nothing
set Mfn_$name$Instance$name$AABB(instance).h2 = x
endmethod
public method createInstance takes nothing returns integer
return Mfn_$name$Instance$name$AABB.create()
endmethod
public method destroyInstance takes integer instance returns nothing
call Mfn_$name$Instance$name$AABB(instance).destroy()
endmethod
endstruct
private function Mfn$name$Mfn takes nothing returns nothing
set $name$ = Mfn$name$1122.create()
endfunction
endscope
//! endtextmacro
//default container ^^
//! runtextmacro CONTAINER("defaultInstance")
interface Instance
public method getInstance takes integer id returns integer defaults 0
public method setInstance takes integer id, integer value returns nothing defaults nothing
public method setIdInstance takes integer instance, integer value returns nothing defaults nothing
public method getIdInstance takes integer instance returns integer defaults 0
public method getH takes integer instance returns string defaults null
public method getH2 takes integer instance returns string defaults null
public method setH takes integer instance, string x returns nothing defaults nothing
public method setH2 takes integer instance, string x returns nothing defaults nothing
public method createInstance takes nothing returns integer defaults 0
public method destroyInstance takes integer instance returns nothing defaults nothing
endinterface
interface Data
public string h = "you "
public string h2 =" are a loser"
public integer index = 0
public delegate Instance instance = defaultInstance
public method makeInstance takes nothing returns integer defaults 0
public method unmakeInstance takes integer instance returns nothing defaults nothing
public method addInstance takes integer instance returns nothing defaults nothing
public method removeInstance takes integer instance returns nothing defaults nothing
public method greet takes integer instance, string greet returns nothing defaults nothing
endinterface
struct Prototype extends Data
implement Module
public method makeInstance takes nothing returns integer
//! runtextmacro Mfn_MAKE("instance", "Instance")
call .setH(instance, .h)
call .setH2(instance, .h2)
return instance
endmethod
public method unmakeInstance takes integer instance returns nothing
//! runtextmacro Mfn_UNMAKE("instance", "Instance")
endmethod
public method addInstance takes integer instance returns nothing
//! runtextmacro Mfn_ADD_INDEX("this", "Instance", "index", "instance")
endmethod
public method removeInstance takes integer instance returns nothing
//! runtextmacro Mfn_REMOVE_INDEX("this", "instance", "Instance", "index")
endmethod
endstruct
JASS:
//Level 3 design, defined types
//make a container
//! runtextmacro CONTAINER("instance1")
struct Type1 extends Prototype
public string h = "hi "
public string h2 = " beep beep"
public delegate Instance instance = instance1
endstruct
struct Type2 extends Prototype
endstruct
JASS:
library a initializer ini requires Mfn
private function start takes nothing returns nothing
//for fun, let's create some types through our interface
local Data a = Type1.create()
local Data b = Type2.create()
//Now let's set up some instance variables, just integers ^^
local integer instance
local integer instance2
local integer array instances
//finally a counter
local integer x = 1
//Ok, let's stry setting up a bunch of instances in the array
loop
set instances[x] = a.makeInstance()
call a.setH(instances[x], I2S(x))
set x = x + 1
exitwhen x > 10
endloop
set x = 0
//Now let's greet via a loop. The only way to loop through them is via a stack.
//We can get the stack id of any instance via .getIdInstance(instance) and we can get the instance stored in the
//stack via the id via .getInstance(id)
//In this case we are using the id as we want to loop ^^. Instance numbers are useless for looping as some might
//be empty
loop
call a.greet(a.getInstance(x), "Fred")
set x = x + 1
exitwhen x == a.index
endloop
//Now for fun let's use a specific instance number to greet somebody without setting the instance's properties
set instance = a.makeInstance()
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(instance))
call a.greet(instance, "George")
//This would use the type's default properties ^^
//What happens when we have a type without defined values??
set instance2 = b.makeInstance()
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(instance2))
call b.greet(instance2, "John")
//this does exactly what you would expect it to. It uses the default values.
endfunction
private function ini takes nothing returns nothing
call TriggerAddAction(Mfn_ini, function start)
endfunction
endlibrary
Utilities-
Virtual Grid and Math (these 2 are now merged)
Systems-
Graphic Effects (contorts stuff using math. Really specialized for 2D and 3D shapes created with math and structures of those shapes (things rotating around other things, etc)
Data Effects (effects data, can be like upgrades and can apply to any system ^_^)
Model (unsure about doing this)
Spawn + 3 lvl 2 Spawns (one class style spawning, one charge type, and another trainer type o-o)
Spell + lvl 2 spell (lvl 2 defines a type of spell system ^^, which uses nodes to create spells, very interesting and I find it to be an incredible model for spell creation)
Melee
Ranged
Frameworks-
Footmen Wars Framework
Starcraft Zone Control Framework
Level 1 defines basic types such as complex relationships (link between 3 thinks all sharing one thing, etc), combat types (spell- melee+ranged, bow- ranged, etc), etc.
Level 2 defines basic objects that plug into lvl 1's types.
Level 3 defines objects that extend upon lvl 2's basic objects.
Level 4 instantiates things and adds controls and events for them in the map.
Manipulation for a specific map
JASS:
//! textmacro Mfn_SETTINGS
public constant boolean creditLeftSide = false
//! endtextmacro
//! textmacro Mfn_GET_HANDLE_ID
//function GetHandleId takes handle h returns integer
// return h
// return 0
//endfunction
//! endtextmacro
JASS:
library Mfn initializer create
globals
//Version Information
private constant string SYSTEM = "Mfn"
private constant string VERSION_THIS = "4.0"
private constant string AUTHOR = "Nestharus"
private constant string HELPERS = "Jesus4Lyf- Hash"
private constant string TEXTURE_PATH = "ReplaceableTextures\\CommandButtons\\BTNPeriapt1.blp"
private constant string DESCRIPTION = "The Map Framework"
//Ini trigger
public trigger ini = CreateTrigger()
//Map Properties
public real Map_centerX
public real Map_centerY
public real Map_minX
public real Map_minY
public real Map_maxX
public real Map_maxY
public rect Map_map
//Player Properties
public player array players[12]
public integer array playerID[12]
public integer playerCount = 0
public constant force playerForce = CreateForce()
public player array computers[12]
public integer array computerID[12]
public integer computerCount = 0
public constant force computerForce = CreateForce()
public player array all[12]
public integer array allID[12]
public integer allCount = 0
public constant force allForce = CreateForce()
public player host
private constant timer runGameTime = CreateTimer()
public integer gameTime = 0
//Hash Categories
public key ABILITY
public key AI_DIFFICULTY
public key ALLIANCE_TYPE
public key ATTACK_TYPE
public key BLEND_MODE
public key BOOL_EXPR
public key BUFF
public key BUTTON
public key CAMERA_FIELD
public key CAMERA_SETUP
public key CONDITION_FUNC
public key DAMAGE_TYPE
public key DEFEAT_CONDITION
public key DESTRUCTABLE
public key DIALOG
public key DIALOG_EVENT
public key EFFECT
public key EFFECT_TYPE
public key EVENT
public key EVENT_ID
public key F_GAME_STATE
public key FILTER_FUNC
public key FOG_MODIFIER
public key FOG_STATE
public key FORCE
public key GAMECACHE
public key GAME_DIFFICULTY
public key GAME_EVENT
public key GAME_SPEED
public key GAME_STATE
public key GAME_TYPE
public key GROUP
public key HANDLE
public key HASHTABLE
public key I_GAME_STATE
public key IMAGE
public key ITEM
public key ITEM_POOL
public key ITEM_TYPE
public key LEADERBOARD
public key LIGHTNING
public key LIMIT_OP
public key LOCATION
public key MAP_CONTROL
public key MAP_DENSITY
public key MAP_FLAG
public key MAP_SETTING
public key MAP_VISIBILITY
public key MULTIBOARD
public key MULTIBOARD_ITEM
public key PATHING_TYPE
public key PLACEMENT
public key PLAYER
public key PLAYER_COLOR
public key PLAYER_EVENT
public key PLAYER_GAME_RESULT
public key PLAYER_SCORE
public key PLAYER_SLOT_STATE
public key PLAYER_STATE
public key PLAYER_UNIT_EVENT
public key QUEST
public key QUEST_ITEM
public key RACE
public key RACE_PREFERENCE
public key RARITY_CONTROL
public key RECT
public key REGION
public key SOUND
public key SOUND_TYPE
public key START_LOC_PRIO
public key TERRAIN_DEFORMATION
public key TEX_MAP_FLAGS
public key TEXT_TAG
public key TIMER
public key TIMER_DIALOG
public key TRACKABLE
public key TRIGGER
public key TRIGGER_ACTION
public key TRIGGER_CONDITION
public key UBERSPLAT
public key UNIT
public key UNIT_EVENT
public key UNIT_POOL
public key UNIT_STATE
public key UNIT_TYPE
public key VERSION
public key VOLUME_GROUP
public key WEAPON_TYPE
public key WEATHER_EFFECT
public key WIDGET
public key WIDGET_EVENT
public key INTEGER
public key REAL
public key STRING
public key CODE
public key X
public key Y
public key Z
public key INDEX
private gamecache getTheHost
//! runtextmacro Mfn_SETTINGS()
endglobals
//! runtextmacro Mfn_GET_HANDLE_ID()
//Working AI Natives
constant native GetPlayerUnitTypeCount takes player p, integer unitid returns integer
constant native GetUnitGoldCost takes integer unitid returns integer
constant native GetUnitWoodCost takes integer unitid returns integer
constant native GetUnitBuildTime takes integer unitid returns integer
constant native CreepsOnMap takes nothing returns boolean
constant native UnitAlive takes unit id returns boolean
private function getHost takes nothing returns player
call StoreInteger(getTheHost, "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1)
call TriggerSyncStart()
call SyncStoredInteger(getTheHost, "missionKey", "key")
call TriggerSyncReady()
return Player(GetStoredInteger(getTheHost, "missionKey", "key") - 1)
endfunction
//Text Macros
//! textmacro Mfn_CREATE_CONTAINER takes id, type
public struct $id$
public $type$ h
public static method create takes $type$ x returns thistype
local thistype h = thistype.allocate()
set h.h = x
return h
endmethod
endstruct
//! endtextmacro
//! textmacro Mfn_MAKE takes var, type
local integer $var$ = .create$type$()
call .add$type$($var$)
//! endtextmacro
//! textmacro Mfn_UNMAKE takes var, type
call .remove$type$($var$)
call .destroy$type$($var$)
//! endtextmacro
//! textmacro Mfn_REMOVE_INDEX takes owner, parameter, type, index
local integer Mfn_id = .getId$type$($parameter$)
local integer Mfn_recycled = .get$type$($owner$.$index$)
set $owner$.$index$ = $owner$.$index$ - 1
if Mfn_id < $owner$.$index$ then
call .setId$type$(Mfn_recycled, Mfn_id)
call .set$type$(Mfn_id, Mfn_recycled)
endif
call .setId$type$($parameter$, -1)
//! endtextmacro
//! textmacro Mfn_ADD_INDEX takes owner, type, index, instance
call .setId$type$($instance$, $owner$.$index$)
call .set$type$($owner$.$index$, $instance$)
set $owner$.$index$ = $owner$.$index$ + 1
//! endtextmacro
//! textmacro Mfn_CREATE_LOOP1_1 takes index, timeout
local integer timeout = $index$ + $timeout$
//! endtextmacro
//! textmacro Mfn_CREATE_LOOP1_2 takes index, params, condition, function
exitwhen ($condition$) or $index$ >= timeout
endloop
if not ($condition$) then
return $function$.evaluate($params$)
else
//! endtextmacro
//! textmacro Mfn_BUILD_CREDIT_INTERFACE takes name, title, description
public function createCredit$name$ takes string systemName, string versionNumber, string author, string helpers, string texturePath, string description returns nothing
call credit($title$, $description$, texturePath)
endfunction
//! endtextmacro
public constant function STOP_THREAD takes nothing returns integer
return 1/0
endfunction
//System functions
public function credit takes string title, string description, string texturePath returns nothing
local quest credits = CreateQuest()
call QuestSetTitle(credits, title)
call QuestSetDescription(credits, description)
call QuestSetIconPath(credits, texturePath)
call QuestSetDiscovered(credits, true)
call QuestSetCompleted(credits, false)
call QuestSetEnabled(credits, true)
call QuestSetRequired(credits, creditLeftSide)
set credits = null
endfunction
//! runtextmacro Mfn_BUILD_CREDIT_INTERFACE("1", "systemName + \" v\" + versionNumber", "\"Author of this System- |n\" + author + \"|n|nPeople who helped design this system- |n\" + helpers + \"|n|nDescription- |n\" + description")
private function playerLeave takes nothing returns nothing
local player p = GetTriggerPlayer()
local integer pID = GetPlayerId(p)
if p == host then
set host = getHost()
endif
set playerCount = playerCount - 1
set allCount = allCount - 1
call ForceRemovePlayer(playerForce, p)
call ForceRemovePlayer(allForce, p)
if playerID[pID] < playerCount then
set players[playerID[pID]] = players[playerCount]
set playerID[allCount] = allID[pID]
endif
if allID[pID] < allCount then
set all[allID[pID]] = all[allCount]
set allID[allCount] = allID[pID]
endif
set playerID[pID] = -1
set players[playerCount] = null
set allID[pID] = -1
set all[allCount] = null
set p = null
endfunction
private function removeAllUnits takes nothing returns nothing
call RemoveUnit(GetEnumUnit())
endfunction
private function addToGameTime takes nothing returns nothing
set gameTime = gameTime + 10000
endfunction
public function getElapsedGameTime takes nothing returns real
return gameTime + TimerGetElapsed(runGameTime)
endfunction
private function mapSetup takes nothing returns nothing
local integer x = 0
local rect r = GetWorldBounds()
local trigger playerLeaves = CreateTrigger()
local group g = CreateGroup()
call TimerStart(runGameTime, 10000, true, function addToGameTime)
//Setup Map
set Map_minX = GetRectMinX(r) + GetCameraMargin(CAMERA_MARGIN_LEFT)
set Map_minY = GetRectMinY(r) + GetCameraMargin(CAMERA_MARGIN_BOTTOM)
set Map_maxX = GetRectMaxX(r) - GetCameraMargin(CAMERA_MARGIN_RIGHT)
set Map_maxY = GetRectMaxY(r) - GetCameraMargin(CAMERA_MARGIN_TOP)
set Map_centerX = (Map_minX+Map_maxX)/2
set Map_centerY = (Map_minY+Map_maxY)/2
call RemoveRect(r)
set r = null
set Map_map = Rect(Map_minX, Map_minY, Map_maxX, Map_maxY)
//Setup Players
loop
if (GetPlayerController(Player(x)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(x)) == PLAYER_SLOT_STATE_PLAYING) then
set players[playerCount] = Player(x)
set playerID[x] = playerCount
set playerCount = playerCount + 1
call ForceAddPlayer(playerForce, Player(x))
call TriggerRegisterPlayerEvent(playerLeaves, Player(x), EVENT_PLAYER_LEAVE)
elseif (GetPlayerController(Player(x)) == MAP_CONTROL_COMPUTER and GetPlayerSlotState(Player(x)) == PLAYER_SLOT_STATE_PLAYING) then
set computers[computerCount] = Player(x)
set computerID[x] = computerCount
set computerCount = computerCount + 1
call ForceAddPlayer(computerForce, Player(x))
else
call GroupEnumUnitsOfPlayer(g, Player(x), null)
call ForGroup(g, function removeAllUnits)
call GroupClear(g)
endif
if (GetPlayerSlotState(Player(x)) == PLAYER_SLOT_STATE_PLAYING) then
if (GetPlayerController(Player(x)) == MAP_CONTROL_COMPUTER or GetPlayerController(Player(x)) == MAP_CONTROL_USER) then
set all[allCount] = Player(x)
set allID[x] = allCount
set allCount = allCount + 1
call ForceAddPlayer(allForce, Player(x))
endif
endif
set x = x + 1
exitwhen x > 11
endloop
if playerCount > 1 then
set getTheHost = InitGameCache("Mfn")
set host = getHost()
endif
call DestroyGroup(g)
call TriggerAddAction(playerLeaves, function playerLeave)
endfunction
private struct HashIndex
thistype next=0
integer hashedInt
endstruct
globals
private constant integer MAX_HASH_VALUE=8191
private HashIndex array ListOnHash
endglobals
public function Hash takes integer int returns integer
local HashIndex hash=HashIndex(int-(int/MAX_HASH_VALUE)*MAX_HASH_VALUE)
if ListOnHash[hash]==0 then
set ListOnHash[hash]=HashIndex.create()
set hash=ListOnHash[hash]
set hash.hashedInt=int
else
set hash=ListOnHash[hash]
loop
exitwhen hash.hashedInt==int
if hash.next==0 then
set hash.next=HashIndex.create()
set hash=hash.next
set hash.hashedInt=int
return hash
endif
set hash=hash.next
endloop
endif
return hash
endfunction
public function HashFree takes integer int returns nothing
local HashIndex hash=HashIndex(int-(int/MAX_HASH_VALUE)*MAX_HASH_VALUE)
local HashIndex last=ListOnHash[hash]
if last.hashedInt==int then
set ListOnHash[hash]=last.next
call last.destroy()
else
loop
set hash=last.next
exitwhen hash==0
if hash.hashedInt==int then
set last.next=hash.next
call hash.destroy()
return
endif
set last=hash
endloop
endif
endfunction
private function create takes nothing returns nothing
call Mfn_createCredit1(SYSTEM, VERSION_THIS, AUTHOR, HELPERS, TEXTURE_PATH, DESCRIPTION)
call mapSetup()
call TriggerRegisterTimerEvent(ini, .01, false)
endfunction
endlibrary
library Hash initializer ini requires Mfn
globals
private constant string SYSTEM = "Hash"
private constant string VERSION_THIS = "2.0"
private constant string AUTHOR = "Jesus4Lyf"
private constant string HELPERS = "None"
private constant string TEXTURE_PATH = "ReplaceableTextures\\CommandButtons\\BTNOrcCar.blp"
private constant string DESCRIPTION = "Rawcode Hashing"
endglobals
//! textmacro Hash_CREATE takes new
private struct HashIndex
thistype next=0
integer hashedInt
endstruct
globals
private constant integer MAX_HASH_VALUE=8191
private HashIndex array ListOnHash
endglobals
public function Hash takes integer int returns integer
local HashIndex hash=HashIndex(int-(int/MAX_HASH_VALUE)*MAX_HASH_VALUE)
if ListOnHash[hash]==0 then
set ListOnHash[hash]=HashIndex.create()
set hash=ListOnHash[hash]
set hash.hashedInt=int
$new$
else
set hash=ListOnHash[hash]
loop
exitwhen hash.hashedInt==int
if hash.next==0 then
set hash.next=HashIndex.create()
set hash=hash.next
set hash.hashedInt=int
$new$
return hash
endif
set hash=hash.next
endloop
endif
return hash
endfunction
public function HashFree takes integer int returns nothing
local HashIndex hash=HashIndex(int-(int/MAX_HASH_VALUE)*MAX_HASH_VALUE)
local HashIndex last=ListOnHash[hash]
if last.hashedInt==int then
set ListOnHash[hash]=last.next
call last.destroy()
else
loop
set hash=last.next
exitwhen hash==0
if hash.hashedInt==int then
set last.next=hash.next
call hash.destroy()
return
endif
set last=hash
endloop
endif
endfunction
//! endtextmacro
private function ini takes nothing returns nothing
call Mfn_createCredit1(SYSTEM, VERSION_THIS, AUTHOR, HELPERS, TEXTURE_PATH, DESCRIPTION)
endfunction
endlibrary
library RequiresMfn requires Mfn, Hash
endlibrary
Attachments
Last edited: