Author Topic: Generic Gamemode Help (Formerly: Creating AIPlayer Movement)  (Read 4808 times)

Well yea, but what is it exactly that is wrong with that precise usage?

Well yea, but what is it exactly that is wrong with that precise usage?

You need to call the method on a Slayer_PathHandlerSG object. We create a Slayer_PathHandlerSG object here: Slayer.cs:15. Then we can call methods on the object like so:
Code: [Select]
Slayer.pathHandler.addNode(%myBrickOrWhatever);
Remember that the first parameter in a method definition is the object it's being called on.
Code: [Select]
//This:
Slayer.pathHandler.addNode(%myBrickOrWhatever);

//Is the same as this:
Slayer_PathHandlerSG::addNode(Slayer.pathHandler, %myBrickOrWhatever);
In the first case, Slayer.pathHandler is implicitly passed as the first parameter.
« Last Edit: April 02, 2015, 02:47:25 PM by Greek2me »

What is the difference between the different heuristics.


(Any faces you may or may not see on this picture are purely a fidget of your imagination)

I figured out what I think to be the best method to make single hops and that is to make every node linked to the 6 nodes that he is neighbored by, but I need advice on how to find the different nodes. One method, pictured above is to destroy every link and procedurally perform containerboxsearches, activating the next brick. When the next brick gets activated, it does the exact same and links up with 6 of it's neighbors and what should come of it should be a web of links between neighboring nodes.

This seems extremely unpractical though and with game boards getting larger and larger, this could start to have an effect on the load-up time.

What I have node-ing wise.
Code: [Select]
function addLandTileNodes()
{
for(%a = 0; %a < mainBrickGroup.getCount(); %a++)
{
    %b = mainBrickGroup.getObject(%a);
    for(%c = 0; %c < %b.getCount(); %c++)
    {
        %brick = %b.getObject(%c);
        if(%brick.getDatablock().getName() $= "BotTileBrickData")
        {
        if(printBrickToPrintName(%brick) $= "ModTer/blank")
        {
        %brick.node = new FxDTSBrick()
        {
        datablock = brickSlyrBotPathNodeData;
        position = getWord(%brick.getPosition(), 0) SPC getWord(%brick.getPosition(), 1) SPC getWord(%brick.getPosition, 2) + 1.7;
        isPlanted = 1;
        colorID = 1;
        client = -1;
        };
        %brick.node.plant();
//        %error = %brick.node.plant();
//        if(%error)
//        {
//        %brick.node.schedule(33,delete);  Failiure is not an option (hah)
//        return;
//        }
getBrickGroupFromObject(%brick).add(%brick.node);

        %brick.node.setTrusted(1);
        }
        }
}
}
BotWars_Debug("Created Nodes");
}
Code: [Select]
function BotWars_HandleMovement(%troop, %brick)
{
%bricktype = BotWars_settleMovementType(%brick);
%trooptype = %troop.movementType;
if(%bricktype !$= %trooptype)
{
BotWars_Debug("Can't go");
return;
}
BotWars_Debug("movement pass"); //MOVEMENT HERE
BotWars_Debug(slayer.pathHandler.findPath(%troop.activebrick.node, %brick.node).result);
}

If you're properly storing the hexagon map in a simple structure and generating the actual bricks from that then you should be able to find neighbors just by looking in that same structure with offset coordinates?

Code: [Select]
function findNeighboringNodes(%id)
{
initContainerRadiusSearch(%id.getPosition(), 15, $TypeMasks::All);
while(isObject(%search = containerSearchNext()))
{
if(%search.getDatablock().getName() $= "brickSlyrBotPathNodeData" && %search !$= %id && !%id.linkedTo[%search])
{
chainLinkNodes(%id, %search);
}
}
}

function chainLinkNodes(%nodeA, %nodeB)
{
slayer.pathHandler.setLink(%nodeA, %nodeB);
error("set node link");
schedule(100,0,findNeighBoringNodes,%nodeB);
}


SUCCESS!
Dear god, doesn't look like much, but took me the better part of the day.