Data Realms Fan Forums http://45.55.195.193/ |
|
May I make a suggestion? http://45.55.195.193/viewtopic.php?f=4&t=31876 |
Page 1 of 1 |
Author: | 16-Bit [ Sat Oct 06, 2012 2:51 am ] |
Post subject: | May I make a suggestion? |
The AI should have a random chance of switching weapons when reloading so you don't spend money for grenades they don't use! |
Author: | Bombzero [ Sat Oct 06, 2012 6:31 am ] |
Post subject: | Re: May I make a suggestion? |
16-Bit wrote: The AI should have a random chance of switching weapons when reloading so you don't spend money for grenades they don't use! Hmm, interesting point it would be nice if the AI could tactically see "Hmm, so the guy just dove behind that rock, and I have a frag grenade..." currently it seems they only use grenades when they have no other options. |
Author: | Madrawn [ Sat Oct 06, 2012 7:04 pm ] |
Post subject: | Re: May I make a suggestion? |
I had a quick look at base.rte/Actors/AI/... There is a file called HumanAI.lua which, after looking inside, seems to handle when to reload. For example at row 145: Code: function self:CreateSuppressBehavior() if self:EquipFirearm(true) then self.NextBehavior = coroutine.create(HumanBehaviors.ShootArea) self.NextBehaviorName = "ShootArea" else if self.FirearmIsEmpty then self:ReloadFirearm() end return end one could add before or after "self:ReloadFirearm()" something like this and see what happens: Code: local z = math.random(); if z > 0.70 then <whatever is called to switch weapons> I guess you'd have to add it everywhere where you find the ReloadFirearm()-call. But I never modded CC or even programmed in lua. This is just guesswork based on some programming knowledge... Edit: Now I somehow want to try it... What is called to let the AI switch weapons? |
Author: | Abdul Alhazred [ Sun Oct 07, 2012 7:59 am ] |
Post subject: | Re: May I make a suggestion? |
Both Lua and CC is both easy and rewarding to get started with if you have some programming experience, much thanks to the Programming in Lua html-book and the CC-API documention. As you can see the CreateAttackBehavior-function always try to use a firearm first, so the easiest way to do this is probably to create a new factory-function that initializes the HumanBehaviors.ThrowTarget behavior and then call that from HumanBehaviors.ShootTarget and return. Here are a few other things that may help: Set up a test scene (e.g. by modifying the Zombie Cave activity script) so you can spawn units with the press of a button and reload their scripts so you don't have to restart the game every time you make a change. Code: if UInputMan:KeyPressed(6) then -- f-key local Act = CreateAHuman("Silver Man", "Techion.rte") if Act then Act.Pos = self.AreaThrow:GetCenterPoint() Act.Team = Activity.TEAM_1 Act.AIMode = Actor.AIMODE_SENTRY Act:AddInventoryItem(CreateHDFirearm("Pistol", "Base.rte")) MovableMan:AddActor(Act) print(Act.PresetName .. " reload = " .. Act:ReloadScripts()) -- -1 if reload failed self:SetViewState(Activity.ACTORSELECT, Activity.PLAYER_1) self:SetActorSelectCursor(Act.Pos, Activity.PLAYER_1) end end Replace all 'require' with 'dofile' so external files also are reloaded. Code: dofile("Base.rte/Actors/AI/HumanBehaviors.lua") -- instead of require("Actors/AI/HumanBehaviors") |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |