≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Action act pretty... Slow
Posted by:
(you are not logged in)
Enter the missing letter in: "Interna?ional"
(you are not logged in)
Text:
[quote][b][/b] wrote: Alright, I'll... Leave the full code then? So, here it is: [code]/* <action jsname = "action_Shoot" description = "Shoot a bullet, but more advance!"> <property name = "ShootFrom" type = "scenenode"/> <property name = "RelativeTo" type = "scenenode"/> <property name = "Bullet" type = "scenenode"/> <property name = "Speed" type = "float"/> <property name = "LiveTime" type = "int"/> <property name = "DMG" type = "float"/> </action> */ action_Shoot = function() { } action_Shoot.prototype.execute = function() { var Pos = ccbGetSceneNodeProperty (this.ShootFrom, "PositionAbs"); var Rot = ccbGetSceneNodeProperty (this.RelativeTo, "Rotation"); var PosRel = ccbGetSceneNodeProperty (this.RelativeTo, "PositionAbs"); this.Node = ccbCloneSceneNode (this.Bullet); ccbSetSceneNodeProperty (this.Node, "Position", Pos); this.Dir = PosRel.substract(Pos); this.Dir.normalize(); this.OldPos = null; var me = this; this.Func = function() { me.Fire(); }; ccbRegisterOnFrameEvent (this.Func); this.StartTime = new Date().getTime(); this.Folder = ccbGetSceneNodeFromName ("Enemies"); } action_Shoot.prototype.Fire = function() { var Time = new Date().getTime(); if (this.LastTime == null) this.LastTime = Time; var Delta = Time - this.LastTime; var Pos = ccbGetSceneNodeProperty (this.Node, "PositionAbs"); if (this.OldPos == null) { ccbSetSceneNodeProperty (this.Node, "Visible", true); this.OldPos = Pos; }; Pos.x += this.Dir.x * Delta * this.Speed; Pos.y += this.Dir.y * Delta * this.Speed; Pos.z += this.Dir.z * Delta * this.Speed; var Check = Pos; var Col = ccbGetCollisionPointOfWorldWithLine (this.OldPos.x, this.OldPos.y, this.OldPos.z, Pos.x, Pos.y, Pos.z); if (Col || Time >= this.StartTime + this.LiveTime) { ccbRemoveSceneNode (this.Node); if (Col) var Check = Col; ccbUnregisterOnFrameEvent (this.Func); } else ccbSetSceneNodeProperty (this.Node, "Position", Pos); var Count = ccbGetSceneNodeChildCount (this.Folder); XD: for (var h = 0; h < Count; ++h) { var Guh = ccbGetChildSceneNode (this.Folder, h); var Name = ccbGetSceneNodeProperty (Guh, "Name"); if (ccbDoesLineCollideWithBoundingBoxOfSceneNode (Guh, this.OldPos.x, this.OldPos.y, this.OldPos.z, Check.x, Check.y, Check.z)) { var HBs = ccbGetSceneNodeChildCount (Guh); for (var E = 0; E < HBs; ++E) { var num = E + 1; var Eh = ccbGetSceneNodeFromName (Name + "HB" + num); if (ccbDoesLineCollideWithBoundingBoxOfSceneNode (Eh, this.OldPos.x, this.OldPos.y, this.OldPos.z, Check.x, Check.y, Check.z)) { ccbUnregisterOnFrameEvent (this.Func); ccbRemoveSceneNode (this.Node); var HP = ccbGetCopperCubeVariable ("" + Name + ".health"); ccbSetCopperCubeVariable ("" + Name + ".health", HP - this.DMG); break; break XD; }; }; } }; };[/code] I must agree, this looks probably stupid. And I kinda understand it, not gonna lie...[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact