Something went wrong. Try again.
A very rough prototype kag tutorial rework
Something went wrong. Try again.
3.2 kB · 147 lines
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148//////////////////////////// MapsCore////// Used so there's less duplicate code with adding a map level
#include "BlobCharacter"#include "RunnerHead"
// Add in spawns based on a blob// Some maps might want you to spawn at a tent// Some might want you to spawn at a shop, idk//// Returns true if spawning was done correctlybool AddSpawns(CMap@ map, string markerName, string blobToSpawn, int teamNum = 0){ Vec2f[] spawns; if (map.getMarkers(markerName, spawns)) { for (int a = 0; a < spawns.length; a++) { server_CreateBlob(blobToSpawn, 0, spawns[a]); }
return true; } return false;}
// Same as above, but we remove all scripts attached to them// This prevents us from using itbool AddSpawnsCosmeticOnly(CMap@ map, string markerName, string blobToSpawn, int teamNum = 0){ Vec2f[] spawns; if (map.getMarkers(markerName, spawns)) { for (int a = 0; a < spawns.length; a++) { CBlob@ blob = server_CreateBlob(blobToSpawn, 0, spawns[a]); if (blob is null) continue;
// TODO-> Engine side need a way to get all scripts by name! }
return true; } return false;}
/*CBlob@ SpawnInCharacter(string blobName, int team, Vec2f pos, string characterName, bool onInit = true, string customBody = ""){ CBlob@ blob = null;
// Offer them an option to auto init or not // In case they want to set their own settings if (onInit) { @blob = server_CreateBlob(blobName, team, pos); } else { @blob = server_CreateBlobNoInit(blobName); blob.setPosition(pos); blob.server_setTeamNum(team); } if (blob is null) { error("SpawnInCharacter creating a blob has failed!"); return null; }
if (customBody != "") blob.set_string("custom_body", customBody);
blob.AddScript("InteractableCharacter");
// Set character data BlobCharacter@ character = BlobCharacter(blob, characterName); character.PushToGlobalHandler();
return blob;}*/
BlobCharacter@ addCharacterToBlob(CBlob@ blob, string &in characterName, string &in textFile){ if (blob.hasScript("BlobCharacterAddon")) { error("Trying to add a script to a blob that already has BlobCharacterAddon.as"); return null; }
blob.AddScript("BlobCharacterAddon");
BlobCharacter@ character = BlobCharacter(blob, characterName); character.LoadTextConfig(textFile); character.PushToGlobalHandler();
if (!blob.hasScript("EmoteBubble.as")) { blob.AddScript("EmoteBubble.as"); }
return character;}
/// TODO: MOVE TO A NEW FILE
// Basic 0 to 255 (70 heads)// Flags 256 to 511 (78 heads)// Fantasy 512 to 767 (18 heads)// Community 768 to 1023 (60 heads)// 30 unique heads per pack
namespace Heads{ const int[] KNIGHT_WITH_HELMS = { 46, 47, 48, 50, 53, 54, 55, 815, 819, 823, 824, 825, 826 };}
// Todo, maybe include this with a custom CreateBlob & addCharacter funcvoid SetRandomKnightHelm(CBlob@ blob){ blob.setHeadNum(Heads::KNIGHT_WITH_HELMS[XORRandom(Heads::KNIGHT_WITH_HELMS.length)]); LoadHead(blob.getSprite(), blob.getHeadNum());}