Forum

> > Stranded II > Scripts > Scripting Questions
Forums overviewStranded II overview Scripts overviewLog in to reply

English Scripting Questions

2,429 replies
Page
To the start Previous 1 2107 108 109121 122 Next To the start

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
try this:
1
2
3
4
5
6
on:hit {
	$health=health("self");
	if($health<=25) {
		ai_mode currentid(), "flee", "unit", 1;
	}
}

old Re: Scripting Questions

Psytechnic
User Off Offline

Quote
Hurri04 has written
try this:
1
2
3
4
5
6
7
8
9
on:hit {
	$health=health("self");
	if($health<=25) {
		[b]$tmp=random(1,4);
		if($tmp > 2) {[/b]
			ai_mode currentid(), "flee", "unit", 1;
		[b]}[/b]
	}
}


This would give you a 50/50 chance of fleeing.
if($tmp > 3) would give a 25% chance of fleeing
if($tmp > 1) would give a 75% chance of fleeing

alter the $tmp=random(<min>,<max>) values to fine tune if necessary.

If you wanted to make it more realistic, you could use the $health value as an decreasing indicator, like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
on:hit {
	$health=health("self");
	$tmp=random(1,4);
	if($health<=15) {
		if($tmp > 1) {
			ai_mode currentid(), "flee", "unit", 1;
		}
	}
	elseif($health<=20) {
		if($tmp > 2) {
			ai_mode currentid(), "flee", "unit", 1;
		}
	}
	elseif($health<=25) {
		if($tmp > 3) {
			ai_mode currentid(), "flee", "unit", 1;
		}
	}
}

This way, as it becomes more damaged, it becomes more inclined to flee...

(Thanks for the cover bloodshot)
edited 1×, last 01.10.10 12:34:09 pm

old Re: Scripting Questions

Psytechnic
User Off Offline

Quote
Bloodshot has written
elseif($health<=15) { should be if($health<=15) {
]

Yeah, the first 'elseif' should just be 'if', I was copy-pasting-creating. But apart from that, that script should be copy and pastable.

Edited the post.
edited 1×, last 01.10.10 12:34:31 pm

old Re: Scripting Questions

Spicy Night Owl
User Off Offline

Quote
Hey can anyone tell me how to make a grenade script. Here's the code. I want to make it so that when you throw it, he timer starts. Then after the timer ends itll explode. Please copy it and fix it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
### Grenade
id=127
name=Grenade
group=weapon
icon=gfx\grenade.bmp
model=gfx\clod.b3d
color=0,1000,0
behavior=killthrow
mat=metal
weight=50
info=an explosive grenade
healthchange=0
damage=120
script=start
on:attack1 { 5 second timer script goes here
on:timerend { explosion script goes here
script=end
edited 2×, last 03.10.10 07:23:12 pm

old Re: Scripting Questions

UnIdEnTiFiEd
User Off Offline

Quote
i beleive massive mod has a grenade script.

anyway i was wondering if there is anyway i can do this..


on:start {
tired, bit thirsty and very peckish.
}

something like that would be great please

old Re: Scripting Questions

Psytechnic
User Off Offline

Quote
on:start {
consume 0, 70, 30, 75;
}

This script would not change health, would decrease hunger by 70 (to 30), decrease thirst by 30 (to 70) and decrease tiredness by 75 (to 25)...

Yep... Just one command.

old Re: Scripting Questions

UnIdEnTiFiEd
User Off Offline

Quote
thanks! and how can i make it units attack other units that have the predator behavior, but not me? like the soldior object thing in v666 mod but for units instead.
edited 1×, last 04.10.10 09:28:25 am

old Re: Scripting Questions

Psytechnic
User Off Offline

Quote
UnIdEnTiFiEd has written
thanks! and how can i make it units attack other units that have the predator behavior, but not me? like the soldior object thing in v666 mod but for units instead.


Can't be done. I've seen many mentions of this kind of behaviour and it seems that it can't be done by scripting. You'd need to change the source code.

old Re: Scripting Questions

Spicy Night Owl
User Off Offline

Quote
Even if MM does have a grenade script, I dont want to download MM, (no matter how good it is), I just need a grenade script please.

old Re: Scripting Questions

UnIdEnTiFiEd
User Off Offline

Quote
well theres none i know of except that one.

btw is there a script that if i shoot something with a certain weapon it will die?

and how do i make the projectile with the script from defence tower be a bullet, not and arrow?
edited 1×, last 06.10.10 07:56:02 am

old Grenade Script

Smurf
User Off Offline

Quote
Heres a "Grenade" script.I am not sure if its the same as the Massive mod one.In the "Exploding Bomb" script were it says (timer "self",3000,0,"boom";), the "3000" is the delay time,just set any number here.3000=3 seconds delay.



Paste this in "Items_weapons.inf"

### Grenade
id=520
name=Grenade
group=weapon
icon=gfx\banana.bmp
model=gfx\banana.b3d
fx=16
scale=0.3
mat=stone
weight=100
info=Grenade
behaviour=throw
damage=0
speed=15
drag=1.8
rate=3000
script=start
on:impact {
          
                         $tmp=create ("object",530);
                         setpos " object",$tmp,impact_x(),impact_y(),impact_z();
                         setrot " object",$tmp,0,getyaw("unit",1),0;

               }
          }
     }
script=end

--------------------------------------------------------------------

Paste this in "Objects_Stuff.inf"


### Exploding Bomb
id=530
name=explosive
model=gfx\banana.b3d
fx=16
scale=0.3
group=stuff
icon=gfx\banana.bmp
health=5
color=300,300,300
mat=stone
var=radius,Radius of Explosion,200,0
var=damage,Damage,150,0
script=start


on:create {
     
     timer "self",3000,0,"boom";
     }
     
     on:boom {

     
          explosion getx("self"),gety("self"),getz("self") ,$radius,$damage;
free "self";
     }
script=end

-----------------------------------------------------------------------------------------------------
edited 1×, last 11.10.10 06:54:44 am

old Re: Scripting Questions

UnIdEnTiFiEd
User Off Offline

Quote
SLY3152 has written
Sorry to disturb but i really need help .... I was making a mod which i left in between but now i want to restart and saw the inputwin command ....


Please help and tell me how to use it and how to store what the user enters.....

.....

I dont understand, any of that! but if you explain more carefully i might be able to help you..
To the start Previous 1 2107 108 109121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview