MasterOfRa
New Member
- Reaction score
- 10
Is there any reason that you cannot update text tags more than once a second?
I am trying to update them every .3 second, which includes changing their location for the enemys, but it seems to only occur every 1 second.
i am useing a periodic timer that occurs every .3 second, was at .1, i was testing it at a difforent value, which calls the function for all the towers, or enemys, it is only updating every one second.
I am trying to update them every .3 second, which includes changing their location for the enemys, but it seems to only occur every 1 second.
JASS:
library PeriodicStuff initializer init uses Recycler, TowerProperties
globals
endglobals
private function Periodic takes nothing returns nothing
local group g = NewGroup()
local TowerProperties data
local EnemyProperties Data
local unit u
local string s
local integer count
local real x
local real y
local texttag tt
local integer index
local integer int
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g,u)
if (GetWidgetLife(u) > .405)then
set index = GetUnitUserData(u)
if index != 0 then
set data = TowerProperties<u>
if (data != null) then
call data.Process(0.3)
// Health First
endif
else
endif
endif
endloop
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g,u)
if (GetWidgetLife(u) > .405)then
set index = GetUnitUserData(u)
if index != 0 then
set Data = EnemyProperties<u>
if (Data != null) then
call Data.Process(0.3)
endif
endif
endif
endloop
call ReleaseGroup(g)
set tt = null
set g = null
endfunction
private function init takes nothing returns nothing
call TimerStart(NewTimer(),.3,true,function Periodic)
endfunction
endlibrary</u></u>
JASS:
library TowerProperties uses PUI
globals
private constant string FX_SHIELD_RECHARGE = "Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl"
endglobals
struct TowerProperties
//! runtextmacro PUI()
integer techLevel // How high weapons you can buy
integer currentTech // How close you are to the next tech Level
integer damageUpgradeLevel // How high Damage has been upgraded
integer energyUpgradeLevel // How high Energy has been upgraded
integer shieldUpgradeLevel // How high Shields have been upgraded
integer damageMult // What percent of normal damage you deal
real currentEnergy // How high your energy is
integer maxEnergy // How high your energy can go
real currentShield // How high your shield energy is
integer maxShield // How high your shield energy can go
real rechargeRate // Determins how fast effeciency goes up
boolean isShieldOn // Determins whether or not to use the shield
unit owner // Who these stats belong to
integer missiles // How many missiles are lanched at a time?
real angleDelta // How big the angle between the missiles are
texttag ttHealth
texttag ttShield
texttag ttEnergy
texttag ttTech
method Process takes real duration returns nothing
local string s
local integer int
local real x = GetUnitX(.owner)
local real y = GetUnitY(.owner)
local integer count
set .currentEnergy = .currentEnergy + ((.maxEnergy / 17)*duration)
if .currentEnergy > .maxEnergy then
set .currentEnergy = .maxEnergy
endif
set .currentShield = .currentShield + ((.maxShield / 17)*duration)
if .currentShield > .maxShield then
set .currentShield = .maxShield
if .currentEnergy == .maxEnergy then
if not .isShieldOn then
set .isShieldOn = true
call DestroyEffect(AddSpecialEffectTarget(FX_SHIELD_RECHARGE,.owner,"origin"))
set s = GetPlayerName(GetOwningPlayer(.owner))+"039;s "+GetUnitName(.owner)+"039;s Shield has Been Recharged"
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, s)
endif
endif
endif
call SetUnitState(.owner, UNIT_STATE_MANA,GetUnitState(.owner,UNIT_STATE_MANA)+(.rechargeRate * duration))
// Health first
set int = R2I((GetUnitState(.owner,UNIT_STATE_LIFE)/GetUnitState(.owner,UNIT_STATE_MAX_LIFE))*TAG_LENGTH)
set s = COLOR_LIFE
set count = 0
loop
exitwhen count > (TAG_LENGTH - 1)
if count == int then
set s = s + COLOR_EMPTY
endif
set s = s + BAR_CHAR
set count = count + 1
endloop
call SetTextTagText(.ttHealth, s, TAG_SIZE)
call SetTextTagPos(.ttHealth, x - TEXT_SHIFT, y, 100.0)
// Energy Next
set int = R2I((.currentEnergy/.maxEnergy)*TAG_LENGTH)
set s = COLOR_ENERGY
set count = 0
loop
exitwhen count > (TAG_LENGTH - 1)
if count == int then
set s = s + COLOR_EMPTY
endif
set s = s + BAR_CHAR
set count = count + 1
endloop
call SetTextTagText(.ttEnergy, s, TAG_SIZE)
call SetTextTagPos(.ttEnergy, x - TEXT_SHIFT, y, 125.0)
// Now for Shields
set int = R2I((.currentShield/.maxShield)*TAG_LENGTH)
if .isShieldOn then
set s = COLOR_SHIELD
else
set s = COLOR_SHIELD_OFF
endif
set count = 0
loop
exitwhen count > (TAG_LENGTH - 1)
if count == int then
set s = s + COLOR_EMPTY
endif
set s = s + BAR_CHAR
set count = count + 1
endloop
call SetTextTagText(.ttShield, s, TAG_SIZE)
call SetTextTagPos(.ttShield, x - TEXT_SHIFT, y, 150.0)
// And Lastly TechLevel
set int = R2I((I2R(.currentTech)/((I2R(.techLevel) + 1)*4))*TAG_LENGTH)
set s = COLOR_TECH_LEVEL
set count = 0
loop
exitwhen count > (TAG_LENGTH - 1)
if count == int then
set s = s + COLOR_EMPTY
endif
set s = s + BAR_CHAR
set count = count + 1
endloop
call SetTextTagText(.ttTech, s, TAG_SIZE)
call SetTextTagPos(.ttTech, x - TEXT_SHIFT, y, 175.0)
if GetLocalPlayer() != GetOwningPlayer(.owner) then
if DisplayAllyBars then
call SetTextTagVisibility(.ttHealth, true)
call SetTextTagVisibility(.ttShield, true)
call SetTextTagVisibility(.ttEnergy, true)
call SetTextTagVisibility(.ttTech , true)
else
call SetTextTagVisibility(.ttHealth, false)
call SetTextTagVisibility(.ttShield, false)
call SetTextTagVisibility(.ttEnergy, false)
call SetTextTagVisibility(.ttTech , false)
endif
endif
endmethod
method ModifyMissileCount takes integer change returns nothing
set .missiles = .missiles + change
if .missiles < 1 then
set .missiles = 1
call SimError(GetOwningPlayer(.owner),"You cannot fire 0 missiles!")
elseif .missiles > 5 then
set .missiles = 5
call SimError(GetOwningPlayer(.owner),"You cannot fire more than 5 missiles!")
elseif .missiles == 1 then
if GetLocalPlayer() == GetOwningPlayer(.owner) then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,5,"Now fireing "+I2S(.missiles)+" missile at a time.")
endif
else
if GetLocalPlayer() == GetOwningPlayer(.owner) then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,5,"Now fireing "+I2S(.missiles)+" missiles at a time.")
endif
endif
endmethod
method Display takes player whichPlayer returns nothing
if GetLocalPlayer() == whichPlayer then
call ClearTextMessages()
endif
call DisplayTimedTextToPlayer(whichPlayer, 0.52, -1.00,15,GetPlayerName(GetOwningPlayer(.owner))+"039;s Stats:")
call DisplayTimedTextToPlayer(whichPlayer, 0.52, -1.00,15," - Tech Level: "+I2S(.techLevel )+" -- "+I2S((.currentTech * 100)/((.techLevel + 1) * 4))+"%")
call DisplayTimedTextToPlayer(whichPlayer, 0.52, -1.00,15," - Damage Level: " +I2S(.damageUpgradeLevel)+" -- "+I2S(.damageMult)+"%")
call DisplayTimedTextToPlayer(whichPlayer, 0.52, -1.00,15," - Shield Level: "+I2S(.shieldUpgradeLevel)+" -- "+I2S(R2I(.currentShield))+"/"+I2S(.maxShield))
call DisplayTimedTextToPlayer(whichPlayer, 0.52, -1.00,15," - Energy Level: " +I2S(.energyUpgradeLevel)+" -- "+I2S(R2I(.currentEnergy))+"/"+I2S(.maxEnergy))
endmethod
endstruct
endlibrary
JASS:
library EnemyProperties uses PUI, Globals
struct EnemyProperties
//! runtextmacro PUI()
real damageMin
real damageMax
integer critChance
real critMult
integer bounty
real currentShield
real shieldGen
integer maxShield
real splash
boolean isShieldOn
unit owner
texttag ttHealth
texttag ttShield
method Process takes real duration returns nothing
local string s
local integer int
local real x = GetUnitX(.owner)
local real y = GetUnitY(.owner)
local integer count
set .currentShield = .currentShield + (.shieldGen * duration)
if .currentShield > .maxShield then
set .currentShield = .maxShield
endif
// Health First
set int = R2I((GetUnitState(.owner,UNIT_STATE_LIFE)/GetUnitState(.owner,UNIT_STATE_MAX_LIFE))*TAG_LENGTH / 2)
set s = COLOR_LIFE
set count = 0
loop
exitwhen count > (TAG_LENGTH / 2 - 1)
if count == int then
set s = s + COLOR_EMPTY
endif
set s = s + BAR_CHAR
set count = count + 1
endloop
call SetTextTagText(.ttHealth, s, TAG_SIZE)
call SetTextTagPos(.ttHealth, x - TEXT_SHIFT / 2, y, 50.0)
if IsUnitVisible(.owner,Player(0)) then
if DisplayEnemyBars then
call SetTextTagVisibility(.ttHealth, true)
else
call SetTextTagVisibility(.ttHealth, false)
endif
else
call SetTextTagVisibility(.ttHealth, false)
endif
if .isShieldOn then
// Now for Shields
set int = R2I((.currentShield/.maxShield)*TAG_LENGTH)
set s = COLOR_SHIELD
set count = 0
loop
exitwhen count > (TAG_LENGTH / 2 - 1)
if count == int then
set s = s + COLOR_EMPTY
endif
set s = s + BAR_CHAR
set count = count + 1
endloop
call SetTextTagText(.ttShield, s, TAG_SIZE)
call SetTextTagPos(.ttShield, x - TEXT_SHIFT / 2, y, 75.0)
if IsUnitVisible(.owner,Player(0)) then
call SetTextTagVisibility(.ttShield, true)
else
call SetTextTagVisibility(.ttShield, false)
endif
endif
endmethod
method crit takes nothing returns boolean
if GetRandomInt(0,99) < .critChance then
return true
endif
return false
endmethod
endstruct
endlibrary
i am useing a periodic timer that occurs every .3 second, was at .1, i was testing it at a difforent value, which calls the function for all the towers, or enemys, it is only updating every one second.