• 🏆 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!

[Solved] Basic Variable Assignment :(

Status
Not open for further replies.
Level 1
Joined
Jan 23, 2015
Messages
160
I'm trying to implement TriggerHappy's Equipment System and I'm just bad at everything I think. I'm just trying to change what unit gets to use the system, I can't even figure out how to assign "equipment" to a unit I want, instead of the default based on what race you are. I think this is supposed to be easy to do but I'm too dumb. Hope someone can help. Thanks!

JASS:
scope StartGame initializer Init
    globals
        Camera array PlayerCamera
        unit array PlayerHero
    endglobals
    private function StartGame takes nothing returns nothing
        local trigger trig
        local integer i = 0
        local User user
        local Equipment equipment
        local Inventory inv
        local integer array urace
       
        set urace[1] = 'Hpal'
        set urace[2] = 'Obla'
        set urace[3] = 'Ulic'
        set urace[4] = 'Edem'
        loop
            exitwhen i == User.AmountPlaying
           
            set user = User.fromPlaying(i)
            set PlayerCamera[user.id] = Camera.create()
           
            // create hero
            set equipment = equipment.create.evaluate(CreateUnitAtLoc(user.handle, urace[GetHandleId(GetPlayerRace(user.handle))], GetStartLocationLoc(GetPlayerStartLocation(user.handle)), 180))
           
            call UnitAddAbility(equipment.unit, 'A001')
            call UnitAddAbility(equipment.unit, 'A002')
           
            if (User.Local == user.handle) then
                call SelectUnit(equipment.unit, true)
                call PanCameraToTimed(GetUnitX(equipment.unit), GetUnitY(equipment.unit), 0)
            endif
           
            set inv = Inventory.create(equipment.unit)
           
            set PlayerHero[user.id] = equipment.unit
           
            call SetPlayerAllianceStateBJ(Player(bj_PLAYER_NEUTRAL_EXTRA), user.handle, bj_ALLIANCE_ALLIED_VISION)
            call SetPlayerAllianceStateBJ(user.handle, Player(bj_PLAYER_NEUTRAL_EXTRA), bj_ALLIANCE_ALLIED_VISION)
           
            set i = i + 1
        endloop
    endfunction
   
    private function Init takes nothing returns nothing
        call SetSkyModel("Environment\\Sky\\Sky\\SkyLight.mdl")
        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 22.00)
        call StartGame()
    endfunction
endscope
 
Level 1
Joined
Jan 23, 2015
Messages
160
I edited your Star Game trigger to replace the equipment.create to what it is now, set equipment = equipment.create(udg_myunit)

It compiles properly but when I go into the game, the unit doesn't have the abilities of Character and Inventory. Adding these abilities to the hero manually crashes the game upon loading.

JASS:
scope StartGame initializer Init
    globals
        Camera array PlayerCamera
        unit array PlayerHero
    endglobals
    private function StartGame takes nothing returns nothing
        local trigger trig
        local integer i = 0
        local User user
        local Equipment equipment
        local Inventory inv
        local integer array urace
      
        set urace[1] = 'Hpal'
        set urace[2] = 'Obla'
        set urace[3] = 'Ulic'
        set urace[4] = 'Edem'
        loop
            exitwhen i == User.AmountPlaying
          
            set user = User.fromPlaying(i)
            set PlayerCamera[user.id] = Camera.create()
          
            // create hero
            set equipment = equipment.create(udg_myunit)
          
            call UnitAddAbility(equipment.unit, 'A001')
            call UnitAddAbility(equipment.unit, 'A002')
          
            if (User.Local == user.handle) then
                call SelectUnit(equipment.unit, true)
                call PanCameraToTimed(GetUnitX(equipment.unit), GetUnitY(equipment.unit), 0)
            endif
          
            set inv = Inventory.create(equipment.unit)
          
            set PlayerHero[user.id] = equipment.unit
          
            call SetPlayerAllianceStateBJ(Player(bj_PLAYER_NEUTRAL_EXTRA), user.handle, bj_ALLIANCE_ALLIED_VISION)
            call SetPlayerAllianceStateBJ(user.handle, Player(bj_PLAYER_NEUTRAL_EXTRA), bj_ALLIANCE_ALLIED_VISION)
          
            set i = i + 1
        endloop
    endfunction
  
    private function Init takes nothing returns nothing
        call SetSkyModel("Environment\\Sky\\Sky\\SkyLight.mdl")
        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 22.00)
        call StartGame()
    endfunction
endscope

If I attempt to just do call equipment.create(udg_myunit) as a custom script, I get an error saying "equipment is not a type that allows . syntax"

I've been banging my head against the wall trying to do something that must be pretty simple but I keep screwing it up or not getting the intended result. I know I've bugged you about this system a hundred times over what is probably pretty trivial stuff but hot damn do I need a step by step on what I'm doing wrong.
upload_2018-3-3_15-8-31.png


When I add the abilities to myunit through triggers or manually, if I click on him, game crashes.
 
Last edited:
Level 1
Joined
Jan 23, 2015
Messages
160
The crash only occurs when I attempt to change the equipment = equipment.create underneath //create hero.

I can change it to a hero of my choosing, but this hero won't get the Character or Inventory abilities. If I had them manually or thru another trigger, I get a few seconds into the game before crash.

I'm not certain how to safely change it to a variable (unit) of my choosing. I have seen others use this system so I know it is possible, but the example for creating a hero given in the example map for this system is pretty confusing (for me)


-

I figured it out with a lot of help, but it was super easy and I'm embarrassed. Case closed, thanks all
 
Last edited:
Status
Not open for further replies.
Top