Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lightning handle package & hero attribute functions for units #42

Merged
merged 30 commits into from Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c94241b
Added Orders class to Assets from cJass' library.
Trokkin Nov 26, 2017
a0e362d
Just for testing purposes.
Trokkin Dec 4, 2017
3929b75
Added illusion wand string
Trokkin Dec 4, 2017
6e4a65d
An temporary fix to ability issue
Trokkin Dec 4, 2017
9a7ad0d
Merge pull request #1 from wurstscript/master
Trokkin Dec 6, 2017
6af6fcb
Pulled origin/master and merged it.
Trokkin Dec 9, 2017
40bdd76
refactored InstantDummyCaster
Trokkin Dec 9, 2017
765028c
Fixed debug level back
Trokkin Dec 9, 2017
e52a362
Moved Orders to different package; split Orders in two classes; named…
Trokkin Dec 9, 2017
4bb6e0b
Fixed credits
Trokkin Dec 9, 2017
81ac1e8
Fixed intendation in Orders.wurst online
Trokkin Dec 9, 2017
4ea0390
Merge branch 'master' of https://github.com/wurstscript/wurstStdlib2 …
Trokkin Dec 13, 2017
8329238
Made IDC position logical
Trokkin Dec 13, 2017
0ee92ef
Added some special orders Frotty has suggested
Trokkin Dec 13, 2017
5cb9b85
Added more comments.
Trokkin Dec 13, 2017
d490890
Merged from origin master
Trokkin Dec 21, 2017
74f4ced
Merge branch 'master' of https://github.com/Trokkin/WurstStdlib2
Trokkin Dec 22, 2017
88ccbd6
Fixed IDC not casting some spells most of the time
Trokkin Dec 22, 2017
d82905c
Fixed the fix.
Trokkin Dec 22, 2017
f92a2ad
Fixed alignment once more
Trokkin Dec 23, 2017
998f298
Removed extraneous spaces
Trokkin Dec 23, 2017
ead21a8
Added hero attribute functions to unit's handle.
Trokkin Jan 19, 2018
95d0b34
Created lightning handle package.
Trokkin Jan 19, 2018
684b2fe
Merge branch 'master' of https://github.com/wurstscript/wurstStdlib2
Trokkin Jan 19, 2018
d34a238
Added lightning types and fixed lightning end vector name.
Trokkin Jan 20, 2018
d465a22
Added spaces to new unit functions.
Trokkin Jan 20, 2018
526bd97
Added unit.getMaxMana() function. Oh god.
Trokkin Jan 20, 2018
adf1633
Added some comments and lightning.getColor# wrappers.
Trokkin Jan 20, 2018
dec0166
Replaced LightningType enum with string constants.
Trokkin Jan 21, 2018
7a085c2
Omitted "string" type from lightning constants.
Trokkin Jan 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
68 changes: 68 additions & 0 deletions wurst/_handles/Lightning.wurst
@@ -0,0 +1,68 @@
package Lightning
import NoWurst
import Vectors
import Colors

public constant string LIGHTNING_CHAIN_LIGHTNING_PRIMARY = "CLPB"
Copy link
Member

@Frotty Frotty Jan 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omit "string" defs here. if you have "constant" it will infer the type.

public constant string LIGHTNING_CHAIN_LIGHTNING_SEECONDARY = "CLSB"
public constant string LIGHTNING_DRAIN = "DRAB"
public constant string LIGHTNING_DRAIN_LIFE = "DRAL"
public constant string LIGHTNING_DRAIN_MANA = "DRAM"
public constant string LIGHTNING_FINGER_OF_DEATH = "AFOD"
public constant string LIGHTNING_FORKED_LIGHTNING = "FORK"
public constant string LIGHTNING_HEALING_WAWE_PRIMARY = "HWPB"
public constant string LIGHTNING_HEALING_WAWE_SEECONDARY = "HWSB"
public constant string LIGHTNING_LIGHTNING_ATTACK = "CHIM"
public constant string LIGHTNING_MAGIC_LEASH = "LEAS"
public constant string LIGHTNING_MANA_BURN = "MBUR"
public constant string LIGHTNING_MANA_FLARE = "MFPB"
public constant string 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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave empty lines between functions

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
Expand Up @@ -22,3 +22,4 @@ import public Unit
import public Widget
import public GameCache
import public Force
import public Lightning