Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

patch for trucks to make them auto "help-build" nearby incomplete structures. #737

Closed
wzdev-ci opened this issue Jul 20, 2009 · 35 comments
Closed

Comments

@wzdev-ci
Copy link
Contributor

resolution_fixed type_patch (an actual patch, not a request for one) | by ouch


very few changes were needed to make this work, so there will be little impact in performance I imagine.

the only minor defect is that once a truck is auto building, the build icon for that structure will light up. so if you want to build another of that structure then clicking the icon will stop the auto build process only to have the truck immediately start back up. But holding shift will allow you to place new structures, and the truck will immediately stop auto building and start building the new ones.


Issue migrated from trac:737 at 2022-04-15 19:01:37 -0700

@wzdev-ci
Copy link
Contributor Author

ouch commented


Hope I did this right...

let me know if I didn't

@wzdev-ci
Copy link
Contributor Author

Zarel commented


You declare helpbuild in the wrong place, and you only help build structures that are damaged.

But overall, those are easy things to fix. If everyone else agrees that this is a good idea, I can fix those issues and commit this.

@wzdev-ci
Copy link
Contributor Author

ouch commented


well the current trunk has the buildings start out fully damaged and then slowly get repaired as they are being built. so I thought it was the proper way to handle that.

but where was I supposed to declare helpbuild?

And I can easily fix it if you don't want to waste the time to do so.

@wzdev-ci
Copy link
Contributor Author

Per commented


That minor defect sounds rather annoying. Any chance of fixing it first?

@wzdev-ci
Copy link
Contributor Author

Zarel commented


No, no, it's not a big deal; I'd be rewriting most of your patch when committing it; it's negligible.

I suppose if you're planning on submitting other patches though, you may as well learn CodingStyle. Read that wikipage.

You should also make your indentation match ours. Remember, we use Tab to indent. You are apparently using a text editor that turns tabs into spaces; turn off that feature.

Do not comment out code; simply delete it. I also don't understand why you removed the comment //check for damage. You don't need the helpbuild variable at all, simply use something like if ((STRUCTURE)psObj->status == SS_BUILT) instead of if (helpbuild).

@wzdev-ci
Copy link
Contributor Author

ouch commented


sorry for my delay in response. I was recently "let go" of my job...

Havn't been able to concentrate enough to do any programming lately.

But I'll look into fixing that per. But don't expect it too soon I'm afraid...

@wzdev-ci
Copy link
Contributor Author

Buginator commented


Wait, didn't trucks always do this anyway? I could of swore they would start helping out if they were just sitting there?

@wzdev-ci
Copy link
Contributor Author

Zarel commented


Nope, they don't.

@wzdev-ci
Copy link
Contributor Author

ouch commented


seems like they should though don't it? :)

Zarel: I'm not sure you can type cast from BASE_OBJECT like that. It keeps telling me that:

BASE_OBJECT’ has no member named ‘status’

even when using your code: "(STRUCTURE)psObj->status == SS_BUILT"

@wzdev-ci
Copy link
Contributor Author

ouch commented


added a new version where tab preservation was turned on in my ide, and the trucks now autobuild oil derricks on non-burning oil patches.

I was still not able to get Zarels code to work. Even type casting (STRUCTURE *) like I see i other parts of code. Not sure as to what I'm doing wrong there.

the auto building on oil derricks is something that bothered me since the CD version so many years ago. To see them finally doing it damn near brings a tear to my eye... lol

@wzdev-ci
Copy link
Contributor Author

Zarel commented


Yeah, I meant (STRUCTURE *).

Try ((STRUCTURE *)psObj)->status == SS_BUILT? I can never remember the C precedence rules.

@wzdev-ci
Copy link
Contributor Author

ouch commented


yep that did it. not sure why forcing it to apply the typedef first would matter though as I don't recall any other code needing it but oh, well it works.

I updated the file to reflect the changes.

oh and per, I looked into fixing that defect (which actually behaves differently than I thought) but because the interface loads directly from what the truck is doing I would probably need to make a new order and action to bypass the way the interface works. But I've been playing with it and I actually like how it is now. Simply because it allows the user to either immediately start a new list of tasks or it allows you to build off what it's currently doing and add on tasks to do when it's finished auto-building.

I have attached my order.c file so that those that can compile the code can easily try out the new truck behaviors for themselves.

But I really think you will like it, I know I do. Expansion and setting up defenses in hot firefights are a LOT easier. It almost seems like the trucks actually WANT to live now... ;p

@wzdev-ci
Copy link
Contributor Author

ouch uploaded file order.h (10.7 KiB)

@wzdev-ci
Copy link
Contributor Author

ouch commented


