Page 2 of 5

Re: Rotating weapon help

Posted: July 10th, 2010, 7:01 pm
by Drofder2004
My guess is that you have chosen to use "trigger_once" in the mapping?

Re: Rotating weapon help

Posted: July 10th, 2010, 9:25 pm
by Rezil
It's not a trigger, it's a weapon entity.

Re: Rotating weapon help

Posted: July 11th, 2010, 9:29 am
by Drofder2004
In that case, the weapon is deleting itself once picked up, I would assume.

Re: Rotating weapon help

Posted: July 11th, 2010, 9:52 am
by <LT>YosemiteSam[NL]
Drofder2004 wrote:In that case, the weapon is deleting itself once picked up, I would assume.
Maybe that is the case, dunno.
But I want the weapon you drop to be deleted before the spawn otherwise during gameplay their will be a whole pileup of weapons people drop :?

Re: Rotating weapon help

Posted: July 11th, 2010, 1:26 pm
by Rezil
Drofder2004 wrote:In that case, the weapon is deleting itself once picked up, I would assume.
Right, but what's the new weapon that has been dropped called now?

Re: Rotating weapon help

Posted: July 11th, 2010, 2:25 pm
by Drofder2004
Rezil wrote:
Drofder2004 wrote:In that case, the weapon is deleting itself once picked up, I would assume.
Right, but what's the new weapon that has been dropped called now?
Not sure what you mean, the error is because we are referencing "self" which is deleted after the trigger?

Re: Rotating weapon help

Posted: July 11th, 2010, 2:29 pm
by Rezil
I mean now that we've picked up 'weapon' and dropped our currently selected weapon, can we assign a targetname to this dropped weapon(to delete it afterwards)?

Re: Rotating weapon help

Posted: July 11th, 2010, 5:36 pm
by Drofder2004
Is the weapon dropped automatically by ingame code or you handling it by "removing" the weapon form the player and placing it manually on the floor?

If everything at this current stage is working with no error, can you post the new current script?
(Or jump on Xfire, I think you are now on my list :P)

Re: Rotating weapon help

Posted: July 11th, 2010, 5:37 pm
by Rezil
Me? Sam?

Re: Rotating weapon help

Posted: July 11th, 2010, 5:42 pm
by Drofder2004
Rezil wrote:Me? Sam?
Whoever has the code? :P

Re: Rotating weapon help

Posted: July 11th, 2010, 5:51 pm
by Rezil
Have added you on XFire, didn't recieve any invitation, hence the confusion.

Code: Select all

main()
{
   WeaponRespawner("redeemer", 10);
}

WeaponRespawner(targetname, defaultrespawndelay)
{
  weapons = getentarray("redeemer", "targetname");
  if(weapons.size > 0)
  {
    for(i=0; i < weapons.size; i++)
    {
       if(!isdefined(weapons[i].script_timescale))
          weapons[i].script_timescale = defaultrespawndelay;
   
       weapons[i] thread weapon_think(weapons[i].script_timescale);
    }
  }
}

weapon_think(delaytime)
{
  classname = self.classname;
  model = self.model;
  count = self.count;
  org = self.origin;
  angles = self.angles;
  targetname = self.targetname;
  flags = self.spawnflags;

  self waittill("trigger");

  wait delaytime;

  weapon = spawn(classname, org, flags);
  weapon.angles = angles;
  weapon.count = count;
  weapon setmodel(model);
  weapon.script_timescale = delaytime;
  weapon.targetname = targetname;
  weapon playsound("spawnsound");
 
  weapon thread weapon_think(delaytime);
}
That's what I've gathered so far.
Is the weapon dropped automatically by ingame code or you handling it by "removing" the weapon form the player and placing it manually on the floor?
Ingame code, probably hard-coded from cod1 since I didn't find any reference to weapons and picking them up in any .gsc.

Re: Rotating weapon help

Posted: July 11th, 2010, 6:20 pm
by Drofder2004
Yes, its hard coded.

So, one way of doing this would be get a list of entities and filter them by classname or model, or you could even compare the entities origins and locate the neareast to the player and this is almost always going to be the weapon...

Also, might be worth testing to see if "ent.owner" is used in CoD2.

Re: Rotating weapon help

Posted: July 11th, 2010, 6:35 pm
by Rezil
Reworking the whole pick-up script. brb

Re: Rotating weapon help

Posted: July 11th, 2010, 10:18 pm
by Rezil
Done, see here.

Re: Rotating weapon help

Posted: July 12th, 2010, 9:49 am
by <LT>YosemiteSam[NL]
Rezil wrote:Done, see here.
Thx alot guys... going to experiment with that for a bit. I have no clue on what it lookslike ingame but I soon will.

I tried to spawn the weapon with your script m8 but I get a bad syntax error ;

Code: Select all

******* script compile error *******
bad syntax: (file 'maps/mp/_weapon_pickup.gsc', line 33)
setupWeaponForPickup("panzerschreck_mp", "xmodel/weapon_panzerschreck", 5);
                     *
this is the code I changed for my weapon ( panzerschreck);

Code: Select all

*/

setupWeaponForPickup("panzerschreck_mp", "xmodel/weapon_panzerschreck", 5);
{
   precachemodel(weapon_xmodel);
   trig = getentarray("weapon_pickup_" +weapon_name,"targetname");
   org = getentarray("weapon_origin_" +weapon_name,"targetname");
   if(org.size == trig.size) //same ammount of origins and triggers, otherwise you get errors
   {
      for(i=0;i<org.size;i++)
      {
         trig[i] thread WeaponPickup(org[i], weapon_name, weapon_xmodel, delay);
         
      }
   }
}

WeaponPickup(o, weapon, xmodel, delay)
{
   while(1)
   {
      o setmodel(xmodel);
      o notsolid(); //already true, just not sure about all script_models
      self waittill("trigger", user);
      c_weap = user getcurrentweapon();
      if(user hasweapon(weapon)) 
      { //user already has that weapon, so keep the model showing and only max out the ammo
            user givemaxammo(weapon); 
            wait 10; //to prevent unlimited ammo while staying inside the trigger
            o playsound("weapon_maxammo"); 
      }
      else 
      {
         user takeweapon(c_weap);
         user giveweapon(weapon);
         user switchtoweapon(weapon);
         o playsound("weapon_pickup");
         
         o hide();
         self maps\mp\_utility::TriggerOff();
         
         if(isdefined(delay))
         {
            wait delay;
         }
         
         self maps\mp\_utility::TriggerOn();
         o playsound("spawnsound");
         o show();
      }
   }
}