• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Angle problem

Status
Not open for further replies.
Level 13
Joined
Mar 16, 2008
Messages
941
EDIT: Found the problem. xecollider uses xefx, what requires radians, damn me.

Hey guys.
Like somebody may have read I'm testing xe (from Vexorian) at the moment, but I'm facing a problem and I can't find the mistake:
JASS:
scope CagedOutside initializer InitCage

    globals
        private constant integer ID_SPELL = 'A002'
        private constant integer ID_STUN = 'A003'
        private constant integer ID_DUMMY_ORDER = 852095 //Thunderbolt
        
        private constant integer MISSLE_AMOUNT = 4
        private constant integer MISSLE_INCREASE = 2
        private constant string MISSLE_PATH = "Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl"
        
        private constant string COLLISION_PATH = "Objects\\Spawnmodels\\Human\\FragmentationShards\\FragBoomSpawn.mdl"
        
        private constant real SIZE_RADIUS = 100.
    endglobals

    private struct Cage extends xecollider
        private unit caster
        private player owner
        private real damage
        
        
        method onUnitHitEx takes unit target returns nothing
            local xecast cagecast = xecast.createBasicA(ID_STUN, ID_DUMMY_ORDER, this.owner)
            local xedamage cagedamage = xedamage.create()
            
            call cagecast.castOnAOE(this.x, this.y, SIZE_RADIUS)
            set cagedamage.exception = UNIT_TYPE_STRUCTURE
            call cagedamage.damageAOE(this.caster, this.x, this.y, SIZE_RADIUS, this.damage)
            call cagedamage.destroy()
        endmethod
        
        method onUnitHit takes unit target returns nothing
            if IsUnitEnemy(target, this.owner) and not IsUnitType(target, UNIT_TYPE_STRUCTURE) then
                call this.onUnitHitEx(target)
                call DestroyEffect(AddSpecialEffect(COLLISION_PATH, this.x, this.y))
                call this.terminate()
            endif
        endmethod
        
        static method startex takes nothing returns nothing
            local thistype this
            local unit caster = GetTriggerUnit()
            local player owner = GetOwningPlayer(caster)
            local real x = GetUnitX(caster)
            local real y = GetUnitY(caster)
            local real facing = GetUnitFacing(caster)
            local integer level = GetUnitAbilityLevel(caster, ID_SPELL)
            local integer i = 0
            local integer imax = MISSLE_AMOUNT+MISSLE_INCREASE*level
            local real factor = 360./imax
            
            loop
                exitwhen i >= imax
                
                call BJDebugMsg(R2S(factor*i))
                set this = Cage.create(x, y, factor*i+facing)
                set this.fxpath = MISSLE_PATH
                set this.speed = 600
                set this.z = 50
                set this.expirationTime = 2.
                
                set this.caster = caster
                set this.owner = owner
                set this.damage = level*70
                
                set i = i+1
            endloop
            
            set caster = null
        endmethod
        
        static method start takes nothing returns boolean
            if GetSpellAbilityId() == ID_SPELL then
                call thistype.startex()
            endif
            return false
        endmethod
            
    endstruct
    
    private function InitCage takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        
        loop
            exitwhen i >= bj_MAX_PLAYER_SLOTS
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, BOOLEXPR_TRUE)
            set i = i+1
        endloop
        call TriggerAddCondition(t, Condition(function Cage.start))
        
        call XE_PreloadAbility('A003')
        call Preload(MISSLE_PATH)
        call Preload(COLLISION_PATH)
    endfunction
endscope

It's quite simple: xecollider creates (level+(level-1)) missles which explode upon impact, stunning all units within a explosion range of 100.
However, this completly works, but the angles of the missles are completly wrong, BUT the debug messages show that the angles are set correctly.
Dumb me? I've added shots of 4, 6 and 8 missles.

Greets, Justify

PS: The ex-methods are used because I don't want the locals to be allocated each time a wrong spell is cast/a wrong unit is found, being more unperformant in my logic then this extra method call.

PPS: No, it's not a facing bug btw. This also occures when I remove the facing part.

PPPS: (...) Yes, each single spell creates the right amount of messages. The extra numbers are from previous screenshot tries
 

Attachments

  • WC3ScrnShot_120709_194618_01.jpg
    WC3ScrnShot_120709_194618_01.jpg
    115.8 KB · Views: 93
  • WC3ScrnShot_120709_193526_02.jpg
    WC3ScrnShot_120709_193526_02.jpg
    114 KB · Views: 127
  • WC3ScrnShot_120709_194152_04.jpg
    WC3ScrnShot_120709_194152_04.jpg
    116.3 KB · Views: 95
Last edited:
Status
Not open for further replies.
Top