Rotating weapon help

Have questions about CoD2 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Rotating weapon help

Post by Drofder2004 » July 10th, 2010, 7:01 pm

My guess is that you have chosen to use "trigger_once" in the mapping?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Rotating weapon help

Post by Rezil » July 10th, 2010, 9:25 pm

It's not a trigger, it's a weapon entity.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Rotating weapon help

Post by Drofder2004 » July 11th, 2010, 9:29 am

In that case, the weapon is deleting itself once picked up, I would assume.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Rotating weapon help

Post by <LT>YosemiteSam[NL] » July 11th, 2010, 9:52 am

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 :?

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Rotating weapon help

Post by Rezil » July 11th, 2010, 1:26 pm

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?
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Rotating weapon help

Post by Drofder2004 » July 11th, 2010, 2:25 pm

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?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Rotating weapon help

Post by Rezil » July 11th, 2010, 2:29 pm

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)?
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Rotating weapon help

Post by Drofder2004 » July 11th, 2010, 5:36 pm

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)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Rotating weapon help

Post by Rezil » July 11th, 2010, 5:37 pm

Me? Sam?
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Rotating weapon help

Post by Drofder2004 » July 11th, 2010, 5:42 pm

Rezil wrote:Me? Sam?
Whoever has the code? :P
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Rotating weapon help

Post by Rezil » July 11th, 2010, 5:51 pm

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.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Rotating weapon help

Post by Drofder2004 » July 11th, 2010, 6:20 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Rotating weapon help

Post by Rezil » July 11th, 2010, 6:35 pm

Reworking the whole pick-up script. brb
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Rotating weapon help

Post by Rezil » July 11th, 2010, 10:18 pm

Done, see here.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Rotating weapon help

Post by <LT>YosemiteSam[NL] » July 12th, 2010, 9:49 am

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();
      }
   }
}

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests