Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# AGENTS.md

## WurstScript Project Rules

- Prefer extension functions over calling bare natives directly.
- Prefer chaining extension calls with the `..` cascade operator when it improves readability and keeps call chains efficient.
- Avoid `location` handles. Use `vec2`-based APIs instead.
- For sets of units, prefer `group`.
- For sets of players, prefer `force`.
- For arbitrary data collections, prefer `LinkedList`.
- Use the highest abstraction level that is practical:
- Example: prefer hashmap-style abstractions over raw hashtable usage when performance is not a critical hot path.
- In critical hot paths, choose the more performant lower-level approach.
- Use asset constants from asset packages instead of raw asset path strings.
- Follow WurstScript language rules strictly (e.g. no `continue`; use valid Wurst constructs only).

## Guideline Priority

When rules conflict:
1. Correctness
2. Performance requirements of the code path
3. Readability and abstraction level
280 changes: 280 additions & 0 deletions wurst/_handles/CommonNativeExtensions.wurst
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
package CommonNativeExtensions
import NoWurst
import Annotations
import Vectors

public function gametype.setGameTypeSupported(boolean value)
SetGameTypeSupported(this, value)

public function mapflag.setMapFlag(boolean value)
SetMapFlag(this, value)

public function placement.setGamePlacement()
SetGamePlacement(this)

public function gamespeed.setGameSpeed()
SetGameSpeed(this)

public function gamedifficulty.setGameDifficulty()
SetGameDifficulty(this)

public function mapdensity.setResourceDensity()
SetResourceDensity(this)

public function mapdensity.setCreatureDensity()
SetCreatureDensity(this)

public function gametype.isGameTypeSupported() returns boolean
return IsGameTypeSupported(this)

public function mapflag.isMapFlagSet() returns boolean
return IsMapFlagSet(this)

@deprecated("Use vec2.rectFrom(vec2) to avoid location handles.")
public function location.rectFromLoc(location max) returns rect
return RectFromLoc(this, max)

public function vec2.rectFrom(vec2 max) returns rect
return Rect(this.x, this.y, max.x, max.y)

public function conditionfunc.destroyCondition()
DestroyCondition(this)

public function filterfunc.destroyFilter()
DestroyFilter(this)

@deprecated("Use player.hasVisibility(vec2) or vec2.isVisibleToPlayer(player).")
public function location.isLocationVisibleToPlayer(player whichPlayer) returns boolean
return IsLocationVisibleToPlayer(this, whichPlayer)

@deprecated("Use vec2.isFoggedToPlayer(player) to avoid location handles.")
public function location.isLocationFoggedToPlayer(player whichPlayer) returns boolean
return IsLocationFoggedToPlayer(this, whichPlayer)

@deprecated("Use vec2.isMaskedToPlayer(player) to avoid location handles.")
public function location.isLocationMaskedToPlayer(player whichPlayer) returns boolean
return IsLocationMaskedToPlayer(this, whichPlayer)

public function vec2.isVisibleToPlayer(player whichPlayer) returns boolean
return IsVisibleToPlayer(this.x, this.y, whichPlayer)

public function vec2.isFoggedToPlayer(player whichPlayer) returns boolean
return IsFoggedToPlayer(this.x, this.y, whichPlayer)

public function vec2.isMaskedToPlayer(player whichPlayer) returns boolean
return IsMaskedToPlayer(this.x, this.y, whichPlayer)

public function vec2.pingMinimap(real duration)
PingMinimap(this.x, this.y, duration)

public function vec2.pingMinimapEx(real duration, integer red, integer green, integer blue, boolean extraEffects)
PingMinimapEx(this.x, this.y, duration, red, green, blue, extraEffects)

public function vec2.createMinimapIcon(integer red, integer green, integer blue, string pingPath, fogstate fogVisibility) returns minimapicon
return CreateMinimapIcon(this.x, this.y, red, green, blue, pingPath, fogVisibility)

public function vec2.terrainDeformRipple(real radius, real depth, integer duration, integer count, real spaceWaves, real timeWaves, real radiusStartPct, boolean limitNeg) returns terraindeformation
return TerrainDeformRipple(this.x, this.y, radius, depth, duration, count, spaceWaves, timeWaves, radiusStartPct, limitNeg)

public function vec2.terrainDeformWave(vec2 direction, real distance, real speed, real radius, real depth, integer trailTime, integer count) returns terraindeformation
return TerrainDeformWave(this.x, this.y, direction.x, direction.y, distance, speed, radius, depth, trailTime, count)

public function vec2.terrainDeformRandom(real radius, real minDelta, real maxDelta, integer duration, integer updateInterval) returns terraindeformation
return TerrainDeformRandom(this.x, this.y, radius, minDelta, maxDelta, duration, updateInterval)

public function vec2.getTerrainCliffLevel() returns integer
return GetTerrainCliffLevel(this.x, this.y)

public function vec2.createUbersplat(string name, integer red, integer green, integer blue, integer alpha, boolean forcePaused, boolean noBirthTime) returns ubersplat
return CreateUbersplat(this.x, this.y, name, red, green, blue, alpha, forcePaused, noBirthTime)

public function vec2.isPointBlighted() returns boolean
return IsPointBlighted(this.x, this.y)

public function vec2.setDoodadAnimation(real radius, integer doodadID, boolean nearestOnly, string animName, boolean animRandom)
SetDoodadAnimation(this.x, this.y, radius, doodadID, nearestOnly, animName, animRandom)

public function version.versionCompatible() returns boolean
return VersionCompatible(this)

public function version.versionSupported() returns boolean
return VersionSupported(this)

public function race.setCampaignMenuRace()
SetCampaignMenuRace(this)

public function fgamestate.setFloatGameState(real value)
SetFloatGameState(this, value)

public function fgamestate.getFloatGameState() returns real
return GetFloatGameState(this)

public function igamestate.setIntegerGameState(integer value)
SetIntegerGameState(this, value)

public function igamestate.getIntegerGameState() returns integer
return GetIntegerGameState(this)

public function gamedifficulty.setDefaultDifficulty()
SetDefaultDifficulty(this)

public function unitpool.destroyUnitPool()
DestroyUnitPool(this)

public function unitpool.unitPoolAddUnitType(integer unitId, real weight)
UnitPoolAddUnitType(this, unitId, weight)

public function unitpool.unitPoolRemoveUnitType(integer unitId)
UnitPoolRemoveUnitType(this, unitId)

public function unitpool.placeRandomUnit(player forWhichPlayer, real x, real y, real facing) returns unit
return PlaceRandomUnit(this, forWhichPlayer, x, y, facing)

public function unitpool.placeRandomUnit(player forWhichPlayer, vec2 pos, real facing) returns unit
return PlaceRandomUnit(this, forWhichPlayer, pos.x, pos.y, facing)

public function itempool.destroyItemPool()
DestroyItemPool(this)

public function itempool.itemPoolAddItemType(integer itemId, real weight)
ItemPoolAddItemType(this, itemId, weight)

public function itempool.itemPoolRemoveItemType(integer itemId)
ItemPoolRemoveItemType(this, itemId)

public function itempool.placeRandomItem(real x, real y) returns item
return PlaceRandomItem(this, x, y)

public function itempool.placeRandomItem(vec2 pos) returns item
return PlaceRandomItem(this, pos.x, pos.y)

public function itemtype.chooseRandomItemEx(integer level) returns integer
return ChooseRandomItemEx(this, level)

@deprecated("Use vec2.createMinimapIcon(...) to avoid location handles.")
public function location.createMinimapIconAtLoc(integer red, integer green, integer blue, string pingPath, fogstate fogVisibility) returns minimapicon
return CreateMinimapIconAtLoc(this, red, green, blue, pingPath, fogVisibility)

public function minimapicon.destroyMinimapIcon()
DestroyMinimapIcon(this)

public function minimapicon.setMinimapIconVisible(boolean visible)
SetMinimapIconVisible(this, visible)

public function minimapicon.setMinimapIconOrphanDestroy(boolean doDestroy)
SetMinimapIconOrphanDestroy(this, doDestroy)

public function defeatcondition.destroyDefeatCondition()
DestroyDefeatCondition(this)

public function defeatcondition.defeatConditionSetDescription(string description)
DefeatConditionSetDescription(this, description)

public function leaderboard.destroyLeaderboard()
DestroyLeaderboard(this)

public function leaderboard.leaderboardDisplay(boolean show)
LeaderboardDisplay(this, show)

public function leaderboard.isLeaderboardDisplayed() returns boolean
return IsLeaderboardDisplayed(this)

public function leaderboard.leaderboardGetItemCount() returns integer
return LeaderboardGetItemCount(this)

public function leaderboard.leaderboardSetSizeByItemCount(integer count)
LeaderboardSetSizeByItemCount(this, count)

public function leaderboard.leaderboardAddItem(string label, integer value, player p)
LeaderboardAddItem(this, label, value, p)

public function leaderboard.leaderboardRemoveItem(integer index)
LeaderboardRemoveItem(this, index)

public function leaderboard.leaderboardRemovePlayerItem(player p)
LeaderboardRemovePlayerItem(this, p)

public function leaderboard.leaderboardClear()
LeaderboardClear(this)

public function leaderboard.leaderboardSortItemsByValue(boolean ascending)
LeaderboardSortItemsByValue(this, ascending)

public function leaderboard.leaderboardSortItemsByPlayer(boolean ascending)
LeaderboardSortItemsByPlayer(this, ascending)

public function leaderboard.leaderboardSortItemsByLabel(boolean ascending)
LeaderboardSortItemsByLabel(this, ascending)

public function leaderboard.leaderboardHasPlayerItem(player p) returns boolean
return LeaderboardHasPlayerItem(this, p)

public function leaderboard.leaderboardGetPlayerIndex(player p) returns integer
return LeaderboardGetPlayerIndex(this, p)

public function leaderboard.leaderboardSetLabel(string label)
LeaderboardSetLabel(this, label)

public function leaderboard.leaderboardGetLabelText() returns string
return LeaderboardGetLabelText(this)

public function leaderboard.leaderboardSetLabelColor(integer red, integer green, integer blue, integer alpha)
LeaderboardSetLabelColor(this, red, green, blue, alpha)

public function leaderboard.leaderboardSetValueColor(integer red, integer green, integer blue, integer alpha)
LeaderboardSetValueColor(this, red, green, blue, alpha)

public function leaderboard.leaderboardSetStyle(boolean showLabel, boolean showNames, boolean showValues, boolean showIcons)
LeaderboardSetStyle(this, showLabel, showNames, showValues, showIcons)

public function leaderboard.leaderboardSetItemValue(integer whichItem, integer val)
LeaderboardSetItemValue(this, whichItem, val)

public function leaderboard.leaderboardSetItemLabel(integer whichItem, string val)
LeaderboardSetItemLabel(this, whichItem, val)

public function leaderboard.leaderboardSetItemStyle(integer whichItem, boolean showLabel, boolean showValue, boolean showIcon)
LeaderboardSetItemStyle(this, whichItem, showLabel, showValue, showIcon)

public function leaderboard.leaderboardSetItemLabelColor(integer whichItem, integer red, integer green, integer blue, integer alpha)
LeaderboardSetItemLabelColor(this, whichItem, red, green, blue, alpha)

public function leaderboard.leaderboardSetItemValueColor(integer whichItem, integer red, integer green, integer blue, integer alpha)
LeaderboardSetItemValueColor(this, whichItem, red, green, blue, alpha)

@deprecated("Use camerasetup.getDestPosition() from package Camera.")
public function camerasetup.cameraSetupGetDestPositionLoc() returns location
return CameraSetupGetDestPositionLoc(this)

public function camerasetup.cameraSetupSetLabel(string label)
BlzCameraSetupSetLabel(this, label)

public function camerasetup.cameraSetupGetLabel() returns string
return BlzCameraSetupGetLabel(this)

public function volumegroup.volumeGroupSetVolume(real scale)
VolumeGroupSetVolume(this, scale)

public function terraindeformation.terrainDeformStop(integer duration)
TerrainDeformStop(this, duration)

public function ubersplat.destroyUbersplat()
DestroyUbersplat(this)

public function ubersplat.resetUbersplat()
ResetUbersplat(this)

public function ubersplat.finishUbersplat()
FinishUbersplat(this)

public function ubersplat.showUbersplat(boolean flag)
ShowUbersplat(this, flag)

public function ubersplat.setUbersplatRender(boolean flag)
SetUbersplatRender(this, flag)

public function ubersplat.setUbersplatRenderAlways(boolean flag)
SetUbersplatRenderAlways(this, flag)

public function commandbuttoneffect.destroyCommandButtonEffect()
DestroyCommandButtonEffect(this)
4 changes: 4 additions & 0 deletions wurst/_handles/Force.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ public function force.next() returns player
public function force.close()
this.clear()
this.destr()

public function force.has(player whichPlayer) returns boolean
return BlzForceHasPlayer(this, whichPlayer)

34 changes: 29 additions & 5 deletions wurst/_handles/Group.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,34 @@ public function group.get(int index) returns unit
return BlzGroupUnitAt(this, index)

/* Group iterator */
class GroupIterator
private group g
private int i = 0
private int n = 0

group iterGroup
construct(group source)
g = CreateGroup()
g.add(source)
n = g.size()

function hasNext() returns bool
return i < n

function next() returns unit
let u = g.get(i)
i += 1
return u

function close()
destroy this

ondestroy
g.clear()
g.destr()

/** Creates a new iterator for this group. */
public function group.iterator() returns group
iterGroup = CreateGroup()
iterGroup.add(this)
return iterGroup
public function group.iterator() returns GroupIterator
return new GroupIterator(this)

/** Returns whether the iterator has the next item */
public function group.hasNext() returns bool
Expand All @@ -134,3 +154,7 @@ public function group.next() returns unit
public function group.close()
this.clear()
this.destr()

public function group.forGroup(code callback)
ForGroup(this, callback)

6 changes: 6 additions & 0 deletions wurst/_handles/Image.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ public function image.remove()
error("Nullpointer exeption by destroying an image")
DestroyImage(this)

public function image.setImageRender(boolean flag)
SetImageRender(this, flag)

public function image.setImageAboveWater(boolean flag, boolean useWaterAlpha)
SetImageAboveWater(this, flag, useWaterAlpha)

13 changes: 13 additions & 0 deletions wurst/_handles/Item.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ public function item.getIconPath() returns string
public function item.setIconPath(string path)
BlzSetItemIconPath(this, path)

public function item.getSkin() returns int
return BlzGetItemSkin(this)

public function item.setSkin(int skinId)
BlzSetItemSkin(this, skinId)

// Item-Ability Get/Setters
public function item.getAbilityByIndex(int index) returns ability
return BlzGetItemAbilityByIndex(this, index)
Expand Down Expand Up @@ -191,3 +197,10 @@ public function item.updateDetailsForPlayer(player p, string itemName, string it
Returns false if no player is given. */
public function item.updateDetailsForAll(string itemName, string itemTooltip, string itemExtendedTooltip, string itemDesc, string itemIcon) returns bool
return this.updateDetails(null, itemName, itemTooltip, itemExtendedTooltip, itemDesc, itemIcon)

public function item.setItemDropID(integer unitId)
SetItemDropID(this, unitId)

public function item.blzSetItemSkin(integer skinId)
BlzSetItemSkin(this, skinId)

Loading