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

Detect unit's "CODE" by Trigger (ASCII)

Status
Not open for further replies.
Level 11
Joined
Oct 20, 2007
Messages
342
Detect unit's "CODE" by Trigger
Explanation:

example:
i set "hero" as an unit type variable.
normally i want set "hero" = paladin use the trigger:
  • Set hero = Paladin

but how do i set it using unit's code???
like
  • Set hero = "Hpal"

* Unit's Code: Ctrl+D at unit editor you will see the code, that wat i mean.
 
Level 11
Joined
Oct 20, 2007
Messages
342
i have make an small experiment...
found this:
set udg_integer = 50
set udg_real = 10.02
set udg_Hero = 'Hpal'
set udg_string = "lalala"


integer and real got no (') or (")
string is using (") quotation mark that i know,
but hero using ('), is that integer?

well, that not the point.

so can i make a loop like:
Code:
For each (Integer A) from 1 to 10, do (Actions)
    Loop - Actions
        set udg_hero[Integer A] = 'A00' + '1'

but how should i convert if not sure it is integer or string....
 
Level 11
Joined
Oct 20, 2007
Messages
342
no no no....
not that.... and that kind of function i think does not exist also.

1st i want understand about unit code

2nd i want do a function like:

JASS:
For each (udg_Integer_A) from 1 to 10, do (Actions)
    Loop - Actions
        set udg_hero[udg_Integer_A] = 'A00' + udg_Integer_A

USE to reduce more time in set in unit variable
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
A unit data id IS an integer.

As you know, an integer can be represented in different bases.
Consider the number "15" in base 10.
"F" is the same number as "15", except it's in base 16.

Unit data id's are numbers in base 256, where the cyphers are ascii signs. For example: the ascii sign '1' is the number 49.
The ascii number '11' would then be: 49 * 256 + 49 = 12593

A unit raw data id is basically an integer, but it's represented by 4 ascii characters in the object editor instead of a decimal number.

All ascii values are here:
asciifull.gif


(the extended ascii values not included)

Notice how there is a jump between numbers 0 - 9 and characters a-z.

The easiest thing you could probably do is an easy loop like:

  • Custom script: set udg_TempInt = 'A000'
  • For Integer A from 0 to 9 do:
    • Set hero[Integer A] = TempInt + Integer A
  • Custom script: set udg_TempInt = 'A00A'
  • For Integer A from 0 to 25 do:
    • Set hero[10 + Integer A] = TempInt + Integer A
hero[] obviously has to be an integer.
 
Status
Not open for further replies.
Top