Rotating weapon help
Moderator: Core Staff
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
Rotating weapon help
I have 1 weapon in my map which I want to rotate continiously.
I checked the box "rotate" in the entity window of the weapon but that doesn't work.
Can I do this by rotating the weapon around an origin or will that cause a script error when the weapon is picked up ?
Anyone have some ideas on this ?
I checked the box "rotate" in the entity window of the weapon but that doesn't work.
Can I do this by rotating the weapon around an origin or will that cause a script error when the weapon is picked up ?
Anyone have some ideas on this ?
-
- 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
If it's an entity you can give it a targetname and make it rotate by scripting(in theory, I haven't actually tried it).
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.
[...]
#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.
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
Re: Rotating weapon help
I also thought about that but haven't tried it either.
But like I said you have to rotate it around an origin and I think when the weapon is picked up the script doesn't recognize the entity anymore, so it will give an error.
But enough theory .... I'll try it when I get home.
But like I said you have to rotate it around an origin and I think when the weapon is picked up the script doesn't recognize the entity anymore, so it will give an error.
But enough theory .... I'll try it when I get home.

-
- 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
Well you could make it seem like the player picked up the weapon - make a script_model, add a trigger_use_touch around it then give the player the weapon via script and hide the script_model. Then you could handle dropping the currently selected weapon, checking whether the player already has that weapon etc. all through a seperate .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.
[...]
#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.
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
Re: Rotating weapon help
thx rezil I'll sort that out later. But i have a different spawn problem which I also had 3 years ago,
I can respawn a weapon with scripting but but everytime it respawns the weapon falls to the floor/ground (I have suspended checked in the entity window of the weapon). I want it to be suspended aswell.
Second, I want the weapon I "drop" (when I pick up the spawnable weapon) to be gone after the spawnable weapon respawns.
To put it more clearly I hope
;
What's happening now;
- pick up spawnable weapon (which is suspended)
- current weapon replaces the spawnable weapon (and is suspended aswell)
- after X seconds weapon is respawned and drops to the floor
- The weapon which replaced the spawnable weapon is still there.
What I want to happen;
- pick up spawnable weapon (which is suspended)
- current weapon replaces the spawnable weapon (and is suspended aswell)
- after X seconds weapon is respawned (suspended) and replaces the suspended weapon
This is the gsc I use for the respawn;
I can respawn a weapon with scripting but but everytime it respawns the weapon falls to the floor/ground (I have suspended checked in the entity window of the weapon). I want it to be suspended aswell.
Second, I want the weapon I "drop" (when I pick up the spawnable weapon) to be gone after the spawnable weapon respawns.
To put it more clearly I hope

What's happening now;
- pick up spawnable weapon (which is suspended)
- current weapon replaces the spawnable weapon (and is suspended aswell)
- after X seconds weapon is respawned and drops to the floor
- The weapon which replaced the spawnable weapon is still there.
What I want to happen;
- pick up spawnable weapon (which is suspended)
- current weapon replaces the spawnable weapon (and is suspended aswell)
- after X seconds weapon is respawned (suspended) and replaces the suspended weapon
This is the gsc I use for the respawn;
Code: Select all
main()
{
WeaponRespawner("redeemer", 10);
}
// Create multiplayer weapons in Radiant as follows:
// Create weapons in the 2d window with right click "weapons" and select a weapon with _mp at the end which is available in mp
// Set the targetname to a value of your choice, e.g. "weapons" and use the same value to kick off your respawners
// Optional: Set count to the number of weapons that spawn at a time, e.g. 3 for three grenades at once
// Optional: set script_timescale to the time in seconds between respawns
// In your main script include the below functions and place an initial call to the WeaponRespawner in the main routine of your map
// A typically call would be: "WeaponRespawner("weapons", 5);" that will manage all entities with targetname weapons and a default respawn delay of 5 seconds
WeaponRespawner(targetname, defaultrespawndelay)
{
// by sentchy
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;
// kick off a thread to listen for when the item gets picked up
weapons[i] thread weapon_think(weapons[i].script_timescale);
}
}
}
// self = weapon reference
weapon_think(delaytime)
{
// capture important weapon data first to allow us to respawn them
classname = self.classname;
model = self.model;
count = self.count;
org = self.origin;
angles = self.angles;
targetname = self.targetname;
// Wait till the weapon gets picked up
self waittill("trigger");
// Wait the delay before respawn
wait delaytime;
// respawn the weapon
weapon = spawn(classname, org);
weapon.angles = angles;
weapon.count = count;
weapon setmodel(model);
weapon.script_timescale = delaytime;
weapon.targetname = targetname;
weapon playsound("spawnsound");
// Kick off a new thread with the new weapon and kill the old one
weapon thread weapon_think(delaytime);
}
-
- 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
Add this line of code under "targetname = self.targetname;":
Then, modify the spawn command. Instead of
use
and test.
Code: Select all
flags = self.spawnflags;
Code: Select all
weapon = spawn(classname, org);
Code: Select all
weapon = spawn(classname, org, flags);
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.
[...]
#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.
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
Re: Rotating weapon help
THX REZ ! works like a charm
Now I want the weapon which i left when picking up the spawnable weapon to be delted before/during the respawn.
Drof told me a few years back to do it with "entity delete();" or "entity destroy();"
I tried that but to no avail, any ideas ?

Now I want the weapon which i left when picking up the spawnable weapon to be delted before/during the respawn.
Drof told me a few years back to do it with "entity delete();" or "entity destroy();"
I tried that but to no avail, any ideas ?
-
- 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
self delete(); after self waittill("trigger");
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.
[...]
#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.
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
Re: Rotating weapon help
I tried that but I get a script error (when picking up the weapon in game);
If it is removed don't wine about it 
Code: Select all
removed entity is not an entity ??

-
- 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
Hm, not an entity? Well if you picked up the weapon and replaced it with another, it should still register as an entity. Try self hide(); and see if you can still pick it up.
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.
[...]
#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.
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Rotating weapon help
Why delete it? Just use the TriggerOff and TriggerOn functions from utility.
Combined with a loop.
Unless you plan on adding multiple new weapons, then there is no point in creating a template function.
Combined with a loop.
Unless you plan on adding multiple new weapons, then there is no point in creating a template function.

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
-
- 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
I think that's what he's going for. Multiple arrays of weapons and just calling the same function on them. I almost never use TriggerOff but I suppose it would work here.Unless you plan on adding multiple new weapons, then there is no point in creating a template function.
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.
[...]
#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.
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
Re: Rotating weapon help
Yep, that's what I want to make, a lot of weapons with the same function.Rezil wrote:I think that's what he's going for. Multiple arrays of weapons and just calling the same function on them. I almost never use TriggerOff but I suppose it would work here.Unless you plan on adding multiple new weapons, then there is no point in creating a template function.
That self hide(); gives the same error. also triedit with model but that doesn't work.
-
- 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
self TriggerOff();
And add #include maps\mp\_utility; to the very top of the script.
And add #include maps\mp\_utility; to the very top of the script.
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.
[...]
#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.
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
Re: Rotating weapon help
Did that now I get this errror;Rezil wrote:self TriggerOff();
And add #include maps\mp\_utility; to the very top of the script.
You do not have the required permissions to view the files attached to this post.
Who is online
Users browsing this forum: No registered users and 2 guests