• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Bouncing Wisp, lol : D

Status
Not open for further replies.
Level 31
Joined
Jul 10, 2007
Messages
6,306
I made this while working on a system for testing purposes and found it fun to watch = ).

You need the latest vJASS to run this. You can just paste it into a random map and hit save/test and it'll run : P

JASS:
//! external ObjectMerger w3a Amrf PFLY ansf "(PFLY)" aart "" arac 0

struct Tester extends array
    //START_X and START_Y determined by map
    private static constant real START_PITCH = 225
    private static constant real START_YAW = 45
    private static constant real START_Z = 500
    
    private static constant integer PLATFORM_FLY = 'PFLY'
    private static constant real INTERVAL = .03125
        
    private static real fieldOffset
    private static unit u
    private static real x
    private static real y
    private static real z
    private static real yaw //left right
    private static real pitch //90 up, 270 down
    private static real yawRad
    private static real pitchRad
    private static real velocity
    private static real translationX
    private static real translationY
    private static real translationZ
    
    private static real maxX
    private static real maxY
    private static real minX
    private static real minY
    
    private static method run takes nothing returns nothing
        if (x >= maxX or x <= minX) then
            set translationX = translationX*-1
            set translationZ = translationZ * -1
        endif
        if (y >= maxY or y <= minY) then
            set translationY = translationY * -1
            set translationZ = translationZ * -1
        endif
        if (z <= 0 or z >= 1000) then
            set translationZ = translationZ * -1
        endif
        
        set x = x + translationX
        set y = y + translationY
        set z = z + translationZ
        
        call SetUnitX(u, x)
        call SetUnitY(u, y)
        call SetUnitFlyHeight(u, z, z/INTERVAL)
        
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, z+fieldOffset, 0)
        call SetCameraPosition(x, y+z/2)
    endmethod
    
    private static method onInit takes nothing returns nothing
        local fogmodifier fog = CreateFogModifierRect(Player(0), FOG_OF_WAR_VISIBLE, bj_mapInitialPlayableArea, true, false)
        set maxX = GetRectMaxX(bj_mapInitialPlayableArea)
        set maxY = GetRectMaxY(bj_mapInitialPlayableArea)
        set minX = GetRectMinX(bj_mapInitialPlayableArea)
        set minY = GetRectMinY(bj_mapInitialPlayableArea)
        set fieldOffset = GetCameraField(CAMERA_FIELD_TARGET_DISTANCE)
        set x = (RAbsBJ(maxX)-RAbsBJ(minX))/2
        set y = (RAbsBJ(maxY)-RAbsBJ(minY))/2
        set z = START_Z
        set pitch = START_PITCH
        set yaw = START_YAW+90
        call FogModifierStart(fog)
        call TimerStart(CreateTimer(), INTERVAL, true, function thistype.run)
        set u = CreateUnit(Player(0), 'ewsp', x, y, yaw)
        call SelectUnit(u, true)
        call SetPlayerAbilityAvailable(Player(0), PLATFORM_FLY, false)
        call UnitAddAbility(u, PLATFORM_FLY)
        call UnitMakeAbilityPermanent(u, true, PLATFORM_FLY)
        call SetUnitFlyHeight(u, z, z/INTERVAL)
        set pitchRad = pitch*bj_DEGTORAD
        set yawRad = yaw*bj_DEGTORAD
        set velocity = 100*10
        
        set translationX = INTERVAL*velocity*Sin(yawRad)*Cos(pitchRad)
        set translationY = INTERVAL*velocity*Cos(yawRad)*Cos(pitchRad)
        set translationZ = INTERVAL*velocity*Sin(pitchRad)
    endmethod
endstruct

And here is 3D targeting methinks. If anyone wants to check over my math, go for it : D. I winged it, lol (Never done 3D vectors before, just used mah logic)

JASS:
set yawRad = Atan2(targetY - yK, targetX - xK)
set yawK = yawRad*bj_RADTODEG
set pitchX = SquareRoot(Pow(targetX-xK, 2)+Pow(targetY-yK, 2))
set pitchY = targetZ-zK
set pitchRad = Atan2(pitchY, pitchX)
set pitchK = pitchRad*bj_RADTODEG
                        
set translationX = MOVE_INTERVAL*speedK*Sin(yawRad)*Cos(pitchRad)
set translationY = MOVE_INTERVAL*speedK*Cos(yawRad)*Cos(pitchRad)
set translationZ = MOVE_INTERVAL*speedK*Sin(pitchRad)

Next I gotta do magnetism, elasticity, friction, precise collision, and gravity i think? : O
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
I know it's pretty basic ^.^

Like I said, was just a fun little thing i whipped up while designing a system ^.^

Wanting to do stuff like elasticity, gravity, magnetism, friction, and precise collision ; ). I'm planning so that you can have like things riding objects and so on.

This is what I've imagined for the longest time-
A flying city with moving floors (imagine linked platforms moving in different directions, like column 1 goes up and column 2 goes down, and imagine that the pattern continues all across)

Units being able to walk all over while being carried like normal

A hallway with holes in the floor (floor still moving)

Canons on either side firing rockets into the air with slight homing

Flying monsters (imagine regular 3D) with swords and magic (warriors land and fight and lift off and wizards cast)

A hero with a gun providing support on a platform
A lead warrior leading the way across
A priest healing people where the spell effectiveness is based on the ability of the priest to outline a line with a mouse
Platforms being made up of many smaller platforms, so as a piece is damaged enough, it'll fall off like debris coming off of a building


Honestly, that scenario would be so fun to play!! That is my dream, to make that ; D.

Ofc I'd want different projectiles to have gravity/charges/magnetism/elasticity so you could have absolutely wild spells.

Also imagine jumping up and down on a highly elastic floor or walking across these platforms with almost no friction? Or gliding around on a rocket pack : O.

I think it all begins with a powerful vector and spawn system (spawning so that effects can be shared across, like rocket attacks on canons, plus so these effects can be generated in patterns with ease, like a huge ball of fire made up of many units that eventually explodes (easy with adv spawning+adv vectors)).
 
Status
Not open for further replies.
Top