Page 1 of 2
Looking for alternative Teamcannon actor.
Posted: Thu Sep 14, 2017 4:23 pm
by Terraniux
Hello,
Last night I spend almost 2 hours trying to find a working actor that I need. I'm using an AttachTag method.
I have a LoopMover that is endlessy triggered. What I want is some sort of actor that has the same properties as a TeamCannon, but is not a "pawn".
The problem with all actors that are under "PAWNS", they only move 1 key point, then freeze on that keypoint.
All other actors like DECORATION / INVENTORY ITEMS, are working fine. They follow the mover every keypoint perfectly.
Under "effects" I found :
ArrowSpawner - but that doesn't do any damage, and doesn't follow player.
Mortar spawner - it comes close, and is fun, but it doesn't shoot straight.
BoulderSpawner - but those are not what I need.
Is there a actor like TeamCannon that follows the player, shoots at them , wherever they go?
Edit: I prefer using something stock in the engine, unless it's not possible.
Re: Looking for alternative Teamcannon actor.
Posted: Thu Sep 14, 2017 8:24 pm
by EvilGrins
After a fashion... TeamMonsters can be sorta fun if used properly (attached the .u file).
There's also this ยท
viewtopic.php?f=34&t=11779
![Image](http://ic.pics.livejournal.com/evilgrins/3189901/4069637/4069637_original.png)
Re: Looking for alternative Teamcannon actor.
Posted: Thu Sep 14, 2017 10:02 pm
by Terraniux
Good idea, but same problem. Doesn't work. Thanks though.
The shitty thing is I know zero about coding.... maybe that's a part i should learn someday.....
I'm struggling to see the difference / missing link that between them is.
Re: Looking for alternative Teamcannon actor.
Posted: Thu Sep 14, 2017 10:12 pm
by Chamberly
It can be made using codes from the default engine but it'll be a custom script (subclassing in other that is not a pawn) and it can be MyLevel'd or not, depending on how you want it to be made... but that's as far I can acknowledge despite not doing enough coding practice.
Thought sharing this would give other the idea to make it if they know how to do it easily. If not, we'll have to start working on one altogether
![Satan :satan:](./images/smilies/Satan.gif)
& I don't mind starting out carrying this process and I may not get everything right but other can make the changes.
Re: Looking for alternative Teamcannon actor.
Posted: Fri Sep 15, 2017 12:32 am
by Barbie
I didn't find the reason why for example a TeamCannon is not moved if attached to a Mover by TeamCannon.AttachTag == Mover.Tag. In StationaryPawn.uc I found
Code: Select all
simulated function AddVelocity( vector NewVelocity ) {
Velocity = vect(0,0,0);
}
But overriding that function and setting another value for
Velocity did not change anything.
A possible approach with brutal violence is polling Mover's location and setting TeamCannon's location accordingly. But I'm not satisfied with this solution, because software should be event-driven and not do resource intensive polling. Because it should be attached to a constantly moving mover, it would be ok using the resource intensive Tick() function in this case.
Code: Select all
class MovableTeamCannon expands TeamCannon;
var(TeamCannon) Name MyMoverTag;
var Mover MyMover;
var vector MoverOffset;
event PostBeginPlay() {
// Find my mover:
if (MyMoverTag == '')
{
Disable('Tick');
return;
}
foreach AllActors(Class'Mover', MyMover, MyMoverTag)
break;
if (MyMover != None)
MoverOffset = MyMover.Location - Location;
else
Disable('Tick');
}
event Tick(float DeltaTime) {
if (MyMover.Location + MoverOffset != Location)
SetLocation(MyMover.Location - MoverOffset);
}
Usage: Give the Mover an unique Tag and set
MovableTeamCannon.TeamCannon.MyMoverTag to this Tag.
Test map with MyLevel'ed
MovableTeamCannon attached. Improvements welcome.
Re: Looking for alternative Teamcannon actor.
Posted: Fri Sep 15, 2017 1:13 am
by Terraniux
Thank you very much Barbie, will try it out.
![Thumbs Up! :thuup:](./images/smilies/icon_tup.gif)
Re: Looking for alternative Teamcannon actor.
Posted: Fri Sep 15, 2017 1:40 am
by Barbie
I did an error: Instead of
Code: Select all
if (MyMover.Location + MoverOffset != Location)
it has to be
Code: Select all
if (MyMover.Location - MoverOffset != Location)
(Notice the - instead of +)
Re: Looking for alternative Teamcannon actor.
Posted: Fri Sep 15, 2017 2:13 am
by JackGriffin
Your going to need to create a new class combining stationary pawn and team cannon. The nulling of AddVelocity in stationary pawn is going to mess up everything when you attempt to move this. If Barbie doesn't have time let me know and I'll do it for you. I'd get it tonight but I'm really tired, been scripting all day.
Re: Looking for alternative Teamcannon actor.
Posted: Fri Sep 15, 2017 5:14 am
by sektor2111
Barbie wrote:I didn't find the reason why for example a TeamCannon is not moved if attached to a Mover by TeamCannon.AttachTag == Mover.Tag.
Actually... all is a bit wrong. Cough Barbie, first of all MOVER is moving actor VIA AttachTag and not reversal, is
Mover.AttachTag = Actor.Tag and mover is indeed an AttachMover I have used only default stuff for Moving... a book like a plane in "bombingyard" and a sort of knife in "CTF-A_Trn" demo map or such. Dynamic things have to be tested ON-Line - in MH-TrainCommando some dynamic sounds are operated by a "Book" attached to an AttachMover because... AmbientSound is crapped On-Line at movement being supposed to be a static thing (Epic specific awesome deals) and for sure Mover is transporting Actor not reversal.
This thing with tick I think is way expensive. Engine is moving actor on a movable base (AttachMover) as long as actor is not bStatic and doesn't have that many things in common with addvelocity. Actually a "knife" child is not pushed by something doing damage but that thing can be moved by Mover...
All testing is required because Cannon having this Mover(base) will change base when it do spawns its own base screwing things (I guess). All this setup needs a check and also Net testing.
Edit:I did a little test - like I said, cannon will discard Mover(base) going messed up.
[attachment=0]Cannon.jpg[/attachment]
Here I would do a "tracker" attaching All Cannon crap to mover... LATER and using even a common Mover for this task...
However, by doing checks to Cannon, it is changing whatever Physics to None in state deactivated happening after 6 seconds and this will not be helpful - mover(Base) is being discarded. And then, we need to do a child cannon overriding default cannon habits and "SetBase" setup. And later cannon probably will not be nice because it has to change physics according to combat... so definitely will be required a tick operated by Cannon requiring other cannon type than default and quitting Base deals.
To summarize not all Actors are intended to be attached by a Mover as being their Base, some of them are changing physics and then they are losing this Base, all these having not many common things with AddVelocity. I did not check a cannon taking in account "BaseChange()" event, probably this is a cheap solution for re-attaching cannon back to base when physics are changed - but will require testing of course for being in proper timing and... if "BaseChange()" will get called.
Re: Looking for alternative Teamcannon actor.
Posted: Fri Sep 15, 2017 10:51 am
by Chris
As we know, animations (and that includes movers) is done by linear interpolation which increments the step with a factor of time rather than a constant frame value (We can't assume that we're Vert-synced).
It also means that the progress (or location) is incremented each tick according to delta time as such:
Code: Select all
DeltaDistance = (Distance' * (DeltaTimeMs / TotalTimeMs))
Where Distance' (vector prime notation) is the distance between the start vector and end vector (keypoints) (EndLocation - StartLocation).
Now the problem I can see with your solution Barbie is that it all depends on what actor is being updated first.
If the mover is being updated first, and then the cannon then it's fine, but if say the cannon would be updated first and then the mover, the cannon would be slacking behind with one frame. How noticable that is all depends on your framerate and the Distance' but I thought I should point it out. In terms of efficiency there is pretty much no overhead, maybe cache MyMover.Location. The reason why this doesn't have extra overhead even if it's a bruteforce technique is because the mover is also operating on Tick() and thus calling SetLocation on the Attached object from the mover, or vice versa doesn't matter, the only overhead is the extra function frame of calling Tick() in the cannon as well.
Of course, attaching an object to a mover should mean that the object has no physics altering its location.
Re: Looking for alternative Teamcannon actor.
Posted: Fri Sep 15, 2017 8:49 pm
by Terraniux
I thank you all for your input and commentary. What barbie made for me, is good and helped me. The MovingTeamCannon is following the mover perfectly.
I can release a quick ingame video what i mean. What I do understand that this actor is actually pressing the engine with more fuel than necessary ? Do I read that correct ????
All the code and scripting talk is hocus pocus for me.
![??? :???:](./images/smilies/wasFragezeichen.gif)
Like I said before, maybe i should try to learn a little bit about it.
But, can somebody try to explain to me, in plain simplified english, why TeamCannon does not move along the mover properly?
I thank you all again for your efforts, especially barbie
![Thumbs Up! :thuup:](./images/smilies/icon_tup.gif)
Re: Looking for alternative Teamcannon actor.
Posted: Fri Sep 15, 2017 9:16 pm
by sektor2111
Terraniux wrote:But, can somebody try to explain to me, in plain simplified english, why TeamCannon does not move along the mover properly?
TeamCannon moving to state idle is changing Physics to NONE (free levitate) even if previously has NONE as well. Changing physics make cannon (any pawn I guess) to leave any possible Mover-Base - else if Base would not be possible to be left, no Pawn could jump from Lifts ever - because Pawn traveling with Lift is the same as Cannon attached to Mover - Both of them have a Moving BASE.
I could attach some decorations, some smoke-spawner, mortarspawner, these have to be checked for their bMovable=True and bStatic=False - it doesn't seems to be a need for bCollideActors, AttachMover is moving them if they doesn't operate any Physics related changes.
Perhaps we need to start a topic with a few U files containing some MH stuff for being MyLevel-ed with "Obj Load" directive without any compilation. U files are going to have things needed but which doesn't exist in stock (swjumppad, custom cannons, Navigation stuff, lights, several pawns, fixes related to Skaarj, etc.) and mapper will happily use them from Actor browser without pumping brains through the head.
Edit: Right now I thought at a solution, more exactly what I would do - because I don't think I would need a TeamCannon.
Taking a decoration supporting mesh change and putting cannon's mesh over it. Then add there a mortarspawner or whatever boulderspawner - they can be triggered normally. This is the simplest way, using default stock stuff. All these are going to look like a cannon firing boulders or whatever mortars.
Re: Looking for alternative Teamcannon actor.
Posted: Fri Sep 15, 2017 9:27 pm
by Terraniux
OK, I understand a little bit better now. Thank You. If it matters, I added a video here.
Some actors I forgot to add, (which are working like the mortor and such) are missing, but you get what i mean.
The moving Teamcannon is from Barbie. All actors present have the AttachTag has the mover.
h9bTQwbF134
Re: Looking for alternative Teamcannon actor.
Posted: Fri Sep 15, 2017 11:21 pm
by Barbie
Terraniux wrote:What I do understand that this actor is actually pressing the engine with more fuel than necessary ?
Polling is just an inefficient method: imagine your handy had no bell - you have to look all few minutes if there is a call or SMS or whatever and because most of the times there will be nothing, you waste time with that.
Same is with the Tick() function: It looks about 30 times per second if the Mover has moved, and if so, the TeamCannon' location is updated. That's not really stress for the machine but a lot of unnecessary functions calls.
Re: Looking for alternative Teamcannon actor.
Posted: Sat Sep 16, 2017 7:31 am
by MrLoathsome
Exactly correct Barbie.
If you look at some of my old junk code, the last few projects I did where this would be an issue all have a config var so the user/admin can
set the polling rate to suit both the needs of their gametype and their hardware.
In some mutators I had them detecting how many times event X had been polled without any action needed, and after Y number of executions
the code would throttle down the rate of those checks, and turn it back up to full speed as soon as something happened. Repeat.
Not the ideal solution, but it seemed to work well for the most part. Cuts back on the unnecessary functions calls a LOT.
*This probably wont help the OP much until they do spend at least some time looking at Uscript, but I had to post this anyway.
Kickass thread. Everybody's replies have been awesome.
![Lets Rock! :rock:](./images/smilies/DatRockt.gif)