Skip to content

Commit

Permalink
Add lightning handle package & hero attribute functions for units (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trokkin authored and Frotty committed Jan 22, 2018
1 parent e2abd8a commit 445b93b
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
68 changes: 68 additions & 0 deletions wurst/_handles/Lightning.wurst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package Lightning
import NoWurst
import Vectors
import Colors

public constant LIGHTNING_CHAIN_LIGHTNING_PRIMARY = "CLPB"
public constant LIGHTNING_CHAIN_LIGHTNING_SEECONDARY = "CLSB"
public constant LIGHTNING_DRAIN = "DRAB"
public constant LIGHTNING_DRAIN_LIFE = "DRAL"
public constant LIGHTNING_DRAIN_MANA = "DRAM"
public constant LIGHTNING_FINGER_OF_DEATH = "AFOD"
public constant LIGHTNING_FORKED_LIGHTNING = "FORK"
public constant LIGHTNING_HEALING_WAWE_PRIMARY = "HWPB"
public constant LIGHTNING_HEALING_WAWE_SEECONDARY = "HWSB"
public constant LIGHTNING_LIGHTNING_ATTACK = "CHIM"
public constant LIGHTNING_MAGIC_LEASH = "LEAS"
public constant LIGHTNING_MANA_BURN = "MBUR"
public constant LIGHTNING_MANA_FLARE = "MFPB"
public constant LIGHTNING_SPIRIT_LINK = "SPLK"

/** Acts as with vec3 version but with z equal to terrain height. */
public function addLightning(string codeName, bool checkVisibility, vec2 start, vec2 _end) returns lightning
return AddLightning(codeName, checkVisibility, start.x, start.y, _end.x, _end.y)

/** Warning, z value of vec3 should consider terrain height.
(usually with z==0 the lightning spawns very low under ground) */
public function addLightning(string codeName, bool checkVisibility, vec3 start, vec3 _end) returns lightning
return AddLightningEx(codeName, checkVisibility, start.x, start.y, start.z, _end.x, _end.y, _end.z)

/** Acts as with vec3 version but with z equal to terrain height. */
public function lightning.move(bool checkVisibility, vec2 start, vec2 _end) returns bool
return MoveLightning(this, checkVisibility, start.x, start.y, _end.x, _end.y)

/** Warning, z value of vec3 should consider terrain height.
(usually with z==0 the lightning spawns very low under ground) */
public function lightning.move(bool checkVisibility, vec3 start, vec3 _end) returns bool
return MoveLightningEx(this, checkVisibility, start.x, start.y, start.z, _end.x, _end.y, _end.z)

public function lightning.setColor(colorA c) returns boolean
return SetLightningColor(this, c.red / 255, c.green / 255, c.blue / 255, c.alpha / 255)

public function lightning.setColor(color c) returns boolean
return SetLightningColor(this, c.red / 255, c.green / 255, c.blue / 255, 1)

/** Gets given lightning's color.
Uses approximation since it's stored in reals. */
public function lightning.getColor() returns color
return color((255 * this.getColorR() + .5).toInt(), (255 * this.getColorG() + .5).toInt(), (255 * this.getColorB() + .5).toInt())

/** Gets given lightning's color with alpha channel.
Uses approximation since it's stored in reals. */
public function lightning.getColorWithA() returns colorA
return this.getColor().withAlpha( (255 * this.getColorA() + .5).toInt() )

public function lightning.getColorR() returns real
return GetLightningColorR(this)

public function lightning.getColorG() returns real
return GetLightningColorG(this)

public function lightning.getColorB() returns real
return GetLightningColorB(this)

public function lightning.getColorA() returns real
return GetLightningColorA(this)

public function lightning.destr() returns bool
return DestroyLightning(this)
30 changes: 30 additions & 0 deletions wurst/_handles/Unit.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,33 @@ public function unit.addState( unitstate state, real value )
public function unit.addXp(int toAdd, boolean showEyeCandy)
AddHeroXP(this, toAdd, showEyeCandy)

public function unit.getStr(bool includeBonuses) returns int
return GetHeroStr(this, includeBonuses)

public function unit.getAgi(bool includeBonuses) returns int
return GetHeroAgi(this, includeBonuses)

public function unit.getInt(bool includeBonuses) returns int
return GetHeroInt(this, includeBonuses)

public function unit.setStr(int value)
SetHeroStr(this, value, true)

public function unit.setAgi(int value)
SetHeroAgi(this, value, true)

public function unit.setInt(int value)
SetHeroInt(this, value, true)

public function unit.addStr(int value)
SetHeroStr(this, this.getStr(false) + value, true)

public function unit.addAgi(int value)
SetHeroAgi(this, this.getAgi(false) + value, true)

public function unit.addInt(int value)
SetHeroInt(this, this.getInt(false) + value, true)

public function unit.damageTarget(unit target, real amount)
UnitDamageTarget(this, target, amount, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)

Expand Down Expand Up @@ -83,6 +110,9 @@ public function unit.getMana() returns real

public function unit.getMaxHP() returns real
return this.getState( UNIT_STATE_MAX_LIFE )

public function unit.getMaxMana() returns real
return this.getState(UNIT_STATE_MAX_MANA)

public function unit.getMoveSpeed() returns real
return GetUnitMoveSpeed(this)
Expand Down
1 change: 1 addition & 0 deletions wurst/_handles/_Handles.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ import public Unit
import public Widget
import public GameCache
import public Force
import public Lightning

0 comments on commit 445b93b

Please sign in to comment.