Jump to content

Scripting fireweapon, useweapon or another solution for my mech?


Recommended Posts

I'm putting together a fallout lore friendly

based on the robobrain. Nothing groundbreaking or unique, just using illiysium's vehicle script and a slightly modified model. I thought I'd be able to use a playgroup AttackRight 1, a 16 frame delay and a fireweapon command. However the bot has 3 AttackRight animations, with only one being an actual attack. The playgroup command is choosing one that simply has the hands at the torso with the claws pointing up, so the mech's just firing off a laser into the sky.

 

From what I'v read I can't select the specific animation in the group, so will I need to copy it and make it a idle animation to plug into the script.

 

Or is there a better way. I thought about utilizing the useweapon, so I didn't have to deal with any animation issues, but a required parameter is the target and I have no idea how to generate that dynamically during the battle. Do I make an ref that's a floating reticle. Or some block that acts as a sort of bot assisted auto aim via script that can be place ref's in the var when the crosshair is close to a actor/object.......or ?????

Link to comment
Share on other sites

Well copied (and renamed) the RightAttack to the idle animations, gave it an ID and plugged it into the script. The animation does go through it's cycle, but.....

 

I guess I need a timer to have the fireweapon function go off at the 15th frame of the animation. Right now it's like a ridiculously powerful Gatling gun if you hold down the fire button, firing at a very high rate through the whole range of the animation. Plus I don't have access to any other direction (up, down left, right etc) which can make it tricky to hit actors (especially when the mech is double their height and the laser is going right over the head).

 

So I think I'll have to move on to the useweapon function. If anyone has a idea how to implement the target parameter (as a ref) that would be great. Then I won't have to deal with any animation issues, the game engine will just use the appropriate animation for hitting the target.

 

I'm thinking there is probably a script/function that returns the ref of anything under the crosshair. That would work if it could be pluged into variable and that var used as the parameter (don't know if it will work, target parameter not accept a var).

 

Anyway any ideas/suggestions would be appreciated.

Edited by devinpatterson
Link to comment
Share on other sites

If the creature's AI is in combat, it will have a combat target ref. So a script on the robot could have something like this, plus whatever control code you have for the animation - maybe with it's own timer to simplify things.

 

scn MyRobotScript

ref rTargetREF
float fTimer


BEGIN GameMode

if (fTimer > 0)	;timer so useweapon doesn't get spammed on the robot
	set fTimer to fTimer - GetSecondsPassed
else

	set rTargetREF to GetCombatTarget
	set rMySelf to GetSelf				;only use GetSelf if robot is placed in the editor

	if (rTargetREF)
		if (rTargetREF.GetDead == 0)	;just in case
			if (GetDistance.rTargetREF <= 1500)	; or whatever the weapon range is
				UseWeapon MyWeaponItem rMySelf rTargetREF 5
				set fTimer to 10 + GetRandomPercent / 15	; or whatever works
			endif
		endif
	endif
	
endif

END

 

 

For the 'FireWeapon' function, you need to line up the geometry to the target ;)

 

If you want to be able to target actors with your crosshair, you'll need FOSE/NVSE to change the pick length dyamically so you can get the crosshair ref at a distance, like The Enclave Commander mods do. Then you can supply the ref to your robot for the useweapon function

Link to comment
Share on other sites

  • 2 weeks later...

If the creature's AI is in combat, it will have a combat target ref. So a script on the robot could have something like this, plus whatever control code you have for the animation - maybe with it's own timer to simplify things.

 

It does have a option via a key to turn on an auto attack function (ie a autopilot), but I'd like to be able to have the player control the actual attacks as well. Your suggestion below sounds very promising, since the rideable creatures script requires NVSE anyway.

 

If you want to be able to target actors with your crosshair, you'll need FOSE/NVSE to change the pick length dyamically so you can get the crosshair ref at a distance, like The Enclave Commander mods do. Then you can supply the ref to your robot for the useweapon function

 

Great, I will check into these Rickerhk, thank you very much for the suggestion :thumbsup:

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...