heh, forgot the order.h file...

but yeah, if I "fixed" that defect the user would have no choice but to start a new list of actions only instead of being given a choice.

@wzdev-ci
Copy link
Contributor Author

ouch commented


So... has anyone tried it yet?

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Aug 1, 2009

Zarel commented


We prefer diffs to replacement files. In fact, we rather dislike replacement files.

More importantly, the technical aspect isn't such a big deal. Even if your patch didn't work, it'd take about five minutes to write one that does.

We're mostly just unsure about whether something like this would be more useful than not. I think it might cause problems when you're trying to order a bunch of trucks to do different things. Which one was the one you just ordered, and which ones are just following along?

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Aug 1, 2009

ouch commented


the updated diff file is up there already.

I gave the replacement file so those with the code could easily find out if such an change is usefull or not.

So far everyone seems to just be speculateing and not actually trying it.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Aug 1, 2009

Zarel commented


I'd recommend posting a thread in Gen Dev asking for feedback. I'm personally neutral, so I'm going to wait until a few people say it's a good idea before I commit.

@wzdev-ci
Copy link
Contributor Author

Cyp commented


The "so if you want to build another of that structure then clicking the icon will stop the auto build process only to have the truck immediately start back up" issue is fixed, a while ago – the shift-click is now implied in all cases. Clicking the icon used to randomly cancel orders, even without this patch, anyway. Probably due to bugs making the icon light up incorrectly.

So that issue is out of the way.

@wzdev-ci
Copy link
Contributor Author

Zarel commented


Well, I'm fine with auto-help-build now. Anyone want to clean up the patch and commit it (emphasis on "clean up the patch first" and by that I mean "rewrite it").

@wzdev-ci
Copy link
Contributor Author

ouch commented


I can do that if you would like. Did you want auto build dericks too or just the auto help build?

I strongly believe they should do both personally. I actually don't play the normal game anymore, I always use this patch I like it so much... I havn't played in ages though...

@wzdev-ci
Copy link
Contributor Author

Zarel commented


Autoderricking is probably a good idea, too.

@wzdev-ci
Copy link
Contributor Author

Per commented


This is completely wrong. The micro-AI must never give orders. Actions are the domain of the micro-AI, while orders are the domain of humans and AI scripts. Mixing these up will mess up things really badly.

Auto-building derricks also sounds rather annoying.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Mar 3, 2010

ouch uploaded file order.c (126.1 KiB)

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Mar 3, 2010

ouch uploaded file ouch.diff (7.5 KiB)

Patch adds automation enhancments to trucks

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Mar 3, 2010

ouch commented


Ok, Here it is... a major re-write was done to give the trucks the ability to change their automation range depending on what mode the truck is in. Again, it's probably something they should have done to begin with...

Hold 1.5 tiles (had some issues with larger buildings (2x2) being hard to get in range, factories are still a problem with this I think)

guard 3 tiles

pursue 5 tiles

Also, we really should put those modes on the factory default settings list at some point.

But anyway I tested this during one game without any issues with it. Being able to set different ranges can come in handy. ;)

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Mar 3, 2010

ouch commented


forgot to add that orders.h is no longer needed as I removed the function I used before. (I figured, "when would a function that does that actually be used again for something else?")

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Mar 4, 2010

Per commented


Again, this is completely wrong. Orders are not supposed to be used that way. The micro-AI should not start such things like this - that is for humans and AIs to decide. The patch would mess up the AI badly.

Also, when a single conditional contains 15 function calls, most of whom are duplicates of each other, you really should consider refactoring your code.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Mar 4, 2010

Zarel commented


Once I am done refactoring the order/action code, the micro-AI will not be touching any droid orders...

All future patches should take that into account.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Mar 4, 2010

ouch commented


I must of missed something... how can you have something like this without giving droids orders? are you supposed to tap into the game engine directly?

and yeah that "if" statement is pretty sweet isn't it per? ;)

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Mar 4, 2010

Zarel commented


You set the droid to do actions directly.

@wzdev-ci
Copy link
Contributor Author

Cyp <cyp@...> changed resolution from `` to fixed

@wzdev-ci
Copy link
Contributor Author

Cyp <cyp@...> committed [24]


In Warzone2100/warzone2100@24c8416:

#CommitTicketReference repository="" revision="24c8416c1345594e834629d0cf467e37088964b7"
Let idle trucks help with building structures as well as repairing them.

Fixes #737.

@wzdev-ci
Copy link
Contributor Author

Cyp <cyp@...> changed status from new to closed

@wzdev-ci
Copy link
Contributor Author

Cyp <cyp@...> changed owner from `` to Cyp <cyp@wz2100.net>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant