Frikfile saving/loading botwaypoints?
Moderator: InsideQC Admins
4 posts
• Page 1 of 1
Frikfile saving/loading botwaypoints?
hey,
im having trouble with frikfile and saving/loading my bot waypoints
Saving seems to work, but it seems not to load and spawn on the map..
Anybody can help me?
heres the frikfile code:
an if needed heres the waypoint spawn code:
im having trouble with frikfile and saving/loading my bot waypoints
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;
};
-

drm_wayne - Posts: 232
- Joined: Sat Feb 11, 2012 5:47 pm
Re: Frikfile saving/loading botwaypoints?
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)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Re: Frikfile saving/loading botwaypoints?
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.
-

drm_wayne - Posts: 232
- Joined: Sat Feb 11, 2012 5:47 pm
Re: Frikfile saving/loading botwaypoints?
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
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest