Another simple JASS question...

Cloak_Master

Active Member
Reaction score
41
Alright folks, I'm having another problem with JASS (What's new...) Anyways, I'm trying to make an ability that shrugs off damage for the unit. The code is like this.

Code:
function Trig_Steel_Shell_Ability_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetAttackedUnitBJ()) == 'o00T' ) ) then
return false
endif
return true
endfunction

function Trig_Steel_Shell_Ability_Func002C takes nothing returns boolean
if ( not ( udg_DiceRoll[1] <= 9 ) ) then
return false
endif
return true
endfunction

function Trig_Steel_Shell_Ability_Actions takes nothing returns nothing
set udg_DiceRoll[1] = GetRandomInt(1, 100)
if ( Trig_Steel_Shell_Ability_Func002C() ) then
set udg_RandomREAL[1] = GetUnitStateSwap(UNIT_STATE_LIFE, GetAttackedUnitBJ())
call TriggerSleepAction( 0.30 )
call CreateTextTagUnitBJ( ( R2S ((udg_RandomREAL[1] - GetUnitStateSwap(UNIT_STATE_LIFE,GetAttackedUnitBJ()))) + " damage shrugged off" ), GetAttackedUnitBJ(), 0, 10, 0.00, 100, 0.00, 0 )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 2.00 )
call SetUnitLifeBJ( GetAttackedUnitBJ(), udg_RandomREAL[1] )
call AddSpecialEffectLocBJ( GetUnitLoc(GetAttackedUnitBJ()), "Abilities\\Spells\\NightElf\\Taunt\\TauntCaster.mdl" )
set udg_LeakControl[10] = GetLastCreatedEffectBJ()
call DestroyEffectBJ( udg_LeakControl[10] )
else
call DoNothing(  )
endif
endfunction

The problem?

This line...
Code:
call CreateTextTagUnitBJ( ( R2S ((udg_RandomREAL[1] - GetUnitStateSwap(UNIT_STATE_LIFE,GetAttackedUnitBJ()))) + " damage shrugged off" ), GetAttackedUnitBJ(), 0, 10, 0.00, 100, 0.00, 0 )

It shows the damage shrugged off as a real, and I want to round it up to an integer. But I can't find where to put the code. Any thoughts? Thanks.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Code:
call CreateTextTagUnitBJ( ( I2S(R2I ((udg_RandomREAL[1] - GetUnitStateSwap(UNIT_STATE_LIFE,GetAttackedUnitBJ())))) + " damage shrugged off" ), GetAttackedUnitBJ(), 0, 10, 0.00, 100, 0.00, 0 )

Try that.

May I ask why you translated that to custom script? It looks exactly as an gui trigger.

@zyzfcs: You can write jass in the normal trigger editor, just use Edit/Convert to Custom Text and it let you write your own code. However jass isnt simple, and it is easy to make misstakes for someone new to jass.
If you realy want to learn jass I suggest that you read our 2 jass tutorials here:
http://world-editor-tutorials.thehelper.net/
 

Cloak_Master

Active Member
Reaction score
41
Because I had no idea how to make it go from a real to a string them from that to an integer without JASS. Thanks though.
 

emjlr3

Change can be a good thing
Reaction score
395
yea that same exact thing could be done in GUI, if your new, or dont know what your doing, only use JASS when needed, here it is not
 

Cloak_Master

Active Member
Reaction score
41
emjlr3 said:
yea that same exact thing could be done in GUI, if your new, or dont know what your doing, only use JASS when needed, here it is not

I am not either... I'm just not accustomed to working with strings. I much prefer math... Anyways... thanks for adding to that.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top