[vJASS] Anime Damage Display System

User avatar
Enalias
Site Admin
Site Admin
Posts: 200
Joined: Sat Sep 15, 2018 1:57 pm
Reputation: 9
Location: Florida, U.S.A.
Website: http://chaosrealm.co/memberlist.php?mod ... rofile&u=2
Discord: https://discord.gg/BUEZkef
Twitch: https://www.twitch.tv/enalias
Contact:
United States of America

[vJASS] Anime Damage Display System

#1

Post by Enalias » Mon Nov 05, 2018 11:18 am

THIS IS A VJASS SYSTEM. YOU NEED JASS NEWGEN PACK IN ORDER TO RUN IT!
For what it is?
To show damage on screen, but in form of images (different of the most, that's in form of text - precisely, texttags).

How do I install?
You just need to copy the script below and the models attached to your map.

Script:
Spoiler
Show
[jass]/*
*=============================================================================
* Anime Damage Display 1.1
* Created by:
* IncendiaryMonkey
* For more systems like that, visit:
* http://www.warcraftmule.blogspot.com
* [email protected]
*=============================================================================
* This system display the amount of damage dealt to a hero in form of images.
* The image changes depainding of the quantify of damage.
* Simple like that!
*=============================================================================
* Changelog:
* 1.1
* - Compatible with flying heroes
*/
library ADDS
//------------------------------------------------------------------------
//CONFIGURATIONS
//------------------------------------------------------------------------
globals
//There are three kind of damage: Low, Normal and High.
//Those labels affects the size of number
private constant real NORMAL_DMG = 500 //Below that it's considered "low"
private constant real HIGH_DMG = 5000 //Below that it's considered "normal"

//On those lines it's define the models name
private constant string NAME_PREFIX = "war3mapImported\\Number_" //You need the variations (i.e, Number_0, Number_1) for each number
private constant string NAME_SUFIX_SMALL = "_Small"
private constant string NAME_SUFIX_LARGE = "_Large"

//Options
private constant boolean IGNORE_LOW_DMG = true //Ignore damage equal or below to 1?
private constant boolean ONLY_HEROES = true //Display damage only on heroes? (Highly recommended to let it true)

//OBS: To make an "ignore list", go to lines 117 and 142
endglobals
//------------------------------------------------------------------------
//END OF CONFIGURATIONS
//------------------------------------------------------------------------
/*
* This struct draws the numbers on screen
*/
private struct Graphics

private static constant real SPACEMENT = 65.0 //Spacement between numbers
private static constant real RATIO_SMALL = 0.7 //Ratio of spacement between small numbers
private static constant real RATIO_LARGE = 1.3 //Ratio of spacement between large numbers

/*
* Draw a number on a determined position
*/
private static method drawNumber takes string number, real posX, real posY, string sufix returns nothing
call DestroyEffect(AddSpecialEffect(NAME_PREFIX + number + sufix + ".mdx", posX, posY))
endmethod

/*
* Get an aligned position
*/
private static method getPosition takes real initialPos, integer actual, integer final, real ratio returns real
return initialPos - (SPACEMENT * ratio * (final / 2)) + (SPACEMENT * ratio * actual)
endmethod

/*
* Draw the numbers on the screen
*/
public static method draw takes unit target, real amount returns nothing
local real posX = GetUnitX(target)
local real posY = GetUnitY(target) + GetUnitFlyHeight(target)
local string numbers = I2S(R2I(amount))
local integer size = StringLength(numbers)
local real newX
local string sufix
local real ratio
local integer i
if amount >= HIGH_DMG then
set sufix = NAME_SUFIX_LARGE
set ratio = RATIO_LARGE
elseif amount >= NORMAL_DMG then
set sufix = ""
set ratio = 1.0
else
set sufix = NAME_SUFIX_SMALL
set ratio = RATIO_SMALL
endif
for i = 0 to (size - 1)
set newX = thistype.getPosition(posX, i, size, ratio)
call thistype.drawNumber(SubString(numbers, i, i + 1), newX, posY, sufix)
endfor
endmethod

endstruct

/*
* This struct register the events
*/
private struct System

private static trigger mainTrig

/*
* Show the damage on the screen
*/
private static method showDamage takes nothing returns boolean
local real amount = GetEventDamage()
if (IGNORE_LOW_DMG and amount > 1) or (not IGNORE_LOW_DMG) then
call Graphics.draw(GetTriggerUnit(), GetEventDamage())
endif
return false
endmethod

/*
* Register an entering unit on the system
*/
private static method enterMap takes nothing returns boolean
if (ONLY_HEROES and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO)) or (not ONLY_HEROES) then
call TriggerRegisterUnitEvent(mainTrig, GetTriggerUnit(), EVENT_UNIT_DAMAGED)
endif
return false
endmethod

/*
* Create a trigger to register an entering unit on the system
*/
private static method addFutureUnits takes nothing returns nothing
local trigger trig = CreateTrigger()
local region rectRegion = CreateRegion()
call RegionAddRect(rectRegion, bj_mapInitialPlayableArea)
call TriggerRegisterEnterRegion(trig, rectRegion, null)
call TriggerAddCondition(trig, Condition(function thistype.enterMap))
endmethod

/*
* Register the preplaced units on the system
*/
private static method addPreplacedUnits takes nothing returns nothing
local group preplacedUnits = CreateGroup()
local unit pickedUnit
call GroupEnumUnitsInRect(preplacedUnits, bj_mapInitialPlayableArea, null)
for pickedUnit in preplacedUnits
if (ONLY_HEROES and IsUnitType(pickedUnit, UNIT_TYPE_HERO)) or (not ONLY_HEROES) then
call TriggerRegisterUnitEvent(mainTrig, pickedUnit, EVENT_UNIT_DAMAGED)
endif
endfor
call DestroyGroup(preplacedUnits)
set preplacedUnits = null
set pickedUnit = null
endmethod

/*
* Create the main trigger
*/
private static method createMainTrigger takes nothing returns nothing
set mainTrig = CreateTrigger()
call TriggerAddCondition(mainTrig, Condition(function thistype.showDamage))
endmethod

private static method onInit takes nothing returns nothing
call thistype.createMainTrigger()
call thistype.addPreplacedUnits()
call thistype.addFutureUnits()
endmethod

endstruct

endlibrary[/jass]
Image
Credits: IncendiaryMonkey
You do not have the required permissions to view the files attached to this post.

Return to “Systems”

×