• 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.

[JASS] changing a unit's model mid-game

Status
Not open for further replies.
Level 3
Joined
Feb 7, 2006
Messages
14
Google results consist of a post on bnet forums where vexorian also asks this. wc3sear.ch results 0. Is it possible with JASS script to change a unit's Model attribute mid-game?

i.e. have a footman walk onto a pad and he looks like a knight, but other than appearence hes still the same footman.


If not, is it possible to use the "Something comes within -range- of -unit-" event with a newely-created-mid-game unit, despite having to select a pre-placed-existing unit in the WorldEdit GUI.


Both would massively reduce lag in dodgeball :)
 
Level 5
Joined
May 22, 2006
Messages
150
Actually it looks like this " "Something comes within -range- of -unit-" event" does not work at all.

But it may be possible by using the "Something enters the region -region-" event.

I will try to solve your problem, but please first describe, where exactly the unit shall "transform".
Is it a static place? A moving location? A jumping one? Maybe the surroundings of another unit?

And shall extra stuff occur?
Maybe the selection of the "transforming" unit jumping from the removed to the newly created one?
 
Level 3
Joined
Feb 7, 2006
Messages
14
Thankyou for the responce, it has been confirmed that:
changing a units model property mid-game is not possible. Moving on..

metamorphosis is not an option.

using regions is not an option, because while they can technically move, to all intense purposes they effectively cant, its basically a trigger which shouldnt be in the world edit because its not possible with the war3 game engine.

the matter at hand now, is the (comes within -range- of -unit-) event.

LordZsar1 i can confirm that the event works because my dodgeball map's dodge detection has been using it successfully for 5 patches.

However what does NOT work, due to being denied by the World Edit GUI, is to have the -unit- equal to any old unit. The unit MUST be a pre-existing pre-placed on-map-initialisation unit somewhere on the map.

More specifically, dodgeball maps give players the freedom to choose their heros (from 6 options) at the start. Multiple players can have the same hero. Thus when a player chooses his hero, a new hero is made for them. Players do not play with pre-placed pre-existing units.

This problem is about providing an event to proc when a ball comes within a certain range of any of the heros. Its not possible by constantly centering a region on each player, because as ive just said regions CANNOT be moved (it doesn't work). Its not possible using the World Edit within -range- event because the players heros cannot be used as the -unit- of the event, because they didnt exist on map loading.

What i seek, specifically, is whether JASS has the power to use a newly created unit as the -unit- of that event; because the world edit does not.

There is no other way to go about what i seek, the map is already operational but using a laggy work-around. Using the within -range- event with the players newely created units as the -unit-, is the ONLY way to further this map function.

In most likelyhood there really isnt anything else to be done, this is just a hopeful post ^_^
 
Level 2
Joined
Sep 10, 2004
Messages
21
because as ive just said regions CANNOT be moved (it doesn't work)
WE says they cant be moved if they´re preset. IMO you can move it if you make it a variable and create a rect by trigger, then moving it.

What i seek, specifically, is whether JASS has the power to use a newly created unit as the -unit- of that event

(triggers when the hero is created, assuming udg_hero[a] is the hero of player a which was just created)
JASS:
call TriggerRegisterUnitInRangeSimple(gg_trg_ballhits,udg_hero[a],150)
would add the event "a unit comes in 150 range of hero[a]" to the trigger "ballhits".
You can add this in a "Custom Script" line in a GUI trigger.
You just should add a condition to "ballhits" which is:
Unit Type Comparison - Unit Type of (Triggering Unit) equal to (Ball Unit Type)

That´s it.
 
Level 5
Joined
Feb 16, 2006
Messages
151
What i seek, specifically, is whether JASS has the power to use a newly created unit as the -unit- of that event; because the world edit does not.
It does, I have that in my map. But I don't know the details of yours, so ...
Hmm...
So, let's see:
Try this
JASS:
local trigger OK = CreateTrigger()
local unit created
set created = CreateUnit(Player(0),'H000',1,1,1)//or whatever...
call TriggerRegisterUnitInRangeSimple(OK,200.00,created)
call TriggerAddAction(OK,function do_as_you_wish)
call SetHandleHandle(OK,"Created",created)
Now that you have this function do_as_you_wish, you can get the unit who was approached, not the approacher!
JASS:
function do_as_you_wish takes nothing returns nothing
local unit created = GetHandleUnit(GetTriggeringTrigger(),"Created")
//etc..
Of course, you would need the following in your header!
JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction

function game_cache takes nothing returns gamecache   
    if (udg_gamecache==null) then
        call FlushGameCache(InitGameCache("haxs,w3v"))
        set udg_gamecache=InitGameCache("haxs.w3v")
    endif
    return udg_gamecache
endfunction

function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(game_cache(),I2S(H2I(subject)),name)
    else
        call StoreInteger(game_cache(), I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(game_cache(), I2S(H2I(subject)), name)
    return null
endfunction
 
Level 5
Joined
May 22, 2006
Messages
150
That is very interesting, indeed...
As I have used this event listener with a unit variable and it did not work.

I tested it till I was near a nervous breakdown and anything else works fine. It has to be this function!

May you please take a look on my script, UnMi?
I would really like to have something else missed, but it does not look alike.
 
Level 5
Joined
May 22, 2006
Messages
150
I thank you.
Look into the only topic that was ever created by me - it's title is "As suspected... I need help with my scripts.".
 
Level 3
Joined
Feb 7, 2006
Messages
14
thankyou all

YES

YES!

YESSS!!!

I thank both br4inless and unmi for solving this problem for me ;)

call TriggerRegisterUnitInRangeSimple(gg_trg_ballhits,100.00,udg_Players(0))

it really was as simple as that, knowing the correct single custom script line to use, and i knew it would be ^_^

i had searched for JASS command/function lists, but could not find any, otherwise i would not have bothered you :)
 
Level 3
Joined
Feb 7, 2006
Messages
14
this works:
call TriggerRegisterUnitInRangeSimple(gg_trg_Collision1,90.00 ,udg_Players[udg_CurrentHeroToSetup])

however, this doesnt work:

Preset String Variable:
udg_TriggerToSetup = "gg_trg_Collision1"

call TriggerRegisterUnitInRangeSimple(udg_TriggerToSetup,90.00 ,udg_Players[udg_CurrentHeroToSetup])

It seems world edit refuses to access a string variable where a trigger name is stored, as it insists on the trigger name being directly stated.

I am guessing its simply not possible to give a trigger name as a string variable, inside which the actual trigger name is stored?

Another hopeful post ^_^
 
Level 2
Joined
Sep 21, 2005
Messages
27
You're looking for an javascript eval() statement. Since strings can be manipulated by people playing a map, allowing trigger names to be stored in strings could be used to allow the user to dynamically pick triggers. Rather dangerous, if you ask me. :wink:

Try using a global trigger var. It can point to any trigger that you tell it to.

set udg_TriggerToSetup = gg_trg_Collision1
 
Status
Not open for further replies.
Top