Created
July 29, 2017 16:12
-
-
Save msg555/bf9b21390049b8078d72b1eda4ed7d77 to your computer and use it in GitHub Desktop.
Create and setup an AI controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class script { | |
bool firstFrame; | |
script() { | |
firstFrame = true; | |
} | |
void step(int entities) { | |
if (!firstFrame) { | |
return; | |
} | |
firstFrame = false; | |
entity@ e = create_entity("enemy_critter"); | |
e.y(-200); | |
g.add_entity(@e); | |
entity@ ai_e = create_entity("AI_controller"); | |
ai_e.y(-200); | |
varstruct@ ai_vars = ai_e.vars(); | |
ai_vars.get_var("puppet_id").set_int32(e.id()); | |
vararray@ ai_nodes = ai_vars.get_var("nodes").get_array(); | |
vararray@ ai_wait_times = ai_vars.get_var("nodes_wait_time").get_array(); | |
ai_nodes.resize(2); | |
ai_nodes.at(0).set_vec2(0, -400); | |
ai_nodes.at(1).set_vec2(-200, -400); | |
ai_wait_times.resize(2); | |
ai_wait_times.at(0).set_int32(1); | |
ai_wait_times.at(1).set_int32(1); | |
g.add_entity(@ai_e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment