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

Creating an NPC system?

Status
Not open for further replies.
Been having a hard time with this... I set a new unit's ID to 1, and these are basically the triggers:

  • SpawnNPC
    • Events
      • Game - Player Any Player types a chat message containing "/spawn", matching Partially
    • Local Variables
      • ID = 0 <Integer>
    • Conditions
    • Actions
      • Variable - Set ID = (Integer((Substring((Entered chat string), 8, 12))))
      • Unit - Create 1 (Unit type from (String(ID))) for player 0 at (Current camera target of player (Triggering player)) using default facing (No Options)
  • Debug On
    • Events
      • Game - Player Any Player types a chat message containing "dbg63", matching Partially
    • Local Variables
    • Conditions
    • Actions
      • Variable - Set Debug = true
In fact, in the debugger, neither ran. I am using these via a mod file.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
How do mods store their triggers? If they place it to the normal trigger script there is a 90% chance it will not work as the map trigger script will overwrite them. In that case you need to make them into a library and store the library on the mod (as libraries store their scripts in a separate file).

Why do you not set ID as you declare it? It saves setting it to 0 needlessly.

Variable - Set ID = (Integer((Substring((Entered chat string), 8, 12))))
SC2 comes with a lot of advanced string manipulating functions. For example you could just read the second word (if present) and convert that to an integer.

Actually... Come to think of it... Why are you converting it to an integer and then back to a string anyway? Just store it as a local string I would imagine being more efficient.
 
Status
Not open for further replies.
Top