Forum

Frikfile saving/loading botwaypoints?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Frikfile saving/loading botwaypoints?

Postby drm_wayne » Wed Nov 20, 2013 1:21 pm

hey,

im having trouble with frikfile and saving/loading my bot waypoints :oops:
Saving seems to work, but it seems not to load and spawn on the map..
Anybody can help me?

heres the frikfile code:

Code: Select all
void(vector here, float which) create_waypoint;

void() write_waypoints =
{
   local float file;
   string h;

   h = strcat(mappath, ".way");
   file = fopen (h, FILE_WRITE);
   local entity botwp;
   botwp = find(world, classname, "waypoint");
   while (botwp)
   {
      dprint ("Saving waypoints\n");
      fputs(file,"create_waypoint(");
      fputs(file,vtos(botwp.origin));
      fputs(file,")\n");
      
      botwp = find(botwp, classname, "waypoint");
      if (botwp)
         fputs(file,"\n");
   }
   fclose(file);
};

void() Load_Waypoints =
{
   float file, which;
   string h;
   local vector here;
   dprint("loading waypoints.. \n");

   h = strcat(mappath, ".way");
   file = fopen (h, FILE_READ);

   if (file == -1)
   {
      dprint("Error: file not found \n");
      return;
   }

   while (1)
   {
      bprint("Loading waypoint\n");
      // the first line is just a comment, ignore it
      h = fgets(file);   
      if (h != "waypoint")
      {
         bprint("Last waypoint\n");
         fclose(file);
         return;
      }

      h = (fgets(file));
      here = stov(h);
      
      h = (fgets(file));
      which = stof(h);
      
      create_waypoint(here, which);
   }
};


an if needed heres the waypoint spawn code:

Code: Select all
void(vector here, float which) create_waypoint =
{
local entity ent;

   ent = spawn();
   ent.solid = #SOLID_TRIGGER;
   ent.movetype = #MOVETYPE_NONE;
   setorigin(ent, here);
   ent.model = "progs/s_bubble.spr";
   ent.touch = way_touch;
   ent.flags = FL_ITEM;
   ent.classname = "waypoint";
   ent.waypoint = which;
   total_ways = total_ways + 1;
};
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: Frikfile saving/loading botwaypoints?

Postby frag.machine » Wed Nov 20, 2013 2:41 pm

The file I/O part seems OK. Have you tested create_waypoint() separately? Something like adding a impulse to spawn a hardcoded waypoint just to see if it works?
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: Frikfile saving/loading botwaypoints?

Postby drm_wayne » Wed Nov 20, 2013 4:44 pm

frag.machine wrote:The file I/O part seems OK. Have you tested create_waypoint() separately? Something like adding a impulse to spawn a hardcoded waypoint just to see if it works?


yes it works...
I waypointed 2 testmaps and then added 2 bots, they roam the map perfectly (if they dont find waypoints on the maps they use coffee_move).
I think i make some errors at loading them, but im not really good at frikfile stuff.
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: Frikfile saving/loading botwaypoints?

Postby Jukki » Thu Nov 21, 2013 12:21 pm

I found your problem as i said in skype, he had wrong syntaxes for the loading and saving
Jukki
 
Posts: 214
Joined: Wed Apr 07, 2010 4:59 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest