Quake3World.com Forums
     Programming Discussion
        Map entities


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Map entities

Insane Quaker
Insane Quaker
Joined: 05 Mar 2010
Posts: 384
PostPosted: 10-20-2012 11:08 AM           Profile Send private message  E-mail  Edit post Reply with quote


Hi,
I've being battling to find a way to replace entities in a map at map loading time. After numerous attempts I've run out of ideas. I've worked my way all the way back to G_SpawnEntitiesFromString() trying to figure it out, alas, no luck! Here's my latest (quick) attempt to load ammo_bfg entities as ammo_cells:

g_items.c:

void G_SpawnItem (gentity_t *ent, gitem_t *item) {
G_SpawnFloat( "random", "0", &ent->random );
G_SpawnFloat( "wait", "0", &ent->wait );

RegisterItem( item );
if ( G_ItemDisabled(item) )
return;

ent->item = item;

if ( !strcmp(ent->item->classname, "ammo_bfg" ) ) {
strcpy(ent->item->classname, "ammo_cells" );
strcpy(ent->item->pickup_name, "Cells" );
strcpy(ent->item->world_model[0], va("models/powerups/ammo/plasmaam.md3") );
}

...
}

It makes absolutely no difference. What am I doing wrong?




Top
                 

Veteran
Veteran
Joined: 13 Jan 2008
Posts: 167
PostPosted: 10-20-2012 11:52 PM           Profile Send private message  E-mail  Edit post Reply with quote


Hi,

I am not surprised that you have problems. The whole spawn module has been designed by a person who must be nuts. It is unnecessarily convoluted and very hard to understand.

I suspect that the cause of your problem is that you do not modify the 'giType' and 'giTag' fields of the item structure. Try to set them like this:

Code:
ent->item->giType = IT_AMMO;
ent->item->giTag = WP_PLASMAGUN;


Hope this works (I have not tried it, to be honest).

EDIT:

I may have found a better solution. You could try to modify the function 'G_CallSpawn' in 'g_spawn.c'. There is a 'for' loop in which the function tries to find the item with the given classname. I have added the code I think is needed:

Code:
//_SP added
  if (strcmp(ent->classname, "ammo_bfg") == 0)
    strcpy(ent->classname, "ammo_plasma");
//_SP

  // check item spawn functions
  for (item = bg_itemlist + 1; item->classname; item++)
  {

    if (!strcmp(item->classname, ent->classname))
    {
      G_SpawnItem(ent, item);
      return qtrue;
    }
  }


In this way the fully initialized item structure of the plasma ammo is found and used, no need for any further hacking (I think).




Top
                 

Insane Quaker
Insane Quaker
Joined: 05 Mar 2010
Posts: 384
PostPosted: 10-21-2012 06:58 AM           Profile Send private message  E-mail  Edit post Reply with quote


That works, thanks!




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.