unit FragmentShader(VertexOut vertex, Field <unit> Unit, Field <data> Data, Field <magic> Magic, PlayerTuple Teams) { data data_here = Data[Here]; unit unit_here = Unit[Here]; magic magic_here = Magic[Here]; if (Something(data_here)) { if (data_here.action == UnitAction.Spawning) { unit barracks = Unit[dir_to_vec(Reverse(data_here.direction))]; unit_here.player = barracks.player; unit_here.team = barracks.team; unit_here.type = UnitType.Footman; unit_here.anim = Anim.Stand; } if (data_here.action == UnitAction.Raising) { unit_here.player = magic_here.raising_player; unit_here.team = GetPlayerVal(Teams, magic_here.raising_player); unit_here.type = UnitType.Skeleton; unit_here.anim = Anim.StartRaise; } } return(unit_here); }
magic FragmentShader(VertexOut vertex, Field <data> Select, Field <magic> Magic, Field <TeamTuple> AntiMagic) { magic here = Magic[Here]; data select = Select[Here]; if (Something(select)) { TeamTuple antimagic = AntiMagic[Here]; bool block_kill = antimagic.TeamOne > _0 || antimagic.TeamTwo > _0 || antimagic.TeamThree > _0 || antimagic.TeamFour > _0; if (!block_kill) { here.kill = _true; } } return(here); }
magic FragmentShader(VertexOut vertex, Field <magic> Magic, Field <data> CurrentData, Field <data> PreviousData, Field <corpse> Corpses, Field <PlayerTuple> Necromancy) { magic here = Magic[Here]; corpse corpse_here = Corpses[Here]; PlayerTuple necromancy = Necromancy[Here]; data cur_data = CurrentData[Here], prev_data = PreviousData[Here]; // Reset the kill bit here.kill = _false; here.raising_player = Player.None; // Check for resurrection if (CorpsePresent(corpse_here) && !Something(cur_data) && !Something(prev_data)) { float player = Player.None; float necro = _0; if (necromancy.PlayerOne > necro) { necro = necromancy.PlayerOne; player = Player.One; } if (necromancy.PlayerTwo > necro) { necro = necromancy.PlayerTwo; player = Player.Two; } if (necromancy.PlayerThree > necro) { necro = necromancy.PlayerThree; player = Player.Three; } if (necromancy.PlayerFour > necro) { necro = necromancy.PlayerFour; player = Player.Four; } here.raising_player = player; } return(here); }
corpse FragmentShader(VertexOut vertex, Field <unit> Unit, Field <data> Data, Field <corpse> Corpses, Field <magic> Magic) { unit unit_here = Unit[Here]; data data_here = Data[Here]; corpse corpse_here = Corpses[Here]; magic magic_here = Magic[Here]; // Removed corpses that are being raised. if (magic_here.raising_player != Player.None && unit_here.anim == Anim.StartRaise) { corpse_here = corpse.Nothing; } if (Something(data_here) && unit_here.anim == Anim.Die && LeavesCorpse(unit_here)) { corpse_here.direction = data_here.direction; corpse_here.type = unit_here.type; corpse_here.player = unit_here.player; } return(corpse_here); }
data FragmentShader(VertexOut vertex, Field <unit> Unit, Field <data> CurrentData, Field <data> PreviousData, Field <vec4> Random, Field <magic> Magic) { data cur_data = CurrentData[Here], prev_data = PreviousData[Here]; vec4 rnd = Random[Here]; magic magic_here = Magic[Here]; // Check for barracks spawning if (!Something(cur_data) && !Something(prev_data) && rnd.x > .93) { unit unit_right = Unit[RightOne], unit_up = Unit[UpOne], unit_left = Unit[LeftOne], unit_down = Unit[DownOne]; data data_right = PreviousData[RightOne], data_up = PreviousData[UpOne], data_left = PreviousData[LeftOne], data_down = PreviousData[DownOne]; float spawn_dir = Dir.None; // Spawn units on the side of the barracks facing the target they are headed toward //if (unit_left.type == UnitType.Barracks && prior_direction(data_left) == Dir.Right) spawn_dir = Dir.Right; //if (unit_right.type == UnitType.Barracks && prior_direction(data_right) == Dir.Left) spawn_dir = Dir.Left; //if (unit_up.type == UnitType.Barracks && prior_direction(data_up) == Dir.Down) spawn_dir = Dir.Down; //if (unit_down.type == UnitType.Barracks && prior_direction(data_down) == Dir.Up) spawn_dir = Dir.Up; // Spawn units anywhere adjacent to the barracks if (unit_left.type == UnitType.Barracks) { spawn_dir = Dir.Right; } if (unit_right.type == UnitType.Barracks) { spawn_dir = Dir.Left; } if (unit_up.type == UnitType.Barracks) { spawn_dir = Dir.Down; } if (unit_down.type == UnitType.Barracks) { spawn_dir = Dir.Up; } if (IsValid(spawn_dir)) { cur_data.direction = spawn_dir; cur_data.action = UnitAction.Spawning; cur_data.change = Change.Stayed; set_selected(ref cur_data, false); set_prior_direction(ref cur_data, cur_data.direction); } } else { // Otherwise check if we are raising a skeleton if (!Something(cur_data) && magic_here.raising_player != Player.None) { cur_data.direction = Dir.Right; cur_data.action = UnitAction.Raising; cur_data.change = Change.Stayed; set_selected(ref cur_data, false); set_prior_direction(ref cur_data, cur_data.direction); } } return(cur_data); }
data FragmentShader(VertexOut vertex, Field <vec4> TargetData, Field <unit> Unit, Field <extra> Extra, Field <data> Data, Field <data> PrevData, Field <vec4> PathToOtherTeams, Field <vec4> RandomField, Field <magic> Magic, Field <geo> Geo, Field <geo> AntiGeo, Field <dirward> DirwardRight, Field <dirward> DirwardLeft, Field <dirward> DirwardUp, Field <dirward> DirwardDown) { data data_here = Data[Here]; magic magic_here = Magic[Here]; if (Something(data_here)) { data path = data.Nothing; // Get info for this unit unit unit_here = Unit[Here]; // Remove if dead unit if (unit_here.anim == Anim.Die && IsUnit(unit_here)) { return(data.Nothing); } // Remove if dead building building b = (building)(vec4)data_here; if (IsBuilding(unit_here)) { // If this building is alive if (data_here.direction == Dir.Stationary) { // If this is a building that has been hit enough times to explode if (unit_here.hit_count >= _5) { data_here.direction = Dir.StationaryDying; } } else { // Otherwise remove it if the explosion animation is done float frame = ExplosionSpriteSheet.ExplosionFrame(0, b); if (frame >= ExplosionSpriteSheet.AnimLength) { return(data.Nothing); } } } // Units that are done being raised should switch to attacking. if (IsUnit(unit_here) && unit_here.anim == Anim.DoRaise) { data_here.action = UnitAction.Attacking; } // Units that are about to be incinerated or are being raised can't move. if (IsUnit(unit_here) && (magic_here.kill == _true || unit_here.anim == Anim.StartRaise)) { data_here.action = UnitAction.Stopped; return(data_here); } // Buildings can't move. if (IsBuilding(unit_here)) { if (IsCenter((building)(vec4)data_here)) { // Set the building direction toward its "target". set_prior_direction(ref data_here, BuildingDirection(vertex, TargetData, (building)(vec4)data_here)); } return(data_here); } // Get nearby paths to other teams vec4 _value_right = PathToOtherTeams[RightOne], _value_up = PathToOtherTeams[UpOne], _value_left = PathToOtherTeams[LeftOne], _value_down = PathToOtherTeams[DownOne]; // Get specific paths to enemies of this particular unit float value_right = 1, value_left = 1, value_up = 1, value_down = 1; if (unit_here.team == Team.One) { value_right = _value_right.x; value_left = _value_left.x; value_up = _value_up.x; value_down = _value_down.x; } else if (unit_here.team == Team.Two) { value_right = _value_right.y; value_left = _value_left.y; value_up = _value_up.y; value_down = _value_down.y; } else if (unit_here.team == Team.Three) { value_right = _value_right.z; value_left = _value_left.z; value_up = _value_up.z; value_down = _value_down.z; } else if (unit_here.team == Team.Four) { value_right = _value_right.w; value_left = _value_left.w; value_up = _value_up.w; value_down = _value_down.w; } float auto_attack_cutoff = _12; if (unit_here.type == UnitType.DragonLord) { auto_attack_cutoff = _2; } if (unit_here.type == UnitType.Necromancer) { auto_attack_cutoff = _2; } float min = 256; float hold_dir = data_here.direction; if (data_here.action == UnitAction.Attacking || data_here.action == UnitAction.Guard) { if (value_right < min) { data_here.direction = Dir.Right; min = value_right; } if (value_up < min) { data_here.direction = Dir.Up; min = value_up; } if (value_left < min) { data_here.direction = Dir.Left; min = value_left; } if (value_down < min) { data_here.direction = Dir.Down; min = value_down; } } if (min > auto_attack_cutoff) { // Not within auto attack range, so fallback to previous direction. data_here.direction = hold_dir; } else { // If we're within auto attack range and we're a necromancer, we should run away. // Necromancers are cowards. if (unit_here.type == UnitType.Necromancer) { TurnAround(ref data_here); } } // If we are guarding and a unit is close, switch to attacking if (min < auto_attack_cutoff && data_here.action == UnitAction.Guard) { data_here.action = UnitAction.Attacking; } // If we aren't attacking, or if a unit is too far away if (min > auto_attack_cutoff && data_here.action == UnitAction.Attacking || data_here.action == UnitAction.Moving) { NaivePathfind(vertex, Data, PrevData, TargetData, Extra, RandomField, Geo, AntiGeo, DirwardRight, DirwardLeft, DirwardUp, DirwardDown, unit_here, ref data_here); } } return(data_here); }