This commit is contained in:
the me 2022-08-15 18:01:09 -07:00
parent 0ead044da1
commit 51cc3f3ca6
20 changed files with 278 additions and 33 deletions

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "data",
"path": "folders/Scripts/util/data.yy",
},
"resourceVersion": "1.0",
"name": "array_contains",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -0,0 +1,12 @@
function array_contains_within(array, val) {
var i, j;
for (i=0; i<array_length(array); i++) {
if typeof(array[i]) == "struct" {
var dudes = variable_struct_get_names(array[i]);
for (j=0; j<array_length(dudes); j++) {
if array[i][$dudes[j]] == val return true;
}
}
}
return false;
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "data",
"path": "folders/Scripts/util/data.yy",
},
"resourceVersion": "1.0",
"name": "array_contains_within",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -1,6 +1,11 @@
function c_gettile(x, y, absolute=false) {
var thex = round((x-16)/ts.x);
var they = round((y-16)/ts.y);
if absolute {
var thex = round((x-16)/ts.x);
var they = round((y-16)/ts.y);
} else {
var thex = x;
var they = y;
}
if c_tileexists(thex, they) return mp[thex][they];
return noone;
}

View file

@ -0,0 +1,6 @@
function c_resetbattlevar(target=id) {
with target {
attacks = 0;
attacked = 0;
}
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "Scripts",
"path": "folders/Scripts.yy",
},
"resourceVersion": "1.0",
"name": "c_resetbattlevar",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -11,6 +11,18 @@ function c_selectunit(unitobject) {
}
}
}
ARTICULATOR.selectedunit = unitobject;
}
function c_deselectunit(unitobject) {
if ARTICULATOR.selectedunit != unitobject return false
state = st_standing;
drawstate = c_null;
c_decolor_all(c_cyan);
c_decolor_all(c_red);
c_decolor_all(c_green);
ARTICULATOR.selectedunit = noone;
return true;
}
function c_colortile(x, y, color) {

View file

@ -0,0 +1,53 @@
function c_generatecombatstack(combatants=[]) {
log(combatants);
//c_doallhook(hooks.precombat);
for (i=0; i<array_length(combatants); i++) {
c_resetbattlevar(combatants[i]);
}
//while combatants != [] {
log("whiling");
var i=0;
for (i=0; i<array_length(combatants); i++) {
//c_dodualhook(combatants[i], preaction);
tryaction(combatants[i], combatants[(i+1)%array_length(combatants)]);
//c_dodualhook(combatants[i], postaction);
}
//}
for (i=0; i<array_length(combatants); i++) {
c_resetbattlevar(combatants[i]);
}
}
function c_recordaction(action) {
log(action);
}
function c_dodualhook(host, hook) {
}
function c_doallhook(hook) {
}
function tryaction(me, them) {
//c_dodualhook(hooks.onstaminacheck);
while me.continuecombat(me, them) {
//action = defaultaction;
//c_dodualhook(hooks.prehit);
c_recordaction(me.action.effect(me, them));
//c_dodualhook(hooks.posthit);
}
}
/*action {
effect: function() {
}
animation: new actionanim()
}*/
function insertaction(action, interruptable) {
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "Scripts",
"path": "folders/Scripts.yy",
},
"resourceVersion": "1.0",
"name": "combat",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -42,48 +42,48 @@ function st_moving() {
c_decolor_all(c_red);
c_decolor_all(c_green);
var guy = c_gettile(x, y, true);
c_colortile(guy.x, guy.y, c_green);
//log("selecting");
var rng = [1];
var guy = c_gettile(x, y, true);
var hitting = noone;
if guy != noone {
c_colortile(guy.x, guy.y, c_green);
switch dir {
case DIR.LEFT:
c_colortile(guy.x-1, guy.y, c_red);
break;
case DIR.DOWN:
c_colortile(guy.x, guy.y+1, c_red);
break;
case DIR.UP:
c_colortile(guy.x, guy.y-1, c_red);
break;
case DIR.RIGHT:
c_colortile(guy.x+1, guy.y, c_red);
break;
}
}
if select {
var rng = [1];
var guy = c_gettile(x, y, true);
var hitting = noone;
switch dir {
case DIR.LEFT:
hitting = c_gettile(guy.x-1, guy.y);
c_colortile(guy.x-1, guy.y, c_red);
break;
case DIR.DOWN:
hitting = c_gettile(guy.x, guy.y+1);
c_colortile(guy.x, guy.y+1, c_red);
break;
case DIR.UP:
hitting = c_gettile(guy.x, guy.y-1);
c_colortile(guy.x, guy.y-1, c_red);
break;
case DIR.RIGHT:
hitting = c_gettile(guy.x+1, guy.y);
c_colortile(guy.x+1, guy.y, c_red);
break;
}
if hitting != noone {
if hitting != noone && select {
log("found one");
log(hitting.contents, hitting.x, hitting.y);
var i;
for (i=0; i<array_length(hitting.contents); i++) {
if instance_exists(hitting.contents[i]) {
log("is instance");
if hitting.contents[i].object_index = o_unit {
log("is unit");
log("found two");
c_generatecombatstack([id, hitting.contents[i]]);
}
}
}
}
}
if back {
state = st_standing;
drawstate = c_null;
c_deselectunit(id);
}
/*if x < (pos.x-mov)*ts.x {
x = (pos.x-mov)*ts.x;

View file

@ -14,9 +14,11 @@ function stat(name_, fullname_, desc_, replacements_=[]) constructor {
function unitstat(val_, name_, fullname_, desc_, replacements_) : stat(name_, fullname_, desc_, replacements_) constructor {
val = val_;
cap = val_;
modifier = 0;
}
nu stat("hp", "health", "vitality");
nu stat("str", "strength", "physical power");
nu stat("def", "defense", "physical defense");
nu stat("def", "defense", "physical defense");
nu stat("spd", "speed", "avoid and follow-up");

View file

@ -25,7 +25,7 @@ function unit(personaldata_, classdata_, stats_) constructor {
global.unitdata[$name] = self;
}
nu unit(mydata, mydata, [st.hp.add(92), st.str.add(20), st.def.add(20)]);
nu unit(mydata, mydata, [st.hp.add(92), st.str.add(20), st.def.add(20), st.spd.add(5)]);
mydata = {
name: "kris",
@ -33,7 +33,7 @@ mydata = {
skills: ["SKILLS.LUNA"],
sprite: s_guy2,
}
nu unit(mydata, mydata, [st.hp.add(92), st.str.add(20), st.def.add(20)]);
nu unit(mydata, mydata, [st.hp.add(92), st.str.add(20), st.def.add(20), st.spd.add(5)]);
function archetypedata() constructor {
//PERSONALDATA AND CLASSDATA ARE THE SAME THINGS