Help with walls, ai unit ignore and changing unit categorys

Help with walls, ai unit ignore and changing unit categorys

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Tiberium
Posts: 18
Joined: 29 Jun 2012, 19:42

Help with walls, ai unit ignore and changing unit categorys

Post by Tiberium »

Hey another post another set of questions! :-)

Im stuck trying to figure out a good way to make walls but i have a few ideas if anyone could point me in the right direction.

Heres what im thinking: I make the walls a unit not a feature and set it as a bad target category for everything so it wont effect a firefight if theres actual units to attack there and so ai will attack walls. this is so i can give the unit a script and so walls are repairable and can be sold.

That said in the unit script i want it to check for other walls in either north, east, south and west and show/rotate or hide a piece so each will look connected the other wall piece should also recheck if it needs to update its self. walls will be one square tile.

So does anyone know a piece of magic code that can check one tile in all four directions for a unit?

Also another question :P i made an airstrip and a plane comes in to drop off units that was built and the plane is for purly visual so i made it non selectable works brillant for players not so good for ai who insists on defending his base with them regardless lol so has anyone got an idea how to make ai ignore a unit without opening a can of worms by making my own ai? im not ready to do that yet.

and last question i have a helicopter in my game but i have a problem with units attacking the helicopter. i have anti air sam sites that fire at it as its flies with is good but if i was to land near the sam they continue to shoot at it and also ive set tanks not to shoot at aircraft so they just smile at the landed helicopter. i believe if i could change the category to LAND when landed and FLY when flying at runtime i could get what i want but i got a feeling im not so lucky on this one.

And thats all for now :lol: but thanks for any help on any of these!
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Help with walls, ai unit ignore and changing unit catego

Post by FLOZi »

Tiberium wrote:That said in the unit script i want it to check for other walls in either north, east, south and west and show/rotate or hide a piece so each will look connected the other wall piece should also recheck if it needs to update its self. walls will be one square tile.

So does anyone know a piece of magic code that can check one tile in all four directions for a unit?
Spring.GetUnitsInCylinder, Spring.GetUnitPosition and some vector maths.
Also another question :P i made an airstrip and a plane comes in to drop off units that was built and the plane is for purly visual so i made it non selectable works brillant for players not so good for ai who insists on defending his base with them regardless lol so has anyone got an idea how to make ai ignore a unit without opening a can of worms by making my own ai? im not ready to do that yet.
Try using Spring.SetUnitNeutral(unitID, true).
and last question i have a helicopter in my game but i have a problem with units attacking the helicopter. i have anti air sam sites that fire at it as its flies with is good but if i was to land near the sam they continue to shoot at it and also ive set tanks not to shoot at aircraft so they just smile at the landed helicopter. i believe if i could change the category to LAND when landed and FLY when flying at runtime i could get what i want but i got a feeling im not so lucky on this one.
There's no dynamic switching of categories currently. You could either:
  1. Switch the unit out for a 'landed' version (and back again when you want to take off i.e. issue a move order)
  2. 2. Do some checking of attack commands using AllowCommand (to prevent new attack orders against landed helis) and/or the TargetWeight script callin...
I would go with option #1. :wink:
User avatar
Tiberium
Posts: 18
Joined: 29 Jun 2012, 19:42

Re: Help with walls, ai unit ignore and changing unit catego

Post by Tiberium »

wow 3 out of 3 lol thanks guess ill be busy for a while now and option 1 does sound better :P
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Help with walls, ai unit ignore and changing unit catego

Post by knorke »

Heres what im thinking: I make the walls a unit not a feature and set it as a bad target category for everything so it wont effect a firefight if theres actual units to attack there and so ai will attack walls. this is so i can give the unit a script and so walls are repairable and can be sold.
i do that in my mod and seems to work good, so seems legit.

maybe watch out how many walls you allow players to make and do not make them too small. If it needs a dozen wall-units to make some short wall you quickly end up with unitcounts in the hundreds just for walls.
and last question i have a helicopter in my game but i have a problem with units attacking the helicopter. i have anti air sam sites that fire at it as its flies with is good but if i was to land near the sam they continue to shoot at it
4) SetUnitNeutral (unitID) when it lands: you will still be able to manually target the heli but turrets will not shot at it own their own.
4.2) To allow anti-ground units to shot at landed aircraft, do the above and spawn a fake-unit at positon of the heli. Then transfer all damage from the fake-unit to the real heli.
5) In AimWeapon() unitscript callin, dis-allow shoting if the gun is aiming too low (if pitch is too low or something)
Limit fire arc of turret so it can only target in an upward cone above it.
Also another question :P i made an airstrip and a plane comes in to drop off units that was built and the plane is for purly visual so i made it non selectable works brillant for players not so good for ai who insists on defending his base with them
Try using Spring.SetUnitNeutral(unitID, true).
As I understand, the problem is the AI is giving commands (move, attack etc) to the deco plane.
I think with the AllowCommand() you can block that but not sure how can block the AI commands but still allow the GiveOrderToUnit from your gadget. (asuming you do that)
There is some CMD_INTERNAL parameter but could not get that to work.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Help with walls, ai unit ignore and changing unit catego

Post by knorke »

and last question i have a helicopter in my game but i have a problem with units attacking the helicopter. i have anti air sam sites that fire at it as its flies with is good but if i was to land near the sam they continue to shoot at it
6) This seems superstupid but I think I would try this way:
give the SAM turret two weapons:
one instantly-hitting one (eg laser, can be invisible) and the real missile weapon.
Then in a gadget you do

Code: Select all

UnitPreDamaged (unitID .. weaponID ... attackerID)
if (aircraft was hit by targeting laser) then
  if (aircraft is flying) then
      TellTurretItIsAllowedToShot()
  else
  --aircraft is landed: do nothing
  end
end
And ofc the turret's script does not allow to fire the 2nd weapon unless the gadget unblocks it.

Advantage:
-no unit swapping needed (imo that causes many problems)
-no TargetWeight/AllowCommand callins needed (fear and uncertainty how they work)
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Help with walls, ai unit ignore and changing unit catego

Post by FLOZi »

knorke wrote:
Also another question :P i made an airstrip and a plane comes in to drop off units that was built and the plane is for purly visual so i made it non selectable works brillant for players not so good for ai who insists on defending his base with them
Try using Spring.SetUnitNeutral(unitID, true).
As I understand, the problem is the AI is giving commands (move, attack etc) to the deco plane.
I think with the AllowCommand() you can block that but not sure how can block the AI commands but still allow the GiveOrderToUnit from your gadget. (asuming you do that)
There is some CMD_INTERNAL parameter but could not get that to work.
Herp, yeah, parsing fail by me there. Some more details on how the fly in/drop off system works might help.

Other proposals for heli targeting are quite interesting. My knorke all grown up Image

I would say that modifying weapons being able to fire gadget side is messy (S44 nightmare ammo gadget!) but you probably rather meant making a call into the LUS... you could probably get targetID in AimWeapon and just go from there btw, without needing the 'targeting laser', but then you're running the check every 15 frames on every unit with a weapon.

Unit swapping only really becomes an issue if the unitID is being used elsewhere by another gadget, imo.
User avatar
Tiberium
Posts: 18
Joined: 29 Jun 2012, 19:42

Re: Help with walls, ai unit ignore and changing unit catego

Post by Tiberium »

hey i made a little video to show you how the plane works but im going to upload it on youtube tomorrow since it will take forever to upload.

I see a problem with unit swapping the helicopter i do infact use the unit id to kill the unit from factory and re create another at map edge so it flies to the helipad. maybe at the same time the unit is swapped i could swap the unitID i had in a table? i only use to store what factory made the deleted unit i think :P

also the weapon blocking way will the units still be caught up aimming at the helicopter whilst being told no to firing? so while they keep trying yet theres other targets just free to move around?

thanks for the insight on this :) think im on the right track with the walls although i am now worried about unitnumbers hmm seems good and bad about this too. Also to be a pain the deco plane needs team colour i guess its not important but would be nice to see who it belongs too. set neutral does this give it a neutral team colour?
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Help with walls, ai unit ignore and changing unit catego

Post by Forboding Angel »

Tiberium wrote:Heres what im thinking: I make the walls a unit not a feature and set it as a bad target category for everything so it wont effect a firefight if theres actual units to attack there and so ai will attack walls. this is so i can give the unit a script and so walls are repairable and can be sold.
I did this in evo. Works well.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Help with walls, ai unit ignore and changing unit catego

Post by AF »

For reference, when talking about the AI, you need to specify which AI, as there are many, all with different code bases and authors
User avatar
Tiberium
Posts: 18
Joined: 29 Jun 2012, 19:42

Re: Help with walls, ai unit ignore and changing unit catego

Post by Tiberium »

Hey sorry for the delay! Youtube took forever to upload to and in the mean time ive got the walls working :D

hopefully this video will show the pros and cons of what i have for the airstrip at the moment.
http://www.youtube.com/watch?v=iByNyETAFTA

And heres a couple pictures of the walls.
Test one still showing the corner piece on every wall.
Image

And finished walls.
Image

Forboding Angel i really need to check this evo game out i hear good things about it.

Hey AF im using RAI but i assumed most generic AI would use the same method of grabbing all combat units into a list to defend its self :oops: i think its cause it has a weapon its flaged as a combat unit and sent into the list maybe? if it was a plain old constructor i doubt it would of used it to to defend with. Im in need of some way the unit is ignored by any generic AI. i will work on a dedicated AI later but for time being im happy with RAI
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Help with walls, ai unit ignore and changing unit catego

Post by knorke »

that looks very good!
User avatar
azaremoth
Cursed Developer
Posts: 549
Joined: 17 Feb 2005, 22:05

Re: Help with walls, ai unit ignore and changing unit catego

Post by azaremoth »

Oh - love what you are doing there... All those memories from my childhood. :wink:

The transport plane touchdown looks perfect! You should also check EvoRTS for the way base building works - It is (or "was" - I did not have a look for a longer time now) quite close to C&C imho.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Help with walls, ai unit ignore and changing unit catego

Post by Forboding Angel »

Yeah, still is. The difference is that in evo the constructor is mobile (having a building doing the construction proved to be too troublesome in the long run). But yeah, everything builds in ~ 5 seconds.

@Tiberium, in case you're curious, what I do isn't any secret. Just set workertime to 1 then buildtime can be however many seconds you want. I settled upon 5 due to the way that resources in spring works. Setting 0 had some ugly side effects.

If you had a way to block building if the resources were not available then that would do it.

I REALLY like what you have done here. My nostalgia is kicking in pretty hardcore =D
User avatar
Tiberium
Posts: 18
Joined: 29 Jun 2012, 19:42

Re: Help with walls, ai unit ignore and changing unit catego

Post by Tiberium »

Thanks for all the nice support! My name makes sense now right haha :D i just been playing Evo and i used RAI and i swear the AI knew what it was doing haha i was prettymuch celebrating my victory whilst sending what i thought was a huge army only to get decimated when i got there :P its a really good game and i appreciate the transport lift aircraft taking units to factory points and liking that UI!
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Help with walls, ai unit ignore and changing unit catego

Post by AF »

Weapons used for sfx count as weapons, the AI usually can't see any difference.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Help with walls, ai unit ignore and changing unit catego

Post by smoth »

dude, you are doing something I have been planning for some time! WOOT! Are you going to pd/cc/gpl that code?
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Help with walls, ai unit ignore and changing unit catego

Post by Forboding Angel »

Tiberium wrote:Thanks for all the nice support! My name makes sense now right haha :D i just been playing Evo and i used RAI and i swear the AI knew what it was doing haha i was prettymuch celebrating my victory whilst sending what i thought was a huge army only to get decimated when i got there :P its a really good game and i appreciate the transport lift aircraft taking units to factory points and liking that UI!
RAI plays EVO??? O_O

I must test this blasphemy! :mrgreen:
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Help with walls, ai unit ignore and changing unit catego

Post by FLOZi »

The walls are sweet, did you go the way I suggested or try something else?
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Help with walls, ai unit ignore and changing unit catego

Post by Google_Frog »

If I were you I wouldn't mess with the main game to try and get some generic AIs to work. Later on you can make your own.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Help with walls, ai unit ignore and changing unit catego

Post by hoijui »

azaremoth wrote:Oh - love what you are doing there... All those memories from my childhood. :wink:
+1

niiice!! :D
Post Reply

Return to “Game Development”