• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[vJASS] Spell Floating Text Need Help

Status
Not open for further replies.
Level 4
Joined
Apr 7, 2012
Messages
63
This is a script for a spell.Holybolt will damage the target if it is an enemy or heal the target if it is an ally.I'm having some problems with floating text.It says that I can't convert a real to integer.

JASS:
scope HolyBolt initializer Init
globals
      private constant integer HolyBolt = 'A007'
      private constant string HEAL_EFFECT = "Abilities\\Spells\\Human\\ManaFlare\\ManaFlareBase.mdl"
      private constant string DAMAGE_EFFECT ="Abilities\\Weapons\\DemolisherFireMissile\\DemolisherFireMissile.mdl"
endglobals

private function HolyBolt_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A007'
endfunction

private function Actions takes nothing returns nothing
    local unit hero
    local unit target
    local integer lvl
    local real int 
    local real str
    local real damage                                 
    local real heal
    local integer pid
    local player owner
    
    
    set hero = GetTriggerUnit()
    set owner = GetOwningPlayer(hero)
    set pid = GetPlayerId(owner) + 1
    set target = GetSpellTargetUnit()
    set lvl = GetUnitAbilityLevel(hero,HolyBolt)
    set int = GetHeroInt(hero,true)
    set str = GetHeroStr(hero,true)
    set damage = (udg_StatsMentalPower[pid]*0.75)
    set heal = (udg_StatsMentalPower[pid]*0.75)
    
    if IsUnitAlly(target,GetOwningPlayer(hero)) then
        if GetRandomInt(1,100) <= udg_StatsMentalCriticalChance[pid] then
             call SetWidgetLife(target,GetWidgetLife(target)+heal+(udg_StatsMentalCriticalPower[pid]*0.75))
        else
             call SetWidgetLife(target,GetWidgetLife(target)+heal)
    call DestroyEffect(AddSpecialEffectTarget(HEAL_EFFECT,target,"chest") ) 
        endif
    endif
    if IsUnitEnemy(target,GetOwningPlayer(hero)) then
          if GetRandomInt(1,100) <= udg_StatsMentalCriticalChance[pid] then
               call UnitDamageTarget(hero,target,damage+(udg_StatsMentalCriticalPower[pid]*0.75),true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
               set udg_TempPoint = GetUnitLoc(udg_DamageEventTarget)
    call CreateTextTagLocBJ( R2S(damage) + I2S(udg_StatsMentalCriticalPower[pid]*0.75) , udg_TempPoint, 60.00, 10.00, 100, 100, 100, 0)
    call RemoveLocation(udg_TempPoint)
    call ShowTextTagForceBJ( false, GetLastCreatedTextTag(), GetPlayersAll() )
    call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
    call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 95.00, 90 )
    call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 2.00 )
    call ShowTextTagForceBJ( true, GetLastCreatedTextTag(), GetForceOfPlayer(GetOwningPlayer(hero)) )
    else 
                call UnitDamageTarget(hero,target,damage,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
     call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT,target,"origin") ) 
    endif
    endif
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger HolyBoltTrg = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( HolyBoltTrg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( HolyBoltTrg, Condition( function HolyBolt_Conditions ) )
    call TriggerAddAction( HolyBoltTrg, function Actions )
endfunction
endscope

At this line...
JASS:
call CreateTextTagLocBJ( R2S(damage) + I2S(udg_StatsMentalCriticalPower[pid]*0.75) , udg_TempPoint, 60.00, 10.00, 100, 100, 100, 0)

...is the syntax error.
 
Level 5
Joined
Jun 16, 2004
Messages
108
When you multiply an integer and a real, the result is a real. Therefore, either use R2S, or use I2S(R2I()), like this:
JASS:
call CreateTextTagLocBJ( R2S(damage) + I2S(R2I(udg_StatsMentalCriticalPower[pid]*0.75)) , udg_TempPoint, 60.00, 10.00, 100, 100, 100, 0)
 
Status
Not open for further replies.
Top