gcsim icon indicating copy to clipboard operation
gcsim copied to clipboard

gcsl additional work

Open srliao opened this issue 1 year ago • 2 comments

continuation of #1148

remaining todos as follows:

  • [ ] add null type
  • [ ] add parsing unit tests
  • [ ] add comparison support for diff variable types (currently only support comparing numbers)
let a string = "blah";
let b string = "boo";
return a == b; //should return 0
  • [ ] add character type; should support various methods such as .cd, .energy, etc
  • [ ] add action type; should also support method (tbd)
  • [ ] add custom functions re pre-delay
  • [ ] parse existing fields into system calls, utilizing character and action type where appropriate
  • [ ] separate warnings and errors in parsed results; warnings are more linting related; errors = parse/compile errors
  • [ ] add support for ast validators to be loaded at parse time
  • [ ] add default validator that does type checking
let a = "blah"
return a == 1; //this should fail parse

fn x(a string) string {
   return a + " is cool";
}
print(fn(1)); //this should fail as 1 is not a string
  • [ ] refactor sysfunc into regular functions but injected into env at init; error handled user unintended use of system function name (identifier already exists error)

Specific to making wait useable in character actions

To make it delay to write xingqiu attack, wait(10), attack, delay(5), attack;, the parsing needs to be changed such as the entire line is treated as a statement (vs currently it is carved out the same way character stats parsing is carved out) and each action can be parsed as part of the recursive parser

  • [ ] rewrite action parsing into parseStmt; action should be parsed recursively same as all other AST
  • [ ] allow for wait in character actions (shelved for now because this is very difficult to implement)

Optional

  • [ ] add deprecation warning for wait; suggest user to use sleep
  • [ ] add read-only variables (add const keyword?).
const val = 5;
val = 4; # error
  • [ ] rewrite sys_func into a switch statement for better performance instead of using map

srliao avatar Aug 24 '23 12:08 srliao

nahida char lvl=90/90 cons=2 talent=9,10,10;
nahida add weapon="pamber" refine=5 lvl=90/90;
nahida add set="deepwoodmemories" count=4;
nahida add stats def%=0.10930001 def=74.07001 hp=5497.0100999999995 atk=416.040009 atk%=0.040800004 er=0.27850002500000004 em=228.460003 cr=0.559900009 cd=0.65270003 dendro%=0.466;

zhongli char lvl=82/90 cons=0 talent=2,9,8;
zhongli add weapon="blacktassel" refine=5 lvl=90/90;
zhongli add set="tenacityofthemillelith" count=4;
zhongli add stats def%=0.26240001 def=39.350002 hp=6184.14014 hp%=1.543700013 atk=445.220018 atk%=0.39640003399999996 er=0.10360002 em=118.89000100000001 cr=0.035000002 cd=0.07769999999999999;

fischl char lvl=90/90 cons=6 talent=4,9,8;
fischl add weapon="thestringless" refine=5 lvl=90/90;
fischl add set="gladiatorsfinale" count=2;
fischl add set="shimenawasreminiscence" count=2;
#fischl add set="gt" count=4;
fischl add stats def=101.85001299999999 hp=5317.75006 hp%=0.15150001000000002 atk=338.240002 atk%=0.6467000300000001 er=0.1684 cr=0.6066000559999999 cd=1.111600052 electro%=0.466;

yaemiko char lvl=90/90 cons=0 talent=9,10,10;
yaemiko add weapon="kagurasverity" refine=1 lvl=90/90;
yaemiko add set="gladiatorsfinale" count=2;
yaemiko add set="shimenawasreminiscence" count=2;
#yaemiko add set="gt" count=4;
yaemiko add stats def=23.150002 hp=4780 atk=410.210009 atk%=0.63500003 er=0.064800005 em=254.090012 cr=0.567600025 cd=0.629300014 electro%=0.466;

options iteration=1000 duration=90;

active zhongli;

target lvl=100 resist=0.1 radius=2 pos=0,2.4; 
energy every interval=480,720 amount=1;

fn rand_delay(mean, stddev) {
  let del = randnorm() * stddev + mean;
  if del > (mean + mean) {
    del = mean + mean;
  }
  delay(del);
}

let prev_char_id = -1;
let prev_action_id = -1;

let _execute_action = execute_action;
fn execute_action(char_id, action_id, p) {
  print(prev_char_id, " ", prev_action_id, " ", char_id, " ", action_id);
  if action_id == .action.swap {
    # add delay before swap
    rand_delay(12, 3);
  } else if prev_action_id == .action.attack && action_id != .action.attack && action_id != .action.charge {
    # add delay after attack, but only if not followed by another attack or charge
    rand_delay(3, 1);
  } else if prev_action_id != .action.attack {
    # add delay to everything else
    rand_delay(3, 1);
  }

  prev_char_id = char_id;
  prev_action_id = action_id;
  return _execute_action(char_id, action_id, p);
}

while 1 {
    switch 1 {
        case .yae.skill.charge == 3 && .yae.swap.ready:
            yae attack;
            yae skill, attack, skill, attack, skill;
            #yae attack;
        case .nahida.burst.ready && .nahida.swap.ready:
            nahida skill[hold=30];
            nahida burst;
        case .zhongli.skill.ready && .zhongli.swap.ready:
            zhongli skill[hold=1];
        case (!.fischl.oz && .fischl.burst.ready) && .fischl.swap.ready:
            fischl burst;
            nahida swap;
        case (!.fischl.oz  && .fischl.skill.ready) && .fischl.swap.ready:
            fischl skill;
        case .yae.burst.ready && .yae.swap.ready:
            yae attack, burst, skill:3, attack;
        #case .zhongli.burst.ready && .zhongli.onfield:
            #zhongli burst;
        case .yae.onfield:
            yae attack;
        case .fischl.onfield:
            fischl attack;
        case .zhongli.onfield:
            zhongli attack;
        case .nahida.onfield:
            nahida attack;
        default:
            wait(1);
    }

}

somehow this script here is working with implicit swap but i don't expect it to. need to resolve

srliao avatar Sep 06 '23 16:09 srliao

related: https://discord.com/channels/845087716541595668/1058288549033689139

k0l11 avatar Dec 17 '23 12:12 k0l11