- Joined
- Dec 12, 2008
- Messages
- 7,385
I've been having some issues with my code for the "Floating Text Kills System"
I'm changing it JASS/vJASS, but for some reason, the floating texts won't show up in game D:
Here's the code:
Please help
I'm changing it JASS/vJASS, but for some reason, the floating texts won't show up in game D:
Here's the code:
JASS:
library FTKS initializer InitFTKS
//************************************************************************
// Floating Text Kills System v2.0.0
//
// Created by:
// Magtheridon96
//
// Written in: vJASS
//
// [url]www.hiveworkshop.com[/url]
//************************************************************************
//
//************************************************************************
//
// This system was created on January 30, 2011.
//
// To implement the system, simply go to the "Implementation"
// section of the Documentation and follow the given instructions.
//
// If you find any bugs, exploits, leaks, or problems in general,
// please report them to me at [url]www.hiveworkshop.com[/url]. Suggestions
// and "gentle" constructive critisism would be appreciated.
//
// Remember to give credit to me (Magtheridon96) if you implement
// this system into your map.
//
//************************************************************************
//
//************************************************************************
//
//
// Changelog
//
// Last Updated: April 9, 2011
//
// *** v1.0.0 ***
// Release of Floating Text Kills System
//
// *** v1.1.0 ***
// Fixed some leaks
// Added new strings
// Gave system a bit of intelligence (It's still stupid anyways :P)
//
// *** v2.0.0 ***
// Completely rewrote the system in vJASS
// Changed version numbers =P
//
//************************************************************************
//
//************************************************************************
//
// Implementation
//
// 1- Create a new trigger
// 2- Click Edit -> Convert to Custom Text
// 3- Copy all the contents of this trigger into your trigger
// 4- Enjoy :)
//
//************************************************************************
//
//************************************************************************
//
// Modifications
//
// This system is just begging for user modifications.
// I gave you samples of strings you can use as floating texts.
// Feel free to modify them, and in rare cases, if your map has
// completely different player colors, feel free to change the
// Player Color variables.
//
//************************************************************************
globals
// The Kill Strings
private constant string array KS
// The Player Colors
private constant string array KC
// How many strings correspond to a hard kill?
private constant integer SH = 5
// How many strings are there?
private constant integer MAX_STRINGS = 10
// What do you consider as "High HP" in your map?
private constant real HIGH_HP = 2000.00
// Does the system work for heroes and ONLY heroes?
private constant boolean ONLY_FOR_HEROES = false
// The lifespan of the floating text
private constant real TEXT_AGE = 2.50
// The fading age of the floating text
private constant real TEXT_FADE_AGE = 1.75
// The size of the floating text
private constant real TEXT_FONT = 8.00
// The velocity of the floating text
private constant real TEXT_SPEED = 64.00
// The angle of the floating text
private constant real TEXT_ANGLE = 90.00
endglobals
private function Settings takes nothing returns nothing
//======================================
// Strings that correspond to hard kills
//======================================
set KS[1] = "PWNED"
set KS[2] = "OWNED"
set KS[3] = "ULTRA KILL!"
set KS[4] = "EPIC!"
set KS[5] = "AWESOME!"
//======================================
// Strings that correspond to easy kills
//======================================
set KS[6] = "NOOB!"
set KS[7] = "lol"
set KS[8] = "Omg"
set KS[9] = "Ouch :/"
set KS[10] = "HEY!"
//==============
// Player Colors
//==============
set KC[1] = "|cffff0303"
set KC[2] = "|cff0042ff"
set KC[3] = "|cff1ce6b9"
set KC[4] = "|cff540081"
set KC[5] = "|cffffff01"
set KC[6] = "|cfffe8a0e"
set KC[7] = "|cff20c000"
set KC[8] = "|cffe55bb0"
set KC[9] = "|cff959697"
set KC[10] = "|cff7ebff1"
set KC[11] = "|cff106246"
set KC[12] = "|cff4e2a04"
set KC[13] = "|cffffffff"
set KC[14] = "|cffffffff"
set KC[15] = "|cffffffff"
set KC[16] = "|cffffffff"
endfunction
private function CreateFT takes integer i, integer i2 returns nothing
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
local integer pi = GetPlayerId(p)
local texttag tt
local real v
local real x
local real y
//===============================
// We create the floating text
//===============================
set tt = CreateTextTag()
//===============================
// Here, we set:
//
// -Text
// -Text Age
// -Text Fading Age
// -Text Position
// -Text Permanency
// -Text Font
//===============================
call SetTextTagAge(tt, TEXT_AGE)
call SetTextTagText(tt, KC[pi+1] + KS[GetRandomInt(i, i2)] + "|r", TEXT_FONT)
call SetTextTagPosUnit(tt, u, 100.00)
call SetTextTagFadepoint(tt, TEXT_FADE_AGE)
call SetTextTagPermanent(tt, false)
//===============================
// Here, we give the floating
// text it's velocity.
//===============================
set v = TEXT_SPEED * 0.0005546875 // Don't ask :P
set x = v * Cos(TEXT_ANGLE * bj_DEGTORAD)
set y = v * Sin(TEXT_ANGLE * bj_DEGTORAD)
call SetTextTagVelocity(tt, x, y)
endfunction
private function execFTKS takes nothing returns nothing
local unit u = GetTriggerUnit()
local real hp = GetUnitState(u, UNIT_STATE_MAX_LIFE)
local integer i = 1
if (ONLY_FOR_HEROES) then
if IsUnitType(u, UNIT_TYPE_HERO) and hp <= HIGH_HP then
call CreateFT(1, SH)
else
call CreateFT(SH + 1, MAX_STRINGS)
endif
else
if hp <= HIGH_HP then
call CreateFT(1, SH)
else
call CreateFT(SH + 1, MAX_STRINGS)
endif
endif
endfunction
private function InitFTKS takes nothing returns nothing
local trigger t
local integer i = 0
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
call Settings()
call TriggerAddAction(t, function execFTKS)
endfunction
endlibrary
Please help