something like enemy ai
This commit is contained in:
parent
f52e476acf
commit
0b371ac22d
|
@ -97,6 +97,7 @@
|
|||
{"id":{"name":"array_greatest","path":"scripts/array_greatest/array_greatest.yy",},"order":4,},
|
||||
{"id":{"name":"c_null","path":"scripts/c_null/c_null.yy",},"order":4,},
|
||||
{"id":{"name":"array_contains_within","path":"scripts/array_contains_within/array_contains_within.yy",},"order":19,},
|
||||
{"id":{"name":"c_passableeval","path":"scripts/c_passableeval/c_passableeval.yy",},"order":25,},
|
||||
{"id":{"name":"st_moving","path":"scripts/st_moving/st_moving.yy",},"order":7,},
|
||||
{"id":{"name":"c_deleteunit","path":"scripts/c_deleteunit/c_deleteunit.yy",},"order":22,},
|
||||
{"id":{"name":"Room1","path":"rooms/Room1/Room1.yy",},"order":0,},
|
||||
|
@ -136,11 +137,8 @@
|
|||
{"folderPath":"folders/Scripts/util/drawing/vlambeer.yy","order":1,"resourceVersion":"1.0","name":"vlambeer","tags":[],"resourceType":"GMFolder",},
|
||||
{"folderPath":"folders/Scripts/util.yy","order":1,"resourceVersion":"1.0","name":"util","tags":[],"resourceType":"GMFolder",},
|
||||
{"folderPath":"folders/Sprites/momiji.yy","order":2,"resourceVersion":"1.0","name":"momiji","tags":[],"resourceType":"GMFolder",},
|
||||
<<<<<<< HEAD
|
||||
{"folderPath":"folders/Sprites/wabbit.yy","order":3,"resourceVersion":"1.0","name":"wabbit","tags":[],"resourceType":"GMFolder",},
|
||||
=======
|
||||
{"folderPath":"folders/Scripts/3d.yy","order":19,"resourceVersion":"1.0","name":"3d","tags":[],"resourceType":"GMFolder",},
|
||||
>>>>>>> a9003c47cacfdee8c6ba2588fdb26b55ad87617b
|
||||
],
|
||||
"AudioGroups": [
|
||||
{"targets":-1,"resourceVersion":"1.3","name":"audiogroup_default","resourceType":"GMAudioGroup",},
|
||||
|
@ -149,17 +147,12 @@
|
|||
{"isScaled":true,"autocrop":true,"border":2,"mipsToGenerate":0,"groupParent":null,"targets":-1,"resourceVersion":"1.3","name":"Default","resourceType":"GMTextureGroup",},
|
||||
],
|
||||
"IncludedFiles": [
|
||||
<<<<<<< HEAD
|
||||
{"CopyToMask":-1,"filePath":"datafiles/Test Map","resourceVersion":"1.0","name":"GBA Test.dat","resourceType":"GMIncludedFile",},
|
||||
{"CopyToMask":-1,"filePath":"datafiles/Test Map","resourceVersion":"1.0","name":"GBA Test.size","resourceType":"GMIncludedFile",},
|
||||
{"CopyToMask":-1,"filePath":"datafiles/Test Map","resourceVersion":"1.0","name":"grass.png","resourceType":"GMIncludedFile",},
|
||||
{"CopyToMask":-1,"filePath":"datafiles/Test Map","resourceVersion":"1.0","name":"koakuma.png","resourceType":"GMIncludedFile",},
|
||||
{"CopyToMask":-1,"filePath":"datafiles","resourceVersion":"1.0","name":"shrine thing tex.png","resourceType":"GMIncludedFile",},
|
||||
{"CopyToMask":-1,"filePath":"datafiles","resourceVersion":"1.0","name":"shrine thing.dat","resourceType":"GMIncludedFile",},
|
||||
=======
|
||||
{"CopyToMask":-1,"filePath":"datafiles","resourceVersion":"1.0","name":"shrine thing.dat","resourceType":"GMIncludedFile",},
|
||||
{"CopyToMask":-1,"filePath":"datafiles","resourceVersion":"1.0","name":"shrine thing tex.png","resourceType":"GMIncludedFile",},
|
||||
>>>>>>> a9003c47cacfdee8c6ba2588fdb26b55ad87617b
|
||||
],
|
||||
"MetaData": {
|
||||
"IDEVersion": "2.3.3.574",
|
||||
|
|
|
@ -23,12 +23,8 @@ function getProj(){
|
|||
function getView(){
|
||||
var _x = global.camerax;
|
||||
var _y = global.cameray;
|
||||
<<<<<<< HEAD
|
||||
var half = (7.5*32)+40;
|
||||
return matrix_build_lookat(_x,_y+180,150,_x,_y,0,0,0,-1);
|
||||
=======
|
||||
return matrix_build_lookat(_x,_y+100,100,_x,_y,0,0,0,-1);
|
||||
>>>>>>> a9003c47cacfdee8c6ba2588fdb26b55ad87617b
|
||||
}
|
||||
|
||||
function setCam(){
|
||||
|
@ -37,9 +33,7 @@ function setCam(){
|
|||
camera_set_view_mat(cam,getView())
|
||||
camera_apply(cam);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
global.turn = ARMY.US;
|
||||
=======
|
||||
|
||||
function drawModels(){
|
||||
gpu_set_cullmode(cull_counterclockwise);
|
||||
|
@ -53,6 +47,6 @@ function drawModels(){
|
|||
|
||||
models = [];
|
||||
|
||||
var spr = sprite_add("./shrine thing tex.png",0,false,false,0,0);
|
||||
//var spr = sprite_add("./shrine thing tex.png",0,false,false,0,0);
|
||||
var spr = sprite_add("./Test Map/grass.png",0,false,false,0,0);
|
||||
nu Model("./shrine thing.dat",spr);
|
||||
>>>>>>> a9003c47cacfdee8c6ba2588fdb26b55ad87617b
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
while global.turn == ARMY.THEM {
|
||||
var done = true;
|
||||
for (k=0; k<array_length(global.units[ARMY.THEM]); k++) {
|
||||
var target = global.units[ARMY.THEM][k];
|
||||
if !target.waiting {
|
||||
done = false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
c_doenemyai(target);
|
||||
}
|
||||
if done {
|
||||
c_dewait(global.turn);
|
||||
global.turn = (global.turn+1)%2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
c_input();
|
||||
var mouse = c_2dto3d(mouse_x,mouse_y);
|
||||
if select && selectedunit == noone {
|
||||
|
|
|
@ -6,42 +6,52 @@ function c_doenemyai(target) {
|
|||
case AI.KILLER:
|
||||
var dude = c_findnearestunit(ARMY.US);
|
||||
repeat(target.data.mov.val) {
|
||||
var dist = c_tiledist(target.pos.x, target.pos.y, dude.pos.x, dude.pos.y);
|
||||
if dist.x+dist.y <= target.data.rng.val {
|
||||
log("started combat")
|
||||
c_generatecombatstack([target, dude]);
|
||||
break;
|
||||
}
|
||||
log(c_tiledist(target.pos.x, target.pos.y, dude.pos.x, dude.pos.y));
|
||||
var guy = c_gettile(target.pos.x, target.pos.y);
|
||||
if target.pos.x < dude.x {
|
||||
if target.pos.x < dude.pos.x {
|
||||
var guy = c_gettile(target.pos.x+1, target.pos.y);
|
||||
} else if target.pos.x > dude.x {
|
||||
} else if target.pos.x > dude.pos.x {
|
||||
var guy = c_gettile(target.pos.x-1, target.pos.y);
|
||||
}
|
||||
if target.pos.y < dude.y {
|
||||
var guy = c_gettile(target.pos.x+1, target.pos.y);
|
||||
} else if target.pos.x > dude.x {
|
||||
var guy = c_gettile(target.pos.x-1, target.pos.y);
|
||||
if target.pos.y < dude.pos.y {
|
||||
var guy = c_gettile(target.pos.x, target.pos.y+1);
|
||||
} else if target.pos.y > dude.pos.y {
|
||||
var guy = c_gettile(target.pos.x, target.pos.y-1);
|
||||
}
|
||||
if guy.passable {
|
||||
c_moveunit(target, guy);
|
||||
continue;
|
||||
if guy != noone {
|
||||
if guy.passable && !c_containsunit(guy.x, guy.y) {
|
||||
c_moveunit(target, guy);
|
||||
}
|
||||
}
|
||||
c_loadmarkings();
|
||||
}
|
||||
target.waiting = true;
|
||||
break;
|
||||
case AI.WAITER:
|
||||
|
||||
target.waiting = true;
|
||||
break;
|
||||
case AI.ESCAPER:
|
||||
|
||||
target.waiting = true;
|
||||
break;
|
||||
}
|
||||
c_loadmarkings();
|
||||
}
|
||||
|
||||
function c_findnearestunit(alignment) {
|
||||
var lowest = new vec2(99, 99);
|
||||
var lowestunit = new vec2(99, 99);
|
||||
var lowestunit = noone;
|
||||
for (i=0; i<array_length(global.units[alignment]); i++) {
|
||||
var guy = global.units[alignment][i].pos;
|
||||
if (lowest.x + lowest.y < guy.x + guy.y) {
|
||||
if (lowest.x + lowest.y > guy.x + guy.y) {
|
||||
lowest = guy;
|
||||
lowestunit = global.units[alignment][i];
|
||||
}
|
||||
}
|
||||
return
|
||||
return lowestunit;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
function c_passableeval() {
|
||||
/*var i, j;
|
||||
for (i=0; i<array_length(global.map); i++) {
|
||||
for (i=0; i<array_length(global.map[i]); i++) {
|
||||
global.map[i][j].passable
|
||||
}
|
||||
}
|
||||
for (i=0; i<array_length(global.map); i++) {
|
||||
for (i=0; i<array_length(global.map[i]); i++) {
|
||||
if c_containsunit(global.map[i][j]) {
|
||||
global.map[i][j].passable
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
function c_containsunit(x, y) {
|
||||
var tile = c_gettile(x, y);
|
||||
for (i=0; i<array_length(tile.contents); i++) {
|
||||
if instance_exists(tile.contents[i]) {
|
||||
if tile.contents[i].object_index = o_unit {
|
||||
return tile.contents[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"isDnD": false,
|
||||
"isCompatibility": false,
|
||||
"parent": {
|
||||
"name": "Scripts",
|
||||
"path": "folders/Scripts.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "c_passableeval",
|
||||
"tags": [],
|
||||
"resourceType": "GMScript",
|
||||
}
|
|
@ -39,14 +39,23 @@ function c_colortile(x, y, color) {
|
|||
}
|
||||
|
||||
function c_markunit(unitobject) {
|
||||
var i, j;
|
||||
var mov = unitobject.data.mov.val;
|
||||
for (i=-mov; i<=mov; i++) {
|
||||
for (j=-mov; j<=mov; j++) {
|
||||
if abs(i)+abs(j) <= mov {
|
||||
(unitobject.marked ? c_decolor : c_colortile)(unitobject.pos.x+i, unitobject.pos.y+j, c_maroon);
|
||||
unitobject.marked = !unitobject.marked;
|
||||
c_loadmarkings();
|
||||
}
|
||||
|
||||
function c_loadmarkings() {
|
||||
c_decolor_all(c_maroon);
|
||||
var k;
|
||||
for (k=0; k<array_length(global.units[ARMY.THEM]); k++) {
|
||||
var unitobject = global.units[ARMY.THEM][k];
|
||||
var i, j;
|
||||
var mov = unitobject.data.mov.val;
|
||||
for (i=-mov; i<=mov; i++) {
|
||||
for (j=-mov; j<=mov; j++) {
|
||||
if abs(i)+abs(j) <= mov {
|
||||
if unitobject.marked c_colortile(unitobject.pos.x+i, unitobject.pos.y+j, c_maroon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unitobject.marked = !unitobject.marked;
|
||||
}
|
|
@ -13,6 +13,7 @@ function unit(personaldata_, classdata_, stats_) constructor {
|
|||
idle = personaldata_.idle;
|
||||
up = personaldata_.up;
|
||||
down = personaldata_.down;
|
||||
aitype = personaldata_.aitype;
|
||||
alignment = noone;
|
||||
var i;
|
||||
for (i=0; i<array_length(stats_); i++) {
|
||||
|
|
Loading…
Reference in New Issue